]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/iD/iD.js
Disable asynchronous object layer loading
[rails.git] / vendor / assets / iD / iD.js
1 "use strict";
2 (() => {
3   var __create = Object.create;
4   var __freeze = Object.freeze;
5   var __defProp = Object.defineProperty;
6   var __defProps = Object.defineProperties;
7   var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8   var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9   var __getOwnPropNames = Object.getOwnPropertyNames;
10   var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11   var __getProtoOf = Object.getPrototypeOf;
12   var __hasOwnProp = Object.prototype.hasOwnProperty;
13   var __propIsEnum = Object.prototype.propertyIsEnumerable;
14   var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
15   var __typeError = (msg) => {
16     throw TypeError(msg);
17   };
18   var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19   var __spreadValues = (a2, b2) => {
20     for (var prop in b2 || (b2 = {}))
21       if (__hasOwnProp.call(b2, prop))
22         __defNormalProp(a2, prop, b2[prop]);
23     if (__getOwnPropSymbols)
24       for (var prop of __getOwnPropSymbols(b2)) {
25         if (__propIsEnum.call(b2, prop))
26           __defNormalProp(a2, prop, b2[prop]);
27       }
28     return a2;
29   };
30   var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
31   var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
32     get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
33   }) : x2)(function(x2) {
34     if (typeof require !== "undefined") return require.apply(this, arguments);
35     throw Error('Dynamic require of "' + x2 + '" is not supported');
36   });
37   var __commonJS = (cb, mod) => function __require2() {
38     return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
39   };
40   var __export = (target, all) => {
41     for (var name in all)
42       __defProp(target, name, { get: all[name], enumerable: true });
43   };
44   var __copyProps = (to, from, except, desc) => {
45     if (from && typeof from === "object" || typeof from === "function") {
46       for (let key of __getOwnPropNames(from))
47         if (!__hasOwnProp.call(to, key) && key !== except)
48           __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
49     }
50     return to;
51   };
52   var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53     // If the importer is in node compatibility mode or this is not an ESM
54     // file that has been converted to a CommonJS file using a Babel-
55     // compatible transform (i.e. "__esModule" has not been set), then set
56     // "default" to the CommonJS "module.exports" for node compatibility.
57     isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58     mod
59   ));
60   var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
61   var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
62   var __await = function(promise, isYieldStar) {
63     this[0] = promise;
64     this[1] = isYieldStar;
65   };
66   var __yieldStar = (value) => {
67     var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
68     if (obj == null) {
69       obj = value[__knownSymbol("iterator")]();
70       method = (k2) => it[k2] = (x2) => obj[k2](x2);
71     } else {
72       obj = obj.call(value);
73       method = (k2) => it[k2] = (v2) => {
74         if (isAwait) {
75           isAwait = false;
76           if (k2 === "throw") throw v2;
77           return v2;
78         }
79         isAwait = true;
80         return {
81           done: false,
82           value: new __await(new Promise((resolve) => {
83             var x2 = obj[k2](v2);
84             if (!(x2 instanceof Object)) __typeError("Object expected");
85             resolve(x2);
86           }), 1)
87         };
88       };
89     }
90     return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x2) => {
91       throw x2;
92     }, "return" in obj && method("return"), it;
93   };
94
95   // node_modules/diacritics/index.js
96   var require_diacritics = __commonJS({
97     "node_modules/diacritics/index.js"(exports2) {
98       exports2.remove = removeDiacritics2;
99       var replacementList = [
100         {
101           base: " ",
102           chars: "\xA0"
103         },
104         {
105           base: "0",
106           chars: "\u07C0"
107         },
108         {
109           base: "A",
110           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"
111         },
112         {
113           base: "AA",
114           chars: "\uA732"
115         },
116         {
117           base: "AE",
118           chars: "\xC6\u01FC\u01E2"
119         },
120         {
121           base: "AO",
122           chars: "\uA734"
123         },
124         {
125           base: "AU",
126           chars: "\uA736"
127         },
128         {
129           base: "AV",
130           chars: "\uA738\uA73A"
131         },
132         {
133           base: "AY",
134           chars: "\uA73C"
135         },
136         {
137           base: "B",
138           chars: "\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0181"
139         },
140         {
141           base: "C",
142           chars: "\u24B8\uFF23\uA73E\u1E08\u0106C\u0108\u010A\u010C\xC7\u0187\u023B"
143         },
144         {
145           base: "D",
146           chars: "\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018A\u0189\u1D05\uA779"
147         },
148         {
149           base: "Dh",
150           chars: "\xD0"
151         },
152         {
153           base: "DZ",
154           chars: "\u01F1\u01C4"
155         },
156         {
157           base: "Dz",
158           chars: "\u01F2\u01C5"
159         },
160         {
161           base: "E",
162           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"
163         },
164         {
165           base: "F",
166           chars: "\uA77C\u24BB\uFF26\u1E1E\u0191\uA77B"
167         },
168         {
169           base: "G",
170           chars: "\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E\u0262"
171         },
172         {
173           base: "H",
174           chars: "\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
175         },
176         {
177           base: "I",
178           chars: "\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
179         },
180         {
181           base: "J",
182           chars: "\u24BF\uFF2A\u0134\u0248\u0237"
183         },
184         {
185           base: "K",
186           chars: "\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
187         },
188         {
189           base: "L",
190           chars: "\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
191         },
192         {
193           base: "LJ",
194           chars: "\u01C7"
195         },
196         {
197           base: "Lj",
198           chars: "\u01C8"
199         },
200         {
201           base: "M",
202           chars: "\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C\u03FB"
203         },
204         {
205           base: "N",
206           chars: "\uA7A4\u0220\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u019D\uA790\u1D0E"
207         },
208         {
209           base: "NJ",
210           chars: "\u01CA"
211         },
212         {
213           base: "Nj",
214           chars: "\u01CB"
215         },
216         {
217           base: "O",
218           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"
219         },
220         {
221           base: "OE",
222           chars: "\u0152"
223         },
224         {
225           base: "OI",
226           chars: "\u01A2"
227         },
228         {
229           base: "OO",
230           chars: "\uA74E"
231         },
232         {
233           base: "OU",
234           chars: "\u0222"
235         },
236         {
237           base: "P",
238           chars: "\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
239         },
240         {
241           base: "Q",
242           chars: "\u24C6\uFF31\uA756\uA758\u024A"
243         },
244         {
245           base: "R",
246           chars: "\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
247         },
248         {
249           base: "S",
250           chars: "\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
251         },
252         {
253           base: "T",
254           chars: "\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
255         },
256         {
257           base: "Th",
258           chars: "\xDE"
259         },
260         {
261           base: "TZ",
262           chars: "\uA728"
263         },
264         {
265           base: "U",
266           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"
267         },
268         {
269           base: "V",
270           chars: "\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
271         },
272         {
273           base: "VY",
274           chars: "\uA760"
275         },
276         {
277           base: "W",
278           chars: "\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
279         },
280         {
281           base: "X",
282           chars: "\u24CD\uFF38\u1E8A\u1E8C"
283         },
284         {
285           base: "Y",
286           chars: "\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
287         },
288         {
289           base: "Z",
290           chars: "\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
291         },
292         {
293           base: "a",
294           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"
295         },
296         {
297           base: "aa",
298           chars: "\uA733"
299         },
300         {
301           base: "ae",
302           chars: "\xE6\u01FD\u01E3"
303         },
304         {
305           base: "ao",
306           chars: "\uA735"
307         },
308         {
309           base: "au",
310           chars: "\uA737"
311         },
312         {
313           base: "av",
314           chars: "\uA739\uA73B"
315         },
316         {
317           base: "ay",
318           chars: "\uA73D"
319         },
320         {
321           base: "b",
322           chars: "\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253\u0182"
323         },
324         {
325           base: "c",
326           chars: "\uFF43\u24D2\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
327         },
328         {
329           base: "d",
330           chars: "\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\u018B\u13E7\u0501\uA7AA"
331         },
332         {
333           base: "dh",
334           chars: "\xF0"
335         },
336         {
337           base: "dz",
338           chars: "\u01F3\u01C6"
339         },
340         {
341           base: "e",
342           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"
343         },
344         {
345           base: "f",
346           chars: "\u24D5\uFF46\u1E1F\u0192"
347         },
348         {
349           base: "ff",
350           chars: "\uFB00"
351         },
352         {
353           base: "fi",
354           chars: "\uFB01"
355         },
356         {
357           base: "fl",
358           chars: "\uFB02"
359         },
360         {
361           base: "ffi",
362           chars: "\uFB03"
363         },
364         {
365           base: "ffl",
366           chars: "\uFB04"
367         },
368         {
369           base: "g",
370           chars: "\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\uA77F\u1D79"
371         },
372         {
373           base: "h",
374           chars: "\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
375         },
376         {
377           base: "hv",
378           chars: "\u0195"
379         },
380         {
381           base: "i",
382           chars: "\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
383         },
384         {
385           base: "j",
386           chars: "\u24D9\uFF4A\u0135\u01F0\u0249"
387         },
388         {
389           base: "k",
390           chars: "\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
391         },
392         {
393           base: "l",
394           chars: "\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747\u026D"
395         },
396         {
397           base: "lj",
398           chars: "\u01C9"
399         },
400         {
401           base: "m",
402           chars: "\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
403         },
404         {
405           base: "n",
406           chars: "\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5\u043B\u0509"
407         },
408         {
409           base: "nj",
410           chars: "\u01CC"
411         },
412         {
413           base: "o",
414           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"
415         },
416         {
417           base: "oe",
418           chars: "\u0153"
419         },
420         {
421           base: "oi",
422           chars: "\u01A3"
423         },
424         {
425           base: "oo",
426           chars: "\uA74F"
427         },
428         {
429           base: "ou",
430           chars: "\u0223"
431         },
432         {
433           base: "p",
434           chars: "\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755\u03C1"
435         },
436         {
437           base: "q",
438           chars: "\u24E0\uFF51\u024B\uA757\uA759"
439         },
440         {
441           base: "r",
442           chars: "\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
443         },
444         {
445           base: "s",
446           chars: "\u24E2\uFF53\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B\u0282"
447         },
448         {
449           base: "ss",
450           chars: "\xDF"
451         },
452         {
453           base: "t",
454           chars: "\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
455         },
456         {
457           base: "th",
458           chars: "\xFE"
459         },
460         {
461           base: "tz",
462           chars: "\uA729"
463         },
464         {
465           base: "u",
466           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"
467         },
468         {
469           base: "v",
470           chars: "\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
471         },
472         {
473           base: "vy",
474           chars: "\uA761"
475         },
476         {
477           base: "w",
478           chars: "\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
479         },
480         {
481           base: "x",
482           chars: "\u24E7\uFF58\u1E8B\u1E8D"
483         },
484         {
485           base: "y",
486           chars: "\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
487         },
488         {
489           base: "z",
490           chars: "\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
491         }
492       ];
493       var diacriticsMap = {};
494       for (i3 = 0; i3 < replacementList.length; i3 += 1) {
495         chars = replacementList[i3].chars;
496         for (j2 = 0; j2 < chars.length; j2 += 1) {
497           diacriticsMap[chars[j2]] = replacementList[i3].base;
498         }
499       }
500       var chars;
501       var j2;
502       var i3;
503       function removeDiacritics2(str) {
504         return str.replace(/[^\u0000-\u007e]/g, function(c2) {
505           return diacriticsMap[c2] || c2;
506         });
507       }
508       exports2.replacementList = replacementList;
509       exports2.diacriticsMap = diacriticsMap;
510     }
511   });
512
513   // node_modules/alif-toolkit/lib/isArabic.js
514   var require_isArabic = __commonJS({
515     "node_modules/alif-toolkit/lib/isArabic.js"(exports2) {
516       "use strict";
517       Object.defineProperty(exports2, "__esModule", { value: true });
518       exports2.isArabic = isArabic;
519       exports2.isMath = isMath;
520       var arabicBlocks = [
521         [1536, 1791],
522         // Arabic https://www.unicode.org/charts/PDF/U0600.pdf
523         [1872, 1919],
524         // supplement https://www.unicode.org/charts/PDF/U0750.pdf
525         [2208, 2303],
526         // Extended-A https://www.unicode.org/charts/PDF/U08A0.pdf
527         [64336, 65023],
528         // Presentation Forms-A https://www.unicode.org/charts/PDF/UFB50.pdf
529         [65136, 65279],
530         // Presentation Forms-B https://www.unicode.org/charts/PDF/UFE70.pdf
531         [69216, 69247],
532         // Rumi numerals https://www.unicode.org/charts/PDF/U10E60.pdf
533         [126064, 126143],
534         // Indic Siyaq numerals https://www.unicode.org/charts/PDF/U1EC70.pdf
535         [126464, 126719]
536         // Mathematical Alphabetic symbols https://www.unicode.org/charts/PDF/U1EE00.pdf
537       ];
538       function isArabic(char) {
539         if (char.length > 1) {
540           throw new Error("isArabic works on only one-character strings");
541         }
542         let code = char.charCodeAt(0);
543         for (let i3 = 0; i3 < arabicBlocks.length; i3++) {
544           let block2 = arabicBlocks[i3];
545           if (code >= block2[0] && code <= block2[1]) {
546             return true;
547           }
548         }
549         return false;
550       }
551       function isMath(char) {
552         if (char.length > 2) {
553           throw new Error("isMath works on only one-character strings");
554         }
555         let code = char.charCodeAt(0);
556         return code >= 1632 && code <= 1644 || code >= 1776 && code <= 1785;
557       }
558     }
559   });
560
561   // node_modules/alif-toolkit/lib/unicode-arabic.js
562   var require_unicode_arabic = __commonJS({
563     "node_modules/alif-toolkit/lib/unicode-arabic.js"(exports2) {
564       "use strict";
565       Object.defineProperty(exports2, "__esModule", { value: true });
566       var arabicReference = {
567         "alef": {
568           "normal": [
569             "\u0627"
570           ],
571           "madda_above": {
572             "normal": [
573               "\u0627\u0653",
574               "\u0622"
575             ],
576             "isolated": "\uFE81",
577             "final": "\uFE82"
578           },
579           "hamza_above": {
580             "normal": [
581               "\u0627\u0654",
582               "\u0623"
583             ],
584             "isolated": "\uFE83",
585             "final": "\uFE84"
586           },
587           "hamza_below": {
588             "normal": [
589               "\u0627\u0655",
590               "\u0625"
591             ],
592             "isolated": "\uFE87",
593             "final": "\uFE88"
594           },
595           "wasla": {
596             "normal": "\u0671",
597             "isolated": "\uFB50",
598             "final": "\uFB51"
599           },
600           "wavy_hamza_above": [
601             "\u0672"
602           ],
603           "wavy_hamza_below": [
604             "\u0627\u065F",
605             "\u0673"
606           ],
607           "high_hamza": [
608             "\u0675",
609             "\u0627\u0674"
610           ],
611           "indic_two_above": [
612             "\u0773"
613           ],
614           "indic_three_above": [
615             "\u0774"
616           ],
617           "fathatan": {
618             "normal": [
619               "\u0627\u064B"
620             ],
621             "final": "\uFD3C",
622             "isolated": "\uFD3D"
623           },
624           "isolated": "\uFE8D",
625           "final": "\uFE8E"
626         },
627         "beh": {
628           "normal": [
629             "\u0628"
630           ],
631           "dotless": [
632             "\u066E"
633           ],
634           "three_dots_horizontally_below": [
635             "\u0750"
636           ],
637           "dot_below_three_dots_above": [
638             "\u0751"
639           ],
640           "three_dots_pointing_upwards_below": [
641             "\u0752"
642           ],
643           "three_dots_pointing_upwards_below_two_dots_above": [
644             "\u0753"
645           ],
646           "two_dots_below_dot_above": [
647             "\u0754"
648           ],
649           "inverted_small_v_below": [
650             "\u0755"
651           ],
652           "small_v": [
653             "\u0756"
654           ],
655           "small_v_below": [
656             "\u08A0"
657           ],
658           "hamza_above": [
659             "\u08A1"
660           ],
661           "small_meem_above": [
662             "\u08B6"
663           ],
664           "isolated": "\uFE8F",
665           "final": "\uFE90",
666           "initial": "\uFE91",
667           "medial": "\uFE92"
668         },
669         "teh marbuta": {
670           "normal": [
671             "\u0629"
672           ],
673           "isolated": "\uFE93",
674           "final": "\uFE94"
675         },
676         "teh": {
677           "normal": [
678             "\u062A"
679           ],
680           "ring": [
681             "\u067C"
682           ],
683           "three_dots_above_downwards": [
684             "\u067D"
685           ],
686           "small_teh_above": [
687             "\u08B8"
688           ],
689           "isolated": "\uFE95",
690           "final": "\uFE96",
691           "initial": "\uFE97",
692           "medial": "\uFE98"
693         },
694         "theh": {
695           "normal": [
696             "\u062B"
697           ],
698           "isolated": "\uFE99",
699           "final": "\uFE9A",
700           "initial": "\uFE9B",
701           "medial": "\uFE9C"
702         },
703         "jeem": {
704           "normal": [
705             "\u062C"
706           ],
707           "two_dots_above": [
708             "\u08A2"
709           ],
710           "isolated": "\uFE9D",
711           "final": "\uFE9E",
712           "initial": "\uFE9F",
713           "medial": "\uFEA0"
714         },
715         "hah": {
716           "normal": [
717             "\u062D"
718           ],
719           "hamza_above": [
720             "\u0681"
721           ],
722           "two_dots_vertical_above": [
723             "\u0682"
724           ],
725           "three_dots_above": [
726             "\u0685"
727           ],
728           "two_dots_above": [
729             "\u0757"
730           ],
731           "three_dots_pointing_upwards_below": [
732             "\u0758"
733           ],
734           "small_tah_below": [
735             "\u076E"
736           ],
737           "small_tah_two_dots": [
738             "\u076F"
739           ],
740           "small_tah_above": [
741             "\u0772"
742           ],
743           "indic_four_below": [
744             "\u077C"
745           ],
746           "isolated": "\uFEA1",
747           "final": "\uFEA2",
748           "initial": "\uFEA3",
749           "medial": "\uFEA4"
750         },
751         "khah": {
752           "normal": [
753             "\u062E"
754           ],
755           "isolated": "\uFEA5",
756           "final": "\uFEA6",
757           "initial": "\uFEA7",
758           "medial": "\uFEA8"
759         },
760         "dal": {
761           "normal": [
762             "\u062F"
763           ],
764           "ring": [
765             "\u0689"
766           ],
767           "dot_below": [
768             "\u068A"
769           ],
770           "dot_below_small_tah": [
771             "\u068B"
772           ],
773           "three_dots_above_downwards": [
774             "\u068F"
775           ],
776           "four_dots_above": [
777             "\u0690"
778           ],
779           "inverted_v": [
780             "\u06EE"
781           ],
782           "two_dots_vertically_below_small_tah": [
783             "\u0759"
784           ],
785           "inverted_small_v_below": [
786             "\u075A"
787           ],
788           "three_dots_below": [
789             "\u08AE"
790           ],
791           "isolated": "\uFEA9",
792           "final": "\uFEAA"
793         },
794         "thal": {
795           "normal": [
796             "\u0630"
797           ],
798           "isolated": "\uFEAB",
799           "final": "\uFEAC"
800         },
801         "reh": {
802           "normal": [
803             "\u0631"
804           ],
805           "small_v": [
806             "\u0692"
807           ],
808           "ring": [
809             "\u0693"
810           ],
811           "dot_below": [
812             "\u0694"
813           ],
814           "small_v_below": [
815             "\u0695"
816           ],
817           "dot_below_dot_above": [
818             "\u0696"
819           ],
820           "two_dots_above": [
821             "\u0697"
822           ],
823           "four_dots_above": [
824             "\u0699"
825           ],
826           "inverted_v": [
827             "\u06EF"
828           ],
829           "stroke": [
830             "\u075B"
831           ],
832           "two_dots_vertically_above": [
833             "\u076B"
834           ],
835           "hamza_above": [
836             "\u076C"
837           ],
838           "small_tah_two_dots": [
839             "\u0771"
840           ],
841           "loop": [
842             "\u08AA"
843           ],
844           "small_noon_above": [
845             "\u08B9"
846           ],
847           "isolated": "\uFEAD",
848           "final": "\uFEAE"
849         },
850         "zain": {
851           "normal": [
852             "\u0632"
853           ],
854           "inverted_v_above": [
855             "\u08B2"
856           ],
857           "isolated": "\uFEAF",
858           "final": "\uFEB0"
859         },
860         "seen": {
861           "normal": [
862             "\u0633"
863           ],
864           "dot_below_dot_above": [
865             "\u069A"
866           ],
867           "three_dots_below": [
868             "\u069B"
869           ],
870           "three_dots_below_three_dots_above": [
871             "\u069C"
872           ],
873           "four_dots_above": [
874             "\u075C"
875           ],
876           "two_dots_vertically_above": [
877             "\u076D"
878           ],
879           "small_tah_two_dots": [
880             "\u0770"
881           ],
882           "indic_four_above": [
883             "\u077D"
884           ],
885           "inverted_v": [
886             "\u077E"
887           ],
888           "isolated": "\uFEB1",
889           "final": "\uFEB2",
890           "initial": "\uFEB3",
891           "medial": "\uFEB4"
892         },
893         "sheen": {
894           "normal": [
895             "\u0634"
896           ],
897           "dot_below": [
898             "\u06FA"
899           ],
900           "isolated": "\uFEB5",
901           "final": "\uFEB6",
902           "initial": "\uFEB7",
903           "medial": "\uFEB8"
904         },
905         "sad": {
906           "normal": [
907             "\u0635"
908           ],
909           "two_dots_below": [
910             "\u069D"
911           ],
912           "three_dots_above": [
913             "\u069E"
914           ],
915           "three_dots_below": [
916             "\u08AF"
917           ],
918           "isolated": "\uFEB9",
919           "final": "\uFEBA",
920           "initial": "\uFEBB",
921           "medial": "\uFEBC"
922         },
923         "dad": {
924           "normal": [
925             "\u0636"
926           ],
927           "dot_below": [
928             "\u06FB"
929           ],
930           "isolated": "\uFEBD",
931           "final": "\uFEBE",
932           "initial": "\uFEBF",
933           "medial": "\uFEC0"
934         },
935         "tah": {
936           "normal": [
937             "\u0637"
938           ],
939           "three_dots_above": [
940             "\u069F"
941           ],
942           "two_dots_above": [
943             "\u08A3"
944           ],
945           "isolated": "\uFEC1",
946           "final": "\uFEC2",
947           "initial": "\uFEC3",
948           "medial": "\uFEC4"
949         },
950         "zah": {
951           "normal": [
952             "\u0638"
953           ],
954           "isolated": "\uFEC5",
955           "final": "\uFEC6",
956           "initial": "\uFEC7",
957           "medial": "\uFEC8"
958         },
959         "ain": {
960           "normal": [
961             "\u0639"
962           ],
963           "three_dots_above": [
964             "\u06A0"
965           ],
966           "two_dots_above": [
967             "\u075D"
968           ],
969           "three_dots_pointing_downwards_above": [
970             "\u075E"
971           ],
972           "two_dots_vertically_above": [
973             "\u075F"
974           ],
975           "three_dots_below": [
976             "\u08B3"
977           ],
978           "isolated": "\uFEC9",
979           "final": "\uFECA",
980           "initial": "\uFECB",
981           "medial": "\uFECC"
982         },
983         "ghain": {
984           "normal": [
985             "\u063A"
986           ],
987           "dot_below": [
988             "\u06FC"
989           ],
990           "isolated": "\uFECD",
991           "final": "\uFECE",
992           "initial": "\uFECF",
993           "medial": "\uFED0"
994         },
995         "feh": {
996           "normal": [
997             "\u0641"
998           ],
999           "dotless": [
1000             "\u06A1"
1001           ],
1002           "dot_moved_below": [
1003             "\u06A2"
1004           ],
1005           "dot_below": [
1006             "\u06A3"
1007           ],
1008           "three_dots_below": [
1009             "\u06A5"
1010           ],
1011           "two_dots_below": [
1012             "\u0760"
1013           ],
1014           "three_dots_pointing_upwards_below": [
1015             "\u0761"
1016           ],
1017           "dot_below_three_dots_above": [
1018             "\u08A4"
1019           ],
1020           "isolated": "\uFED1",
1021           "final": "\uFED2",
1022           "initial": "\uFED3",
1023           "medial": "\uFED4"
1024         },
1025         "qaf": {
1026           "normal": [
1027             "\u0642"
1028           ],
1029           "dotless": [
1030             "\u066F"
1031           ],
1032           "dot_above": [
1033             "\u06A7"
1034           ],
1035           "three_dots_above": [
1036             "\u06A8"
1037           ],
1038           "dot_below": [
1039             "\u08A5"
1040           ],
1041           "isolated": "\uFED5",
1042           "final": "\uFED6",
1043           "initial": "\uFED7",
1044           "medial": "\uFED8"
1045         },
1046         "kaf": {
1047           "normal": [
1048             "\u0643"
1049           ],
1050           "swash": [
1051             "\u06AA"
1052           ],
1053           "ring": [
1054             "\u06AB"
1055           ],
1056           "dot_above": [
1057             "\u06AC"
1058           ],
1059           "three_dots_below": [
1060             "\u06AE"
1061           ],
1062           "two_dots_above": [
1063             "\u077F"
1064           ],
1065           "dot_below": [
1066             "\u08B4"
1067           ],
1068           "isolated": "\uFED9",
1069           "final": "\uFEDA",
1070           "initial": "\uFEDB",
1071           "medial": "\uFEDC"
1072         },
1073         "lam": {
1074           "normal": [
1075             "\u0644"
1076           ],
1077           "small_v": [
1078             "\u06B5"
1079           ],
1080           "dot_above": [
1081             "\u06B6"
1082           ],
1083           "three_dots_above": [
1084             "\u06B7"
1085           ],
1086           "three_dots_below": [
1087             "\u06B8"
1088           ],
1089           "bar": [
1090             "\u076A"
1091           ],
1092           "double_bar": [
1093             "\u08A6"
1094           ],
1095           "isolated": "\uFEDD",
1096           "final": "\uFEDE",
1097           "initial": "\uFEDF",
1098           "medial": "\uFEE0"
1099         },
1100         "meem": {
1101           "normal": [
1102             "\u0645"
1103           ],
1104           "dot_above": [
1105             "\u0765"
1106           ],
1107           "dot_below": [
1108             "\u0766"
1109           ],
1110           "three_dots_above": [
1111             "\u08A7"
1112           ],
1113           "isolated": "\uFEE1",
1114           "final": "\uFEE2",
1115           "initial": "\uFEE3",
1116           "medial": "\uFEE4"
1117         },
1118         "noon": {
1119           "normal": [
1120             "\u0646"
1121           ],
1122           "dot_below": [
1123             "\u06B9"
1124           ],
1125           "ring": [
1126             "\u06BC"
1127           ],
1128           "three_dots_above": [
1129             "\u06BD"
1130           ],
1131           "two_dots_below": [
1132             "\u0767"
1133           ],
1134           "small_tah": [
1135             "\u0768"
1136           ],
1137           "small_v": [
1138             "\u0769"
1139           ],
1140           "isolated": "\uFEE5",
1141           "final": "\uFEE6",
1142           "initial": "\uFEE7",
1143           "medial": "\uFEE8"
1144         },
1145         "heh": {
1146           "normal": [
1147             "\u0647"
1148           ],
1149           "isolated": "\uFEE9",
1150           "final": "\uFEEA",
1151           "initial": "\uFEEB",
1152           "medial": "\uFEEC"
1153         },
1154         "waw": {
1155           "normal": [
1156             "\u0648"
1157           ],
1158           "hamza_above": {
1159             "normal": [
1160               "\u0624",
1161               "\u0648\u0654"
1162             ],
1163             "isolated": "\uFE85",
1164             "final": "\uFE86"
1165           },
1166           "high_hamza": [
1167             "\u0676",
1168             "\u0648\u0674"
1169           ],
1170           "ring": [
1171             "\u06C4"
1172           ],
1173           "two_dots_above": [
1174             "\u06CA"
1175           ],
1176           "dot_above": [
1177             "\u06CF"
1178           ],
1179           "indic_two_above": [
1180             "\u0778"
1181           ],
1182           "indic_three_above": [
1183             "\u0779"
1184           ],
1185           "dot_within": [
1186             "\u08AB"
1187           ],
1188           "isolated": "\uFEED",
1189           "final": "\uFEEE"
1190         },
1191         "alef_maksura": {
1192           "normal": [
1193             "\u0649"
1194           ],
1195           "hamza_above": [
1196             "\u0626",
1197             "\u064A\u0654"
1198           ],
1199           "initial": "\uFBE8",
1200           "medial": "\uFBE9",
1201           "isolated": "\uFEEF",
1202           "final": "\uFEF0"
1203         },
1204         "yeh": {
1205           "normal": [
1206             "\u064A"
1207           ],
1208           "hamza_above": {
1209             "normal": [
1210               "\u0626",
1211               "\u0649\u0654"
1212             ],
1213             "isolated": "\uFE89",
1214             "final": "\uFE8A",
1215             "initial": "\uFE8B",
1216             "medial": "\uFE8C"
1217           },
1218           "two_dots_below_hamza_above": [
1219             "\u08A8"
1220           ],
1221           "high_hamza": [
1222             "\u0678",
1223             "\u064A\u0674"
1224           ],
1225           "tail": [
1226             "\u06CD"
1227           ],
1228           "small_v": [
1229             "\u06CE"
1230           ],
1231           "three_dots_below": [
1232             "\u06D1"
1233           ],
1234           "two_dots_below_dot_above": [
1235             "\u08A9"
1236           ],
1237           "two_dots_below_small_noon_above": [
1238             "\u08BA"
1239           ],
1240           "isolated": "\uFEF1",
1241           "final": "\uFEF2",
1242           "initial": "\uFEF3",
1243           "medial": "\uFEF4"
1244         },
1245         "tteh": {
1246           "normal": [
1247             "\u0679"
1248           ],
1249           "isolated": "\uFB66",
1250           "final": "\uFB67",
1251           "initial": "\uFB68",
1252           "medial": "\uFB69"
1253         },
1254         "tteheh": {
1255           "normal": [
1256             "\u067A"
1257           ],
1258           "isolated": "\uFB5E",
1259           "final": "\uFB5F",
1260           "initial": "\uFB60",
1261           "medial": "\uFB61"
1262         },
1263         "beeh": {
1264           "normal": [
1265             "\u067B"
1266           ],
1267           "isolated": "\uFB52",
1268           "final": "\uFB53",
1269           "initial": "\uFB54",
1270           "medial": "\uFB55"
1271         },
1272         "peh": {
1273           "normal": [
1274             "\u067E"
1275           ],
1276           "small_meem_above": [
1277             "\u08B7"
1278           ],
1279           "isolated": "\uFB56",
1280           "final": "\uFB57",
1281           "initial": "\uFB58",
1282           "medial": "\uFB59"
1283         },
1284         "teheh": {
1285           "normal": [
1286             "\u067F"
1287           ],
1288           "isolated": "\uFB62",
1289           "final": "\uFB63",
1290           "initial": "\uFB64",
1291           "medial": "\uFB65"
1292         },
1293         "beheh": {
1294           "normal": [
1295             "\u0680"
1296           ],
1297           "isolated": "\uFB5A",
1298           "final": "\uFB5B",
1299           "initial": "\uFB5C",
1300           "medial": "\uFB5D"
1301         },
1302         "nyeh": {
1303           "normal": [
1304             "\u0683"
1305           ],
1306           "isolated": "\uFB76",
1307           "final": "\uFB77",
1308           "initial": "\uFB78",
1309           "medial": "\uFB79"
1310         },
1311         "dyeh": {
1312           "normal": [
1313             "\u0684"
1314           ],
1315           "isolated": "\uFB72",
1316           "final": "\uFB73",
1317           "initial": "\uFB74",
1318           "medial": "\uFB75"
1319         },
1320         "tcheh": {
1321           "normal": [
1322             "\u0686"
1323           ],
1324           "dot_above": [
1325             "\u06BF"
1326           ],
1327           "isolated": "\uFB7A",
1328           "final": "\uFB7B",
1329           "initial": "\uFB7C",
1330           "medial": "\uFB7D"
1331         },
1332         "tcheheh": {
1333           "normal": [
1334             "\u0687"
1335           ],
1336           "isolated": "\uFB7E",
1337           "final": "\uFB7F",
1338           "initial": "\uFB80",
1339           "medial": "\uFB81"
1340         },
1341         "ddal": {
1342           "normal": [
1343             "\u0688"
1344           ],
1345           "isolated": "\uFB88",
1346           "final": "\uFB89"
1347         },
1348         "dahal": {
1349           "normal": [
1350             "\u068C"
1351           ],
1352           "isolated": "\uFB84",
1353           "final": "\uFB85"
1354         },
1355         "ddahal": {
1356           "normal": [
1357             "\u068D"
1358           ],
1359           "isolated": "\uFB82",
1360           "final": "\uFB83"
1361         },
1362         "dul": {
1363           "normal": [
1364             "\u068F",
1365             "\u068E"
1366           ],
1367           "isolated": "\uFB86",
1368           "final": "\uFB87"
1369         },
1370         "rreh": {
1371           "normal": [
1372             "\u0691"
1373           ],
1374           "isolated": "\uFB8C",
1375           "final": "\uFB8D"
1376         },
1377         "jeh": {
1378           "normal": [
1379             "\u0698"
1380           ],
1381           "isolated": "\uFB8A",
1382           "final": "\uFB8B"
1383         },
1384         "veh": {
1385           "normal": [
1386             "\u06A4"
1387           ],
1388           "isolated": "\uFB6A",
1389           "final": "\uFB6B",
1390           "initial": "\uFB6C",
1391           "medial": "\uFB6D"
1392         },
1393         "peheh": {
1394           "normal": [
1395             "\u06A6"
1396           ],
1397           "isolated": "\uFB6E",
1398           "final": "\uFB6F",
1399           "initial": "\uFB70",
1400           "medial": "\uFB71"
1401         },
1402         "keheh": {
1403           "normal": [
1404             "\u06A9"
1405           ],
1406           "dot_above": [
1407             "\u0762"
1408           ],
1409           "three_dots_above": [
1410             "\u0763"
1411           ],
1412           "three_dots_pointing_upwards_below": [
1413             "\u0764"
1414           ],
1415           "isolated": "\uFB8E",
1416           "final": "\uFB8F",
1417           "initial": "\uFB90",
1418           "medial": "\uFB91"
1419         },
1420         "ng": {
1421           "normal": [
1422             "\u06AD"
1423           ],
1424           "isolated": "\uFBD3",
1425           "final": "\uFBD4",
1426           "initial": "\uFBD5",
1427           "medial": "\uFBD6"
1428         },
1429         "gaf": {
1430           "normal": [
1431             "\u06AF"
1432           ],
1433           "ring": [
1434             "\u06B0"
1435           ],
1436           "two_dots_below": [
1437             "\u06B2"
1438           ],
1439           "three_dots_above": [
1440             "\u06B4"
1441           ],
1442           "inverted_stroke": [
1443             "\u08B0"
1444           ],
1445           "isolated": "\uFB92",
1446           "final": "\uFB93",
1447           "initial": "\uFB94",
1448           "medial": "\uFB95"
1449         },
1450         "ngoeh": {
1451           "normal": [
1452             "\u06B1"
1453           ],
1454           "isolated": "\uFB9A",
1455           "final": "\uFB9B",
1456           "initial": "\uFB9C",
1457           "medial": "\uFB9D"
1458         },
1459         "gueh": {
1460           "normal": [
1461             "\u06B3"
1462           ],
1463           "isolated": "\uFB96",
1464           "final": "\uFB97",
1465           "initial": "\uFB98",
1466           "medial": "\uFB99"
1467         },
1468         "noon ghunna": {
1469           "normal": [
1470             "\u06BA"
1471           ],
1472           "isolated": "\uFB9E",
1473           "final": "\uFB9F"
1474         },
1475         "rnoon": {
1476           "normal": [
1477             "\u06BB"
1478           ],
1479           "isolated": "\uFBA0",
1480           "final": "\uFBA1",
1481           "initial": "\uFBA2",
1482           "medial": "\uFBA3"
1483         },
1484         "heh doachashmee": {
1485           "normal": [
1486             "\u06BE"
1487           ],
1488           "isolated": "\uFBAA",
1489           "final": "\uFBAB",
1490           "initial": "\uFBAC",
1491           "medial": "\uFBAD"
1492         },
1493         "heh goal": {
1494           "normal": [
1495             "\u06C1"
1496           ],
1497           "hamza_above": [
1498             "\u06C1\u0654",
1499             "\u06C2"
1500           ],
1501           "isolated": "\uFBA6",
1502           "final": "\uFBA7",
1503           "initial": "\uFBA8",
1504           "medial": "\uFBA9"
1505         },
1506         "teh marbuta goal": {
1507           "normal": [
1508             "\u06C3"
1509           ]
1510         },
1511         "kirghiz oe": {
1512           "normal": [
1513             "\u06C5"
1514           ],
1515           "isolated": "\uFBE0",
1516           "final": "\uFBE1"
1517         },
1518         "oe": {
1519           "normal": [
1520             "\u06C6"
1521           ],
1522           "isolated": "\uFBD9",
1523           "final": "\uFBDA"
1524         },
1525         "u": {
1526           "normal": [
1527             "\u06C7"
1528           ],
1529           "hamza_above": {
1530             "normal": [
1531               "\u0677",
1532               "\u06C7\u0674"
1533             ],
1534             "isolated": "\uFBDD"
1535           },
1536           "isolated": "\uFBD7",
1537           "final": "\uFBD8"
1538         },
1539         "yu": {
1540           "normal": [
1541             "\u06C8"
1542           ],
1543           "isolated": "\uFBDB",
1544           "final": "\uFBDC"
1545         },
1546         "kirghiz yu": {
1547           "normal": [
1548             "\u06C9"
1549           ],
1550           "isolated": "\uFBE2",
1551           "final": "\uFBE3"
1552         },
1553         "ve": {
1554           "normal": [
1555             "\u06CB"
1556           ],
1557           "isolated": "\uFBDE",
1558           "final": "\uFBDF"
1559         },
1560         "farsi yeh": {
1561           "normal": [
1562             "\u06CC"
1563           ],
1564           "indic_two_above": [
1565             "\u0775"
1566           ],
1567           "indic_three_above": [
1568             "\u0776"
1569           ],
1570           "indic_four_above": [
1571             "\u0777"
1572           ],
1573           "isolated": "\uFBFC",
1574           "final": "\uFBFD",
1575           "initial": "\uFBFE",
1576           "medial": "\uFBFF"
1577         },
1578         "e": {
1579           "normal": [
1580             "\u06D0"
1581           ],
1582           "isolated": "\uFBE4",
1583           "final": "\uFBE5",
1584           "initial": "\uFBE6",
1585           "medial": "\uFBE7"
1586         },
1587         "yeh barree": {
1588           "normal": [
1589             "\u06D2"
1590           ],
1591           "hamza_above": {
1592             "normal": [
1593               "\u06D2\u0654",
1594               "\u06D3"
1595             ],
1596             "isolated": "\uFBB0",
1597             "final": "\uFBB1"
1598           },
1599           "indic_two_above": [
1600             "\u077A"
1601           ],
1602           "indic_three_above": [
1603             "\u077B"
1604           ],
1605           "isolated": "\uFBAE",
1606           "final": "\uFBAF"
1607         },
1608         "ae": {
1609           "normal": [
1610             "\u06D5"
1611           ],
1612           "isolated": "\u06D5",
1613           "final": "\uFEEA",
1614           "yeh_above": {
1615             "normal": [
1616               "\u06C0",
1617               "\u06D5\u0654"
1618             ],
1619             "isolated": "\uFBA4",
1620             "final": "\uFBA5"
1621           }
1622         },
1623         "rohingya yeh": {
1624           "normal": [
1625             "\u08AC"
1626           ]
1627         },
1628         "low alef": {
1629           "normal": [
1630             "\u08AD"
1631           ]
1632         },
1633         "straight waw": {
1634           "normal": [
1635             "\u08B1"
1636           ]
1637         },
1638         "african feh": {
1639           "normal": [
1640             "\u08BB"
1641           ]
1642         },
1643         "african qaf": {
1644           "normal": [
1645             "\u08BC"
1646           ]
1647         },
1648         "african noon": {
1649           "normal": [
1650             "\u08BD"
1651           ]
1652         }
1653       };
1654       exports2.default = arabicReference;
1655     }
1656   });
1657
1658   // node_modules/alif-toolkit/lib/unicode-ligatures.js
1659   var require_unicode_ligatures = __commonJS({
1660     "node_modules/alif-toolkit/lib/unicode-ligatures.js"(exports2) {
1661       "use strict";
1662       Object.defineProperty(exports2, "__esModule", { value: true });
1663       var ligatureReference = {
1664         "\u0626\u0627": {
1665           "isolated": "\uFBEA",
1666           "final": "\uFBEB"
1667         },
1668         "\u0626\u06D5": {
1669           "isolated": "\uFBEC",
1670           "final": "\uFBED"
1671         },
1672         "\u0626\u0648": {
1673           "isolated": "\uFBEE",
1674           "final": "\uFBEF"
1675         },
1676         "\u0626\u06C7": {
1677           "isolated": "\uFBF0",
1678           "final": "\uFBF1"
1679         },
1680         "\u0626\u06C6": {
1681           "isolated": "\uFBF2",
1682           "final": "\uFBF3"
1683         },
1684         "\u0626\u06C8": {
1685           "isolated": "\uFBF4",
1686           "final": "\uFBF5"
1687         },
1688         "\u0626\u06D0": {
1689           "isolated": "\uFBF6",
1690           "final": "\uFBF7",
1691           "initial": "\uFBF8"
1692         },
1693         "\u0626\u0649": {
1694           "uighur_kirghiz": {
1695             "isolated": "\uFBF9",
1696             "final": "\uFBFA",
1697             "initial": "\uFBFB"
1698           },
1699           "isolated": "\uFC03",
1700           "final": "\uFC68"
1701         },
1702         "\u0626\u062C": {
1703           "isolated": "\uFC00",
1704           "initial": "\uFC97"
1705         },
1706         "\u0626\u062D": {
1707           "isolated": "\uFC01",
1708           "initial": "\uFC98"
1709         },
1710         "\u0626\u0645": {
1711           "isolated": "\uFC02",
1712           "final": "\uFC66",
1713           "initial": "\uFC9A",
1714           "medial": "\uFCDF"
1715         },
1716         "\u0626\u064A": {
1717           "isolated": "\uFC04",
1718           "final": "\uFC69"
1719         },
1720         "\u0628\u062C": {
1721           "isolated": "\uFC05",
1722           "initial": "\uFC9C"
1723         },
1724         "\u0628\u062D": {
1725           "isolated": "\uFC06",
1726           "initial": "\uFC9D"
1727         },
1728         "\u0628\u062E": {
1729           "isolated": "\uFC07",
1730           "initial": "\uFC9E"
1731         },
1732         "\u0628\u0645": {
1733           "isolated": "\uFC08",
1734           "final": "\uFC6C",
1735           "initial": "\uFC9F",
1736           "medial": "\uFCE1"
1737         },
1738         "\u0628\u0649": {
1739           "isolated": "\uFC09",
1740           "final": "\uFC6E"
1741         },
1742         "\u0628\u064A": {
1743           "isolated": "\uFC0A",
1744           "final": "\uFC6F"
1745         },
1746         "\u062A\u062C": {
1747           "isolated": "\uFC0B",
1748           "initial": "\uFCA1"
1749         },
1750         "\u062A\u062D": {
1751           "isolated": "\uFC0C",
1752           "initial": "\uFCA2"
1753         },
1754         "\u062A\u062E": {
1755           "isolated": "\uFC0D",
1756           "initial": "\uFCA3"
1757         },
1758         "\u062A\u0645": {
1759           "isolated": "\uFC0E",
1760           "final": "\uFC72",
1761           "initial": "\uFCA4",
1762           "medial": "\uFCE3"
1763         },
1764         "\u062A\u0649": {
1765           "isolated": "\uFC0F",
1766           "final": "\uFC74"
1767         },
1768         "\u062A\u064A": {
1769           "isolated": "\uFC10",
1770           "final": "\uFC75"
1771         },
1772         "\u062B\u062C": {
1773           "isolated": "\uFC11"
1774         },
1775         "\u062B\u0645": {
1776           "isolated": "\uFC12",
1777           "final": "\uFC78",
1778           "initial": "\uFCA6",
1779           "medial": "\uFCE5"
1780         },
1781         "\u062B\u0649": {
1782           "isolated": "\uFC13",
1783           "final": "\uFC7A"
1784         },
1785         "\u062B\u0648": {
1786           "isolated": "\uFC14"
1787         },
1788         "\u062C\u062D": {
1789           "isolated": "\uFC15",
1790           "initial": "\uFCA7"
1791         },
1792         "\u062C\u0645": {
1793           "isolated": "\uFC16",
1794           "initial": "\uFCA8"
1795         },
1796         "\u062D\u062C": {
1797           "isolated": "\uFC17",
1798           "initial": "\uFCA9"
1799         },
1800         "\u062D\u0645": {
1801           "isolated": "\uFC18",
1802           "initial": "\uFCAA"
1803         },
1804         "\u062E\u062C": {
1805           "isolated": "\uFC19",
1806           "initial": "\uFCAB"
1807         },
1808         "\u062E\u062D": {
1809           "isolated": "\uFC1A"
1810         },
1811         "\u062E\u0645": {
1812           "isolated": "\uFC1B",
1813           "initial": "\uFCAC"
1814         },
1815         "\u0633\u062C": {
1816           "isolated": "\uFC1C",
1817           "initial": "\uFCAD",
1818           "medial": "\uFD34"
1819         },
1820         "\u0633\u062D": {
1821           "isolated": "\uFC1D",
1822           "initial": "\uFCAE",
1823           "medial": "\uFD35"
1824         },
1825         "\u0633\u062E": {
1826           "isolated": "\uFC1E",
1827           "initial": "\uFCAF",
1828           "medial": "\uFD36"
1829         },
1830         "\u0633\u0645": {
1831           "isolated": "\uFC1F",
1832           "initial": "\uFCB0",
1833           "medial": "\uFCE7"
1834         },
1835         "\u0635\u062D": {
1836           "isolated": "\uFC20",
1837           "initial": "\uFCB1"
1838         },
1839         "\u0635\u0645": {
1840           "isolated": "\uFC21",
1841           "initial": "\uFCB3"
1842         },
1843         "\u0636\u062C": {
1844           "isolated": "\uFC22",
1845           "initial": "\uFCB4"
1846         },
1847         "\u0636\u062D": {
1848           "isolated": "\uFC23",
1849           "initial": "\uFCB5"
1850         },
1851         "\u0636\u062E": {
1852           "isolated": "\uFC24",
1853           "initial": "\uFCB6"
1854         },
1855         "\u0636\u0645": {
1856           "isolated": "\uFC25",
1857           "initial": "\uFCB7"
1858         },
1859         "\u0637\u062D": {
1860           "isolated": "\uFC26",
1861           "initial": "\uFCB8"
1862         },
1863         "\u0637\u0645": {
1864           "isolated": "\uFC27",
1865           "initial": "\uFD33",
1866           "medial": "\uFD3A"
1867         },
1868         "\u0638\u0645": {
1869           "isolated": "\uFC28",
1870           "initial": "\uFCB9",
1871           "medial": "\uFD3B"
1872         },
1873         "\u0639\u062C": {
1874           "isolated": "\uFC29",
1875           "initial": "\uFCBA"
1876         },
1877         "\u0639\u0645": {
1878           "isolated": "\uFC2A",
1879           "initial": "\uFCBB"
1880         },
1881         "\u063A\u062C": {
1882           "isolated": "\uFC2B",
1883           "initial": "\uFCBC"
1884         },
1885         "\u063A\u0645": {
1886           "isolated": "\uFC2C",
1887           "initial": "\uFCBD"
1888         },
1889         "\u0641\u062C": {
1890           "isolated": "\uFC2D",
1891           "initial": "\uFCBE"
1892         },
1893         "\u0641\u062D": {
1894           "isolated": "\uFC2E",
1895           "initial": "\uFCBF"
1896         },
1897         "\u0641\u062E": {
1898           "isolated": "\uFC2F",
1899           "initial": "\uFCC0"
1900         },
1901         "\u0641\u0645": {
1902           "isolated": "\uFC30",
1903           "initial": "\uFCC1"
1904         },
1905         "\u0641\u0649": {
1906           "isolated": "\uFC31",
1907           "final": "\uFC7C"
1908         },
1909         "\u0641\u064A": {
1910           "isolated": "\uFC32",
1911           "final": "\uFC7D"
1912         },
1913         "\u0642\u062D": {
1914           "isolated": "\uFC33",
1915           "initial": "\uFCC2"
1916         },
1917         "\u0642\u0645": {
1918           "isolated": "\uFC34",
1919           "initial": "\uFCC3"
1920         },
1921         "\u0642\u0649": {
1922           "isolated": "\uFC35",
1923           "final": "\uFC7E"
1924         },
1925         "\u0642\u064A": {
1926           "isolated": "\uFC36",
1927           "final": "\uFC7F"
1928         },
1929         "\u0643\u0627": {
1930           "isolated": "\uFC37",
1931           "final": "\uFC80"
1932         },
1933         "\u0643\u062C": {
1934           "isolated": "\uFC38",
1935           "initial": "\uFCC4"
1936         },
1937         "\u0643\u062D": {
1938           "isolated": "\uFC39",
1939           "initial": "\uFCC5"
1940         },
1941         "\u0643\u062E": {
1942           "isolated": "\uFC3A",
1943           "initial": "\uFCC6"
1944         },
1945         "\u0643\u0644": {
1946           "isolated": "\uFC3B",
1947           "final": "\uFC81",
1948           "initial": "\uFCC7",
1949           "medial": "\uFCEB"
1950         },
1951         "\u0643\u0645": {
1952           "isolated": "\uFC3C",
1953           "final": "\uFC82",
1954           "initial": "\uFCC8",
1955           "medial": "\uFCEC"
1956         },
1957         "\u0643\u0649": {
1958           "isolated": "\uFC3D",
1959           "final": "\uFC83"
1960         },
1961         "\u0643\u064A": {
1962           "isolated": "\uFC3E",
1963           "final": "\uFC84"
1964         },
1965         "\u0644\u062C": {
1966           "isolated": "\uFC3F",
1967           "initial": "\uFCC9"
1968         },
1969         "\u0644\u062D": {
1970           "isolated": "\uFC40",
1971           "initial": "\uFCCA"
1972         },
1973         "\u0644\u062E": {
1974           "isolated": "\uFC41",
1975           "initial": "\uFCCB"
1976         },
1977         "\u0644\u0645": {
1978           "isolated": "\uFC42",
1979           "final": "\uFC85",
1980           "initial": "\uFCCC",
1981           "medial": "\uFCED"
1982         },
1983         "\u0644\u0649": {
1984           "isolated": "\uFC43",
1985           "final": "\uFC86"
1986         },
1987         "\u0644\u064A": {
1988           "isolated": "\uFC44",
1989           "final": "\uFC87"
1990         },
1991         "\u0645\u062C": {
1992           "isolated": "\uFC45",
1993           "initial": "\uFCCE"
1994         },
1995         "\u0645\u062D": {
1996           "isolated": "\uFC46",
1997           "initial": "\uFCCF"
1998         },
1999         "\u0645\u062E": {
2000           "isolated": "\uFC47",
2001           "initial": "\uFCD0"
2002         },
2003         "\u0645\u0645": {
2004           "isolated": "\uFC48",
2005           "final": "\uFC89",
2006           "initial": "\uFCD1"
2007         },
2008         "\u0645\u0649": {
2009           "isolated": "\uFC49"
2010         },
2011         "\u0645\u064A": {
2012           "isolated": "\uFC4A"
2013         },
2014         "\u0646\u062C": {
2015           "isolated": "\uFC4B",
2016           "initial": "\uFCD2"
2017         },
2018         "\u0646\u062D": {
2019           "isolated": "\uFC4C",
2020           "initial": "\uFCD3"
2021         },
2022         "\u0646\u062E": {
2023           "isolated": "\uFC4D",
2024           "initial": "\uFCD4"
2025         },
2026         "\u0646\u0645": {
2027           "isolated": "\uFC4E",
2028           "final": "\uFC8C",
2029           "initial": "\uFCD5",
2030           "medial": "\uFCEE"
2031         },
2032         "\u0646\u0649": {
2033           "isolated": "\uFC4F",
2034           "final": "\uFC8E"
2035         },
2036         "\u0646\u064A": {
2037           "isolated": "\uFC50",
2038           "final": "\uFC8F"
2039         },
2040         "\u0647\u062C": {
2041           "isolated": "\uFC51",
2042           "initial": "\uFCD7"
2043         },
2044         "\u0647\u0645": {
2045           "isolated": "\uFC52",
2046           "initial": "\uFCD8"
2047         },
2048         "\u0647\u0649": {
2049           "isolated": "\uFC53"
2050         },
2051         "\u0647\u064A": {
2052           "isolated": "\uFC54"
2053         },
2054         "\u064A\u062C": {
2055           "isolated": "\uFC55",
2056           "initial": "\uFCDA"
2057         },
2058         "\u064A\u062D": {
2059           "isolated": "\uFC56",
2060           "initial": "\uFCDB"
2061         },
2062         "\u064A\u062E": {
2063           "isolated": "\uFC57",
2064           "initial": "\uFCDC"
2065         },
2066         "\u064A\u0645": {
2067           "isolated": "\uFC58",
2068           "final": "\uFC93",
2069           "initial": "\uFCDD",
2070           "medial": "\uFCF0"
2071         },
2072         "\u064A\u0649": {
2073           "isolated": "\uFC59",
2074           "final": "\uFC95"
2075         },
2076         "\u064A\u064A": {
2077           "isolated": "\uFC5A",
2078           "final": "\uFC96"
2079         },
2080         "\u0630\u0670": {
2081           "isolated": "\uFC5B"
2082         },
2083         "\u0631\u0670": {
2084           "isolated": "\uFC5C"
2085         },
2086         "\u0649\u0670": {
2087           "isolated": "\uFC5D",
2088           "final": "\uFC90"
2089         },
2090         "\u064C\u0651": {
2091           "isolated": "\uFC5E"
2092         },
2093         "\u064D\u0651": {
2094           "isolated": "\uFC5F"
2095         },
2096         "\u064E\u0651": {
2097           "isolated": "\uFC60"
2098         },
2099         "\u064F\u0651": {
2100           "isolated": "\uFC61"
2101         },
2102         "\u0650\u0651": {
2103           "isolated": "\uFC62"
2104         },
2105         "\u0651\u0670": {
2106           "isolated": "\uFC63"
2107         },
2108         "\u0626\u0631": {
2109           "final": "\uFC64"
2110         },
2111         "\u0626\u0632": {
2112           "final": "\uFC65"
2113         },
2114         "\u0626\u0646": {
2115           "final": "\uFC67"
2116         },
2117         "\u0628\u0631": {
2118           "final": "\uFC6A"
2119         },
2120         "\u0628\u0632": {
2121           "final": "\uFC6B"
2122         },
2123         "\u0628\u0646": {
2124           "final": "\uFC6D"
2125         },
2126         "\u062A\u0631": {
2127           "final": "\uFC70"
2128         },
2129         "\u062A\u0632": {
2130           "final": "\uFC71"
2131         },
2132         "\u062A\u0646": {
2133           "final": "\uFC73"
2134         },
2135         "\u062B\u0631": {
2136           "final": "\uFC76"
2137         },
2138         "\u062B\u0632": {
2139           "final": "\uFC77"
2140         },
2141         "\u062B\u0646": {
2142           "final": "\uFC79"
2143         },
2144         "\u062B\u064A": {
2145           "final": "\uFC7B"
2146         },
2147         "\u0645\u0627": {
2148           "final": "\uFC88"
2149         },
2150         "\u0646\u0631": {
2151           "final": "\uFC8A"
2152         },
2153         "\u0646\u0632": {
2154           "final": "\uFC8B"
2155         },
2156         "\u0646\u0646": {
2157           "final": "\uFC8D"
2158         },
2159         "\u064A\u0631": {
2160           "final": "\uFC91"
2161         },
2162         "\u064A\u0632": {
2163           "final": "\uFC92"
2164         },
2165         "\u064A\u0646": {
2166           "final": "\uFC94"
2167         },
2168         "\u0626\u062E": {
2169           "initial": "\uFC99"
2170         },
2171         "\u0626\u0647": {
2172           "initial": "\uFC9B",
2173           "medial": "\uFCE0"
2174         },
2175         "\u0628\u0647": {
2176           "initial": "\uFCA0",
2177           "medial": "\uFCE2"
2178         },
2179         "\u062A\u0647": {
2180           "initial": "\uFCA5",
2181           "medial": "\uFCE4"
2182         },
2183         "\u0635\u062E": {
2184           "initial": "\uFCB2"
2185         },
2186         "\u0644\u0647": {
2187           "initial": "\uFCCD"
2188         },
2189         "\u0646\u0647": {
2190           "initial": "\uFCD6",
2191           "medial": "\uFCEF"
2192         },
2193         "\u0647\u0670": {
2194           "initial": "\uFCD9"
2195         },
2196         "\u064A\u0647": {
2197           "initial": "\uFCDE",
2198           "medial": "\uFCF1"
2199         },
2200         "\u062B\u0647": {
2201           "medial": "\uFCE6"
2202         },
2203         "\u0633\u0647": {
2204           "medial": "\uFCE8",
2205           "initial": "\uFD31"
2206         },
2207         "\u0634\u0645": {
2208           "medial": "\uFCE9",
2209           "isolated": "\uFD0C",
2210           "final": "\uFD28",
2211           "initial": "\uFD30"
2212         },
2213         "\u0634\u0647": {
2214           "medial": "\uFCEA",
2215           "initial": "\uFD32"
2216         },
2217         "\u0640\u064E\u0651": {
2218           "medial": "\uFCF2"
2219         },
2220         "\u0640\u064F\u0651": {
2221           "medial": "\uFCF3"
2222         },
2223         "\u0640\u0650\u0651": {
2224           "medial": "\uFCF4"
2225         },
2226         "\u0637\u0649": {
2227           "isolated": "\uFCF5",
2228           "final": "\uFD11"
2229         },
2230         "\u0637\u064A": {
2231           "isolated": "\uFCF6",
2232           "final": "\uFD12"
2233         },
2234         "\u0639\u0649": {
2235           "isolated": "\uFCF7",
2236           "final": "\uFD13"
2237         },
2238         "\u0639\u064A": {
2239           "isolated": "\uFCF8",
2240           "final": "\uFD14"
2241         },
2242         "\u063A\u0649": {
2243           "isolated": "\uFCF9",
2244           "final": "\uFD15"
2245         },
2246         "\u063A\u064A": {
2247           "isolated": "\uFCFA",
2248           "final": "\uFD16"
2249         },
2250         "\u0633\u0649": {
2251           "isolated": "\uFCFB"
2252         },
2253         "\u0633\u064A": {
2254           "isolated": "\uFCFC",
2255           "final": "\uFD18"
2256         },
2257         "\u0634\u0649": {
2258           "isolated": "\uFCFD",
2259           "final": "\uFD19"
2260         },
2261         "\u0634\u064A": {
2262           "isolated": "\uFCFE",
2263           "final": "\uFD1A"
2264         },
2265         "\u062D\u0649": {
2266           "isolated": "\uFCFF",
2267           "final": "\uFD1B"
2268         },
2269         "\u062D\u064A": {
2270           "isolated": "\uFD00",
2271           "final": "\uFD1C"
2272         },
2273         "\u062C\u0649": {
2274           "isolated": "\uFD01",
2275           "final": "\uFD1D"
2276         },
2277         "\u062C\u064A": {
2278           "isolated": "\uFD02",
2279           "final": "\uFD1E"
2280         },
2281         "\u062E\u0649": {
2282           "isolated": "\uFD03",
2283           "final": "\uFD1F"
2284         },
2285         "\u062E\u064A": {
2286           "isolated": "\uFD04",
2287           "final": "\uFD20"
2288         },
2289         "\u0635\u0649": {
2290           "isolated": "\uFD05",
2291           "final": "\uFD21"
2292         },
2293         "\u0635\u064A": {
2294           "isolated": "\uFD06",
2295           "final": "\uFD22"
2296         },
2297         "\u0636\u0649": {
2298           "isolated": "\uFD07",
2299           "final": "\uFD23"
2300         },
2301         "\u0636\u064A": {
2302           "isolated": "\uFD08",
2303           "final": "\uFD24"
2304         },
2305         "\u0634\u062C": {
2306           "isolated": "\uFD09",
2307           "final": "\uFD25",
2308           "initial": "\uFD2D",
2309           "medial": "\uFD37"
2310         },
2311         "\u0634\u062D": {
2312           "isolated": "\uFD0A",
2313           "final": "\uFD26",
2314           "initial": "\uFD2E",
2315           "medial": "\uFD38"
2316         },
2317         "\u0634\u062E": {
2318           "isolated": "\uFD0B",
2319           "final": "\uFD27",
2320           "initial": "\uFD2F",
2321           "medial": "\uFD39"
2322         },
2323         "\u0634\u0631": {
2324           "isolated": "\uFD0D",
2325           "final": "\uFD29"
2326         },
2327         "\u0633\u0631": {
2328           "isolated": "\uFD0E",
2329           "final": "\uFD2A"
2330         },
2331         "\u0635\u0631": {
2332           "isolated": "\uFD0F",
2333           "final": "\uFD2B"
2334         },
2335         "\u0636\u0631": {
2336           "isolated": "\uFD10",
2337           "final": "\uFD2C"
2338         },
2339         "\u0633\u0639": {
2340           "final": "\uFD17"
2341         },
2342         "\u062A\u062C\u0645": {
2343           "initial": "\uFD50"
2344         },
2345         "\u062A\u062D\u062C": {
2346           "final": "\uFD51",
2347           "initial": "\uFD52"
2348         },
2349         "\u062A\u062D\u0645": {
2350           "initial": "\uFD53"
2351         },
2352         "\u062A\u062E\u0645": {
2353           "initial": "\uFD54"
2354         },
2355         "\u062A\u0645\u062C": {
2356           "initial": "\uFD55"
2357         },
2358         "\u062A\u0645\u062D": {
2359           "initial": "\uFD56"
2360         },
2361         "\u062A\u0645\u062E": {
2362           "initial": "\uFD57"
2363         },
2364         "\u062C\u0645\u062D": {
2365           "final": "\uFD58",
2366           "initial": "\uFD59"
2367         },
2368         "\u062D\u0645\u064A": {
2369           "final": "\uFD5A"
2370         },
2371         "\u062D\u0645\u0649": {
2372           "final": "\uFD5B"
2373         },
2374         "\u0633\u062D\u062C": {
2375           "initial": "\uFD5C"
2376         },
2377         "\u0633\u062C\u062D": {
2378           "initial": "\uFD5D"
2379         },
2380         "\u0633\u062C\u0649": {
2381           "final": "\uFD5E"
2382         },
2383         "\u0633\u0645\u062D": {
2384           "final": "\uFD5F",
2385           "initial": "\uFD60"
2386         },
2387         "\u0633\u0645\u062C": {
2388           "initial": "\uFD61"
2389         },
2390         "\u0633\u0645\u0645": {
2391           "final": "\uFD62",
2392           "initial": "\uFD63"
2393         },
2394         "\u0635\u062D\u062D": {
2395           "final": "\uFD64",
2396           "initial": "\uFD65"
2397         },
2398         "\u0635\u0645\u0645": {
2399           "final": "\uFD66",
2400           "initial": "\uFDC5"
2401         },
2402         "\u0634\u062D\u0645": {
2403           "final": "\uFD67",
2404           "initial": "\uFD68"
2405         },
2406         "\u0634\u062C\u064A": {
2407           "final": "\uFD69"
2408         },
2409         "\u0634\u0645\u062E": {
2410           "final": "\uFD6A",
2411           "initial": "\uFD6B"
2412         },
2413         "\u0634\u0645\u0645": {
2414           "final": "\uFD6C",
2415           "initial": "\uFD6D"
2416         },
2417         "\u0636\u062D\u0649": {
2418           "final": "\uFD6E"
2419         },
2420         "\u0636\u062E\u0645": {
2421           "final": "\uFD6F",
2422           "initial": "\uFD70"
2423         },
2424         "\u0636\u0645\u062D": {
2425           "final": "\uFD71"
2426         },
2427         "\u0637\u0645\u062D": {
2428           "initial": "\uFD72"
2429         },
2430         "\u0637\u0645\u0645": {
2431           "initial": "\uFD73"
2432         },
2433         "\u0637\u0645\u064A": {
2434           "final": "\uFD74"
2435         },
2436         "\u0639\u062C\u0645": {
2437           "final": "\uFD75",
2438           "initial": "\uFDC4"
2439         },
2440         "\u0639\u0645\u0645": {
2441           "final": "\uFD76",
2442           "initial": "\uFD77"
2443         },
2444         "\u0639\u0645\u0649": {
2445           "final": "\uFD78"
2446         },
2447         "\u063A\u0645\u0645": {
2448           "final": "\uFD79"
2449         },
2450         "\u063A\u0645\u064A": {
2451           "final": "\uFD7A"
2452         },
2453         "\u063A\u0645\u0649": {
2454           "final": "\uFD7B"
2455         },
2456         "\u0641\u062E\u0645": {
2457           "final": "\uFD7C",
2458           "initial": "\uFD7D"
2459         },
2460         "\u0642\u0645\u062D": {
2461           "final": "\uFD7E",
2462           "initial": "\uFDB4"
2463         },
2464         "\u0642\u0645\u0645": {
2465           "final": "\uFD7F"
2466         },
2467         "\u0644\u062D\u0645": {
2468           "final": "\uFD80",
2469           "initial": "\uFDB5"
2470         },
2471         "\u0644\u062D\u064A": {
2472           "final": "\uFD81"
2473         },
2474         "\u0644\u062D\u0649": {
2475           "final": "\uFD82"
2476         },
2477         "\u0644\u062C\u062C": {
2478           "initial": "\uFD83",
2479           "final": "\uFD84"
2480         },
2481         "\u0644\u062E\u0645": {
2482           "final": "\uFD85",
2483           "initial": "\uFD86"
2484         },
2485         "\u0644\u0645\u062D": {
2486           "final": "\uFD87",
2487           "initial": "\uFD88"
2488         },
2489         "\u0645\u062D\u062C": {
2490           "initial": "\uFD89"
2491         },
2492         "\u0645\u062D\u0645": {
2493           "initial": "\uFD8A"
2494         },
2495         "\u0645\u062D\u064A": {
2496           "final": "\uFD8B"
2497         },
2498         "\u0645\u062C\u062D": {
2499           "initial": "\uFD8C"
2500         },
2501         "\u0645\u062C\u0645": {
2502           "initial": "\uFD8D"
2503         },
2504         "\u0645\u062E\u062C": {
2505           "initial": "\uFD8E"
2506         },
2507         "\u0645\u062E\u0645": {
2508           "initial": "\uFD8F"
2509         },
2510         "\u0645\u062C\u062E": {
2511           "initial": "\uFD92"
2512         },
2513         "\u0647\u0645\u062C": {
2514           "initial": "\uFD93"
2515         },
2516         "\u0647\u0645\u0645": {
2517           "initial": "\uFD94"
2518         },
2519         "\u0646\u062D\u0645": {
2520           "initial": "\uFD95"
2521         },
2522         "\u0646\u062D\u0649": {
2523           "final": "\uFD96"
2524         },
2525         "\u0646\u062C\u0645": {
2526           "final": "\uFD97",
2527           "initial": "\uFD98"
2528         },
2529         "\u0646\u062C\u0649": {
2530           "final": "\uFD99"
2531         },
2532         "\u0646\u0645\u064A": {
2533           "final": "\uFD9A"
2534         },
2535         "\u0646\u0645\u0649": {
2536           "final": "\uFD9B"
2537         },
2538         "\u064A\u0645\u0645": {
2539           "final": "\uFD9C",
2540           "initial": "\uFD9D"
2541         },
2542         "\u0628\u062E\u064A": {
2543           "final": "\uFD9E"
2544         },
2545         "\u062A\u062C\u064A": {
2546           "final": "\uFD9F"
2547         },
2548         "\u062A\u062C\u0649": {
2549           "final": "\uFDA0"
2550         },
2551         "\u062A\u062E\u064A": {
2552           "final": "\uFDA1"
2553         },
2554         "\u062A\u062E\u0649": {
2555           "final": "\uFDA2"
2556         },
2557         "\u062A\u0645\u064A": {
2558           "final": "\uFDA3"
2559         },
2560         "\u062A\u0645\u0649": {
2561           "final": "\uFDA4"
2562         },
2563         "\u062C\u0645\u064A": {
2564           "final": "\uFDA5"
2565         },
2566         "\u062C\u062D\u0649": {
2567           "final": "\uFDA6"
2568         },
2569         "\u062C\u0645\u0649": {
2570           "final": "\uFDA7"
2571         },
2572         "\u0633\u062E\u0649": {
2573           "final": "\uFDA8"
2574         },
2575         "\u0635\u062D\u064A": {
2576           "final": "\uFDA9"
2577         },
2578         "\u0634\u062D\u064A": {
2579           "final": "\uFDAA"
2580         },
2581         "\u0636\u062D\u064A": {
2582           "final": "\uFDAB"
2583         },
2584         "\u0644\u062C\u064A": {
2585           "final": "\uFDAC"
2586         },
2587         "\u0644\u0645\u064A": {
2588           "final": "\uFDAD"
2589         },
2590         "\u064A\u062D\u064A": {
2591           "final": "\uFDAE"
2592         },
2593         "\u064A\u062C\u064A": {
2594           "final": "\uFDAF"
2595         },
2596         "\u064A\u0645\u064A": {
2597           "final": "\uFDB0"
2598         },
2599         "\u0645\u0645\u064A": {
2600           "final": "\uFDB1"
2601         },
2602         "\u0642\u0645\u064A": {
2603           "final": "\uFDB2"
2604         },
2605         "\u0646\u062D\u064A": {
2606           "final": "\uFDB3"
2607         },
2608         "\u0639\u0645\u064A": {
2609           "final": "\uFDB6"
2610         },
2611         "\u0643\u0645\u064A": {
2612           "final": "\uFDB7"
2613         },
2614         "\u0646\u062C\u062D": {
2615           "initial": "\uFDB8",
2616           "final": "\uFDBD"
2617         },
2618         "\u0645\u062E\u064A": {
2619           "final": "\uFDB9"
2620         },
2621         "\u0644\u062C\u0645": {
2622           "initial": "\uFDBA",
2623           "final": "\uFDBC"
2624         },
2625         "\u0643\u0645\u0645": {
2626           "final": "\uFDBB",
2627           "initial": "\uFDC3"
2628         },
2629         "\u062C\u062D\u064A": {
2630           "final": "\uFDBE"
2631         },
2632         "\u062D\u062C\u064A": {
2633           "final": "\uFDBF"
2634         },
2635         "\u0645\u062C\u064A": {
2636           "final": "\uFDC0"
2637         },
2638         "\u0641\u0645\u064A": {
2639           "final": "\uFDC1"
2640         },
2641         "\u0628\u062D\u064A": {
2642           "final": "\uFDC2"
2643         },
2644         "\u0633\u062E\u064A": {
2645           "final": "\uFDC6"
2646         },
2647         "\u0646\u062C\u064A": {
2648           "final": "\uFDC7"
2649         },
2650         "\u0644\u0622": {
2651           "isolated": "\uFEF5",
2652           "final": "\uFEF6"
2653         },
2654         "\u0644\u0623": {
2655           "isolated": "\uFEF7",
2656           "final": "\uFEF8"
2657         },
2658         "\u0644\u0625": {
2659           "isolated": "\uFEF9",
2660           "final": "\uFEFA"
2661         },
2662         "\u0644\u0627": {
2663           "isolated": "\uFEFB",
2664           "final": "\uFEFC"
2665         },
2666         "words": {
2667           "\u0635\u0644\u06D2": "\uFDF0",
2668           "\u0642\u0644\u06D2": "\uFDF1",
2669           "\u0627\u0644\u0644\u0647": "\uFDF2",
2670           "\u0627\u0643\u0628\u0631": "\uFDF3",
2671           "\u0645\u062D\u0645\u062F": "\uFDF4",
2672           "\u0635\u0644\u0639\u0645": "\uFDF5",
2673           "\u0631\u0633\u0648\u0644": "\uFDF6",
2674           "\u0639\u0644\u064A\u0647": "\uFDF7",
2675           "\u0648\u0633\u0644\u0645": "\uFDF8",
2676           "\u0635\u0644\u0649": "\uFDF9",
2677           "\u0635\u0644\u0649\u0627\u0644\u0644\u0647\u0639\u0644\u064A\u0647\u0648\u0633\u0644\u0645": "\uFDFA",
2678           "\u062C\u0644\u062C\u0644\u0627\u0644\u0647": "\uFDFB",
2679           "\u0631\u06CC\u0627\u0644": "\uFDFC"
2680         }
2681       };
2682       exports2.default = ligatureReference;
2683     }
2684   });
2685
2686   // node_modules/alif-toolkit/lib/reference.js
2687   var require_reference = __commonJS({
2688     "node_modules/alif-toolkit/lib/reference.js"(exports2) {
2689       "use strict";
2690       Object.defineProperty(exports2, "__esModule", { value: true });
2691       exports2.ligatureWordList = exports2.ligatureList = exports2.letterList = exports2.alefs = exports2.lams = exports2.lineBreakers = exports2.tashkeel = void 0;
2692       var unicode_arabic_1 = require_unicode_arabic();
2693       var unicode_ligatures_1 = require_unicode_ligatures();
2694       var letterList = Object.keys(unicode_arabic_1.default);
2695       exports2.letterList = letterList;
2696       var ligatureList = Object.keys(unicode_ligatures_1.default);
2697       exports2.ligatureList = ligatureList;
2698       var ligatureWordList = Object.keys(unicode_ligatures_1.default.words);
2699       exports2.ligatureWordList = ligatureWordList;
2700       var lams = "\u0644\u06B5\u06B6\u06B7\u06B8";
2701       exports2.lams = lams;
2702       var alefs = "\u0627\u0622\u0623\u0625\u0671\u0672\u0673\u0675\u0773\u0774";
2703       exports2.alefs = alefs;
2704       var tashkeel = "\u0605\u0640\u0670\u0674\u06DF\u06E7\u06E8";
2705       exports2.tashkeel = tashkeel;
2706       function addToTashkeel(start2, finish) {
2707         for (var i3 = start2; i3 <= finish; i3++) {
2708           exports2.tashkeel = tashkeel += String.fromCharCode(i3);
2709         }
2710       }
2711       addToTashkeel(1552, 1562);
2712       addToTashkeel(1611, 1631);
2713       addToTashkeel(1750, 1756);
2714       addToTashkeel(1760, 1764);
2715       addToTashkeel(1770, 1773);
2716       addToTashkeel(2259, 2273);
2717       addToTashkeel(2275, 2303);
2718       addToTashkeel(65136, 65151);
2719       var lineBreakers = "\u0627\u0629\u0648\u06C0\u06CF\u06FD\u06FE\u076B\u076C\u0771\u0773\u0774\u0778\u0779\u08E2\u08B1\u08B2\u08B9";
2720       exports2.lineBreakers = lineBreakers;
2721       function addToLineBreakers(start2, finish) {
2722         for (var i3 = start2; i3 <= finish; i3++) {
2723           exports2.lineBreakers = lineBreakers += String.fromCharCode(i3);
2724         }
2725       }
2726       addToLineBreakers(1536, 1567);
2727       addToLineBreakers(1569, 1573);
2728       addToLineBreakers(1583, 1586);
2729       addToLineBreakers(1632, 1645);
2730       addToLineBreakers(1649, 1655);
2731       addToLineBreakers(1672, 1689);
2732       addToLineBreakers(1731, 1739);
2733       addToLineBreakers(1746, 1785);
2734       addToLineBreakers(1881, 1883);
2735       addToLineBreakers(2218, 2222);
2736       addToLineBreakers(64336, 65021);
2737       addToLineBreakers(65152, 65276);
2738       addToLineBreakers(69216, 69247);
2739       addToLineBreakers(126064, 126143);
2740       addToLineBreakers(126464, 126719);
2741     }
2742   });
2743
2744   // node_modules/alif-toolkit/lib/GlyphSplitter.js
2745   var require_GlyphSplitter = __commonJS({
2746     "node_modules/alif-toolkit/lib/GlyphSplitter.js"(exports2) {
2747       "use strict";
2748       Object.defineProperty(exports2, "__esModule", { value: true });
2749       exports2.GlyphSplitter = GlyphSplitter;
2750       var isArabic_1 = require_isArabic();
2751       var reference_1 = require_reference();
2752       function GlyphSplitter(word) {
2753         let letters = [];
2754         let lastLetter = "";
2755         word.split("").forEach((letter) => {
2756           if ((0, isArabic_1.isArabic)(letter)) {
2757             if (reference_1.tashkeel.indexOf(letter) > -1) {
2758               letters[letters.length - 1] += letter;
2759             } 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)) {
2760               letters[letters.length - 1] += letter;
2761             } else {
2762               letters.push(letter);
2763             }
2764           } else {
2765             letters.push(letter);
2766           }
2767           if (reference_1.tashkeel.indexOf(letter) === -1) {
2768             lastLetter = letter;
2769           }
2770         });
2771         return letters;
2772       }
2773     }
2774   });
2775
2776   // node_modules/alif-toolkit/lib/BaselineSplitter.js
2777   var require_BaselineSplitter = __commonJS({
2778     "node_modules/alif-toolkit/lib/BaselineSplitter.js"(exports2) {
2779       "use strict";
2780       Object.defineProperty(exports2, "__esModule", { value: true });
2781       exports2.BaselineSplitter = BaselineSplitter;
2782       var isArabic_1 = require_isArabic();
2783       var reference_1 = require_reference();
2784       function BaselineSplitter(word) {
2785         let letters = [];
2786         let lastLetter = "";
2787         word.split("").forEach((letter) => {
2788           if ((0, isArabic_1.isArabic)(letter) && (0, isArabic_1.isArabic)(lastLetter)) {
2789             if (lastLetter.length && reference_1.tashkeel.indexOf(letter) > -1) {
2790               letters[letters.length - 1] += letter;
2791             } else if (reference_1.lineBreakers.indexOf(lastLetter) > -1) {
2792               letters.push(letter);
2793             } else {
2794               letters[letters.length - 1] += letter;
2795             }
2796           } else {
2797             letters.push(letter);
2798           }
2799           if (reference_1.tashkeel.indexOf(letter) === -1) {
2800             lastLetter = letter;
2801           }
2802         });
2803         return letters;
2804       }
2805     }
2806   });
2807
2808   // node_modules/alif-toolkit/lib/Normalization.js
2809   var require_Normalization = __commonJS({
2810     "node_modules/alif-toolkit/lib/Normalization.js"(exports2) {
2811       "use strict";
2812       Object.defineProperty(exports2, "__esModule", { value: true });
2813       exports2.Normal = Normal;
2814       var unicode_arabic_1 = require_unicode_arabic();
2815       var unicode_ligatures_1 = require_unicode_ligatures();
2816       var isArabic_1 = require_isArabic();
2817       var reference_1 = require_reference();
2818       function Normal(word, breakPresentationForm) {
2819         if (typeof breakPresentationForm === "undefined") {
2820           breakPresentationForm = true;
2821         }
2822         let returnable = "";
2823         word.split("").forEach((letter) => {
2824           if (!(0, isArabic_1.isArabic)(letter)) {
2825             returnable += letter;
2826             return;
2827           }
2828           for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2829             let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2830             let versions = Object.keys(letterForms);
2831             for (let v2 = 0; v2 < versions.length; v2++) {
2832               let localVersion = letterForms[versions[v2]];
2833               if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2834                 let embeddedForms = Object.keys(localVersion);
2835                 for (let ef = 0; ef < embeddedForms.length; ef++) {
2836                   let form = localVersion[embeddedForms[ef]];
2837                   if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2838                     if (form === letter) {
2839                       if (breakPresentationForm && localVersion["normal"] && ["isolated", "initial", "medial", "final"].indexOf(embeddedForms[ef]) > -1) {
2840                         if (typeof localVersion["normal"] === "object") {
2841                           returnable += localVersion["normal"][0];
2842                         } else {
2843                           returnable += localVersion["normal"];
2844                         }
2845                         return;
2846                       }
2847                       returnable += letter;
2848                       return;
2849                     } else if (typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2850                       returnable += form[0];
2851                       return;
2852                     }
2853                   }
2854                 }
2855               } else if (localVersion === letter) {
2856                 if (breakPresentationForm && letterForms["normal"] && ["isolated", "initial", "medial", "final"].indexOf(versions[v2]) > -1) {
2857                   if (typeof letterForms["normal"] === "object") {
2858                     returnable += letterForms["normal"][0];
2859                   } else {
2860                     returnable += letterForms["normal"];
2861                   }
2862                   return;
2863                 }
2864                 returnable += letter;
2865                 return;
2866               } else if (typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2867                 returnable += localVersion[0];
2868                 return;
2869               }
2870             }
2871           }
2872           for (let v2 = 0; v2 < reference_1.ligatureList.length; v2++) {
2873             let normalForm = reference_1.ligatureList[v2];
2874             if (normalForm !== "words") {
2875               let ligForms = Object.keys(unicode_ligatures_1.default[normalForm]);
2876               for (let f2 = 0; f2 < ligForms.length; f2++) {
2877                 if (unicode_ligatures_1.default[normalForm][ligForms[f2]] === letter) {
2878                   returnable += normalForm;
2879                   return;
2880                 }
2881               }
2882             }
2883           }
2884           for (let v3 = 0; v3 < reference_1.ligatureWordList.length; v3++) {
2885             let normalForm = reference_1.ligatureWordList[v3];
2886             if (unicode_ligatures_1.default.words[normalForm] === letter) {
2887               returnable += normalForm;
2888               return;
2889             }
2890           }
2891           returnable += letter;
2892         });
2893         return returnable;
2894       }
2895     }
2896   });
2897
2898   // node_modules/alif-toolkit/lib/CharShaper.js
2899   var require_CharShaper = __commonJS({
2900     "node_modules/alif-toolkit/lib/CharShaper.js"(exports2) {
2901       "use strict";
2902       Object.defineProperty(exports2, "__esModule", { value: true });
2903       exports2.CharShaper = CharShaper;
2904       var unicode_arabic_1 = require_unicode_arabic();
2905       var isArabic_1 = require_isArabic();
2906       var reference_1 = require_reference();
2907       function CharShaper(letter, form) {
2908         if (!(0, isArabic_1.isArabic)(letter)) {
2909           throw new Error("Not Arabic");
2910         }
2911         if (letter === "\u0621") {
2912           return "\u0621";
2913         }
2914         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2915           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2916           let versions = Object.keys(letterForms);
2917           for (let v2 = 0; v2 < versions.length; v2++) {
2918             let localVersion = letterForms[versions[v2]];
2919             if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2920               if (versions.indexOf(form) > -1) {
2921                 return letterForms[form];
2922               }
2923             } else if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2924               let embeddedVersions = Object.keys(localVersion);
2925               for (let ev = 0; ev < embeddedVersions.length; ev++) {
2926                 if (localVersion[embeddedVersions[ev]] === letter || typeof localVersion[embeddedVersions[ev]] === "object" && localVersion[embeddedVersions[ev]].indexOf && localVersion[embeddedVersions[ev]].indexOf(letter) > -1) {
2927                   if (embeddedVersions.indexOf(form) > -1) {
2928                     return localVersion[form];
2929                   }
2930                 }
2931               }
2932             }
2933           }
2934         }
2935       }
2936     }
2937   });
2938
2939   // node_modules/alif-toolkit/lib/WordShaper.js
2940   var require_WordShaper = __commonJS({
2941     "node_modules/alif-toolkit/lib/WordShaper.js"(exports2) {
2942       "use strict";
2943       Object.defineProperty(exports2, "__esModule", { value: true });
2944       exports2.WordShaper = WordShaper2;
2945       var isArabic_1 = require_isArabic();
2946       var reference_1 = require_reference();
2947       var CharShaper_1 = require_CharShaper();
2948       var unicode_ligatures_1 = require_unicode_ligatures();
2949       function WordShaper2(word) {
2950         let state = "initial";
2951         let output = "";
2952         for (let w2 = 0; w2 < word.length; w2++) {
2953           let nextLetter = " ";
2954           for (let nxw = w2 + 1; nxw < word.length; nxw++) {
2955             if (!(0, isArabic_1.isArabic)(word[nxw])) {
2956               break;
2957             }
2958             if (reference_1.tashkeel.indexOf(word[nxw]) === -1) {
2959               nextLetter = word[nxw];
2960               break;
2961             }
2962           }
2963           if (!(0, isArabic_1.isArabic)(word[w2]) || (0, isArabic_1.isMath)(word[w2])) {
2964             output += word[w2];
2965             state = "initial";
2966           } else if (reference_1.tashkeel.indexOf(word[w2]) > -1) {
2967             output += word[w2];
2968           } else if (nextLetter === " " || reference_1.lineBreakers.indexOf(word[w2]) > -1) {
2969             output += (0, CharShaper_1.CharShaper)(word[w2], state === "initial" ? "isolated" : "final");
2970             state = "initial";
2971           } else if (reference_1.lams.indexOf(word[w2]) > -1 && reference_1.alefs.indexOf(nextLetter) > -1) {
2972             output += unicode_ligatures_1.default[word[w2] + nextLetter][state === "initial" ? "isolated" : "final"];
2973             while (word[w2] !== nextLetter) {
2974               w2++;
2975             }
2976             state = "initial";
2977           } else {
2978             output += (0, CharShaper_1.CharShaper)(word[w2], state);
2979             state = "medial";
2980           }
2981         }
2982         return output;
2983       }
2984     }
2985   });
2986
2987   // node_modules/alif-toolkit/lib/ParentLetter.js
2988   var require_ParentLetter = __commonJS({
2989     "node_modules/alif-toolkit/lib/ParentLetter.js"(exports2) {
2990       "use strict";
2991       Object.defineProperty(exports2, "__esModule", { value: true });
2992       exports2.ParentLetter = ParentLetter;
2993       exports2.GrandparentLetter = GrandparentLetter;
2994       var unicode_arabic_1 = require_unicode_arabic();
2995       var isArabic_1 = require_isArabic();
2996       var reference_1 = require_reference();
2997       function ParentLetter(letter) {
2998         if (!(0, isArabic_1.isArabic)(letter)) {
2999           throw new Error("Not an Arabic letter");
3000         }
3001         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
3002           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
3003           let versions = Object.keys(letterForms);
3004           for (let v2 = 0; v2 < versions.length; v2++) {
3005             let localVersion = letterForms[versions[v2]];
3006             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
3007               let embeddedForms = Object.keys(localVersion);
3008               for (let ef = 0; ef < embeddedForms.length; ef++) {
3009                 let form = localVersion[embeddedForms[ef]];
3010                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
3011                   return localVersion;
3012                 }
3013               }
3014             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
3015               return letterForms;
3016             }
3017           }
3018           return null;
3019         }
3020       }
3021       function GrandparentLetter(letter) {
3022         if (!(0, isArabic_1.isArabic)(letter)) {
3023           throw new Error("Not an Arabic letter");
3024         }
3025         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
3026           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
3027           let versions = Object.keys(letterForms);
3028           for (let v2 = 0; v2 < versions.length; v2++) {
3029             let localVersion = letterForms[versions[v2]];
3030             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
3031               let embeddedForms = Object.keys(localVersion);
3032               for (let ef = 0; ef < embeddedForms.length; ef++) {
3033                 let form = localVersion[embeddedForms[ef]];
3034                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
3035                   return letterForms;
3036                 }
3037               }
3038             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
3039               return letterForms;
3040             }
3041           }
3042           return null;
3043         }
3044       }
3045     }
3046   });
3047
3048   // node_modules/alif-toolkit/lib/index.js
3049   var require_lib = __commonJS({
3050     "node_modules/alif-toolkit/lib/index.js"(exports2) {
3051       "use strict";
3052       Object.defineProperty(exports2, "__esModule", { value: true });
3053       exports2.GrandparentLetter = exports2.ParentLetter = exports2.WordShaper = exports2.CharShaper = exports2.Normal = exports2.BaselineSplitter = exports2.GlyphSplitter = exports2.isArabic = void 0;
3054       var isArabic_1 = require_isArabic();
3055       Object.defineProperty(exports2, "isArabic", { enumerable: true, get: function() {
3056         return isArabic_1.isArabic;
3057       } });
3058       var GlyphSplitter_1 = require_GlyphSplitter();
3059       Object.defineProperty(exports2, "GlyphSplitter", { enumerable: true, get: function() {
3060         return GlyphSplitter_1.GlyphSplitter;
3061       } });
3062       var BaselineSplitter_1 = require_BaselineSplitter();
3063       Object.defineProperty(exports2, "BaselineSplitter", { enumerable: true, get: function() {
3064         return BaselineSplitter_1.BaselineSplitter;
3065       } });
3066       var Normalization_1 = require_Normalization();
3067       Object.defineProperty(exports2, "Normal", { enumerable: true, get: function() {
3068         return Normalization_1.Normal;
3069       } });
3070       var CharShaper_1 = require_CharShaper();
3071       Object.defineProperty(exports2, "CharShaper", { enumerable: true, get: function() {
3072         return CharShaper_1.CharShaper;
3073       } });
3074       var WordShaper_1 = require_WordShaper();
3075       Object.defineProperty(exports2, "WordShaper", { enumerable: true, get: function() {
3076         return WordShaper_1.WordShaper;
3077       } });
3078       var ParentLetter_1 = require_ParentLetter();
3079       Object.defineProperty(exports2, "ParentLetter", { enumerable: true, get: function() {
3080         return ParentLetter_1.ParentLetter;
3081       } });
3082       Object.defineProperty(exports2, "GrandparentLetter", { enumerable: true, get: function() {
3083         return ParentLetter_1.GrandparentLetter;
3084       } });
3085     }
3086   });
3087
3088   // node_modules/vparse/index.js
3089   var require_vparse = __commonJS({
3090     "node_modules/vparse/index.js"(exports2, module2) {
3091       (function(window2) {
3092         "use strict";
3093         function parseVersion3(v2) {
3094           var m2 = v2.replace(/[^0-9.]/g, "").match(/[0-9]*\.|[0-9]+/g) || [];
3095           v2 = {
3096             major: +m2[0] || 0,
3097             minor: +m2[1] || 0,
3098             patch: +m2[2] || 0,
3099             build: +m2[3] || 0
3100           };
3101           v2.isEmpty = !v2.major && !v2.minor && !v2.patch && !v2.build;
3102           v2.parsed = [v2.major, v2.minor, v2.patch, v2.build];
3103           v2.text = v2.parsed.join(".");
3104           v2.compare = compare2;
3105           return v2;
3106         }
3107         function compare2(v2) {
3108           if (typeof v2 === "string") {
3109             v2 = parseVersion3(v2);
3110           }
3111           for (var i3 = 0; i3 < 4; i3++) {
3112             if (this.parsed[i3] !== v2.parsed[i3]) {
3113               return this.parsed[i3] > v2.parsed[i3] ? 1 : -1;
3114             }
3115           }
3116           return 0;
3117         }
3118         if (typeof module2 === "object" && module2 && typeof module2.exports === "object") {
3119           module2.exports = parseVersion3;
3120         } else {
3121           window2.parseVersion = parseVersion3;
3122         }
3123       })(exports2);
3124     }
3125   });
3126
3127   // node_modules/aes-js/index.js
3128   var require_aes_js = __commonJS({
3129     "node_modules/aes-js/index.js"(exports2, module2) {
3130       (function(root3) {
3131         "use strict";
3132         function checkInt(value) {
3133           return parseInt(value) === value;
3134         }
3135         function checkInts(arrayish) {
3136           if (!checkInt(arrayish.length)) {
3137             return false;
3138           }
3139           for (var i3 = 0; i3 < arrayish.length; i3++) {
3140             if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) {
3141               return false;
3142             }
3143           }
3144           return true;
3145         }
3146         function coerceArray(arg, copy2) {
3147           if (arg.buffer && arg.name === "Uint8Array") {
3148             if (copy2) {
3149               if (arg.slice) {
3150                 arg = arg.slice();
3151               } else {
3152                 arg = Array.prototype.slice.call(arg);
3153               }
3154             }
3155             return arg;
3156           }
3157           if (Array.isArray(arg)) {
3158             if (!checkInts(arg)) {
3159               throw new Error("Array contains invalid value: " + arg);
3160             }
3161             return new Uint8Array(arg);
3162           }
3163           if (checkInt(arg.length) && checkInts(arg)) {
3164             return new Uint8Array(arg);
3165           }
3166           throw new Error("unsupported array-like object");
3167         }
3168         function createArray(length2) {
3169           return new Uint8Array(length2);
3170         }
3171         function copyArray2(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
3172           if (sourceStart != null || sourceEnd != null) {
3173             if (sourceArray.slice) {
3174               sourceArray = sourceArray.slice(sourceStart, sourceEnd);
3175             } else {
3176               sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
3177             }
3178           }
3179           targetArray.set(sourceArray, targetStart);
3180         }
3181         var convertUtf8 = /* @__PURE__ */ function() {
3182           function toBytes(text) {
3183             var result = [], i3 = 0;
3184             text = encodeURI(text);
3185             while (i3 < text.length) {
3186               var c2 = text.charCodeAt(i3++);
3187               if (c2 === 37) {
3188                 result.push(parseInt(text.substr(i3, 2), 16));
3189                 i3 += 2;
3190               } else {
3191                 result.push(c2);
3192               }
3193             }
3194             return coerceArray(result);
3195           }
3196           function fromBytes(bytes) {
3197             var result = [], i3 = 0;
3198             while (i3 < bytes.length) {
3199               var c2 = bytes[i3];
3200               if (c2 < 128) {
3201                 result.push(String.fromCharCode(c2));
3202                 i3++;
3203               } else if (c2 > 191 && c2 < 224) {
3204                 result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63));
3205                 i3 += 2;
3206               } else {
3207                 result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63));
3208                 i3 += 3;
3209               }
3210             }
3211             return result.join("");
3212           }
3213           return {
3214             toBytes,
3215             fromBytes
3216           };
3217         }();
3218         var convertHex = /* @__PURE__ */ function() {
3219           function toBytes(text) {
3220             var result = [];
3221             for (var i3 = 0; i3 < text.length; i3 += 2) {
3222               result.push(parseInt(text.substr(i3, 2), 16));
3223             }
3224             return result;
3225           }
3226           var Hex = "0123456789abcdef";
3227           function fromBytes(bytes) {
3228             var result = [];
3229             for (var i3 = 0; i3 < bytes.length; i3++) {
3230               var v2 = bytes[i3];
3231               result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]);
3232             }
3233             return result.join("");
3234           }
3235           return {
3236             toBytes,
3237             fromBytes
3238           };
3239         }();
3240         var numberOfRounds = { 16: 10, 24: 12, 32: 14 };
3241         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];
3242         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];
3243         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];
3244         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];
3245         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];
3246         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];
3247         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];
3248         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];
3249         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];
3250         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];
3251         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];
3252         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];
3253         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];
3254         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];
3255         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];
3256         function convertToInt32(bytes) {
3257           var result = [];
3258           for (var i3 = 0; i3 < bytes.length; i3 += 4) {
3259             result.push(
3260               bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3]
3261             );
3262           }
3263           return result;
3264         }
3265         var AES = function(key) {
3266           if (!(this instanceof AES)) {
3267             throw Error("AES must be instanitated with `new`");
3268           }
3269           Object.defineProperty(this, "key", {
3270             value: coerceArray(key, true)
3271           });
3272           this._prepare();
3273         };
3274         AES.prototype._prepare = function() {
3275           var rounds = numberOfRounds[this.key.length];
3276           if (rounds == null) {
3277             throw new Error("invalid key size (must be 16, 24 or 32 bytes)");
3278           }
3279           this._Ke = [];
3280           this._Kd = [];
3281           for (var i3 = 0; i3 <= rounds; i3++) {
3282             this._Ke.push([0, 0, 0, 0]);
3283             this._Kd.push([0, 0, 0, 0]);
3284           }
3285           var roundKeyCount = (rounds + 1) * 4;
3286           var KC = this.key.length / 4;
3287           var tk = convertToInt32(this.key);
3288           var index;
3289           for (var i3 = 0; i3 < KC; i3++) {
3290             index = i3 >> 2;
3291             this._Ke[index][i3 % 4] = tk[i3];
3292             this._Kd[rounds - index][i3 % 4] = tk[i3];
3293           }
3294           var rconpointer = 0;
3295           var t2 = KC, tt2;
3296           while (t2 < roundKeyCount) {
3297             tt2 = tk[KC - 1];
3298             tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24;
3299             rconpointer += 1;
3300             if (KC != 8) {
3301               for (var i3 = 1; i3 < KC; i3++) {
3302                 tk[i3] ^= tk[i3 - 1];
3303               }
3304             } else {
3305               for (var i3 = 1; i3 < KC / 2; i3++) {
3306                 tk[i3] ^= tk[i3 - 1];
3307               }
3308               tt2 = tk[KC / 2 - 1];
3309               tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24;
3310               for (var i3 = KC / 2 + 1; i3 < KC; i3++) {
3311                 tk[i3] ^= tk[i3 - 1];
3312               }
3313             }
3314             var i3 = 0, r2, c2;
3315             while (i3 < KC && t2 < roundKeyCount) {
3316               r2 = t2 >> 2;
3317               c2 = t2 % 4;
3318               this._Ke[r2][c2] = tk[i3];
3319               this._Kd[rounds - r2][c2] = tk[i3++];
3320               t2++;
3321             }
3322           }
3323           for (var r2 = 1; r2 < rounds; r2++) {
3324             for (var c2 = 0; c2 < 4; c2++) {
3325               tt2 = this._Kd[r2][c2];
3326               this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255];
3327             }
3328           }
3329         };
3330         AES.prototype.encrypt = function(plaintext) {
3331           if (plaintext.length != 16) {
3332             throw new Error("invalid plaintext size (must be 16 bytes)");
3333           }
3334           var rounds = this._Ke.length - 1;
3335           var a2 = [0, 0, 0, 0];
3336           var t2 = convertToInt32(plaintext);
3337           for (var i3 = 0; i3 < 4; i3++) {
3338             t2[i3] ^= this._Ke[0][i3];
3339           }
3340           for (var r2 = 1; r2 < rounds; r2++) {
3341             for (var i3 = 0; i3 < 4; i3++) {
3342               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];
3343             }
3344             t2 = a2.slice();
3345           }
3346           var result = createArray(16), tt2;
3347           for (var i3 = 0; i3 < 4; i3++) {
3348             tt2 = this._Ke[rounds][i3];
3349             result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
3350             result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
3351             result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
3352             result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255;
3353           }
3354           return result;
3355         };
3356         AES.prototype.decrypt = function(ciphertext) {
3357           if (ciphertext.length != 16) {
3358             throw new Error("invalid ciphertext size (must be 16 bytes)");
3359           }
3360           var rounds = this._Kd.length - 1;
3361           var a2 = [0, 0, 0, 0];
3362           var t2 = convertToInt32(ciphertext);
3363           for (var i3 = 0; i3 < 4; i3++) {
3364             t2[i3] ^= this._Kd[0][i3];
3365           }
3366           for (var r2 = 1; r2 < rounds; r2++) {
3367             for (var i3 = 0; i3 < 4; i3++) {
3368               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];
3369             }
3370             t2 = a2.slice();
3371           }
3372           var result = createArray(16), tt2;
3373           for (var i3 = 0; i3 < 4; i3++) {
3374             tt2 = this._Kd[rounds][i3];
3375             result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
3376             result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
3377             result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
3378             result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255;
3379           }
3380           return result;
3381         };
3382         var ModeOfOperationECB = function(key) {
3383           if (!(this instanceof ModeOfOperationECB)) {
3384             throw Error("AES must be instanitated with `new`");
3385           }
3386           this.description = "Electronic Code Block";
3387           this.name = "ecb";
3388           this._aes = new AES(key);
3389         };
3390         ModeOfOperationECB.prototype.encrypt = function(plaintext) {
3391           plaintext = coerceArray(plaintext);
3392           if (plaintext.length % 16 !== 0) {
3393             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
3394           }
3395           var ciphertext = createArray(plaintext.length);
3396           var block2 = createArray(16);
3397           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
3398             copyArray2(plaintext, block2, 0, i3, i3 + 16);
3399             block2 = this._aes.encrypt(block2);
3400             copyArray2(block2, ciphertext, i3);
3401           }
3402           return ciphertext;
3403         };
3404         ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
3405           ciphertext = coerceArray(ciphertext);
3406           if (ciphertext.length % 16 !== 0) {
3407             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
3408           }
3409           var plaintext = createArray(ciphertext.length);
3410           var block2 = createArray(16);
3411           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
3412             copyArray2(ciphertext, block2, 0, i3, i3 + 16);
3413             block2 = this._aes.decrypt(block2);
3414             copyArray2(block2, plaintext, i3);
3415           }
3416           return plaintext;
3417         };
3418         var ModeOfOperationCBC = function(key, iv) {
3419           if (!(this instanceof ModeOfOperationCBC)) {
3420             throw Error("AES must be instanitated with `new`");
3421           }
3422           this.description = "Cipher Block Chaining";
3423           this.name = "cbc";
3424           if (!iv) {
3425             iv = createArray(16);
3426           } else if (iv.length != 16) {
3427             throw new Error("invalid initialation vector size (must be 16 bytes)");
3428           }
3429           this._lastCipherblock = coerceArray(iv, true);
3430           this._aes = new AES(key);
3431         };
3432         ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
3433           plaintext = coerceArray(plaintext);
3434           if (plaintext.length % 16 !== 0) {
3435             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
3436           }
3437           var ciphertext = createArray(plaintext.length);
3438           var block2 = createArray(16);
3439           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
3440             copyArray2(plaintext, block2, 0, i3, i3 + 16);
3441             for (var j2 = 0; j2 < 16; j2++) {
3442               block2[j2] ^= this._lastCipherblock[j2];
3443             }
3444             this._lastCipherblock = this._aes.encrypt(block2);
3445             copyArray2(this._lastCipherblock, ciphertext, i3);
3446           }
3447           return ciphertext;
3448         };
3449         ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
3450           ciphertext = coerceArray(ciphertext);
3451           if (ciphertext.length % 16 !== 0) {
3452             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
3453           }
3454           var plaintext = createArray(ciphertext.length);
3455           var block2 = createArray(16);
3456           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
3457             copyArray2(ciphertext, block2, 0, i3, i3 + 16);
3458             block2 = this._aes.decrypt(block2);
3459             for (var j2 = 0; j2 < 16; j2++) {
3460               plaintext[i3 + j2] = block2[j2] ^ this._lastCipherblock[j2];
3461             }
3462             copyArray2(ciphertext, this._lastCipherblock, 0, i3, i3 + 16);
3463           }
3464           return plaintext;
3465         };
3466         var ModeOfOperationCFB = function(key, iv, segmentSize) {
3467           if (!(this instanceof ModeOfOperationCFB)) {
3468             throw Error("AES must be instanitated with `new`");
3469           }
3470           this.description = "Cipher Feedback";
3471           this.name = "cfb";
3472           if (!iv) {
3473             iv = createArray(16);
3474           } else if (iv.length != 16) {
3475             throw new Error("invalid initialation vector size (must be 16 size)");
3476           }
3477           if (!segmentSize) {
3478             segmentSize = 1;
3479           }
3480           this.segmentSize = segmentSize;
3481           this._shiftRegister = coerceArray(iv, true);
3482           this._aes = new AES(key);
3483         };
3484         ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
3485           if (plaintext.length % this.segmentSize != 0) {
3486             throw new Error("invalid plaintext size (must be segmentSize bytes)");
3487           }
3488           var encrypted = coerceArray(plaintext, true);
3489           var xorSegment;
3490           for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) {
3491             xorSegment = this._aes.encrypt(this._shiftRegister);
3492             for (var j2 = 0; j2 < this.segmentSize; j2++) {
3493               encrypted[i3 + j2] ^= xorSegment[j2];
3494             }
3495             copyArray2(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
3496             copyArray2(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
3497           }
3498           return encrypted;
3499         };
3500         ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
3501           if (ciphertext.length % this.segmentSize != 0) {
3502             throw new Error("invalid ciphertext size (must be segmentSize bytes)");
3503           }
3504           var plaintext = coerceArray(ciphertext, true);
3505           var xorSegment;
3506           for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) {
3507             xorSegment = this._aes.encrypt(this._shiftRegister);
3508             for (var j2 = 0; j2 < this.segmentSize; j2++) {
3509               plaintext[i3 + j2] ^= xorSegment[j2];
3510             }
3511             copyArray2(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
3512             copyArray2(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
3513           }
3514           return plaintext;
3515         };
3516         var ModeOfOperationOFB = function(key, iv) {
3517           if (!(this instanceof ModeOfOperationOFB)) {
3518             throw Error("AES must be instanitated with `new`");
3519           }
3520           this.description = "Output Feedback";
3521           this.name = "ofb";
3522           if (!iv) {
3523             iv = createArray(16);
3524           } else if (iv.length != 16) {
3525             throw new Error("invalid initialation vector size (must be 16 bytes)");
3526           }
3527           this._lastPrecipher = coerceArray(iv, true);
3528           this._lastPrecipherIndex = 16;
3529           this._aes = new AES(key);
3530         };
3531         ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
3532           var encrypted = coerceArray(plaintext, true);
3533           for (var i3 = 0; i3 < encrypted.length; i3++) {
3534             if (this._lastPrecipherIndex === 16) {
3535               this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
3536               this._lastPrecipherIndex = 0;
3537             }
3538             encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++];
3539           }
3540           return encrypted;
3541         };
3542         ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
3543         var Counter = function(initialValue) {
3544           if (!(this instanceof Counter)) {
3545             throw Error("Counter must be instanitated with `new`");
3546           }
3547           if (initialValue !== 0 && !initialValue) {
3548             initialValue = 1;
3549           }
3550           if (typeof initialValue === "number") {
3551             this._counter = createArray(16);
3552             this.setValue(initialValue);
3553           } else {
3554             this.setBytes(initialValue);
3555           }
3556         };
3557         Counter.prototype.setValue = function(value) {
3558           if (typeof value !== "number" || parseInt(value) != value) {
3559             throw new Error("invalid counter value (must be an integer)");
3560           }
3561           if (value > Number.MAX_SAFE_INTEGER) {
3562             throw new Error("integer value out of safe range");
3563           }
3564           for (var index = 15; index >= 0; --index) {
3565             this._counter[index] = value % 256;
3566             value = parseInt(value / 256);
3567           }
3568         };
3569         Counter.prototype.setBytes = function(bytes) {
3570           bytes = coerceArray(bytes, true);
3571           if (bytes.length != 16) {
3572             throw new Error("invalid counter bytes size (must be 16 bytes)");
3573           }
3574           this._counter = bytes;
3575         };
3576         Counter.prototype.increment = function() {
3577           for (var i3 = 15; i3 >= 0; i3--) {
3578             if (this._counter[i3] === 255) {
3579               this._counter[i3] = 0;
3580             } else {
3581               this._counter[i3]++;
3582               break;
3583             }
3584           }
3585         };
3586         var ModeOfOperationCTR = function(key, counter) {
3587           if (!(this instanceof ModeOfOperationCTR)) {
3588             throw Error("AES must be instanitated with `new`");
3589           }
3590           this.description = "Counter";
3591           this.name = "ctr";
3592           if (!(counter instanceof Counter)) {
3593             counter = new Counter(counter);
3594           }
3595           this._counter = counter;
3596           this._remainingCounter = null;
3597           this._remainingCounterIndex = 16;
3598           this._aes = new AES(key);
3599         };
3600         ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
3601           var encrypted = coerceArray(plaintext, true);
3602           for (var i3 = 0; i3 < encrypted.length; i3++) {
3603             if (this._remainingCounterIndex === 16) {
3604               this._remainingCounter = this._aes.encrypt(this._counter._counter);
3605               this._remainingCounterIndex = 0;
3606               this._counter.increment();
3607             }
3608             encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++];
3609           }
3610           return encrypted;
3611         };
3612         ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
3613         function pkcs7pad(data) {
3614           data = coerceArray(data, true);
3615           var padder = 16 - data.length % 16;
3616           var result = createArray(data.length + padder);
3617           copyArray2(data, result);
3618           for (var i3 = data.length; i3 < result.length; i3++) {
3619             result[i3] = padder;
3620           }
3621           return result;
3622         }
3623         function pkcs7strip(data) {
3624           data = coerceArray(data, true);
3625           if (data.length < 16) {
3626             throw new Error("PKCS#7 invalid length");
3627           }
3628           var padder = data[data.length - 1];
3629           if (padder > 16) {
3630             throw new Error("PKCS#7 padding byte out of range");
3631           }
3632           var length2 = data.length - padder;
3633           for (var i3 = 0; i3 < padder; i3++) {
3634             if (data[length2 + i3] !== padder) {
3635               throw new Error("PKCS#7 invalid padding byte");
3636             }
3637           }
3638           var result = createArray(length2);
3639           copyArray2(data, result, 0, 0, length2);
3640           return result;
3641         }
3642         var aesjs2 = {
3643           AES,
3644           Counter,
3645           ModeOfOperation: {
3646             ecb: ModeOfOperationECB,
3647             cbc: ModeOfOperationCBC,
3648             cfb: ModeOfOperationCFB,
3649             ofb: ModeOfOperationOFB,
3650             ctr: ModeOfOperationCTR
3651           },
3652           utils: {
3653             hex: convertHex,
3654             utf8: convertUtf8
3655           },
3656           padding: {
3657             pkcs7: {
3658               pad: pkcs7pad,
3659               strip: pkcs7strip
3660             }
3661           },
3662           _arrayTest: {
3663             coerceArray,
3664             createArray,
3665             copyArray: copyArray2
3666           }
3667         };
3668         if (typeof exports2 !== "undefined") {
3669           module2.exports = aesjs2;
3670         } else if (typeof define === "function" && define.amd) {
3671           define([], function() {
3672             return aesjs2;
3673           });
3674         } else {
3675           if (root3.aesjs) {
3676             aesjs2._aesjs = root3.aesjs;
3677           }
3678           root3.aesjs = aesjs2;
3679         }
3680       })(exports2);
3681     }
3682   });
3683
3684   // node_modules/fast-deep-equal/index.js
3685   var require_fast_deep_equal = __commonJS({
3686     "node_modules/fast-deep-equal/index.js"(exports2, module2) {
3687       "use strict";
3688       module2.exports = function equal(a2, b2) {
3689         if (a2 === b2) return true;
3690         if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
3691           if (a2.constructor !== b2.constructor) return false;
3692           var length2, i3, keys2;
3693           if (Array.isArray(a2)) {
3694             length2 = a2.length;
3695             if (length2 != b2.length) return false;
3696             for (i3 = length2; i3-- !== 0; )
3697               if (!equal(a2[i3], b2[i3])) return false;
3698             return true;
3699           }
3700           if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
3701           if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
3702           if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
3703           keys2 = Object.keys(a2);
3704           length2 = keys2.length;
3705           if (length2 !== Object.keys(b2).length) return false;
3706           for (i3 = length2; i3-- !== 0; )
3707             if (!Object.prototype.hasOwnProperty.call(b2, keys2[i3])) return false;
3708           for (i3 = length2; i3-- !== 0; ) {
3709             var key = keys2[i3];
3710             if (!equal(a2[key], b2[key])) return false;
3711           }
3712           return true;
3713         }
3714         return a2 !== a2 && b2 !== b2;
3715       };
3716     }
3717   });
3718
3719   // node_modules/lodash/lodash.js
3720   var require_lodash = __commonJS({
3721     "node_modules/lodash/lodash.js"(exports2, module2) {
3722       (function() {
3723         var undefined2;
3724         var VERSION = "4.17.21";
3725         var LARGE_ARRAY_SIZE2 = 200;
3726         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`";
3727         var HASH_UNDEFINED4 = "__lodash_hash_undefined__";
3728         var MAX_MEMOIZE_SIZE = 500;
3729         var PLACEHOLDER = "__lodash_placeholder__";
3730         var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
3731         var COMPARE_PARTIAL_FLAG5 = 1, COMPARE_UNORDERED_FLAG3 = 2;
3732         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;
3733         var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "...";
3734         var HOT_COUNT2 = 800, HOT_SPAN2 = 16;
3735         var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2, LAZY_WHILE_FLAG = 3;
3736         var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER4 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0;
3737         var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
3738         var wrapFlags = [
3739           ["ary", WRAP_ARY_FLAG],
3740           ["bind", WRAP_BIND_FLAG],
3741           ["bindKey", WRAP_BIND_KEY_FLAG],
3742           ["curry", WRAP_CURRY_FLAG],
3743           ["curryRight", WRAP_CURRY_RIGHT_FLAG],
3744           ["flip", WRAP_FLIP_FLAG],
3745           ["partial", WRAP_PARTIAL_FLAG],
3746           ["partialRight", WRAP_PARTIAL_RIGHT_FLAG],
3747           ["rearg", WRAP_REARG_FLAG]
3748         ];
3749         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]", objectTag5 = "[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]";
3750         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]";
3751         var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
3752         var reEscapedHtml2 = /&(?:amp|lt|gt|quot|#39);/g, reUnescapedHtml2 = /[&<>"']/g, reHasEscapedHtml2 = RegExp(reEscapedHtml2.source), reHasUnescapedHtml2 = RegExp(reUnescapedHtml2.source);
3753         var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g;
3754         var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
3755         var reRegExpChar2 = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar2.source);
3756         var reTrimStart2 = /^\s+/;
3757         var reWhitespace2 = /\s/;
3758         var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, reSplitDetails = /,? & /;
3759         var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
3760         var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
3761         var reEscapeChar = /\\(\\)?/g;
3762         var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
3763         var reFlags = /\w*$/;
3764         var reIsBadHex2 = /^[-+]0x[0-9a-f]+$/i;
3765         var reIsBinary2 = /^0b[01]+$/i;
3766         var reIsHostCtor2 = /^\[object .+?Constructor\]$/;
3767         var reIsOctal2 = /^0o[0-7]+$/i;
3768         var reIsUint2 = /^(?:0|[1-9]\d*)$/;
3769         var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
3770         var reNoMatch = /($^)/;
3771         var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
3772         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;
3773         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";
3774         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("|") + ")";
3775         var reApos = RegExp(rsApos, "g");
3776         var reComboMark = RegExp(rsCombo, "g");
3777         var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
3778         var reUnicodeWord = RegExp([
3779           rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
3780           rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
3781           rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
3782           rsUpper + "+" + rsOptContrUpper,
3783           rsOrdUpper,
3784           rsOrdLower,
3785           rsDigits,
3786           rsEmoji
3787         ].join("|"), "g");
3788         var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
3789         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 ]/;
3790         var contextProps = [
3791           "Array",
3792           "Buffer",
3793           "DataView",
3794           "Date",
3795           "Error",
3796           "Float32Array",
3797           "Float64Array",
3798           "Function",
3799           "Int8Array",
3800           "Int16Array",
3801           "Int32Array",
3802           "Map",
3803           "Math",
3804           "Object",
3805           "Promise",
3806           "RegExp",
3807           "Set",
3808           "String",
3809           "Symbol",
3810           "TypeError",
3811           "Uint8Array",
3812           "Uint8ClampedArray",
3813           "Uint16Array",
3814           "Uint32Array",
3815           "WeakMap",
3816           "_",
3817           "clearTimeout",
3818           "isFinite",
3819           "parseInt",
3820           "setTimeout"
3821         ];
3822         var templateCounter = -1;
3823         var typedArrayTags2 = {};
3824         typedArrayTags2[float32Tag2] = typedArrayTags2[float64Tag2] = typedArrayTags2[int8Tag2] = typedArrayTags2[int16Tag2] = typedArrayTags2[int32Tag2] = typedArrayTags2[uint8Tag2] = typedArrayTags2[uint8ClampedTag2] = typedArrayTags2[uint16Tag2] = typedArrayTags2[uint32Tag2] = true;
3825         typedArrayTags2[argsTag4] = typedArrayTags2[arrayTag3] = typedArrayTags2[arrayBufferTag3] = typedArrayTags2[boolTag3] = typedArrayTags2[dataViewTag4] = typedArrayTags2[dateTag3] = typedArrayTags2[errorTag3] = typedArrayTags2[funcTag3] = typedArrayTags2[mapTag4] = typedArrayTags2[numberTag4] = typedArrayTags2[objectTag5] = typedArrayTags2[regexpTag3] = typedArrayTags2[setTag4] = typedArrayTags2[stringTag3] = typedArrayTags2[weakMapTag3] = false;
3826         var cloneableTags = {};
3827         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[objectTag5] = cloneableTags[regexpTag3] = cloneableTags[setTag4] = cloneableTags[stringTag3] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag2] = cloneableTags[uint8ClampedTag2] = cloneableTags[uint16Tag2] = cloneableTags[uint32Tag2] = true;
3828         cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
3829         var deburredLetters = {
3830           // Latin-1 Supplement block.
3831           "\xC0": "A",
3832           "\xC1": "A",
3833           "\xC2": "A",
3834           "\xC3": "A",
3835           "\xC4": "A",
3836           "\xC5": "A",
3837           "\xE0": "a",
3838           "\xE1": "a",
3839           "\xE2": "a",
3840           "\xE3": "a",
3841           "\xE4": "a",
3842           "\xE5": "a",
3843           "\xC7": "C",
3844           "\xE7": "c",
3845           "\xD0": "D",
3846           "\xF0": "d",
3847           "\xC8": "E",
3848           "\xC9": "E",
3849           "\xCA": "E",
3850           "\xCB": "E",
3851           "\xE8": "e",
3852           "\xE9": "e",
3853           "\xEA": "e",
3854           "\xEB": "e",
3855           "\xCC": "I",
3856           "\xCD": "I",
3857           "\xCE": "I",
3858           "\xCF": "I",
3859           "\xEC": "i",
3860           "\xED": "i",
3861           "\xEE": "i",
3862           "\xEF": "i",
3863           "\xD1": "N",
3864           "\xF1": "n",
3865           "\xD2": "O",
3866           "\xD3": "O",
3867           "\xD4": "O",
3868           "\xD5": "O",
3869           "\xD6": "O",
3870           "\xD8": "O",
3871           "\xF2": "o",
3872           "\xF3": "o",
3873           "\xF4": "o",
3874           "\xF5": "o",
3875           "\xF6": "o",
3876           "\xF8": "o",
3877           "\xD9": "U",
3878           "\xDA": "U",
3879           "\xDB": "U",
3880           "\xDC": "U",
3881           "\xF9": "u",
3882           "\xFA": "u",
3883           "\xFB": "u",
3884           "\xFC": "u",
3885           "\xDD": "Y",
3886           "\xFD": "y",
3887           "\xFF": "y",
3888           "\xC6": "Ae",
3889           "\xE6": "ae",
3890           "\xDE": "Th",
3891           "\xFE": "th",
3892           "\xDF": "ss",
3893           // Latin Extended-A block.
3894           "\u0100": "A",
3895           "\u0102": "A",
3896           "\u0104": "A",
3897           "\u0101": "a",
3898           "\u0103": "a",
3899           "\u0105": "a",
3900           "\u0106": "C",
3901           "\u0108": "C",
3902           "\u010A": "C",
3903           "\u010C": "C",
3904           "\u0107": "c",
3905           "\u0109": "c",
3906           "\u010B": "c",
3907           "\u010D": "c",
3908           "\u010E": "D",
3909           "\u0110": "D",
3910           "\u010F": "d",
3911           "\u0111": "d",
3912           "\u0112": "E",
3913           "\u0114": "E",
3914           "\u0116": "E",
3915           "\u0118": "E",
3916           "\u011A": "E",
3917           "\u0113": "e",
3918           "\u0115": "e",
3919           "\u0117": "e",
3920           "\u0119": "e",
3921           "\u011B": "e",
3922           "\u011C": "G",
3923           "\u011E": "G",
3924           "\u0120": "G",
3925           "\u0122": "G",
3926           "\u011D": "g",
3927           "\u011F": "g",
3928           "\u0121": "g",
3929           "\u0123": "g",
3930           "\u0124": "H",
3931           "\u0126": "H",
3932           "\u0125": "h",
3933           "\u0127": "h",
3934           "\u0128": "I",
3935           "\u012A": "I",
3936           "\u012C": "I",
3937           "\u012E": "I",
3938           "\u0130": "I",
3939           "\u0129": "i",
3940           "\u012B": "i",
3941           "\u012D": "i",
3942           "\u012F": "i",
3943           "\u0131": "i",
3944           "\u0134": "J",
3945           "\u0135": "j",
3946           "\u0136": "K",
3947           "\u0137": "k",
3948           "\u0138": "k",
3949           "\u0139": "L",
3950           "\u013B": "L",
3951           "\u013D": "L",
3952           "\u013F": "L",
3953           "\u0141": "L",
3954           "\u013A": "l",
3955           "\u013C": "l",
3956           "\u013E": "l",
3957           "\u0140": "l",
3958           "\u0142": "l",
3959           "\u0143": "N",
3960           "\u0145": "N",
3961           "\u0147": "N",
3962           "\u014A": "N",
3963           "\u0144": "n",
3964           "\u0146": "n",
3965           "\u0148": "n",
3966           "\u014B": "n",
3967           "\u014C": "O",
3968           "\u014E": "O",
3969           "\u0150": "O",
3970           "\u014D": "o",
3971           "\u014F": "o",
3972           "\u0151": "o",
3973           "\u0154": "R",
3974           "\u0156": "R",
3975           "\u0158": "R",
3976           "\u0155": "r",
3977           "\u0157": "r",
3978           "\u0159": "r",
3979           "\u015A": "S",
3980           "\u015C": "S",
3981           "\u015E": "S",
3982           "\u0160": "S",
3983           "\u015B": "s",
3984           "\u015D": "s",
3985           "\u015F": "s",
3986           "\u0161": "s",
3987           "\u0162": "T",
3988           "\u0164": "T",
3989           "\u0166": "T",
3990           "\u0163": "t",
3991           "\u0165": "t",
3992           "\u0167": "t",
3993           "\u0168": "U",
3994           "\u016A": "U",
3995           "\u016C": "U",
3996           "\u016E": "U",
3997           "\u0170": "U",
3998           "\u0172": "U",
3999           "\u0169": "u",
4000           "\u016B": "u",
4001           "\u016D": "u",
4002           "\u016F": "u",
4003           "\u0171": "u",
4004           "\u0173": "u",
4005           "\u0174": "W",
4006           "\u0175": "w",
4007           "\u0176": "Y",
4008           "\u0177": "y",
4009           "\u0178": "Y",
4010           "\u0179": "Z",
4011           "\u017B": "Z",
4012           "\u017D": "Z",
4013           "\u017A": "z",
4014           "\u017C": "z",
4015           "\u017E": "z",
4016           "\u0132": "IJ",
4017           "\u0133": "ij",
4018           "\u0152": "Oe",
4019           "\u0153": "oe",
4020           "\u0149": "'n",
4021           "\u017F": "s"
4022         };
4023         var htmlEscapes2 = {
4024           "&": "&amp;",
4025           "<": "&lt;",
4026           ">": "&gt;",
4027           '"': "&quot;",
4028           "'": "&#39;"
4029         };
4030         var htmlUnescapes2 = {
4031           "&amp;": "&",
4032           "&lt;": "<",
4033           "&gt;": ">",
4034           "&quot;": '"',
4035           "&#39;": "'"
4036         };
4037         var stringEscapes = {
4038           "\\": "\\",
4039           "'": "'",
4040           "\n": "n",
4041           "\r": "r",
4042           "\u2028": "u2028",
4043           "\u2029": "u2029"
4044         };
4045         var freeParseFloat = parseFloat, freeParseInt2 = parseInt;
4046         var freeGlobal2 = typeof global == "object" && global && global.Object === Object && global;
4047         var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
4048         var root3 = freeGlobal2 || freeSelf2 || Function("return this")();
4049         var freeExports4 = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
4050         var freeModule4 = freeExports4 && typeof module2 == "object" && module2 && !module2.nodeType && module2;
4051         var moduleExports4 = freeModule4 && freeModule4.exports === freeExports4;
4052         var freeProcess2 = moduleExports4 && freeGlobal2.process;
4053         var nodeUtil2 = function() {
4054           try {
4055             var types = freeModule4 && freeModule4.require && freeModule4.require("util").types;
4056             if (types) {
4057               return types;
4058             }
4059             return freeProcess2 && freeProcess2.binding && freeProcess2.binding("util");
4060           } catch (e3) {
4061           }
4062         }();
4063         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;
4064         function apply2(func, thisArg, args) {
4065           switch (args.length) {
4066             case 0:
4067               return func.call(thisArg);
4068             case 1:
4069               return func.call(thisArg, args[0]);
4070             case 2:
4071               return func.call(thisArg, args[0], args[1]);
4072             case 3:
4073               return func.call(thisArg, args[0], args[1], args[2]);
4074           }
4075           return func.apply(thisArg, args);
4076         }
4077         function arrayAggregator(array2, setter, iteratee, accumulator) {
4078           var index = -1, length2 = array2 == null ? 0 : array2.length;
4079           while (++index < length2) {
4080             var value = array2[index];
4081             setter(accumulator, value, iteratee(value), array2);
4082           }
4083           return accumulator;
4084         }
4085         function arrayEach(array2, iteratee) {
4086           var index = -1, length2 = array2 == null ? 0 : array2.length;
4087           while (++index < length2) {
4088             if (iteratee(array2[index], index, array2) === false) {
4089               break;
4090             }
4091           }
4092           return array2;
4093         }
4094         function arrayEachRight(array2, iteratee) {
4095           var length2 = array2 == null ? 0 : array2.length;
4096           while (length2--) {
4097             if (iteratee(array2[length2], length2, array2) === false) {
4098               break;
4099             }
4100           }
4101           return array2;
4102         }
4103         function arrayEvery(array2, predicate) {
4104           var index = -1, length2 = array2 == null ? 0 : array2.length;
4105           while (++index < length2) {
4106             if (!predicate(array2[index], index, array2)) {
4107               return false;
4108             }
4109           }
4110           return true;
4111         }
4112         function arrayFilter2(array2, predicate) {
4113           var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
4114           while (++index < length2) {
4115             var value = array2[index];
4116             if (predicate(value, index, array2)) {
4117               result[resIndex++] = value;
4118             }
4119           }
4120           return result;
4121         }
4122         function arrayIncludes(array2, value) {
4123           var length2 = array2 == null ? 0 : array2.length;
4124           return !!length2 && baseIndexOf(array2, value, 0) > -1;
4125         }
4126         function arrayIncludesWith(array2, value, comparator) {
4127           var index = -1, length2 = array2 == null ? 0 : array2.length;
4128           while (++index < length2) {
4129             if (comparator(value, array2[index])) {
4130               return true;
4131             }
4132           }
4133           return false;
4134         }
4135         function arrayMap2(array2, iteratee) {
4136           var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
4137           while (++index < length2) {
4138             result[index] = iteratee(array2[index], index, array2);
4139           }
4140           return result;
4141         }
4142         function arrayPush2(array2, values) {
4143           var index = -1, length2 = values.length, offset = array2.length;
4144           while (++index < length2) {
4145             array2[offset + index] = values[index];
4146           }
4147           return array2;
4148         }
4149         function arrayReduce(array2, iteratee, accumulator, initAccum) {
4150           var index = -1, length2 = array2 == null ? 0 : array2.length;
4151           if (initAccum && length2) {
4152             accumulator = array2[++index];
4153           }
4154           while (++index < length2) {
4155             accumulator = iteratee(accumulator, array2[index], index, array2);
4156           }
4157           return accumulator;
4158         }
4159         function arrayReduceRight(array2, iteratee, accumulator, initAccum) {
4160           var length2 = array2 == null ? 0 : array2.length;
4161           if (initAccum && length2) {
4162             accumulator = array2[--length2];
4163           }
4164           while (length2--) {
4165             accumulator = iteratee(accumulator, array2[length2], length2, array2);
4166           }
4167           return accumulator;
4168         }
4169         function arraySome2(array2, predicate) {
4170           var index = -1, length2 = array2 == null ? 0 : array2.length;
4171           while (++index < length2) {
4172             if (predicate(array2[index], index, array2)) {
4173               return true;
4174             }
4175           }
4176           return false;
4177         }
4178         var asciiSize = baseProperty("length");
4179         function asciiToArray(string) {
4180           return string.split("");
4181         }
4182         function asciiWords(string) {
4183           return string.match(reAsciiWord) || [];
4184         }
4185         function baseFindKey(collection, predicate, eachFunc) {
4186           var result;
4187           eachFunc(collection, function(value, key, collection2) {
4188             if (predicate(value, key, collection2)) {
4189               result = key;
4190               return false;
4191             }
4192           });
4193           return result;
4194         }
4195         function baseFindIndex(array2, predicate, fromIndex, fromRight) {
4196           var length2 = array2.length, index = fromIndex + (fromRight ? 1 : -1);
4197           while (fromRight ? index-- : ++index < length2) {
4198             if (predicate(array2[index], index, array2)) {
4199               return index;
4200             }
4201           }
4202           return -1;
4203         }
4204         function baseIndexOf(array2, value, fromIndex) {
4205           return value === value ? strictIndexOf(array2, value, fromIndex) : baseFindIndex(array2, baseIsNaN, fromIndex);
4206         }
4207         function baseIndexOfWith(array2, value, fromIndex, comparator) {
4208           var index = fromIndex - 1, length2 = array2.length;
4209           while (++index < length2) {
4210             if (comparator(array2[index], value)) {
4211               return index;
4212             }
4213           }
4214           return -1;
4215         }
4216         function baseIsNaN(value) {
4217           return value !== value;
4218         }
4219         function baseMean(array2, iteratee) {
4220           var length2 = array2 == null ? 0 : array2.length;
4221           return length2 ? baseSum(array2, iteratee) / length2 : NAN2;
4222         }
4223         function baseProperty(key) {
4224           return function(object) {
4225             return object == null ? undefined2 : object[key];
4226           };
4227         }
4228         function basePropertyOf2(object) {
4229           return function(key) {
4230             return object == null ? undefined2 : object[key];
4231           };
4232         }
4233         function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
4234           eachFunc(collection, function(value, index, collection2) {
4235             accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection2);
4236           });
4237           return accumulator;
4238         }
4239         function baseSortBy(array2, comparer) {
4240           var length2 = array2.length;
4241           array2.sort(comparer);
4242           while (length2--) {
4243             array2[length2] = array2[length2].value;
4244           }
4245           return array2;
4246         }
4247         function baseSum(array2, iteratee) {
4248           var result, index = -1, length2 = array2.length;
4249           while (++index < length2) {
4250             var current = iteratee(array2[index]);
4251             if (current !== undefined2) {
4252               result = result === undefined2 ? current : result + current;
4253             }
4254           }
4255           return result;
4256         }
4257         function baseTimes2(n3, iteratee) {
4258           var index = -1, result = Array(n3);
4259           while (++index < n3) {
4260             result[index] = iteratee(index);
4261           }
4262           return result;
4263         }
4264         function baseToPairs(object, props) {
4265           return arrayMap2(props, function(key) {
4266             return [key, object[key]];
4267           });
4268         }
4269         function baseTrim2(string) {
4270           return string ? string.slice(0, trimmedEndIndex2(string) + 1).replace(reTrimStart2, "") : string;
4271         }
4272         function baseUnary2(func) {
4273           return function(value) {
4274             return func(value);
4275           };
4276         }
4277         function baseValues(object, props) {
4278           return arrayMap2(props, function(key) {
4279             return object[key];
4280           });
4281         }
4282         function cacheHas2(cache, key) {
4283           return cache.has(key);
4284         }
4285         function charsStartIndex(strSymbols, chrSymbols) {
4286           var index = -1, length2 = strSymbols.length;
4287           while (++index < length2 && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
4288           }
4289           return index;
4290         }
4291         function charsEndIndex(strSymbols, chrSymbols) {
4292           var index = strSymbols.length;
4293           while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
4294           }
4295           return index;
4296         }
4297         function countHolders(array2, placeholder) {
4298           var length2 = array2.length, result = 0;
4299           while (length2--) {
4300             if (array2[length2] === placeholder) {
4301               ++result;
4302             }
4303           }
4304           return result;
4305         }
4306         var deburrLetter = basePropertyOf2(deburredLetters);
4307         var escapeHtmlChar2 = basePropertyOf2(htmlEscapes2);
4308         function escapeStringChar(chr) {
4309           return "\\" + stringEscapes[chr];
4310         }
4311         function getValue2(object, key) {
4312           return object == null ? undefined2 : object[key];
4313         }
4314         function hasUnicode(string) {
4315           return reHasUnicode.test(string);
4316         }
4317         function hasUnicodeWord(string) {
4318           return reHasUnicodeWord.test(string);
4319         }
4320         function iteratorToArray(iterator) {
4321           var data, result = [];
4322           while (!(data = iterator.next()).done) {
4323             result.push(data.value);
4324           }
4325           return result;
4326         }
4327         function mapToArray2(map2) {
4328           var index = -1, result = Array(map2.size);
4329           map2.forEach(function(value, key) {
4330             result[++index] = [key, value];
4331           });
4332           return result;
4333         }
4334         function overArg2(func, transform2) {
4335           return function(arg) {
4336             return func(transform2(arg));
4337           };
4338         }
4339         function replaceHolders(array2, placeholder) {
4340           var index = -1, length2 = array2.length, resIndex = 0, result = [];
4341           while (++index < length2) {
4342             var value = array2[index];
4343             if (value === placeholder || value === PLACEHOLDER) {
4344               array2[index] = PLACEHOLDER;
4345               result[resIndex++] = index;
4346             }
4347           }
4348           return result;
4349         }
4350         function setToArray2(set4) {
4351           var index = -1, result = Array(set4.size);
4352           set4.forEach(function(value) {
4353             result[++index] = value;
4354           });
4355           return result;
4356         }
4357         function setToPairs(set4) {
4358           var index = -1, result = Array(set4.size);
4359           set4.forEach(function(value) {
4360             result[++index] = [value, value];
4361           });
4362           return result;
4363         }
4364         function strictIndexOf(array2, value, fromIndex) {
4365           var index = fromIndex - 1, length2 = array2.length;
4366           while (++index < length2) {
4367             if (array2[index] === value) {
4368               return index;
4369             }
4370           }
4371           return -1;
4372         }
4373         function strictLastIndexOf(array2, value, fromIndex) {
4374           var index = fromIndex + 1;
4375           while (index--) {
4376             if (array2[index] === value) {
4377               return index;
4378             }
4379           }
4380           return index;
4381         }
4382         function stringSize(string) {
4383           return hasUnicode(string) ? unicodeSize(string) : asciiSize(string);
4384         }
4385         function stringToArray(string) {
4386           return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
4387         }
4388         function trimmedEndIndex2(string) {
4389           var index = string.length;
4390           while (index-- && reWhitespace2.test(string.charAt(index))) {
4391           }
4392           return index;
4393         }
4394         var unescapeHtmlChar2 = basePropertyOf2(htmlUnescapes2);
4395         function unicodeSize(string) {
4396           var result = reUnicode.lastIndex = 0;
4397           while (reUnicode.test(string)) {
4398             ++result;
4399           }
4400           return result;
4401         }
4402         function unicodeToArray(string) {
4403           return string.match(reUnicode) || [];
4404         }
4405         function unicodeWords(string) {
4406           return string.match(reUnicodeWord) || [];
4407         }
4408         var runInContext = function runInContext2(context) {
4409           context = context == null ? root3 : _2.defaults(root3.Object(), context, _2.pick(root3, contextProps));
4410           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;
4411           var arrayProto2 = Array2.prototype, funcProto4 = Function2.prototype, objectProto16 = Object2.prototype;
4412           var coreJsData2 = context["__core-js_shared__"];
4413           var funcToString4 = funcProto4.toString;
4414           var hasOwnProperty13 = objectProto16.hasOwnProperty;
4415           var idCounter = 0;
4416           var maskSrcKey2 = function() {
4417             var uid = /[^.]+$/.exec(coreJsData2 && coreJsData2.keys && coreJsData2.keys.IE_PROTO || "");
4418             return uid ? "Symbol(src)_1." + uid : "";
4419           }();
4420           var nativeObjectToString3 = objectProto16.toString;
4421           var objectCtorString2 = funcToString4.call(Object2);
4422           var oldDash = root3._;
4423           var reIsNative2 = RegExp2(
4424             "^" + funcToString4.call(hasOwnProperty13).replace(reRegExpChar2, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
4425           );
4426           var Buffer4 = moduleExports4 ? context.Buffer : undefined2, Symbol3 = context.Symbol, Uint8Array3 = context.Uint8Array, allocUnsafe2 = Buffer4 ? Buffer4.allocUnsafe : undefined2, getPrototype2 = overArg2(Object2.getPrototypeOf, Object2), objectCreate2 = Object2.create, propertyIsEnumerable3 = objectProto16.propertyIsEnumerable, splice2 = arrayProto2.splice, spreadableSymbol = Symbol3 ? Symbol3.isConcatSpreadable : undefined2, symIterator = Symbol3 ? Symbol3.iterator : undefined2, symToStringTag3 = Symbol3 ? Symbol3.toStringTag : undefined2;
4427           var defineProperty2 = function() {
4428             try {
4429               var func = getNative2(Object2, "defineProperty");
4430               func({}, "", {});
4431               return func;
4432             } catch (e3) {
4433             }
4434           }();
4435           var ctxClearTimeout = context.clearTimeout !== root3.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root3.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root3.setTimeout && context.setTimeout;
4436           var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols2 = Object2.getOwnPropertySymbols, nativeIsBuffer2 = Buffer4 ? Buffer4.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto2.join, nativeKeys2 = overArg2(Object2.keys, Object2), nativeMax3 = Math2.max, nativeMin2 = Math2.min, nativeNow2 = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto2.reverse;
4437           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");
4438           var metaMap = WeakMap2 && new WeakMap2();
4439           var realNames = {};
4440           var dataViewCtorString2 = toSource2(DataView3), mapCtorString2 = toSource2(Map3), promiseCtorString2 = toSource2(Promise3), setCtorString2 = toSource2(Set3), weakMapCtorString2 = toSource2(WeakMap2);
4441           var symbolProto3 = Symbol3 ? Symbol3.prototype : undefined2, symbolValueOf2 = symbolProto3 ? symbolProto3.valueOf : undefined2, symbolToString2 = symbolProto3 ? symbolProto3.toString : undefined2;
4442           function lodash(value) {
4443             if (isObjectLike2(value) && !isArray2(value) && !(value instanceof LazyWrapper)) {
4444               if (value instanceof LodashWrapper) {
4445                 return value;
4446               }
4447               if (hasOwnProperty13.call(value, "__wrapped__")) {
4448                 return wrapperClone(value);
4449               }
4450             }
4451             return new LodashWrapper(value);
4452           }
4453           var baseCreate2 = /* @__PURE__ */ function() {
4454             function object() {
4455             }
4456             return function(proto) {
4457               if (!isObject2(proto)) {
4458                 return {};
4459               }
4460               if (objectCreate2) {
4461                 return objectCreate2(proto);
4462               }
4463               object.prototype = proto;
4464               var result2 = new object();
4465               object.prototype = undefined2;
4466               return result2;
4467             };
4468           }();
4469           function baseLodash() {
4470           }
4471           function LodashWrapper(value, chainAll) {
4472             this.__wrapped__ = value;
4473             this.__actions__ = [];
4474             this.__chain__ = !!chainAll;
4475             this.__index__ = 0;
4476             this.__values__ = undefined2;
4477           }
4478           lodash.templateSettings = {
4479             /**
4480              * Used to detect `data` property values to be HTML-escaped.
4481              *
4482              * @memberOf _.templateSettings
4483              * @type {RegExp}
4484              */
4485             "escape": reEscape,
4486             /**
4487              * Used to detect code to be evaluated.
4488              *
4489              * @memberOf _.templateSettings
4490              * @type {RegExp}
4491              */
4492             "evaluate": reEvaluate,
4493             /**
4494              * Used to detect `data` property values to inject.
4495              *
4496              * @memberOf _.templateSettings
4497              * @type {RegExp}
4498              */
4499             "interpolate": reInterpolate,
4500             /**
4501              * Used to reference the data object in the template text.
4502              *
4503              * @memberOf _.templateSettings
4504              * @type {string}
4505              */
4506             "variable": "",
4507             /**
4508              * Used to import variables into the compiled template.
4509              *
4510              * @memberOf _.templateSettings
4511              * @type {Object}
4512              */
4513             "imports": {
4514               /**
4515                * A reference to the `lodash` function.
4516                *
4517                * @memberOf _.templateSettings.imports
4518                * @type {Function}
4519                */
4520               "_": lodash
4521             }
4522           };
4523           lodash.prototype = baseLodash.prototype;
4524           lodash.prototype.constructor = lodash;
4525           LodashWrapper.prototype = baseCreate2(baseLodash.prototype);
4526           LodashWrapper.prototype.constructor = LodashWrapper;
4527           function LazyWrapper(value) {
4528             this.__wrapped__ = value;
4529             this.__actions__ = [];
4530             this.__dir__ = 1;
4531             this.__filtered__ = false;
4532             this.__iteratees__ = [];
4533             this.__takeCount__ = MAX_ARRAY_LENGTH;
4534             this.__views__ = [];
4535           }
4536           function lazyClone() {
4537             var result2 = new LazyWrapper(this.__wrapped__);
4538             result2.__actions__ = copyArray2(this.__actions__);
4539             result2.__dir__ = this.__dir__;
4540             result2.__filtered__ = this.__filtered__;
4541             result2.__iteratees__ = copyArray2(this.__iteratees__);
4542             result2.__takeCount__ = this.__takeCount__;
4543             result2.__views__ = copyArray2(this.__views__);
4544             return result2;
4545           }
4546           function lazyReverse() {
4547             if (this.__filtered__) {
4548               var result2 = new LazyWrapper(this);
4549               result2.__dir__ = -1;
4550               result2.__filtered__ = true;
4551             } else {
4552               result2 = this.clone();
4553               result2.__dir__ *= -1;
4554             }
4555             return result2;
4556           }
4557           function lazyValue() {
4558             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__);
4559             if (!isArr || !isRight && arrLength == length2 && takeCount == length2) {
4560               return baseWrapperValue(array2, this.__actions__);
4561             }
4562             var result2 = [];
4563             outer:
4564               while (length2-- && resIndex < takeCount) {
4565                 index += dir;
4566                 var iterIndex = -1, value = array2[index];
4567                 while (++iterIndex < iterLength) {
4568                   var data = iteratees[iterIndex], iteratee2 = data.iteratee, type2 = data.type, computed = iteratee2(value);
4569                   if (type2 == LAZY_MAP_FLAG) {
4570                     value = computed;
4571                   } else if (!computed) {
4572                     if (type2 == LAZY_FILTER_FLAG) {
4573                       continue outer;
4574                     } else {
4575                       break outer;
4576                     }
4577                   }
4578                 }
4579                 result2[resIndex++] = value;
4580               }
4581             return result2;
4582           }
4583           LazyWrapper.prototype = baseCreate2(baseLodash.prototype);
4584           LazyWrapper.prototype.constructor = LazyWrapper;
4585           function Hash2(entries) {
4586             var index = -1, length2 = entries == null ? 0 : entries.length;
4587             this.clear();
4588             while (++index < length2) {
4589               var entry = entries[index];
4590               this.set(entry[0], entry[1]);
4591             }
4592           }
4593           function hashClear2() {
4594             this.__data__ = nativeCreate2 ? nativeCreate2(null) : {};
4595             this.size = 0;
4596           }
4597           function hashDelete2(key) {
4598             var result2 = this.has(key) && delete this.__data__[key];
4599             this.size -= result2 ? 1 : 0;
4600             return result2;
4601           }
4602           function hashGet2(key) {
4603             var data = this.__data__;
4604             if (nativeCreate2) {
4605               var result2 = data[key];
4606               return result2 === HASH_UNDEFINED4 ? undefined2 : result2;
4607             }
4608             return hasOwnProperty13.call(data, key) ? data[key] : undefined2;
4609           }
4610           function hashHas2(key) {
4611             var data = this.__data__;
4612             return nativeCreate2 ? data[key] !== undefined2 : hasOwnProperty13.call(data, key);
4613           }
4614           function hashSet2(key, value) {
4615             var data = this.__data__;
4616             this.size += this.has(key) ? 0 : 1;
4617             data[key] = nativeCreate2 && value === undefined2 ? HASH_UNDEFINED4 : value;
4618             return this;
4619           }
4620           Hash2.prototype.clear = hashClear2;
4621           Hash2.prototype["delete"] = hashDelete2;
4622           Hash2.prototype.get = hashGet2;
4623           Hash2.prototype.has = hashHas2;
4624           Hash2.prototype.set = hashSet2;
4625           function ListCache2(entries) {
4626             var index = -1, length2 = entries == null ? 0 : entries.length;
4627             this.clear();
4628             while (++index < length2) {
4629               var entry = entries[index];
4630               this.set(entry[0], entry[1]);
4631             }
4632           }
4633           function listCacheClear2() {
4634             this.__data__ = [];
4635             this.size = 0;
4636           }
4637           function listCacheDelete2(key) {
4638             var data = this.__data__, index = assocIndexOf2(data, key);
4639             if (index < 0) {
4640               return false;
4641             }
4642             var lastIndex = data.length - 1;
4643             if (index == lastIndex) {
4644               data.pop();
4645             } else {
4646               splice2.call(data, index, 1);
4647             }
4648             --this.size;
4649             return true;
4650           }
4651           function listCacheGet2(key) {
4652             var data = this.__data__, index = assocIndexOf2(data, key);
4653             return index < 0 ? undefined2 : data[index][1];
4654           }
4655           function listCacheHas2(key) {
4656             return assocIndexOf2(this.__data__, key) > -1;
4657           }
4658           function listCacheSet2(key, value) {
4659             var data = this.__data__, index = assocIndexOf2(data, key);
4660             if (index < 0) {
4661               ++this.size;
4662               data.push([key, value]);
4663             } else {
4664               data[index][1] = value;
4665             }
4666             return this;
4667           }
4668           ListCache2.prototype.clear = listCacheClear2;
4669           ListCache2.prototype["delete"] = listCacheDelete2;
4670           ListCache2.prototype.get = listCacheGet2;
4671           ListCache2.prototype.has = listCacheHas2;
4672           ListCache2.prototype.set = listCacheSet2;
4673           function MapCache2(entries) {
4674             var index = -1, length2 = entries == null ? 0 : entries.length;
4675             this.clear();
4676             while (++index < length2) {
4677               var entry = entries[index];
4678               this.set(entry[0], entry[1]);
4679             }
4680           }
4681           function mapCacheClear2() {
4682             this.size = 0;
4683             this.__data__ = {
4684               "hash": new Hash2(),
4685               "map": new (Map3 || ListCache2)(),
4686               "string": new Hash2()
4687             };
4688           }
4689           function mapCacheDelete2(key) {
4690             var result2 = getMapData2(this, key)["delete"](key);
4691             this.size -= result2 ? 1 : 0;
4692             return result2;
4693           }
4694           function mapCacheGet2(key) {
4695             return getMapData2(this, key).get(key);
4696           }
4697           function mapCacheHas2(key) {
4698             return getMapData2(this, key).has(key);
4699           }
4700           function mapCacheSet2(key, value) {
4701             var data = getMapData2(this, key), size2 = data.size;
4702             data.set(key, value);
4703             this.size += data.size == size2 ? 0 : 1;
4704             return this;
4705           }
4706           MapCache2.prototype.clear = mapCacheClear2;
4707           MapCache2.prototype["delete"] = mapCacheDelete2;
4708           MapCache2.prototype.get = mapCacheGet2;
4709           MapCache2.prototype.has = mapCacheHas2;
4710           MapCache2.prototype.set = mapCacheSet2;
4711           function SetCache2(values2) {
4712             var index = -1, length2 = values2 == null ? 0 : values2.length;
4713             this.__data__ = new MapCache2();
4714             while (++index < length2) {
4715               this.add(values2[index]);
4716             }
4717           }
4718           function setCacheAdd2(value) {
4719             this.__data__.set(value, HASH_UNDEFINED4);
4720             return this;
4721           }
4722           function setCacheHas2(value) {
4723             return this.__data__.has(value);
4724           }
4725           SetCache2.prototype.add = SetCache2.prototype.push = setCacheAdd2;
4726           SetCache2.prototype.has = setCacheHas2;
4727           function Stack2(entries) {
4728             var data = this.__data__ = new ListCache2(entries);
4729             this.size = data.size;
4730           }
4731           function stackClear2() {
4732             this.__data__ = new ListCache2();
4733             this.size = 0;
4734           }
4735           function stackDelete2(key) {
4736             var data = this.__data__, result2 = data["delete"](key);
4737             this.size = data.size;
4738             return result2;
4739           }
4740           function stackGet2(key) {
4741             return this.__data__.get(key);
4742           }
4743           function stackHas2(key) {
4744             return this.__data__.has(key);
4745           }
4746           function stackSet2(key, value) {
4747             var data = this.__data__;
4748             if (data instanceof ListCache2) {
4749               var pairs2 = data.__data__;
4750               if (!Map3 || pairs2.length < LARGE_ARRAY_SIZE2 - 1) {
4751                 pairs2.push([key, value]);
4752                 this.size = ++data.size;
4753                 return this;
4754               }
4755               data = this.__data__ = new MapCache2(pairs2);
4756             }
4757             data.set(key, value);
4758             this.size = data.size;
4759             return this;
4760           }
4761           Stack2.prototype.clear = stackClear2;
4762           Stack2.prototype["delete"] = stackDelete2;
4763           Stack2.prototype.get = stackGet2;
4764           Stack2.prototype.has = stackHas2;
4765           Stack2.prototype.set = stackSet2;
4766           function arrayLikeKeys2(value, inherited) {
4767             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;
4768             for (var key in value) {
4769               if ((inherited || hasOwnProperty13.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
4770               (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
4771               isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
4772               isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
4773               isIndex2(key, length2)))) {
4774                 result2.push(key);
4775               }
4776             }
4777             return result2;
4778           }
4779           function arraySample(array2) {
4780             var length2 = array2.length;
4781             return length2 ? array2[baseRandom(0, length2 - 1)] : undefined2;
4782           }
4783           function arraySampleSize(array2, n3) {
4784             return shuffleSelf(copyArray2(array2), baseClamp(n3, 0, array2.length));
4785           }
4786           function arrayShuffle(array2) {
4787             return shuffleSelf(copyArray2(array2));
4788           }
4789           function assignMergeValue2(object, key, value) {
4790             if (value !== undefined2 && !eq2(object[key], value) || value === undefined2 && !(key in object)) {
4791               baseAssignValue2(object, key, value);
4792             }
4793           }
4794           function assignValue2(object, key, value) {
4795             var objValue = object[key];
4796             if (!(hasOwnProperty13.call(object, key) && eq2(objValue, value)) || value === undefined2 && !(key in object)) {
4797               baseAssignValue2(object, key, value);
4798             }
4799           }
4800           function assocIndexOf2(array2, key) {
4801             var length2 = array2.length;
4802             while (length2--) {
4803               if (eq2(array2[length2][0], key)) {
4804                 return length2;
4805               }
4806             }
4807             return -1;
4808           }
4809           function baseAggregator(collection, setter, iteratee2, accumulator) {
4810             baseEach(collection, function(value, key, collection2) {
4811               setter(accumulator, value, iteratee2(value), collection2);
4812             });
4813             return accumulator;
4814           }
4815           function baseAssign(object, source) {
4816             return object && copyObject2(source, keys2(source), object);
4817           }
4818           function baseAssignIn(object, source) {
4819             return object && copyObject2(source, keysIn2(source), object);
4820           }
4821           function baseAssignValue2(object, key, value) {
4822             if (key == "__proto__" && defineProperty2) {
4823               defineProperty2(object, key, {
4824                 "configurable": true,
4825                 "enumerable": true,
4826                 "value": value,
4827                 "writable": true
4828               });
4829             } else {
4830               object[key] = value;
4831             }
4832           }
4833           function baseAt(object, paths) {
4834             var index = -1, length2 = paths.length, result2 = Array2(length2), skip = object == null;
4835             while (++index < length2) {
4836               result2[index] = skip ? undefined2 : get4(object, paths[index]);
4837             }
4838             return result2;
4839           }
4840           function baseClamp(number3, lower2, upper) {
4841             if (number3 === number3) {
4842               if (upper !== undefined2) {
4843                 number3 = number3 <= upper ? number3 : upper;
4844               }
4845               if (lower2 !== undefined2) {
4846                 number3 = number3 >= lower2 ? number3 : lower2;
4847               }
4848             }
4849             return number3;
4850           }
4851           function baseClone(value, bitmask, customizer, key, object, stack) {
4852             var result2, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
4853             if (customizer) {
4854               result2 = object ? customizer(value, key, object, stack) : customizer(value);
4855             }
4856             if (result2 !== undefined2) {
4857               return result2;
4858             }
4859             if (!isObject2(value)) {
4860               return value;
4861             }
4862             var isArr = isArray2(value);
4863             if (isArr) {
4864               result2 = initCloneArray(value);
4865               if (!isDeep) {
4866                 return copyArray2(value, result2);
4867               }
4868             } else {
4869               var tag2 = getTag2(value), isFunc = tag2 == funcTag3 || tag2 == genTag2;
4870               if (isBuffer2(value)) {
4871                 return cloneBuffer2(value, isDeep);
4872               }
4873               if (tag2 == objectTag5 || tag2 == argsTag4 || isFunc && !object) {
4874                 result2 = isFlat || isFunc ? {} : initCloneObject2(value);
4875                 if (!isDeep) {
4876                   return isFlat ? copySymbolsIn(value, baseAssignIn(result2, value)) : copySymbols(value, baseAssign(result2, value));
4877                 }
4878               } else {
4879                 if (!cloneableTags[tag2]) {
4880                   return object ? value : {};
4881                 }
4882                 result2 = initCloneByTag(value, tag2, isDeep);
4883               }
4884             }
4885             stack || (stack = new Stack2());
4886             var stacked = stack.get(value);
4887             if (stacked) {
4888               return stacked;
4889             }
4890             stack.set(value, result2);
4891             if (isSet(value)) {
4892               value.forEach(function(subValue) {
4893                 result2.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
4894               });
4895             } else if (isMap(value)) {
4896               value.forEach(function(subValue, key2) {
4897                 result2.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
4898               });
4899             }
4900             var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys2 : isFlat ? keysIn2 : keys2;
4901             var props = isArr ? undefined2 : keysFunc(value);
4902             arrayEach(props || value, function(subValue, key2) {
4903               if (props) {
4904                 key2 = subValue;
4905                 subValue = value[key2];
4906               }
4907               assignValue2(result2, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
4908             });
4909             return result2;
4910           }
4911           function baseConforms(source) {
4912             var props = keys2(source);
4913             return function(object) {
4914               return baseConformsTo(object, source, props);
4915             };
4916           }
4917           function baseConformsTo(object, source, props) {
4918             var length2 = props.length;
4919             if (object == null) {
4920               return !length2;
4921             }
4922             object = Object2(object);
4923             while (length2--) {
4924               var key = props[length2], predicate = source[key], value = object[key];
4925               if (value === undefined2 && !(key in object) || !predicate(value)) {
4926                 return false;
4927               }
4928             }
4929             return true;
4930           }
4931           function baseDelay(func, wait, args) {
4932             if (typeof func != "function") {
4933               throw new TypeError2(FUNC_ERROR_TEXT3);
4934             }
4935             return setTimeout2(function() {
4936               func.apply(undefined2, args);
4937             }, wait);
4938           }
4939           function baseDifference(array2, values2, iteratee2, comparator) {
4940             var index = -1, includes2 = arrayIncludes, isCommon = true, length2 = array2.length, result2 = [], valuesLength = values2.length;
4941             if (!length2) {
4942               return result2;
4943             }
4944             if (iteratee2) {
4945               values2 = arrayMap2(values2, baseUnary2(iteratee2));
4946             }
4947             if (comparator) {
4948               includes2 = arrayIncludesWith;
4949               isCommon = false;
4950             } else if (values2.length >= LARGE_ARRAY_SIZE2) {
4951               includes2 = cacheHas2;
4952               isCommon = false;
4953               values2 = new SetCache2(values2);
4954             }
4955             outer:
4956               while (++index < length2) {
4957                 var value = array2[index], computed = iteratee2 == null ? value : iteratee2(value);
4958                 value = comparator || value !== 0 ? value : 0;
4959                 if (isCommon && computed === computed) {
4960                   var valuesIndex = valuesLength;
4961                   while (valuesIndex--) {
4962                     if (values2[valuesIndex] === computed) {
4963                       continue outer;
4964                     }
4965                   }
4966                   result2.push(value);
4967                 } else if (!includes2(values2, computed, comparator)) {
4968                   result2.push(value);
4969                 }
4970               }
4971             return result2;
4972           }
4973           var baseEach = createBaseEach(baseForOwn);
4974           var baseEachRight = createBaseEach(baseForOwnRight, true);
4975           function baseEvery(collection, predicate) {
4976             var result2 = true;
4977             baseEach(collection, function(value, index, collection2) {
4978               result2 = !!predicate(value, index, collection2);
4979               return result2;
4980             });
4981             return result2;
4982           }
4983           function baseExtremum(array2, iteratee2, comparator) {
4984             var index = -1, length2 = array2.length;
4985             while (++index < length2) {
4986               var value = array2[index], current = iteratee2(value);
4987               if (current != null && (computed === undefined2 ? current === current && !isSymbol2(current) : comparator(current, computed))) {
4988                 var computed = current, result2 = value;
4989               }
4990             }
4991             return result2;
4992           }
4993           function baseFill(array2, value, start2, end) {
4994             var length2 = array2.length;
4995             start2 = toInteger(start2);
4996             if (start2 < 0) {
4997               start2 = -start2 > length2 ? 0 : length2 + start2;
4998             }
4999             end = end === undefined2 || end > length2 ? length2 : toInteger(end);
5000             if (end < 0) {
5001               end += length2;
5002             }
5003             end = start2 > end ? 0 : toLength(end);
5004             while (start2 < end) {
5005               array2[start2++] = value;
5006             }
5007             return array2;
5008           }
5009           function baseFilter(collection, predicate) {
5010             var result2 = [];
5011             baseEach(collection, function(value, index, collection2) {
5012               if (predicate(value, index, collection2)) {
5013                 result2.push(value);
5014               }
5015             });
5016             return result2;
5017           }
5018           function baseFlatten(array2, depth, predicate, isStrict, result2) {
5019             var index = -1, length2 = array2.length;
5020             predicate || (predicate = isFlattenable);
5021             result2 || (result2 = []);
5022             while (++index < length2) {
5023               var value = array2[index];
5024               if (depth > 0 && predicate(value)) {
5025                 if (depth > 1) {
5026                   baseFlatten(value, depth - 1, predicate, isStrict, result2);
5027                 } else {
5028                   arrayPush2(result2, value);
5029                 }
5030               } else if (!isStrict) {
5031                 result2[result2.length] = value;
5032               }
5033             }
5034             return result2;
5035           }
5036           var baseFor2 = createBaseFor2();
5037           var baseForRight = createBaseFor2(true);
5038           function baseForOwn(object, iteratee2) {
5039             return object && baseFor2(object, iteratee2, keys2);
5040           }
5041           function baseForOwnRight(object, iteratee2) {
5042             return object && baseForRight(object, iteratee2, keys2);
5043           }
5044           function baseFunctions(object, props) {
5045             return arrayFilter2(props, function(key) {
5046               return isFunction2(object[key]);
5047             });
5048           }
5049           function baseGet(object, path) {
5050             path = castPath(path, object);
5051             var index = 0, length2 = path.length;
5052             while (object != null && index < length2) {
5053               object = object[toKey(path[index++])];
5054             }
5055             return index && index == length2 ? object : undefined2;
5056           }
5057           function baseGetAllKeys2(object, keysFunc, symbolsFunc) {
5058             var result2 = keysFunc(object);
5059             return isArray2(object) ? result2 : arrayPush2(result2, symbolsFunc(object));
5060           }
5061           function baseGetTag2(value) {
5062             if (value == null) {
5063               return value === undefined2 ? undefinedTag2 : nullTag2;
5064             }
5065             return symToStringTag3 && symToStringTag3 in Object2(value) ? getRawTag2(value) : objectToString2(value);
5066           }
5067           function baseGt(value, other2) {
5068             return value > other2;
5069           }
5070           function baseHas(object, key) {
5071             return object != null && hasOwnProperty13.call(object, key);
5072           }
5073           function baseHasIn(object, key) {
5074             return object != null && key in Object2(object);
5075           }
5076           function baseInRange(number3, start2, end) {
5077             return number3 >= nativeMin2(start2, end) && number3 < nativeMax3(start2, end);
5078           }
5079           function baseIntersection(arrays, iteratee2, comparator) {
5080             var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length2 = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = [];
5081             while (othIndex--) {
5082               var array2 = arrays[othIndex];
5083               if (othIndex && iteratee2) {
5084                 array2 = arrayMap2(array2, baseUnary2(iteratee2));
5085               }
5086               maxLength = nativeMin2(array2.length, maxLength);
5087               caches[othIndex] = !comparator && (iteratee2 || length2 >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2;
5088             }
5089             array2 = arrays[0];
5090             var index = -1, seen = caches[0];
5091             outer:
5092               while (++index < length2 && result2.length < maxLength) {
5093                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5094                 value = comparator || value !== 0 ? value : 0;
5095                 if (!(seen ? cacheHas2(seen, computed) : includes2(result2, computed, comparator))) {
5096                   othIndex = othLength;
5097                   while (--othIndex) {
5098                     var cache = caches[othIndex];
5099                     if (!(cache ? cacheHas2(cache, computed) : includes2(arrays[othIndex], computed, comparator))) {
5100                       continue outer;
5101                     }
5102                   }
5103                   if (seen) {
5104                     seen.push(computed);
5105                   }
5106                   result2.push(value);
5107                 }
5108               }
5109             return result2;
5110           }
5111           function baseInverter(object, setter, iteratee2, accumulator) {
5112             baseForOwn(object, function(value, key, object2) {
5113               setter(accumulator, iteratee2(value), key, object2);
5114             });
5115             return accumulator;
5116           }
5117           function baseInvoke(object, path, args) {
5118             path = castPath(path, object);
5119             object = parent(object, path);
5120             var func = object == null ? object : object[toKey(last(path))];
5121             return func == null ? undefined2 : apply2(func, object, args);
5122           }
5123           function baseIsArguments2(value) {
5124             return isObjectLike2(value) && baseGetTag2(value) == argsTag4;
5125           }
5126           function baseIsArrayBuffer(value) {
5127             return isObjectLike2(value) && baseGetTag2(value) == arrayBufferTag3;
5128           }
5129           function baseIsDate(value) {
5130             return isObjectLike2(value) && baseGetTag2(value) == dateTag3;
5131           }
5132           function baseIsEqual2(value, other2, bitmask, customizer, stack) {
5133             if (value === other2) {
5134               return true;
5135             }
5136             if (value == null || other2 == null || !isObjectLike2(value) && !isObjectLike2(other2)) {
5137               return value !== value && other2 !== other2;
5138             }
5139             return baseIsEqualDeep2(value, other2, bitmask, customizer, baseIsEqual2, stack);
5140           }
5141           function baseIsEqualDeep2(object, other2, bitmask, customizer, equalFunc, stack) {
5142             var objIsArr = isArray2(object), othIsArr = isArray2(other2), objTag = objIsArr ? arrayTag3 : getTag2(object), othTag = othIsArr ? arrayTag3 : getTag2(other2);
5143             objTag = objTag == argsTag4 ? objectTag5 : objTag;
5144             othTag = othTag == argsTag4 ? objectTag5 : othTag;
5145             var objIsObj = objTag == objectTag5, othIsObj = othTag == objectTag5, isSameTag = objTag == othTag;
5146             if (isSameTag && isBuffer2(object)) {
5147               if (!isBuffer2(other2)) {
5148                 return false;
5149               }
5150               objIsArr = true;
5151               objIsObj = false;
5152             }
5153             if (isSameTag && !objIsObj) {
5154               stack || (stack = new Stack2());
5155               return objIsArr || isTypedArray2(object) ? equalArrays2(object, other2, bitmask, customizer, equalFunc, stack) : equalByTag2(object, other2, objTag, bitmask, customizer, equalFunc, stack);
5156             }
5157             if (!(bitmask & COMPARE_PARTIAL_FLAG5)) {
5158               var objIsWrapped = objIsObj && hasOwnProperty13.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty13.call(other2, "__wrapped__");
5159               if (objIsWrapped || othIsWrapped) {
5160                 var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other2.value() : other2;
5161                 stack || (stack = new Stack2());
5162                 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
5163               }
5164             }
5165             if (!isSameTag) {
5166               return false;
5167             }
5168             stack || (stack = new Stack2());
5169             return equalObjects2(object, other2, bitmask, customizer, equalFunc, stack);
5170           }
5171           function baseIsMap(value) {
5172             return isObjectLike2(value) && getTag2(value) == mapTag4;
5173           }
5174           function baseIsMatch(object, source, matchData, customizer) {
5175             var index = matchData.length, length2 = index, noCustomizer = !customizer;
5176             if (object == null) {
5177               return !length2;
5178             }
5179             object = Object2(object);
5180             while (index--) {
5181               var data = matchData[index];
5182               if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
5183                 return false;
5184               }
5185             }
5186             while (++index < length2) {
5187               data = matchData[index];
5188               var key = data[0], objValue = object[key], srcValue = data[1];
5189               if (noCustomizer && data[2]) {
5190                 if (objValue === undefined2 && !(key in object)) {
5191                   return false;
5192                 }
5193               } else {
5194                 var stack = new Stack2();
5195                 if (customizer) {
5196                   var result2 = customizer(objValue, srcValue, key, object, source, stack);
5197                 }
5198                 if (!(result2 === undefined2 ? baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3, customizer, stack) : result2)) {
5199                   return false;
5200                 }
5201               }
5202             }
5203             return true;
5204           }
5205           function baseIsNative2(value) {
5206             if (!isObject2(value) || isMasked2(value)) {
5207               return false;
5208             }
5209             var pattern = isFunction2(value) ? reIsNative2 : reIsHostCtor2;
5210             return pattern.test(toSource2(value));
5211           }
5212           function baseIsRegExp(value) {
5213             return isObjectLike2(value) && baseGetTag2(value) == regexpTag3;
5214           }
5215           function baseIsSet(value) {
5216             return isObjectLike2(value) && getTag2(value) == setTag4;
5217           }
5218           function baseIsTypedArray2(value) {
5219             return isObjectLike2(value) && isLength2(value.length) && !!typedArrayTags2[baseGetTag2(value)];
5220           }
5221           function baseIteratee(value) {
5222             if (typeof value == "function") {
5223               return value;
5224             }
5225             if (value == null) {
5226               return identity5;
5227             }
5228             if (typeof value == "object") {
5229               return isArray2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
5230             }
5231             return property(value);
5232           }
5233           function baseKeys2(object) {
5234             if (!isPrototype2(object)) {
5235               return nativeKeys2(object);
5236             }
5237             var result2 = [];
5238             for (var key in Object2(object)) {
5239               if (hasOwnProperty13.call(object, key) && key != "constructor") {
5240                 result2.push(key);
5241               }
5242             }
5243             return result2;
5244           }
5245           function baseKeysIn2(object) {
5246             if (!isObject2(object)) {
5247               return nativeKeysIn2(object);
5248             }
5249             var isProto = isPrototype2(object), result2 = [];
5250             for (var key in object) {
5251               if (!(key == "constructor" && (isProto || !hasOwnProperty13.call(object, key)))) {
5252                 result2.push(key);
5253               }
5254             }
5255             return result2;
5256           }
5257           function baseLt(value, other2) {
5258             return value < other2;
5259           }
5260           function baseMap(collection, iteratee2) {
5261             var index = -1, result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
5262             baseEach(collection, function(value, key, collection2) {
5263               result2[++index] = iteratee2(value, key, collection2);
5264             });
5265             return result2;
5266           }
5267           function baseMatches(source) {
5268             var matchData = getMatchData(source);
5269             if (matchData.length == 1 && matchData[0][2]) {
5270               return matchesStrictComparable(matchData[0][0], matchData[0][1]);
5271             }
5272             return function(object) {
5273               return object === source || baseIsMatch(object, source, matchData);
5274             };
5275           }
5276           function baseMatchesProperty(path, srcValue) {
5277             if (isKey(path) && isStrictComparable(srcValue)) {
5278               return matchesStrictComparable(toKey(path), srcValue);
5279             }
5280             return function(object) {
5281               var objValue = get4(object, path);
5282               return objValue === undefined2 && objValue === srcValue ? hasIn(object, path) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3);
5283             };
5284           }
5285           function baseMerge2(object, source, srcIndex, customizer, stack) {
5286             if (object === source) {
5287               return;
5288             }
5289             baseFor2(source, function(srcValue, key) {
5290               stack || (stack = new Stack2());
5291               if (isObject2(srcValue)) {
5292                 baseMergeDeep2(object, source, key, srcIndex, baseMerge2, customizer, stack);
5293               } else {
5294                 var newValue = customizer ? customizer(safeGet2(object, key), srcValue, key + "", object, source, stack) : undefined2;
5295                 if (newValue === undefined2) {
5296                   newValue = srcValue;
5297                 }
5298                 assignMergeValue2(object, key, newValue);
5299               }
5300             }, keysIn2);
5301           }
5302           function baseMergeDeep2(object, source, key, srcIndex, mergeFunc, customizer, stack) {
5303             var objValue = safeGet2(object, key), srcValue = safeGet2(source, key), stacked = stack.get(srcValue);
5304             if (stacked) {
5305               assignMergeValue2(object, key, stacked);
5306               return;
5307             }
5308             var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : undefined2;
5309             var isCommon = newValue === undefined2;
5310             if (isCommon) {
5311               var isArr = isArray2(srcValue), isBuff = !isArr && isBuffer2(srcValue), isTyped = !isArr && !isBuff && isTypedArray2(srcValue);
5312               newValue = srcValue;
5313               if (isArr || isBuff || isTyped) {
5314                 if (isArray2(objValue)) {
5315                   newValue = objValue;
5316                 } else if (isArrayLikeObject2(objValue)) {
5317                   newValue = copyArray2(objValue);
5318                 } else if (isBuff) {
5319                   isCommon = false;
5320                   newValue = cloneBuffer2(srcValue, true);
5321                 } else if (isTyped) {
5322                   isCommon = false;
5323                   newValue = cloneTypedArray2(srcValue, true);
5324                 } else {
5325                   newValue = [];
5326                 }
5327               } else if (isPlainObject2(srcValue) || isArguments2(srcValue)) {
5328                 newValue = objValue;
5329                 if (isArguments2(objValue)) {
5330                   newValue = toPlainObject2(objValue);
5331                 } else if (!isObject2(objValue) || isFunction2(objValue)) {
5332                   newValue = initCloneObject2(srcValue);
5333                 }
5334               } else {
5335                 isCommon = false;
5336               }
5337             }
5338             if (isCommon) {
5339               stack.set(srcValue, newValue);
5340               mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
5341               stack["delete"](srcValue);
5342             }
5343             assignMergeValue2(object, key, newValue);
5344           }
5345           function baseNth(array2, n3) {
5346             var length2 = array2.length;
5347             if (!length2) {
5348               return;
5349             }
5350             n3 += n3 < 0 ? length2 : 0;
5351             return isIndex2(n3, length2) ? array2[n3] : undefined2;
5352           }
5353           function baseOrderBy(collection, iteratees, orders) {
5354             if (iteratees.length) {
5355               iteratees = arrayMap2(iteratees, function(iteratee2) {
5356                 if (isArray2(iteratee2)) {
5357                   return function(value) {
5358                     return baseGet(value, iteratee2.length === 1 ? iteratee2[0] : iteratee2);
5359                   };
5360                 }
5361                 return iteratee2;
5362               });
5363             } else {
5364               iteratees = [identity5];
5365             }
5366             var index = -1;
5367             iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
5368             var result2 = baseMap(collection, function(value, key, collection2) {
5369               var criteria = arrayMap2(iteratees, function(iteratee2) {
5370                 return iteratee2(value);
5371               });
5372               return { "criteria": criteria, "index": ++index, "value": value };
5373             });
5374             return baseSortBy(result2, function(object, other2) {
5375               return compareMultiple(object, other2, orders);
5376             });
5377           }
5378           function basePick(object, paths) {
5379             return basePickBy(object, paths, function(value, path) {
5380               return hasIn(object, path);
5381             });
5382           }
5383           function basePickBy(object, paths, predicate) {
5384             var index = -1, length2 = paths.length, result2 = {};
5385             while (++index < length2) {
5386               var path = paths[index], value = baseGet(object, path);
5387               if (predicate(value, path)) {
5388                 baseSet(result2, castPath(path, object), value);
5389               }
5390             }
5391             return result2;
5392           }
5393           function basePropertyDeep(path) {
5394             return function(object) {
5395               return baseGet(object, path);
5396             };
5397           }
5398           function basePullAll(array2, values2, iteratee2, comparator) {
5399             var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length2 = values2.length, seen = array2;
5400             if (array2 === values2) {
5401               values2 = copyArray2(values2);
5402             }
5403             if (iteratee2) {
5404               seen = arrayMap2(array2, baseUnary2(iteratee2));
5405             }
5406             while (++index < length2) {
5407               var fromIndex = 0, value = values2[index], computed = iteratee2 ? iteratee2(value) : value;
5408               while ((fromIndex = indexOf2(seen, computed, fromIndex, comparator)) > -1) {
5409                 if (seen !== array2) {
5410                   splice2.call(seen, fromIndex, 1);
5411                 }
5412                 splice2.call(array2, fromIndex, 1);
5413               }
5414             }
5415             return array2;
5416           }
5417           function basePullAt(array2, indexes) {
5418             var length2 = array2 ? indexes.length : 0, lastIndex = length2 - 1;
5419             while (length2--) {
5420               var index = indexes[length2];
5421               if (length2 == lastIndex || index !== previous) {
5422                 var previous = index;
5423                 if (isIndex2(index)) {
5424                   splice2.call(array2, index, 1);
5425                 } else {
5426                   baseUnset(array2, index);
5427                 }
5428               }
5429             }
5430             return array2;
5431           }
5432           function baseRandom(lower2, upper) {
5433             return lower2 + nativeFloor(nativeRandom() * (upper - lower2 + 1));
5434           }
5435           function baseRange(start2, end, step, fromRight) {
5436             var index = -1, length2 = nativeMax3(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length2);
5437             while (length2--) {
5438               result2[fromRight ? length2 : ++index] = start2;
5439               start2 += step;
5440             }
5441             return result2;
5442           }
5443           function baseRepeat(string, n3) {
5444             var result2 = "";
5445             if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
5446               return result2;
5447             }
5448             do {
5449               if (n3 % 2) {
5450                 result2 += string;
5451               }
5452               n3 = nativeFloor(n3 / 2);
5453               if (n3) {
5454                 string += string;
5455               }
5456             } while (n3);
5457             return result2;
5458           }
5459           function baseRest2(func, start2) {
5460             return setToString2(overRest2(func, start2, identity5), func + "");
5461           }
5462           function baseSample(collection) {
5463             return arraySample(values(collection));
5464           }
5465           function baseSampleSize(collection, n3) {
5466             var array2 = values(collection);
5467             return shuffleSelf(array2, baseClamp(n3, 0, array2.length));
5468           }
5469           function baseSet(object, path, value, customizer) {
5470             if (!isObject2(object)) {
5471               return object;
5472             }
5473             path = castPath(path, object);
5474             var index = -1, length2 = path.length, lastIndex = length2 - 1, nested = object;
5475             while (nested != null && ++index < length2) {
5476               var key = toKey(path[index]), newValue = value;
5477               if (key === "__proto__" || key === "constructor" || key === "prototype") {
5478                 return object;
5479               }
5480               if (index != lastIndex) {
5481                 var objValue = nested[key];
5482                 newValue = customizer ? customizer(objValue, key, nested) : undefined2;
5483                 if (newValue === undefined2) {
5484                   newValue = isObject2(objValue) ? objValue : isIndex2(path[index + 1]) ? [] : {};
5485                 }
5486               }
5487               assignValue2(nested, key, newValue);
5488               nested = nested[key];
5489             }
5490             return object;
5491           }
5492           var baseSetData = !metaMap ? identity5 : function(func, data) {
5493             metaMap.set(func, data);
5494             return func;
5495           };
5496           var baseSetToString2 = !defineProperty2 ? identity5 : function(func, string) {
5497             return defineProperty2(func, "toString", {
5498               "configurable": true,
5499               "enumerable": false,
5500               "value": constant2(string),
5501               "writable": true
5502             });
5503           };
5504           function baseShuffle(collection) {
5505             return shuffleSelf(values(collection));
5506           }
5507           function baseSlice(array2, start2, end) {
5508             var index = -1, length2 = array2.length;
5509             if (start2 < 0) {
5510               start2 = -start2 > length2 ? 0 : length2 + start2;
5511             }
5512             end = end > length2 ? length2 : end;
5513             if (end < 0) {
5514               end += length2;
5515             }
5516             length2 = start2 > end ? 0 : end - start2 >>> 0;
5517             start2 >>>= 0;
5518             var result2 = Array2(length2);
5519             while (++index < length2) {
5520               result2[index] = array2[index + start2];
5521             }
5522             return result2;
5523           }
5524           function baseSome(collection, predicate) {
5525             var result2;
5526             baseEach(collection, function(value, index, collection2) {
5527               result2 = predicate(value, index, collection2);
5528               return !result2;
5529             });
5530             return !!result2;
5531           }
5532           function baseSortedIndex(array2, value, retHighest) {
5533             var low = 0, high = array2 == null ? low : array2.length;
5534             if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
5535               while (low < high) {
5536                 var mid = low + high >>> 1, computed = array2[mid];
5537                 if (computed !== null && !isSymbol2(computed) && (retHighest ? computed <= value : computed < value)) {
5538                   low = mid + 1;
5539                 } else {
5540                   high = mid;
5541                 }
5542               }
5543               return high;
5544             }
5545             return baseSortedIndexBy(array2, value, identity5, retHighest);
5546           }
5547           function baseSortedIndexBy(array2, value, iteratee2, retHighest) {
5548             var low = 0, high = array2 == null ? 0 : array2.length;
5549             if (high === 0) {
5550               return 0;
5551             }
5552             value = iteratee2(value);
5553             var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol2(value), valIsUndefined = value === undefined2;
5554             while (low < high) {
5555               var mid = nativeFloor((low + high) / 2), computed = iteratee2(array2[mid]), othIsDefined = computed !== undefined2, othIsNull = computed === null, othIsReflexive = computed === computed, othIsSymbol = isSymbol2(computed);
5556               if (valIsNaN) {
5557                 var setLow = retHighest || othIsReflexive;
5558               } else if (valIsUndefined) {
5559                 setLow = othIsReflexive && (retHighest || othIsDefined);
5560               } else if (valIsNull) {
5561                 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
5562               } else if (valIsSymbol) {
5563                 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
5564               } else if (othIsNull || othIsSymbol) {
5565                 setLow = false;
5566               } else {
5567                 setLow = retHighest ? computed <= value : computed < value;
5568               }
5569               if (setLow) {
5570                 low = mid + 1;
5571               } else {
5572                 high = mid;
5573               }
5574             }
5575             return nativeMin2(high, MAX_ARRAY_INDEX);
5576           }
5577           function baseSortedUniq(array2, iteratee2) {
5578             var index = -1, length2 = array2.length, resIndex = 0, result2 = [];
5579             while (++index < length2) {
5580               var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5581               if (!index || !eq2(computed, seen)) {
5582                 var seen = computed;
5583                 result2[resIndex++] = value === 0 ? 0 : value;
5584               }
5585             }
5586             return result2;
5587           }
5588           function baseToNumber(value) {
5589             if (typeof value == "number") {
5590               return value;
5591             }
5592             if (isSymbol2(value)) {
5593               return NAN2;
5594             }
5595             return +value;
5596           }
5597           function baseToString2(value) {
5598             if (typeof value == "string") {
5599               return value;
5600             }
5601             if (isArray2(value)) {
5602               return arrayMap2(value, baseToString2) + "";
5603             }
5604             if (isSymbol2(value)) {
5605               return symbolToString2 ? symbolToString2.call(value) : "";
5606             }
5607             var result2 = value + "";
5608             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
5609           }
5610           function baseUniq(array2, iteratee2, comparator) {
5611             var index = -1, includes2 = arrayIncludes, length2 = array2.length, isCommon = true, result2 = [], seen = result2;
5612             if (comparator) {
5613               isCommon = false;
5614               includes2 = arrayIncludesWith;
5615             } else if (length2 >= LARGE_ARRAY_SIZE2) {
5616               var set5 = iteratee2 ? null : createSet(array2);
5617               if (set5) {
5618                 return setToArray2(set5);
5619               }
5620               isCommon = false;
5621               includes2 = cacheHas2;
5622               seen = new SetCache2();
5623             } else {
5624               seen = iteratee2 ? [] : result2;
5625             }
5626             outer:
5627               while (++index < length2) {
5628                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5629                 value = comparator || value !== 0 ? value : 0;
5630                 if (isCommon && computed === computed) {
5631                   var seenIndex = seen.length;
5632                   while (seenIndex--) {
5633                     if (seen[seenIndex] === computed) {
5634                       continue outer;
5635                     }
5636                   }
5637                   if (iteratee2) {
5638                     seen.push(computed);
5639                   }
5640                   result2.push(value);
5641                 } else if (!includes2(seen, computed, comparator)) {
5642                   if (seen !== result2) {
5643                     seen.push(computed);
5644                   }
5645                   result2.push(value);
5646                 }
5647               }
5648             return result2;
5649           }
5650           function baseUnset(object, path) {
5651             path = castPath(path, object);
5652             object = parent(object, path);
5653             return object == null || delete object[toKey(last(path))];
5654           }
5655           function baseUpdate(object, path, updater, customizer) {
5656             return baseSet(object, path, updater(baseGet(object, path)), customizer);
5657           }
5658           function baseWhile(array2, predicate, isDrop, fromRight) {
5659             var length2 = array2.length, index = fromRight ? length2 : -1;
5660             while ((fromRight ? index-- : ++index < length2) && predicate(array2[index], index, array2)) {
5661             }
5662             return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length2) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length2 : index);
5663           }
5664           function baseWrapperValue(value, actions) {
5665             var result2 = value;
5666             if (result2 instanceof LazyWrapper) {
5667               result2 = result2.value();
5668             }
5669             return arrayReduce(actions, function(result3, action) {
5670               return action.func.apply(action.thisArg, arrayPush2([result3], action.args));
5671             }, result2);
5672           }
5673           function baseXor(arrays, iteratee2, comparator) {
5674             var length2 = arrays.length;
5675             if (length2 < 2) {
5676               return length2 ? baseUniq(arrays[0]) : [];
5677             }
5678             var index = -1, result2 = Array2(length2);
5679             while (++index < length2) {
5680               var array2 = arrays[index], othIndex = -1;
5681               while (++othIndex < length2) {
5682                 if (othIndex != index) {
5683                   result2[index] = baseDifference(result2[index] || array2, arrays[othIndex], iteratee2, comparator);
5684                 }
5685               }
5686             }
5687             return baseUniq(baseFlatten(result2, 1), iteratee2, comparator);
5688           }
5689           function baseZipObject(props, values2, assignFunc) {
5690             var index = -1, length2 = props.length, valsLength = values2.length, result2 = {};
5691             while (++index < length2) {
5692               var value = index < valsLength ? values2[index] : undefined2;
5693               assignFunc(result2, props[index], value);
5694             }
5695             return result2;
5696           }
5697           function castArrayLikeObject(value) {
5698             return isArrayLikeObject2(value) ? value : [];
5699           }
5700           function castFunction(value) {
5701             return typeof value == "function" ? value : identity5;
5702           }
5703           function castPath(value, object) {
5704             if (isArray2(value)) {
5705               return value;
5706             }
5707             return isKey(value, object) ? [value] : stringToPath(toString2(value));
5708           }
5709           var castRest = baseRest2;
5710           function castSlice(array2, start2, end) {
5711             var length2 = array2.length;
5712             end = end === undefined2 ? length2 : end;
5713             return !start2 && end >= length2 ? array2 : baseSlice(array2, start2, end);
5714           }
5715           var clearTimeout2 = ctxClearTimeout || function(id2) {
5716             return root3.clearTimeout(id2);
5717           };
5718           function cloneBuffer2(buffer, isDeep) {
5719             if (isDeep) {
5720               return buffer.slice();
5721             }
5722             var length2 = buffer.length, result2 = allocUnsafe2 ? allocUnsafe2(length2) : new buffer.constructor(length2);
5723             buffer.copy(result2);
5724             return result2;
5725           }
5726           function cloneArrayBuffer2(arrayBuffer) {
5727             var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
5728             new Uint8Array3(result2).set(new Uint8Array3(arrayBuffer));
5729             return result2;
5730           }
5731           function cloneDataView(dataView, isDeep) {
5732             var buffer = isDeep ? cloneArrayBuffer2(dataView.buffer) : dataView.buffer;
5733             return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
5734           }
5735           function cloneRegExp(regexp) {
5736             var result2 = new regexp.constructor(regexp.source, reFlags.exec(regexp));
5737             result2.lastIndex = regexp.lastIndex;
5738             return result2;
5739           }
5740           function cloneSymbol(symbol) {
5741             return symbolValueOf2 ? Object2(symbolValueOf2.call(symbol)) : {};
5742           }
5743           function cloneTypedArray2(typedArray, isDeep) {
5744             var buffer = isDeep ? cloneArrayBuffer2(typedArray.buffer) : typedArray.buffer;
5745             return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
5746           }
5747           function compareAscending(value, other2) {
5748             if (value !== other2) {
5749               var valIsDefined = value !== undefined2, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol2(value);
5750               var othIsDefined = other2 !== undefined2, othIsNull = other2 === null, othIsReflexive = other2 === other2, othIsSymbol = isSymbol2(other2);
5751               if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other2 || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
5752                 return 1;
5753               }
5754               if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other2 || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
5755                 return -1;
5756               }
5757             }
5758             return 0;
5759           }
5760           function compareMultiple(object, other2, orders) {
5761             var index = -1, objCriteria = object.criteria, othCriteria = other2.criteria, length2 = objCriteria.length, ordersLength = orders.length;
5762             while (++index < length2) {
5763               var result2 = compareAscending(objCriteria[index], othCriteria[index]);
5764               if (result2) {
5765                 if (index >= ordersLength) {
5766                   return result2;
5767                 }
5768                 var order = orders[index];
5769                 return result2 * (order == "desc" ? -1 : 1);
5770               }
5771             }
5772             return object.index - other2.index;
5773           }
5774           function composeArgs(args, partials, holders, isCurried) {
5775             var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax3(argsLength - holdersLength, 0), result2 = Array2(leftLength + rangeLength), isUncurried = !isCurried;
5776             while (++leftIndex < leftLength) {
5777               result2[leftIndex] = partials[leftIndex];
5778             }
5779             while (++argsIndex < holdersLength) {
5780               if (isUncurried || argsIndex < argsLength) {
5781                 result2[holders[argsIndex]] = args[argsIndex];
5782               }
5783             }
5784             while (rangeLength--) {
5785               result2[leftIndex++] = args[argsIndex++];
5786             }
5787             return result2;
5788           }
5789           function composeArgsRight(args, partials, holders, isCurried) {
5790             var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax3(argsLength - holdersLength, 0), result2 = Array2(rangeLength + rightLength), isUncurried = !isCurried;
5791             while (++argsIndex < rangeLength) {
5792               result2[argsIndex] = args[argsIndex];
5793             }
5794             var offset = argsIndex;
5795             while (++rightIndex < rightLength) {
5796               result2[offset + rightIndex] = partials[rightIndex];
5797             }
5798             while (++holdersIndex < holdersLength) {
5799               if (isUncurried || argsIndex < argsLength) {
5800                 result2[offset + holders[holdersIndex]] = args[argsIndex++];
5801               }
5802             }
5803             return result2;
5804           }
5805           function copyArray2(source, array2) {
5806             var index = -1, length2 = source.length;
5807             array2 || (array2 = Array2(length2));
5808             while (++index < length2) {
5809               array2[index] = source[index];
5810             }
5811             return array2;
5812           }
5813           function copyObject2(source, props, object, customizer) {
5814             var isNew = !object;
5815             object || (object = {});
5816             var index = -1, length2 = props.length;
5817             while (++index < length2) {
5818               var key = props[index];
5819               var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined2;
5820               if (newValue === undefined2) {
5821                 newValue = source[key];
5822               }
5823               if (isNew) {
5824                 baseAssignValue2(object, key, newValue);
5825               } else {
5826                 assignValue2(object, key, newValue);
5827               }
5828             }
5829             return object;
5830           }
5831           function copySymbols(source, object) {
5832             return copyObject2(source, getSymbols2(source), object);
5833           }
5834           function copySymbolsIn(source, object) {
5835             return copyObject2(source, getSymbolsIn(source), object);
5836           }
5837           function createAggregator(setter, initializer) {
5838             return function(collection, iteratee2) {
5839               var func = isArray2(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {};
5840               return func(collection, setter, getIteratee(iteratee2, 2), accumulator);
5841             };
5842           }
5843           function createAssigner2(assigner) {
5844             return baseRest2(function(object, sources) {
5845               var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : undefined2, guard = length2 > 2 ? sources[2] : undefined2;
5846               customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : undefined2;
5847               if (guard && isIterateeCall2(sources[0], sources[1], guard)) {
5848                 customizer = length2 < 3 ? undefined2 : customizer;
5849                 length2 = 1;
5850               }
5851               object = Object2(object);
5852               while (++index < length2) {
5853                 var source = sources[index];
5854                 if (source) {
5855                   assigner(object, source, index, customizer);
5856                 }
5857               }
5858               return object;
5859             });
5860           }
5861           function createBaseEach(eachFunc, fromRight) {
5862             return function(collection, iteratee2) {
5863               if (collection == null) {
5864                 return collection;
5865               }
5866               if (!isArrayLike2(collection)) {
5867                 return eachFunc(collection, iteratee2);
5868               }
5869               var length2 = collection.length, index = fromRight ? length2 : -1, iterable = Object2(collection);
5870               while (fromRight ? index-- : ++index < length2) {
5871                 if (iteratee2(iterable[index], index, iterable) === false) {
5872                   break;
5873                 }
5874               }
5875               return collection;
5876             };
5877           }
5878           function createBaseFor2(fromRight) {
5879             return function(object, iteratee2, keysFunc) {
5880               var index = -1, iterable = Object2(object), props = keysFunc(object), length2 = props.length;
5881               while (length2--) {
5882                 var key = props[fromRight ? length2 : ++index];
5883                 if (iteratee2(iterable[key], key, iterable) === false) {
5884                   break;
5885                 }
5886               }
5887               return object;
5888             };
5889           }
5890           function createBind(func, bitmask, thisArg) {
5891             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
5892             function wrapper() {
5893               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
5894               return fn.apply(isBind ? thisArg : this, arguments);
5895             }
5896             return wrapper;
5897           }
5898           function createCaseFirst(methodName) {
5899             return function(string) {
5900               string = toString2(string);
5901               var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined2;
5902               var chr = strSymbols ? strSymbols[0] : string.charAt(0);
5903               var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
5904               return chr[methodName]() + trailing;
5905             };
5906           }
5907           function createCompounder(callback) {
5908             return function(string) {
5909               return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
5910             };
5911           }
5912           function createCtor(Ctor) {
5913             return function() {
5914               var args = arguments;
5915               switch (args.length) {
5916                 case 0:
5917                   return new Ctor();
5918                 case 1:
5919                   return new Ctor(args[0]);
5920                 case 2:
5921                   return new Ctor(args[0], args[1]);
5922                 case 3:
5923                   return new Ctor(args[0], args[1], args[2]);
5924                 case 4:
5925                   return new Ctor(args[0], args[1], args[2], args[3]);
5926                 case 5:
5927                   return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5928                 case 6:
5929                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5930                 case 7:
5931                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5932               }
5933               var thisBinding = baseCreate2(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
5934               return isObject2(result2) ? result2 : thisBinding;
5935             };
5936           }
5937           function createCurry(func, bitmask, arity) {
5938             var Ctor = createCtor(func);
5939             function wrapper() {
5940               var length2 = arguments.length, args = Array2(length2), index = length2, placeholder = getHolder(wrapper);
5941               while (index--) {
5942                 args[index] = arguments[index];
5943               }
5944               var holders = length2 < 3 && args[0] !== placeholder && args[length2 - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
5945               length2 -= holders.length;
5946               if (length2 < arity) {
5947                 return createRecurry(
5948                   func,
5949                   bitmask,
5950                   createHybrid,
5951                   wrapper.placeholder,
5952                   undefined2,
5953                   args,
5954                   holders,
5955                   undefined2,
5956                   undefined2,
5957                   arity - length2
5958                 );
5959               }
5960               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
5961               return apply2(fn, this, args);
5962             }
5963             return wrapper;
5964           }
5965           function createFind(findIndexFunc) {
5966             return function(collection, predicate, fromIndex) {
5967               var iterable = Object2(collection);
5968               if (!isArrayLike2(collection)) {
5969                 var iteratee2 = getIteratee(predicate, 3);
5970                 collection = keys2(collection);
5971                 predicate = function(key) {
5972                   return iteratee2(iterable[key], key, iterable);
5973                 };
5974               }
5975               var index = findIndexFunc(collection, predicate, fromIndex);
5976               return index > -1 ? iterable[iteratee2 ? collection[index] : index] : undefined2;
5977             };
5978           }
5979           function createFlow(fromRight) {
5980             return flatRest(function(funcs) {
5981               var length2 = funcs.length, index = length2, prereq = LodashWrapper.prototype.thru;
5982               if (fromRight) {
5983                 funcs.reverse();
5984               }
5985               while (index--) {
5986                 var func = funcs[index];
5987                 if (typeof func != "function") {
5988                   throw new TypeError2(FUNC_ERROR_TEXT3);
5989                 }
5990                 if (prereq && !wrapper && getFuncName(func) == "wrapper") {
5991                   var wrapper = new LodashWrapper([], true);
5992                 }
5993               }
5994               index = wrapper ? index : length2;
5995               while (++index < length2) {
5996                 func = funcs[index];
5997                 var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined2;
5998                 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) {
5999                   wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
6000                 } else {
6001                   wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func);
6002                 }
6003               }
6004               return function() {
6005                 var args = arguments, value = args[0];
6006                 if (wrapper && args.length == 1 && isArray2(value)) {
6007                   return wrapper.plant(value).value();
6008                 }
6009                 var index2 = 0, result2 = length2 ? funcs[index2].apply(this, args) : value;
6010                 while (++index2 < length2) {
6011                   result2 = funcs[index2].call(this, result2);
6012                 }
6013                 return result2;
6014               };
6015             });
6016           }
6017           function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
6018             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);
6019             function wrapper() {
6020               var length2 = arguments.length, args = Array2(length2), index = length2;
6021               while (index--) {
6022                 args[index] = arguments[index];
6023               }
6024               if (isCurried) {
6025                 var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
6026               }
6027               if (partials) {
6028                 args = composeArgs(args, partials, holders, isCurried);
6029               }
6030               if (partialsRight) {
6031                 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
6032               }
6033               length2 -= holdersCount;
6034               if (isCurried && length2 < arity) {
6035                 var newHolders = replaceHolders(args, placeholder);
6036                 return createRecurry(
6037                   func,
6038                   bitmask,
6039                   createHybrid,
6040                   wrapper.placeholder,
6041                   thisArg,
6042                   args,
6043                   newHolders,
6044                   argPos,
6045                   ary2,
6046                   arity - length2
6047                 );
6048               }
6049               var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func;
6050               length2 = args.length;
6051               if (argPos) {
6052                 args = reorder(args, argPos);
6053               } else if (isFlip && length2 > 1) {
6054                 args.reverse();
6055               }
6056               if (isAry && ary2 < length2) {
6057                 args.length = ary2;
6058               }
6059               if (this && this !== root3 && this instanceof wrapper) {
6060                 fn = Ctor || createCtor(fn);
6061               }
6062               return fn.apply(thisBinding, args);
6063             }
6064             return wrapper;
6065           }
6066           function createInverter(setter, toIteratee) {
6067             return function(object, iteratee2) {
6068               return baseInverter(object, setter, toIteratee(iteratee2), {});
6069             };
6070           }
6071           function createMathOperation(operator, defaultValue) {
6072             return function(value, other2) {
6073               var result2;
6074               if (value === undefined2 && other2 === undefined2) {
6075                 return defaultValue;
6076               }
6077               if (value !== undefined2) {
6078                 result2 = value;
6079               }
6080               if (other2 !== undefined2) {
6081                 if (result2 === undefined2) {
6082                   return other2;
6083                 }
6084                 if (typeof value == "string" || typeof other2 == "string") {
6085                   value = baseToString2(value);
6086                   other2 = baseToString2(other2);
6087                 } else {
6088                   value = baseToNumber(value);
6089                   other2 = baseToNumber(other2);
6090                 }
6091                 result2 = operator(value, other2);
6092               }
6093               return result2;
6094             };
6095           }
6096           function createOver(arrayFunc) {
6097             return flatRest(function(iteratees) {
6098               iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
6099               return baseRest2(function(args) {
6100                 var thisArg = this;
6101                 return arrayFunc(iteratees, function(iteratee2) {
6102                   return apply2(iteratee2, thisArg, args);
6103                 });
6104               });
6105             });
6106           }
6107           function createPadding(length2, chars) {
6108             chars = chars === undefined2 ? " " : baseToString2(chars);
6109             var charsLength = chars.length;
6110             if (charsLength < 2) {
6111               return charsLength ? baseRepeat(chars, length2) : chars;
6112             }
6113             var result2 = baseRepeat(chars, nativeCeil(length2 / stringSize(chars)));
6114             return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length2).join("") : result2.slice(0, length2);
6115           }
6116           function createPartial(func, bitmask, thisArg, partials) {
6117             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
6118             function wrapper() {
6119               var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
6120               while (++leftIndex < leftLength) {
6121                 args[leftIndex] = partials[leftIndex];
6122               }
6123               while (argsLength--) {
6124                 args[leftIndex++] = arguments[++argsIndex];
6125               }
6126               return apply2(fn, isBind ? thisArg : this, args);
6127             }
6128             return wrapper;
6129           }
6130           function createRange(fromRight) {
6131             return function(start2, end, step) {
6132               if (step && typeof step != "number" && isIterateeCall2(start2, end, step)) {
6133                 end = step = undefined2;
6134               }
6135               start2 = toFinite(start2);
6136               if (end === undefined2) {
6137                 end = start2;
6138                 start2 = 0;
6139               } else {
6140                 end = toFinite(end);
6141               }
6142               step = step === undefined2 ? start2 < end ? 1 : -1 : toFinite(step);
6143               return baseRange(start2, end, step, fromRight);
6144             };
6145           }
6146           function createRelationalOperation(operator) {
6147             return function(value, other2) {
6148               if (!(typeof value == "string" && typeof other2 == "string")) {
6149                 value = toNumber3(value);
6150                 other2 = toNumber3(other2);
6151               }
6152               return operator(value, other2);
6153             };
6154           }
6155           function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
6156             var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined2, newHoldersRight = isCurry ? undefined2 : holders, newPartials = isCurry ? partials : undefined2, newPartialsRight = isCurry ? undefined2 : partials;
6157             bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
6158             bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
6159             if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
6160               bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
6161             }
6162             var newData = [
6163               func,
6164               bitmask,
6165               thisArg,
6166               newPartials,
6167               newHolders,
6168               newPartialsRight,
6169               newHoldersRight,
6170               argPos,
6171               ary2,
6172               arity
6173             ];
6174             var result2 = wrapFunc.apply(undefined2, newData);
6175             if (isLaziable(func)) {
6176               setData(result2, newData);
6177             }
6178             result2.placeholder = placeholder;
6179             return setWrapToString(result2, func, bitmask);
6180           }
6181           function createRound(methodName) {
6182             var func = Math2[methodName];
6183             return function(number3, precision3) {
6184               number3 = toNumber3(number3);
6185               precision3 = precision3 == null ? 0 : nativeMin2(toInteger(precision3), 292);
6186               if (precision3 && nativeIsFinite(number3)) {
6187                 var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision3));
6188                 pair3 = (toString2(value) + "e").split("e");
6189                 return +(pair3[0] + "e" + (+pair3[1] - precision3));
6190               }
6191               return func(number3);
6192             };
6193           }
6194           var createSet = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY2) ? noop3 : function(values2) {
6195             return new Set3(values2);
6196           };
6197           function createToPairs(keysFunc) {
6198             return function(object) {
6199               var tag2 = getTag2(object);
6200               if (tag2 == mapTag4) {
6201                 return mapToArray2(object);
6202               }
6203               if (tag2 == setTag4) {
6204                 return setToPairs(object);
6205               }
6206               return baseToPairs(object, keysFunc(object));
6207             };
6208           }
6209           function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
6210             var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
6211             if (!isBindKey && typeof func != "function") {
6212               throw new TypeError2(FUNC_ERROR_TEXT3);
6213             }
6214             var length2 = partials ? partials.length : 0;
6215             if (!length2) {
6216               bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
6217               partials = holders = undefined2;
6218             }
6219             ary2 = ary2 === undefined2 ? ary2 : nativeMax3(toInteger(ary2), 0);
6220             arity = arity === undefined2 ? arity : toInteger(arity);
6221             length2 -= holders ? holders.length : 0;
6222             if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
6223               var partialsRight = partials, holdersRight = holders;
6224               partials = holders = undefined2;
6225             }
6226             var data = isBindKey ? undefined2 : getData(func);
6227             var newData = [
6228               func,
6229               bitmask,
6230               thisArg,
6231               partials,
6232               holders,
6233               partialsRight,
6234               holdersRight,
6235               argPos,
6236               ary2,
6237               arity
6238             ];
6239             if (data) {
6240               mergeData(newData, data);
6241             }
6242             func = newData[0];
6243             bitmask = newData[1];
6244             thisArg = newData[2];
6245             partials = newData[3];
6246             holders = newData[4];
6247             arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax3(newData[9] - length2, 0);
6248             if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
6249               bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
6250             }
6251             if (!bitmask || bitmask == WRAP_BIND_FLAG) {
6252               var result2 = createBind(func, bitmask, thisArg);
6253             } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
6254               result2 = createCurry(func, bitmask, arity);
6255             } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
6256               result2 = createPartial(func, bitmask, thisArg, partials);
6257             } else {
6258               result2 = createHybrid.apply(undefined2, newData);
6259             }
6260             var setter = data ? baseSetData : setData;
6261             return setWrapToString(setter(result2, newData), func, bitmask);
6262           }
6263           function customDefaultsAssignIn(objValue, srcValue, key, object) {
6264             if (objValue === undefined2 || eq2(objValue, objectProto16[key]) && !hasOwnProperty13.call(object, key)) {
6265               return srcValue;
6266             }
6267             return objValue;
6268           }
6269           function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
6270             if (isObject2(objValue) && isObject2(srcValue)) {
6271               stack.set(srcValue, objValue);
6272               baseMerge2(objValue, srcValue, undefined2, customDefaultsMerge, stack);
6273               stack["delete"](srcValue);
6274             }
6275             return objValue;
6276           }
6277           function customOmitClone(value) {
6278             return isPlainObject2(value) ? undefined2 : value;
6279           }
6280           function equalArrays2(array2, other2, bitmask, customizer, equalFunc, stack) {
6281             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, arrLength = array2.length, othLength = other2.length;
6282             if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
6283               return false;
6284             }
6285             var arrStacked = stack.get(array2);
6286             var othStacked = stack.get(other2);
6287             if (arrStacked && othStacked) {
6288               return arrStacked == other2 && othStacked == array2;
6289             }
6290             var index = -1, result2 = true, seen = bitmask & COMPARE_UNORDERED_FLAG3 ? new SetCache2() : undefined2;
6291             stack.set(array2, other2);
6292             stack.set(other2, array2);
6293             while (++index < arrLength) {
6294               var arrValue = array2[index], othValue = other2[index];
6295               if (customizer) {
6296                 var compared = isPartial ? customizer(othValue, arrValue, index, other2, array2, stack) : customizer(arrValue, othValue, index, array2, other2, stack);
6297               }
6298               if (compared !== undefined2) {
6299                 if (compared) {
6300                   continue;
6301                 }
6302                 result2 = false;
6303                 break;
6304               }
6305               if (seen) {
6306                 if (!arraySome2(other2, function(othValue2, othIndex) {
6307                   if (!cacheHas2(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
6308                     return seen.push(othIndex);
6309                   }
6310                 })) {
6311                   result2 = false;
6312                   break;
6313                 }
6314               } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
6315                 result2 = false;
6316                 break;
6317               }
6318             }
6319             stack["delete"](array2);
6320             stack["delete"](other2);
6321             return result2;
6322           }
6323           function equalByTag2(object, other2, tag2, bitmask, customizer, equalFunc, stack) {
6324             switch (tag2) {
6325               case dataViewTag4:
6326                 if (object.byteLength != other2.byteLength || object.byteOffset != other2.byteOffset) {
6327                   return false;
6328                 }
6329                 object = object.buffer;
6330                 other2 = other2.buffer;
6331               case arrayBufferTag3:
6332                 if (object.byteLength != other2.byteLength || !equalFunc(new Uint8Array3(object), new Uint8Array3(other2))) {
6333                   return false;
6334                 }
6335                 return true;
6336               case boolTag3:
6337               case dateTag3:
6338               case numberTag4:
6339                 return eq2(+object, +other2);
6340               case errorTag3:
6341                 return object.name == other2.name && object.message == other2.message;
6342               case regexpTag3:
6343               case stringTag3:
6344                 return object == other2 + "";
6345               case mapTag4:
6346                 var convert = mapToArray2;
6347               case setTag4:
6348                 var isPartial = bitmask & COMPARE_PARTIAL_FLAG5;
6349                 convert || (convert = setToArray2);
6350                 if (object.size != other2.size && !isPartial) {
6351                   return false;
6352                 }
6353                 var stacked = stack.get(object);
6354                 if (stacked) {
6355                   return stacked == other2;
6356                 }
6357                 bitmask |= COMPARE_UNORDERED_FLAG3;
6358                 stack.set(object, other2);
6359                 var result2 = equalArrays2(convert(object), convert(other2), bitmask, customizer, equalFunc, stack);
6360                 stack["delete"](object);
6361                 return result2;
6362               case symbolTag3:
6363                 if (symbolValueOf2) {
6364                   return symbolValueOf2.call(object) == symbolValueOf2.call(other2);
6365                 }
6366             }
6367             return false;
6368           }
6369           function equalObjects2(object, other2, bitmask, customizer, equalFunc, stack) {
6370             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, objProps = getAllKeys2(object), objLength = objProps.length, othProps = getAllKeys2(other2), othLength = othProps.length;
6371             if (objLength != othLength && !isPartial) {
6372               return false;
6373             }
6374             var index = objLength;
6375             while (index--) {
6376               var key = objProps[index];
6377               if (!(isPartial ? key in other2 : hasOwnProperty13.call(other2, key))) {
6378                 return false;
6379               }
6380             }
6381             var objStacked = stack.get(object);
6382             var othStacked = stack.get(other2);
6383             if (objStacked && othStacked) {
6384               return objStacked == other2 && othStacked == object;
6385             }
6386             var result2 = true;
6387             stack.set(object, other2);
6388             stack.set(other2, object);
6389             var skipCtor = isPartial;
6390             while (++index < objLength) {
6391               key = objProps[index];
6392               var objValue = object[key], othValue = other2[key];
6393               if (customizer) {
6394                 var compared = isPartial ? customizer(othValue, objValue, key, other2, object, stack) : customizer(objValue, othValue, key, object, other2, stack);
6395               }
6396               if (!(compared === undefined2 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
6397                 result2 = false;
6398                 break;
6399               }
6400               skipCtor || (skipCtor = key == "constructor");
6401             }
6402             if (result2 && !skipCtor) {
6403               var objCtor = object.constructor, othCtor = other2.constructor;
6404               if (objCtor != othCtor && ("constructor" in object && "constructor" in other2) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
6405                 result2 = false;
6406               }
6407             }
6408             stack["delete"](object);
6409             stack["delete"](other2);
6410             return result2;
6411           }
6412           function flatRest(func) {
6413             return setToString2(overRest2(func, undefined2, flatten2), func + "");
6414           }
6415           function getAllKeys2(object) {
6416             return baseGetAllKeys2(object, keys2, getSymbols2);
6417           }
6418           function getAllKeysIn(object) {
6419             return baseGetAllKeys2(object, keysIn2, getSymbolsIn);
6420           }
6421           var getData = !metaMap ? noop3 : function(func) {
6422             return metaMap.get(func);
6423           };
6424           function getFuncName(func) {
6425             var result2 = func.name + "", array2 = realNames[result2], length2 = hasOwnProperty13.call(realNames, result2) ? array2.length : 0;
6426             while (length2--) {
6427               var data = array2[length2], otherFunc = data.func;
6428               if (otherFunc == null || otherFunc == func) {
6429                 return data.name;
6430               }
6431             }
6432             return result2;
6433           }
6434           function getHolder(func) {
6435             var object = hasOwnProperty13.call(lodash, "placeholder") ? lodash : func;
6436             return object.placeholder;
6437           }
6438           function getIteratee() {
6439             var result2 = lodash.iteratee || iteratee;
6440             result2 = result2 === iteratee ? baseIteratee : result2;
6441             return arguments.length ? result2(arguments[0], arguments[1]) : result2;
6442           }
6443           function getMapData2(map3, key) {
6444             var data = map3.__data__;
6445             return isKeyable2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
6446           }
6447           function getMatchData(object) {
6448             var result2 = keys2(object), length2 = result2.length;
6449             while (length2--) {
6450               var key = result2[length2], value = object[key];
6451               result2[length2] = [key, value, isStrictComparable(value)];
6452             }
6453             return result2;
6454           }
6455           function getNative2(object, key) {
6456             var value = getValue2(object, key);
6457             return baseIsNative2(value) ? value : undefined2;
6458           }
6459           function getRawTag2(value) {
6460             var isOwn = hasOwnProperty13.call(value, symToStringTag3), tag2 = value[symToStringTag3];
6461             try {
6462               value[symToStringTag3] = undefined2;
6463               var unmasked = true;
6464             } catch (e3) {
6465             }
6466             var result2 = nativeObjectToString3.call(value);
6467             if (unmasked) {
6468               if (isOwn) {
6469                 value[symToStringTag3] = tag2;
6470               } else {
6471                 delete value[symToStringTag3];
6472               }
6473             }
6474             return result2;
6475           }
6476           var getSymbols2 = !nativeGetSymbols2 ? stubArray2 : function(object) {
6477             if (object == null) {
6478               return [];
6479             }
6480             object = Object2(object);
6481             return arrayFilter2(nativeGetSymbols2(object), function(symbol) {
6482               return propertyIsEnumerable3.call(object, symbol);
6483             });
6484           };
6485           var getSymbolsIn = !nativeGetSymbols2 ? stubArray2 : function(object) {
6486             var result2 = [];
6487             while (object) {
6488               arrayPush2(result2, getSymbols2(object));
6489               object = getPrototype2(object);
6490             }
6491             return result2;
6492           };
6493           var getTag2 = baseGetTag2;
6494           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) {
6495             getTag2 = function(value) {
6496               var result2 = baseGetTag2(value), Ctor = result2 == objectTag5 ? value.constructor : undefined2, ctorString = Ctor ? toSource2(Ctor) : "";
6497               if (ctorString) {
6498                 switch (ctorString) {
6499                   case dataViewCtorString2:
6500                     return dataViewTag4;
6501                   case mapCtorString2:
6502                     return mapTag4;
6503                   case promiseCtorString2:
6504                     return promiseTag2;
6505                   case setCtorString2:
6506                     return setTag4;
6507                   case weakMapCtorString2:
6508                     return weakMapTag3;
6509                 }
6510               }
6511               return result2;
6512             };
6513           }
6514           function getView(start2, end, transforms) {
6515             var index = -1, length2 = transforms.length;
6516             while (++index < length2) {
6517               var data = transforms[index], size2 = data.size;
6518               switch (data.type) {
6519                 case "drop":
6520                   start2 += size2;
6521                   break;
6522                 case "dropRight":
6523                   end -= size2;
6524                   break;
6525                 case "take":
6526                   end = nativeMin2(end, start2 + size2);
6527                   break;
6528                 case "takeRight":
6529                   start2 = nativeMax3(start2, end - size2);
6530                   break;
6531               }
6532             }
6533             return { "start": start2, "end": end };
6534           }
6535           function getWrapDetails(source) {
6536             var match = source.match(reWrapDetails);
6537             return match ? match[1].split(reSplitDetails) : [];
6538           }
6539           function hasPath(object, path, hasFunc) {
6540             path = castPath(path, object);
6541             var index = -1, length2 = path.length, result2 = false;
6542             while (++index < length2) {
6543               var key = toKey(path[index]);
6544               if (!(result2 = object != null && hasFunc(object, key))) {
6545                 break;
6546               }
6547               object = object[key];
6548             }
6549             if (result2 || ++index != length2) {
6550               return result2;
6551             }
6552             length2 = object == null ? 0 : object.length;
6553             return !!length2 && isLength2(length2) && isIndex2(key, length2) && (isArray2(object) || isArguments2(object));
6554           }
6555           function initCloneArray(array2) {
6556             var length2 = array2.length, result2 = new array2.constructor(length2);
6557             if (length2 && typeof array2[0] == "string" && hasOwnProperty13.call(array2, "index")) {
6558               result2.index = array2.index;
6559               result2.input = array2.input;
6560             }
6561             return result2;
6562           }
6563           function initCloneObject2(object) {
6564             return typeof object.constructor == "function" && !isPrototype2(object) ? baseCreate2(getPrototype2(object)) : {};
6565           }
6566           function initCloneByTag(object, tag2, isDeep) {
6567             var Ctor = object.constructor;
6568             switch (tag2) {
6569               case arrayBufferTag3:
6570                 return cloneArrayBuffer2(object);
6571               case boolTag3:
6572               case dateTag3:
6573                 return new Ctor(+object);
6574               case dataViewTag4:
6575                 return cloneDataView(object, isDeep);
6576               case float32Tag2:
6577               case float64Tag2:
6578               case int8Tag2:
6579               case int16Tag2:
6580               case int32Tag2:
6581               case uint8Tag2:
6582               case uint8ClampedTag2:
6583               case uint16Tag2:
6584               case uint32Tag2:
6585                 return cloneTypedArray2(object, isDeep);
6586               case mapTag4:
6587                 return new Ctor();
6588               case numberTag4:
6589               case stringTag3:
6590                 return new Ctor(object);
6591               case regexpTag3:
6592                 return cloneRegExp(object);
6593               case setTag4:
6594                 return new Ctor();
6595               case symbolTag3:
6596                 return cloneSymbol(object);
6597             }
6598           }
6599           function insertWrapDetails(source, details) {
6600             var length2 = details.length;
6601             if (!length2) {
6602               return source;
6603             }
6604             var lastIndex = length2 - 1;
6605             details[lastIndex] = (length2 > 1 ? "& " : "") + details[lastIndex];
6606             details = details.join(length2 > 2 ? ", " : " ");
6607             return source.replace(reWrapComment, "{\n/* [wrapped with " + details + "] */\n");
6608           }
6609           function isFlattenable(value) {
6610             return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
6611           }
6612           function isIndex2(value, length2) {
6613             var type2 = typeof value;
6614             length2 = length2 == null ? MAX_SAFE_INTEGER4 : length2;
6615             return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
6616           }
6617           function isIterateeCall2(value, index, object) {
6618             if (!isObject2(object)) {
6619               return false;
6620             }
6621             var type2 = typeof index;
6622             if (type2 == "number" ? isArrayLike2(object) && isIndex2(index, object.length) : type2 == "string" && index in object) {
6623               return eq2(object[index], value);
6624             }
6625             return false;
6626           }
6627           function isKey(value, object) {
6628             if (isArray2(value)) {
6629               return false;
6630             }
6631             var type2 = typeof value;
6632             if (type2 == "number" || type2 == "symbol" || type2 == "boolean" || value == null || isSymbol2(value)) {
6633               return true;
6634             }
6635             return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object2(object);
6636           }
6637           function isKeyable2(value) {
6638             var type2 = typeof value;
6639             return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
6640           }
6641           function isLaziable(func) {
6642             var funcName = getFuncName(func), other2 = lodash[funcName];
6643             if (typeof other2 != "function" || !(funcName in LazyWrapper.prototype)) {
6644               return false;
6645             }
6646             if (func === other2) {
6647               return true;
6648             }
6649             var data = getData(other2);
6650             return !!data && func === data[0];
6651           }
6652           function isMasked2(func) {
6653             return !!maskSrcKey2 && maskSrcKey2 in func;
6654           }
6655           var isMaskable = coreJsData2 ? isFunction2 : stubFalse2;
6656           function isPrototype2(value) {
6657             var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto16;
6658             return value === proto;
6659           }
6660           function isStrictComparable(value) {
6661             return value === value && !isObject2(value);
6662           }
6663           function matchesStrictComparable(key, srcValue) {
6664             return function(object) {
6665               if (object == null) {
6666                 return false;
6667               }
6668               return object[key] === srcValue && (srcValue !== undefined2 || key in Object2(object));
6669             };
6670           }
6671           function memoizeCapped(func) {
6672             var result2 = memoize(func, function(key) {
6673               if (cache.size === MAX_MEMOIZE_SIZE) {
6674                 cache.clear();
6675               }
6676               return key;
6677             });
6678             var cache = result2.cache;
6679             return result2;
6680           }
6681           function mergeData(data, source) {
6682             var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6683             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;
6684             if (!(isCommon || isCombo)) {
6685               return data;
6686             }
6687             if (srcBitmask & WRAP_BIND_FLAG) {
6688               data[2] = source[2];
6689               newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6690             }
6691             var value = source[3];
6692             if (value) {
6693               var partials = data[3];
6694               data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6695               data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6696             }
6697             value = source[5];
6698             if (value) {
6699               partials = data[5];
6700               data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6701               data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6702             }
6703             value = source[7];
6704             if (value) {
6705               data[7] = value;
6706             }
6707             if (srcBitmask & WRAP_ARY_FLAG) {
6708               data[8] = data[8] == null ? source[8] : nativeMin2(data[8], source[8]);
6709             }
6710             if (data[9] == null) {
6711               data[9] = source[9];
6712             }
6713             data[0] = source[0];
6714             data[1] = newBitmask;
6715             return data;
6716           }
6717           function nativeKeysIn2(object) {
6718             var result2 = [];
6719             if (object != null) {
6720               for (var key in Object2(object)) {
6721                 result2.push(key);
6722               }
6723             }
6724             return result2;
6725           }
6726           function objectToString2(value) {
6727             return nativeObjectToString3.call(value);
6728           }
6729           function overRest2(func, start2, transform3) {
6730             start2 = nativeMax3(start2 === undefined2 ? func.length - 1 : start2, 0);
6731             return function() {
6732               var args = arguments, index = -1, length2 = nativeMax3(args.length - start2, 0), array2 = Array2(length2);
6733               while (++index < length2) {
6734                 array2[index] = args[start2 + index];
6735               }
6736               index = -1;
6737               var otherArgs = Array2(start2 + 1);
6738               while (++index < start2) {
6739                 otherArgs[index] = args[index];
6740               }
6741               otherArgs[start2] = transform3(array2);
6742               return apply2(func, this, otherArgs);
6743             };
6744           }
6745           function parent(object, path) {
6746             return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6747           }
6748           function reorder(array2, indexes) {
6749             var arrLength = array2.length, length2 = nativeMin2(indexes.length, arrLength), oldArray = copyArray2(array2);
6750             while (length2--) {
6751               var index = indexes[length2];
6752               array2[length2] = isIndex2(index, arrLength) ? oldArray[index] : undefined2;
6753             }
6754             return array2;
6755           }
6756           function safeGet2(object, key) {
6757             if (key === "constructor" && typeof object[key] === "function") {
6758               return;
6759             }
6760             if (key == "__proto__") {
6761               return;
6762             }
6763             return object[key];
6764           }
6765           var setData = shortOut2(baseSetData);
6766           var setTimeout2 = ctxSetTimeout || function(func, wait) {
6767             return root3.setTimeout(func, wait);
6768           };
6769           var setToString2 = shortOut2(baseSetToString2);
6770           function setWrapToString(wrapper, reference, bitmask) {
6771             var source = reference + "";
6772             return setToString2(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6773           }
6774           function shortOut2(func) {
6775             var count = 0, lastCalled = 0;
6776             return function() {
6777               var stamp = nativeNow2(), remaining = HOT_SPAN2 - (stamp - lastCalled);
6778               lastCalled = stamp;
6779               if (remaining > 0) {
6780                 if (++count >= HOT_COUNT2) {
6781                   return arguments[0];
6782                 }
6783               } else {
6784                 count = 0;
6785               }
6786               return func.apply(undefined2, arguments);
6787             };
6788           }
6789           function shuffleSelf(array2, size2) {
6790             var index = -1, length2 = array2.length, lastIndex = length2 - 1;
6791             size2 = size2 === undefined2 ? length2 : size2;
6792             while (++index < size2) {
6793               var rand = baseRandom(index, lastIndex), value = array2[rand];
6794               array2[rand] = array2[index];
6795               array2[index] = value;
6796             }
6797             array2.length = size2;
6798             return array2;
6799           }
6800           var stringToPath = memoizeCapped(function(string) {
6801             var result2 = [];
6802             if (string.charCodeAt(0) === 46) {
6803               result2.push("");
6804             }
6805             string.replace(rePropName, function(match, number3, quote, subString) {
6806               result2.push(quote ? subString.replace(reEscapeChar, "$1") : number3 || match);
6807             });
6808             return result2;
6809           });
6810           function toKey(value) {
6811             if (typeof value == "string" || isSymbol2(value)) {
6812               return value;
6813             }
6814             var result2 = value + "";
6815             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
6816           }
6817           function toSource2(func) {
6818             if (func != null) {
6819               try {
6820                 return funcToString4.call(func);
6821               } catch (e3) {
6822               }
6823               try {
6824                 return func + "";
6825               } catch (e3) {
6826               }
6827             }
6828             return "";
6829           }
6830           function updateWrapDetails(details, bitmask) {
6831             arrayEach(wrapFlags, function(pair3) {
6832               var value = "_." + pair3[0];
6833               if (bitmask & pair3[1] && !arrayIncludes(details, value)) {
6834                 details.push(value);
6835               }
6836             });
6837             return details.sort();
6838           }
6839           function wrapperClone(wrapper) {
6840             if (wrapper instanceof LazyWrapper) {
6841               return wrapper.clone();
6842             }
6843             var result2 = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6844             result2.__actions__ = copyArray2(wrapper.__actions__);
6845             result2.__index__ = wrapper.__index__;
6846             result2.__values__ = wrapper.__values__;
6847             return result2;
6848           }
6849           function chunk(array2, size2, guard) {
6850             if (guard ? isIterateeCall2(array2, size2, guard) : size2 === undefined2) {
6851               size2 = 1;
6852             } else {
6853               size2 = nativeMax3(toInteger(size2), 0);
6854             }
6855             var length2 = array2 == null ? 0 : array2.length;
6856             if (!length2 || size2 < 1) {
6857               return [];
6858             }
6859             var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length2 / size2));
6860             while (index < length2) {
6861               result2[resIndex++] = baseSlice(array2, index, index += size2);
6862             }
6863             return result2;
6864           }
6865           function compact(array2) {
6866             var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result2 = [];
6867             while (++index < length2) {
6868               var value = array2[index];
6869               if (value) {
6870                 result2[resIndex++] = value;
6871               }
6872             }
6873             return result2;
6874           }
6875           function concat() {
6876             var length2 = arguments.length;
6877             if (!length2) {
6878               return [];
6879             }
6880             var args = Array2(length2 - 1), array2 = arguments[0], index = length2;
6881             while (index--) {
6882               args[index - 1] = arguments[index];
6883             }
6884             return arrayPush2(isArray2(array2) ? copyArray2(array2) : [array2], baseFlatten(args, 1));
6885           }
6886           var difference2 = baseRest2(function(array2, values2) {
6887             return isArrayLikeObject2(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject2, true)) : [];
6888           });
6889           var differenceBy = baseRest2(function(array2, values2) {
6890             var iteratee2 = last(values2);
6891             if (isArrayLikeObject2(iteratee2)) {
6892               iteratee2 = undefined2;
6893             }
6894             return isArrayLikeObject2(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject2, true), getIteratee(iteratee2, 2)) : [];
6895           });
6896           var differenceWith = baseRest2(function(array2, values2) {
6897             var comparator = last(values2);
6898             if (isArrayLikeObject2(comparator)) {
6899               comparator = undefined2;
6900             }
6901             return isArrayLikeObject2(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject2, true), undefined2, comparator) : [];
6902           });
6903           function drop(array2, n3, guard) {
6904             var length2 = array2 == null ? 0 : array2.length;
6905             if (!length2) {
6906               return [];
6907             }
6908             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
6909             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
6910           }
6911           function dropRight(array2, n3, guard) {
6912             var length2 = array2 == null ? 0 : array2.length;
6913             if (!length2) {
6914               return [];
6915             }
6916             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
6917             n3 = length2 - n3;
6918             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
6919           }
6920           function dropRightWhile(array2, predicate) {
6921             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true, true) : [];
6922           }
6923           function dropWhile(array2, predicate) {
6924             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true) : [];
6925           }
6926           function fill(array2, value, start2, end) {
6927             var length2 = array2 == null ? 0 : array2.length;
6928             if (!length2) {
6929               return [];
6930             }
6931             if (start2 && typeof start2 != "number" && isIterateeCall2(array2, value, start2)) {
6932               start2 = 0;
6933               end = length2;
6934             }
6935             return baseFill(array2, value, start2, end);
6936           }
6937           function findIndex(array2, predicate, fromIndex) {
6938             var length2 = array2 == null ? 0 : array2.length;
6939             if (!length2) {
6940               return -1;
6941             }
6942             var index = fromIndex == null ? 0 : toInteger(fromIndex);
6943             if (index < 0) {
6944               index = nativeMax3(length2 + index, 0);
6945             }
6946             return baseFindIndex(array2, getIteratee(predicate, 3), index);
6947           }
6948           function findLastIndex(array2, predicate, fromIndex) {
6949             var length2 = array2 == null ? 0 : array2.length;
6950             if (!length2) {
6951               return -1;
6952             }
6953             var index = length2 - 1;
6954             if (fromIndex !== undefined2) {
6955               index = toInteger(fromIndex);
6956               index = fromIndex < 0 ? nativeMax3(length2 + index, 0) : nativeMin2(index, length2 - 1);
6957             }
6958             return baseFindIndex(array2, getIteratee(predicate, 3), index, true);
6959           }
6960           function flatten2(array2) {
6961             var length2 = array2 == null ? 0 : array2.length;
6962             return length2 ? baseFlatten(array2, 1) : [];
6963           }
6964           function flattenDeep(array2) {
6965             var length2 = array2 == null ? 0 : array2.length;
6966             return length2 ? baseFlatten(array2, INFINITY2) : [];
6967           }
6968           function flattenDepth(array2, depth) {
6969             var length2 = array2 == null ? 0 : array2.length;
6970             if (!length2) {
6971               return [];
6972             }
6973             depth = depth === undefined2 ? 1 : toInteger(depth);
6974             return baseFlatten(array2, depth);
6975           }
6976           function fromPairs(pairs2) {
6977             var index = -1, length2 = pairs2 == null ? 0 : pairs2.length, result2 = {};
6978             while (++index < length2) {
6979               var pair3 = pairs2[index];
6980               result2[pair3[0]] = pair3[1];
6981             }
6982             return result2;
6983           }
6984           function head(array2) {
6985             return array2 && array2.length ? array2[0] : undefined2;
6986           }
6987           function indexOf(array2, value, fromIndex) {
6988             var length2 = array2 == null ? 0 : array2.length;
6989             if (!length2) {
6990               return -1;
6991             }
6992             var index = fromIndex == null ? 0 : toInteger(fromIndex);
6993             if (index < 0) {
6994               index = nativeMax3(length2 + index, 0);
6995             }
6996             return baseIndexOf(array2, value, index);
6997           }
6998           function initial(array2) {
6999             var length2 = array2 == null ? 0 : array2.length;
7000             return length2 ? baseSlice(array2, 0, -1) : [];
7001           }
7002           var intersection2 = baseRest2(function(arrays) {
7003             var mapped = arrayMap2(arrays, castArrayLikeObject);
7004             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
7005           });
7006           var intersectionBy = baseRest2(function(arrays) {
7007             var iteratee2 = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
7008             if (iteratee2 === last(mapped)) {
7009               iteratee2 = undefined2;
7010             } else {
7011               mapped.pop();
7012             }
7013             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, getIteratee(iteratee2, 2)) : [];
7014           });
7015           var intersectionWith = baseRest2(function(arrays) {
7016             var comparator = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
7017             comparator = typeof comparator == "function" ? comparator : undefined2;
7018             if (comparator) {
7019               mapped.pop();
7020             }
7021             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
7022           });
7023           function join(array2, separator) {
7024             return array2 == null ? "" : nativeJoin.call(array2, separator);
7025           }
7026           function last(array2) {
7027             var length2 = array2 == null ? 0 : array2.length;
7028             return length2 ? array2[length2 - 1] : undefined2;
7029           }
7030           function lastIndexOf(array2, value, fromIndex) {
7031             var length2 = array2 == null ? 0 : array2.length;
7032             if (!length2) {
7033               return -1;
7034             }
7035             var index = length2;
7036             if (fromIndex !== undefined2) {
7037               index = toInteger(fromIndex);
7038               index = index < 0 ? nativeMax3(length2 + index, 0) : nativeMin2(index, length2 - 1);
7039             }
7040             return value === value ? strictLastIndexOf(array2, value, index) : baseFindIndex(array2, baseIsNaN, index, true);
7041           }
7042           function nth(array2, n3) {
7043             return array2 && array2.length ? baseNth(array2, toInteger(n3)) : undefined2;
7044           }
7045           var pull = baseRest2(pullAll);
7046           function pullAll(array2, values2) {
7047             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
7048           }
7049           function pullAllBy(array2, values2, iteratee2) {
7050             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, getIteratee(iteratee2, 2)) : array2;
7051           }
7052           function pullAllWith(array2, values2, comparator) {
7053             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, undefined2, comparator) : array2;
7054           }
7055           var pullAt = flatRest(function(array2, indexes) {
7056             var length2 = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes);
7057             basePullAt(array2, arrayMap2(indexes, function(index) {
7058               return isIndex2(index, length2) ? +index : index;
7059             }).sort(compareAscending));
7060             return result2;
7061           });
7062           function remove2(array2, predicate) {
7063             var result2 = [];
7064             if (!(array2 && array2.length)) {
7065               return result2;
7066             }
7067             var index = -1, indexes = [], length2 = array2.length;
7068             predicate = getIteratee(predicate, 3);
7069             while (++index < length2) {
7070               var value = array2[index];
7071               if (predicate(value, index, array2)) {
7072                 result2.push(value);
7073                 indexes.push(index);
7074               }
7075             }
7076             basePullAt(array2, indexes);
7077             return result2;
7078           }
7079           function reverse(array2) {
7080             return array2 == null ? array2 : nativeReverse.call(array2);
7081           }
7082           function slice(array2, start2, end) {
7083             var length2 = array2 == null ? 0 : array2.length;
7084             if (!length2) {
7085               return [];
7086             }
7087             if (end && typeof end != "number" && isIterateeCall2(array2, start2, end)) {
7088               start2 = 0;
7089               end = length2;
7090             } else {
7091               start2 = start2 == null ? 0 : toInteger(start2);
7092               end = end === undefined2 ? length2 : toInteger(end);
7093             }
7094             return baseSlice(array2, start2, end);
7095           }
7096           function sortedIndex(array2, value) {
7097             return baseSortedIndex(array2, value);
7098           }
7099           function sortedIndexBy(array2, value, iteratee2) {
7100             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2));
7101           }
7102           function sortedIndexOf(array2, value) {
7103             var length2 = array2 == null ? 0 : array2.length;
7104             if (length2) {
7105               var index = baseSortedIndex(array2, value);
7106               if (index < length2 && eq2(array2[index], value)) {
7107                 return index;
7108               }
7109             }
7110             return -1;
7111           }
7112           function sortedLastIndex(array2, value) {
7113             return baseSortedIndex(array2, value, true);
7114           }
7115           function sortedLastIndexBy(array2, value, iteratee2) {
7116             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2), true);
7117           }
7118           function sortedLastIndexOf(array2, value) {
7119             var length2 = array2 == null ? 0 : array2.length;
7120             if (length2) {
7121               var index = baseSortedIndex(array2, value, true) - 1;
7122               if (eq2(array2[index], value)) {
7123                 return index;
7124               }
7125             }
7126             return -1;
7127           }
7128           function sortedUniq(array2) {
7129             return array2 && array2.length ? baseSortedUniq(array2) : [];
7130           }
7131           function sortedUniqBy(array2, iteratee2) {
7132             return array2 && array2.length ? baseSortedUniq(array2, getIteratee(iteratee2, 2)) : [];
7133           }
7134           function tail(array2) {
7135             var length2 = array2 == null ? 0 : array2.length;
7136             return length2 ? baseSlice(array2, 1, length2) : [];
7137           }
7138           function take(array2, n3, guard) {
7139             if (!(array2 && array2.length)) {
7140               return [];
7141             }
7142             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7143             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
7144           }
7145           function takeRight(array2, n3, guard) {
7146             var length2 = array2 == null ? 0 : array2.length;
7147             if (!length2) {
7148               return [];
7149             }
7150             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7151             n3 = length2 - n3;
7152             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
7153           }
7154           function takeRightWhile(array2, predicate) {
7155             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), false, true) : [];
7156           }
7157           function takeWhile(array2, predicate) {
7158             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3)) : [];
7159           }
7160           var union2 = baseRest2(function(arrays) {
7161             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject2, true));
7162           });
7163           var unionBy = baseRest2(function(arrays) {
7164             var iteratee2 = last(arrays);
7165             if (isArrayLikeObject2(iteratee2)) {
7166               iteratee2 = undefined2;
7167             }
7168             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject2, true), getIteratee(iteratee2, 2));
7169           });
7170           var unionWith = baseRest2(function(arrays) {
7171             var comparator = last(arrays);
7172             comparator = typeof comparator == "function" ? comparator : undefined2;
7173             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject2, true), undefined2, comparator);
7174           });
7175           function uniq(array2) {
7176             return array2 && array2.length ? baseUniq(array2) : [];
7177           }
7178           function uniqBy(array2, iteratee2) {
7179             return array2 && array2.length ? baseUniq(array2, getIteratee(iteratee2, 2)) : [];
7180           }
7181           function uniqWith(array2, comparator) {
7182             comparator = typeof comparator == "function" ? comparator : undefined2;
7183             return array2 && array2.length ? baseUniq(array2, undefined2, comparator) : [];
7184           }
7185           function unzip(array2) {
7186             if (!(array2 && array2.length)) {
7187               return [];
7188             }
7189             var length2 = 0;
7190             array2 = arrayFilter2(array2, function(group) {
7191               if (isArrayLikeObject2(group)) {
7192                 length2 = nativeMax3(group.length, length2);
7193                 return true;
7194               }
7195             });
7196             return baseTimes2(length2, function(index) {
7197               return arrayMap2(array2, baseProperty(index));
7198             });
7199           }
7200           function unzipWith(array2, iteratee2) {
7201             if (!(array2 && array2.length)) {
7202               return [];
7203             }
7204             var result2 = unzip(array2);
7205             if (iteratee2 == null) {
7206               return result2;
7207             }
7208             return arrayMap2(result2, function(group) {
7209               return apply2(iteratee2, undefined2, group);
7210             });
7211           }
7212           var without = baseRest2(function(array2, values2) {
7213             return isArrayLikeObject2(array2) ? baseDifference(array2, values2) : [];
7214           });
7215           var xor = baseRest2(function(arrays) {
7216             return baseXor(arrayFilter2(arrays, isArrayLikeObject2));
7217           });
7218           var xorBy = baseRest2(function(arrays) {
7219             var iteratee2 = last(arrays);
7220             if (isArrayLikeObject2(iteratee2)) {
7221               iteratee2 = undefined2;
7222             }
7223             return baseXor(arrayFilter2(arrays, isArrayLikeObject2), getIteratee(iteratee2, 2));
7224           });
7225           var xorWith = baseRest2(function(arrays) {
7226             var comparator = last(arrays);
7227             comparator = typeof comparator == "function" ? comparator : undefined2;
7228             return baseXor(arrayFilter2(arrays, isArrayLikeObject2), undefined2, comparator);
7229           });
7230           var zip = baseRest2(unzip);
7231           function zipObject(props, values2) {
7232             return baseZipObject(props || [], values2 || [], assignValue2);
7233           }
7234           function zipObjectDeep(props, values2) {
7235             return baseZipObject(props || [], values2 || [], baseSet);
7236           }
7237           var zipWith = baseRest2(function(arrays) {
7238             var length2 = arrays.length, iteratee2 = length2 > 1 ? arrays[length2 - 1] : undefined2;
7239             iteratee2 = typeof iteratee2 == "function" ? (arrays.pop(), iteratee2) : undefined2;
7240             return unzipWith(arrays, iteratee2);
7241           });
7242           function chain(value) {
7243             var result2 = lodash(value);
7244             result2.__chain__ = true;
7245             return result2;
7246           }
7247           function tap(value, interceptor) {
7248             interceptor(value);
7249             return value;
7250           }
7251           function thru(value, interceptor) {
7252             return interceptor(value);
7253           }
7254           var wrapperAt = flatRest(function(paths) {
7255             var length2 = paths.length, start2 = length2 ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) {
7256               return baseAt(object, paths);
7257             };
7258             if (length2 > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) {
7259               return this.thru(interceptor);
7260             }
7261             value = value.slice(start2, +start2 + (length2 ? 1 : 0));
7262             value.__actions__.push({
7263               "func": thru,
7264               "args": [interceptor],
7265               "thisArg": undefined2
7266             });
7267             return new LodashWrapper(value, this.__chain__).thru(function(array2) {
7268               if (length2 && !array2.length) {
7269                 array2.push(undefined2);
7270               }
7271               return array2;
7272             });
7273           });
7274           function wrapperChain() {
7275             return chain(this);
7276           }
7277           function wrapperCommit() {
7278             return new LodashWrapper(this.value(), this.__chain__);
7279           }
7280           function wrapperNext() {
7281             if (this.__values__ === undefined2) {
7282               this.__values__ = toArray(this.value());
7283             }
7284             var done = this.__index__ >= this.__values__.length, value = done ? undefined2 : this.__values__[this.__index__++];
7285             return { "done": done, "value": value };
7286           }
7287           function wrapperToIterator() {
7288             return this;
7289           }
7290           function wrapperPlant(value) {
7291             var result2, parent2 = this;
7292             while (parent2 instanceof baseLodash) {
7293               var clone3 = wrapperClone(parent2);
7294               clone3.__index__ = 0;
7295               clone3.__values__ = undefined2;
7296               if (result2) {
7297                 previous.__wrapped__ = clone3;
7298               } else {
7299                 result2 = clone3;
7300               }
7301               var previous = clone3;
7302               parent2 = parent2.__wrapped__;
7303             }
7304             previous.__wrapped__ = value;
7305             return result2;
7306           }
7307           function wrapperReverse() {
7308             var value = this.__wrapped__;
7309             if (value instanceof LazyWrapper) {
7310               var wrapped = value;
7311               if (this.__actions__.length) {
7312                 wrapped = new LazyWrapper(this);
7313               }
7314               wrapped = wrapped.reverse();
7315               wrapped.__actions__.push({
7316                 "func": thru,
7317                 "args": [reverse],
7318                 "thisArg": undefined2
7319               });
7320               return new LodashWrapper(wrapped, this.__chain__);
7321             }
7322             return this.thru(reverse);
7323           }
7324           function wrapperValue() {
7325             return baseWrapperValue(this.__wrapped__, this.__actions__);
7326           }
7327           var countBy = createAggregator(function(result2, value, key) {
7328             if (hasOwnProperty13.call(result2, key)) {
7329               ++result2[key];
7330             } else {
7331               baseAssignValue2(result2, key, 1);
7332             }
7333           });
7334           function every(collection, predicate, guard) {
7335             var func = isArray2(collection) ? arrayEvery : baseEvery;
7336             if (guard && isIterateeCall2(collection, predicate, guard)) {
7337               predicate = undefined2;
7338             }
7339             return func(collection, getIteratee(predicate, 3));
7340           }
7341           function filter2(collection, predicate) {
7342             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
7343             return func(collection, getIteratee(predicate, 3));
7344           }
7345           var find2 = createFind(findIndex);
7346           var findLast = createFind(findLastIndex);
7347           function flatMap(collection, iteratee2) {
7348             return baseFlatten(map2(collection, iteratee2), 1);
7349           }
7350           function flatMapDeep(collection, iteratee2) {
7351             return baseFlatten(map2(collection, iteratee2), INFINITY2);
7352           }
7353           function flatMapDepth(collection, iteratee2, depth) {
7354             depth = depth === undefined2 ? 1 : toInteger(depth);
7355             return baseFlatten(map2(collection, iteratee2), depth);
7356           }
7357           function forEach(collection, iteratee2) {
7358             var func = isArray2(collection) ? arrayEach : baseEach;
7359             return func(collection, getIteratee(iteratee2, 3));
7360           }
7361           function forEachRight(collection, iteratee2) {
7362             var func = isArray2(collection) ? arrayEachRight : baseEachRight;
7363             return func(collection, getIteratee(iteratee2, 3));
7364           }
7365           var groupBy = createAggregator(function(result2, value, key) {
7366             if (hasOwnProperty13.call(result2, key)) {
7367               result2[key].push(value);
7368             } else {
7369               baseAssignValue2(result2, key, [value]);
7370             }
7371           });
7372           function includes(collection, value, fromIndex, guard) {
7373             collection = isArrayLike2(collection) ? collection : values(collection);
7374             fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
7375             var length2 = collection.length;
7376             if (fromIndex < 0) {
7377               fromIndex = nativeMax3(length2 + fromIndex, 0);
7378             }
7379             return isString(collection) ? fromIndex <= length2 && collection.indexOf(value, fromIndex) > -1 : !!length2 && baseIndexOf(collection, value, fromIndex) > -1;
7380           }
7381           var invokeMap = baseRest2(function(collection, path, args) {
7382             var index = -1, isFunc = typeof path == "function", result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
7383             baseEach(collection, function(value) {
7384               result2[++index] = isFunc ? apply2(path, value, args) : baseInvoke(value, path, args);
7385             });
7386             return result2;
7387           });
7388           var keyBy = createAggregator(function(result2, value, key) {
7389             baseAssignValue2(result2, key, value);
7390           });
7391           function map2(collection, iteratee2) {
7392             var func = isArray2(collection) ? arrayMap2 : baseMap;
7393             return func(collection, getIteratee(iteratee2, 3));
7394           }
7395           function orderBy(collection, iteratees, orders, guard) {
7396             if (collection == null) {
7397               return [];
7398             }
7399             if (!isArray2(iteratees)) {
7400               iteratees = iteratees == null ? [] : [iteratees];
7401             }
7402             orders = guard ? undefined2 : orders;
7403             if (!isArray2(orders)) {
7404               orders = orders == null ? [] : [orders];
7405             }
7406             return baseOrderBy(collection, iteratees, orders);
7407           }
7408           var partition = createAggregator(function(result2, value, key) {
7409             result2[key ? 0 : 1].push(value);
7410           }, function() {
7411             return [[], []];
7412           });
7413           function reduce(collection, iteratee2, accumulator) {
7414             var func = isArray2(collection) ? arrayReduce : baseReduce, initAccum = arguments.length < 3;
7415             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEach);
7416           }
7417           function reduceRight(collection, iteratee2, accumulator) {
7418             var func = isArray2(collection) ? arrayReduceRight : baseReduce, initAccum = arguments.length < 3;
7419             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEachRight);
7420           }
7421           function reject(collection, predicate) {
7422             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
7423             return func(collection, negate(getIteratee(predicate, 3)));
7424           }
7425           function sample(collection) {
7426             var func = isArray2(collection) ? arraySample : baseSample;
7427             return func(collection);
7428           }
7429           function sampleSize(collection, n3, guard) {
7430             if (guard ? isIterateeCall2(collection, n3, guard) : n3 === undefined2) {
7431               n3 = 1;
7432             } else {
7433               n3 = toInteger(n3);
7434             }
7435             var func = isArray2(collection) ? arraySampleSize : baseSampleSize;
7436             return func(collection, n3);
7437           }
7438           function shuffle(collection) {
7439             var func = isArray2(collection) ? arrayShuffle : baseShuffle;
7440             return func(collection);
7441           }
7442           function size(collection) {
7443             if (collection == null) {
7444               return 0;
7445             }
7446             if (isArrayLike2(collection)) {
7447               return isString(collection) ? stringSize(collection) : collection.length;
7448             }
7449             var tag2 = getTag2(collection);
7450             if (tag2 == mapTag4 || tag2 == setTag4) {
7451               return collection.size;
7452             }
7453             return baseKeys2(collection).length;
7454           }
7455           function some(collection, predicate, guard) {
7456             var func = isArray2(collection) ? arraySome2 : baseSome;
7457             if (guard && isIterateeCall2(collection, predicate, guard)) {
7458               predicate = undefined2;
7459             }
7460             return func(collection, getIteratee(predicate, 3));
7461           }
7462           var sortBy = baseRest2(function(collection, iteratees) {
7463             if (collection == null) {
7464               return [];
7465             }
7466             var length2 = iteratees.length;
7467             if (length2 > 1 && isIterateeCall2(collection, iteratees[0], iteratees[1])) {
7468               iteratees = [];
7469             } else if (length2 > 2 && isIterateeCall2(iteratees[0], iteratees[1], iteratees[2])) {
7470               iteratees = [iteratees[0]];
7471             }
7472             return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
7473           });
7474           var now3 = ctxNow || function() {
7475             return root3.Date.now();
7476           };
7477           function after(n3, func) {
7478             if (typeof func != "function") {
7479               throw new TypeError2(FUNC_ERROR_TEXT3);
7480             }
7481             n3 = toInteger(n3);
7482             return function() {
7483               if (--n3 < 1) {
7484                 return func.apply(this, arguments);
7485               }
7486             };
7487           }
7488           function ary(func, n3, guard) {
7489             n3 = guard ? undefined2 : n3;
7490             n3 = func && n3 == null ? func.length : n3;
7491             return createWrap(func, WRAP_ARY_FLAG, undefined2, undefined2, undefined2, undefined2, n3);
7492           }
7493           function before(n3, func) {
7494             var result2;
7495             if (typeof func != "function") {
7496               throw new TypeError2(FUNC_ERROR_TEXT3);
7497             }
7498             n3 = toInteger(n3);
7499             return function() {
7500               if (--n3 > 0) {
7501                 result2 = func.apply(this, arguments);
7502               }
7503               if (n3 <= 1) {
7504                 func = undefined2;
7505               }
7506               return result2;
7507             };
7508           }
7509           var bind = baseRest2(function(func, thisArg, partials) {
7510             var bitmask = WRAP_BIND_FLAG;
7511             if (partials.length) {
7512               var holders = replaceHolders(partials, getHolder(bind));
7513               bitmask |= WRAP_PARTIAL_FLAG;
7514             }
7515             return createWrap(func, bitmask, thisArg, partials, holders);
7516           });
7517           var bindKey2 = baseRest2(function(object, key, partials) {
7518             var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
7519             if (partials.length) {
7520               var holders = replaceHolders(partials, getHolder(bindKey2));
7521               bitmask |= WRAP_PARTIAL_FLAG;
7522             }
7523             return createWrap(key, bitmask, object, partials, holders);
7524           });
7525           function curry(func, arity, guard) {
7526             arity = guard ? undefined2 : arity;
7527             var result2 = createWrap(func, WRAP_CURRY_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
7528             result2.placeholder = curry.placeholder;
7529             return result2;
7530           }
7531           function curryRight(func, arity, guard) {
7532             arity = guard ? undefined2 : arity;
7533             var result2 = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
7534             result2.placeholder = curryRight.placeholder;
7535             return result2;
7536           }
7537           function debounce2(func, wait, options2) {
7538             var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
7539             if (typeof func != "function") {
7540               throw new TypeError2(FUNC_ERROR_TEXT3);
7541             }
7542             wait = toNumber3(wait) || 0;
7543             if (isObject2(options2)) {
7544               leading = !!options2.leading;
7545               maxing = "maxWait" in options2;
7546               maxWait = maxing ? nativeMax3(toNumber3(options2.maxWait) || 0, wait) : maxWait;
7547               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
7548             }
7549             function invokeFunc(time) {
7550               var args = lastArgs, thisArg = lastThis;
7551               lastArgs = lastThis = undefined2;
7552               lastInvokeTime = time;
7553               result2 = func.apply(thisArg, args);
7554               return result2;
7555             }
7556             function leadingEdge(time) {
7557               lastInvokeTime = time;
7558               timerId = setTimeout2(timerExpired, wait);
7559               return leading ? invokeFunc(time) : result2;
7560             }
7561             function remainingWait(time) {
7562               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
7563               return maxing ? nativeMin2(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
7564             }
7565             function shouldInvoke(time) {
7566               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
7567               return lastCallTime === undefined2 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
7568             }
7569             function timerExpired() {
7570               var time = now3();
7571               if (shouldInvoke(time)) {
7572                 return trailingEdge(time);
7573               }
7574               timerId = setTimeout2(timerExpired, remainingWait(time));
7575             }
7576             function trailingEdge(time) {
7577               timerId = undefined2;
7578               if (trailing && lastArgs) {
7579                 return invokeFunc(time);
7580               }
7581               lastArgs = lastThis = undefined2;
7582               return result2;
7583             }
7584             function cancel() {
7585               if (timerId !== undefined2) {
7586                 clearTimeout2(timerId);
7587               }
7588               lastInvokeTime = 0;
7589               lastArgs = lastCallTime = lastThis = timerId = undefined2;
7590             }
7591             function flush() {
7592               return timerId === undefined2 ? result2 : trailingEdge(now3());
7593             }
7594             function debounced() {
7595               var time = now3(), isInvoking = shouldInvoke(time);
7596               lastArgs = arguments;
7597               lastThis = this;
7598               lastCallTime = time;
7599               if (isInvoking) {
7600                 if (timerId === undefined2) {
7601                   return leadingEdge(lastCallTime);
7602                 }
7603                 if (maxing) {
7604                   clearTimeout2(timerId);
7605                   timerId = setTimeout2(timerExpired, wait);
7606                   return invokeFunc(lastCallTime);
7607                 }
7608               }
7609               if (timerId === undefined2) {
7610                 timerId = setTimeout2(timerExpired, wait);
7611               }
7612               return result2;
7613             }
7614             debounced.cancel = cancel;
7615             debounced.flush = flush;
7616             return debounced;
7617           }
7618           var defer = baseRest2(function(func, args) {
7619             return baseDelay(func, 1, args);
7620           });
7621           var delay = baseRest2(function(func, wait, args) {
7622             return baseDelay(func, toNumber3(wait) || 0, args);
7623           });
7624           function flip(func) {
7625             return createWrap(func, WRAP_FLIP_FLAG);
7626           }
7627           function memoize(func, resolver) {
7628             if (typeof func != "function" || resolver != null && typeof resolver != "function") {
7629               throw new TypeError2(FUNC_ERROR_TEXT3);
7630             }
7631             var memoized = function() {
7632               var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
7633               if (cache.has(key)) {
7634                 return cache.get(key);
7635               }
7636               var result2 = func.apply(this, args);
7637               memoized.cache = cache.set(key, result2) || cache;
7638               return result2;
7639             };
7640             memoized.cache = new (memoize.Cache || MapCache2)();
7641             return memoized;
7642           }
7643           memoize.Cache = MapCache2;
7644           function negate(predicate) {
7645             if (typeof predicate != "function") {
7646               throw new TypeError2(FUNC_ERROR_TEXT3);
7647             }
7648             return function() {
7649               var args = arguments;
7650               switch (args.length) {
7651                 case 0:
7652                   return !predicate.call(this);
7653                 case 1:
7654                   return !predicate.call(this, args[0]);
7655                 case 2:
7656                   return !predicate.call(this, args[0], args[1]);
7657                 case 3:
7658                   return !predicate.call(this, args[0], args[1], args[2]);
7659               }
7660               return !predicate.apply(this, args);
7661             };
7662           }
7663           function once(func) {
7664             return before(2, func);
7665           }
7666           var overArgs = castRest(function(func, transforms) {
7667             transforms = transforms.length == 1 && isArray2(transforms[0]) ? arrayMap2(transforms[0], baseUnary2(getIteratee())) : arrayMap2(baseFlatten(transforms, 1), baseUnary2(getIteratee()));
7668             var funcsLength = transforms.length;
7669             return baseRest2(function(args) {
7670               var index = -1, length2 = nativeMin2(args.length, funcsLength);
7671               while (++index < length2) {
7672                 args[index] = transforms[index].call(this, args[index]);
7673               }
7674               return apply2(func, this, args);
7675             });
7676           });
7677           var partial = baseRest2(function(func, partials) {
7678             var holders = replaceHolders(partials, getHolder(partial));
7679             return createWrap(func, WRAP_PARTIAL_FLAG, undefined2, partials, holders);
7680           });
7681           var partialRight = baseRest2(function(func, partials) {
7682             var holders = replaceHolders(partials, getHolder(partialRight));
7683             return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined2, partials, holders);
7684           });
7685           var rearg = flatRest(function(func, indexes) {
7686             return createWrap(func, WRAP_REARG_FLAG, undefined2, undefined2, undefined2, indexes);
7687           });
7688           function rest(func, start2) {
7689             if (typeof func != "function") {
7690               throw new TypeError2(FUNC_ERROR_TEXT3);
7691             }
7692             start2 = start2 === undefined2 ? start2 : toInteger(start2);
7693             return baseRest2(func, start2);
7694           }
7695           function spread(func, start2) {
7696             if (typeof func != "function") {
7697               throw new TypeError2(FUNC_ERROR_TEXT3);
7698             }
7699             start2 = start2 == null ? 0 : nativeMax3(toInteger(start2), 0);
7700             return baseRest2(function(args) {
7701               var array2 = args[start2], otherArgs = castSlice(args, 0, start2);
7702               if (array2) {
7703                 arrayPush2(otherArgs, array2);
7704               }
7705               return apply2(func, this, otherArgs);
7706             });
7707           }
7708           function throttle2(func, wait, options2) {
7709             var leading = true, trailing = true;
7710             if (typeof func != "function") {
7711               throw new TypeError2(FUNC_ERROR_TEXT3);
7712             }
7713             if (isObject2(options2)) {
7714               leading = "leading" in options2 ? !!options2.leading : leading;
7715               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
7716             }
7717             return debounce2(func, wait, {
7718               "leading": leading,
7719               "maxWait": wait,
7720               "trailing": trailing
7721             });
7722           }
7723           function unary(func) {
7724             return ary(func, 1);
7725           }
7726           function wrap2(value, wrapper) {
7727             return partial(castFunction(wrapper), value);
7728           }
7729           function castArray() {
7730             if (!arguments.length) {
7731               return [];
7732             }
7733             var value = arguments[0];
7734             return isArray2(value) ? value : [value];
7735           }
7736           function clone2(value) {
7737             return baseClone(value, CLONE_SYMBOLS_FLAG);
7738           }
7739           function cloneWith(value, customizer) {
7740             customizer = typeof customizer == "function" ? customizer : undefined2;
7741             return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
7742           }
7743           function cloneDeep(value) {
7744             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
7745           }
7746           function cloneDeepWith(value, customizer) {
7747             customizer = typeof customizer == "function" ? customizer : undefined2;
7748             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
7749           }
7750           function conformsTo(object, source) {
7751             return source == null || baseConformsTo(object, source, keys2(source));
7752           }
7753           function eq2(value, other2) {
7754             return value === other2 || value !== value && other2 !== other2;
7755           }
7756           var gt2 = createRelationalOperation(baseGt);
7757           var gte = createRelationalOperation(function(value, other2) {
7758             return value >= other2;
7759           });
7760           var isArguments2 = baseIsArguments2(/* @__PURE__ */ function() {
7761             return arguments;
7762           }()) ? baseIsArguments2 : function(value) {
7763             return isObjectLike2(value) && hasOwnProperty13.call(value, "callee") && !propertyIsEnumerable3.call(value, "callee");
7764           };
7765           var isArray2 = Array2.isArray;
7766           var isArrayBuffer = nodeIsArrayBuffer ? baseUnary2(nodeIsArrayBuffer) : baseIsArrayBuffer;
7767           function isArrayLike2(value) {
7768             return value != null && isLength2(value.length) && !isFunction2(value);
7769           }
7770           function isArrayLikeObject2(value) {
7771             return isObjectLike2(value) && isArrayLike2(value);
7772           }
7773           function isBoolean(value) {
7774             return value === true || value === false || isObjectLike2(value) && baseGetTag2(value) == boolTag3;
7775           }
7776           var isBuffer2 = nativeIsBuffer2 || stubFalse2;
7777           var isDate = nodeIsDate ? baseUnary2(nodeIsDate) : baseIsDate;
7778           function isElement2(value) {
7779             return isObjectLike2(value) && value.nodeType === 1 && !isPlainObject2(value);
7780           }
7781           function isEmpty(value) {
7782             if (value == null) {
7783               return true;
7784             }
7785             if (isArrayLike2(value) && (isArray2(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer2(value) || isTypedArray2(value) || isArguments2(value))) {
7786               return !value.length;
7787             }
7788             var tag2 = getTag2(value);
7789             if (tag2 == mapTag4 || tag2 == setTag4) {
7790               return !value.size;
7791             }
7792             if (isPrototype2(value)) {
7793               return !baseKeys2(value).length;
7794             }
7795             for (var key in value) {
7796               if (hasOwnProperty13.call(value, key)) {
7797                 return false;
7798               }
7799             }
7800             return true;
7801           }
7802           function isEqual5(value, other2) {
7803             return baseIsEqual2(value, other2);
7804           }
7805           function isEqualWith(value, other2, customizer) {
7806             customizer = typeof customizer == "function" ? customizer : undefined2;
7807             var result2 = customizer ? customizer(value, other2) : undefined2;
7808             return result2 === undefined2 ? baseIsEqual2(value, other2, undefined2, customizer) : !!result2;
7809           }
7810           function isError(value) {
7811             if (!isObjectLike2(value)) {
7812               return false;
7813             }
7814             var tag2 = baseGetTag2(value);
7815             return tag2 == errorTag3 || tag2 == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
7816           }
7817           function isFinite2(value) {
7818             return typeof value == "number" && nativeIsFinite(value);
7819           }
7820           function isFunction2(value) {
7821             if (!isObject2(value)) {
7822               return false;
7823             }
7824             var tag2 = baseGetTag2(value);
7825             return tag2 == funcTag3 || tag2 == genTag2 || tag2 == asyncTag2 || tag2 == proxyTag2;
7826           }
7827           function isInteger(value) {
7828             return typeof value == "number" && value == toInteger(value);
7829           }
7830           function isLength2(value) {
7831             return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER4;
7832           }
7833           function isObject2(value) {
7834             var type2 = typeof value;
7835             return value != null && (type2 == "object" || type2 == "function");
7836           }
7837           function isObjectLike2(value) {
7838             return value != null && typeof value == "object";
7839           }
7840           var isMap = nodeIsMap ? baseUnary2(nodeIsMap) : baseIsMap;
7841           function isMatch(object, source) {
7842             return object === source || baseIsMatch(object, source, getMatchData(source));
7843           }
7844           function isMatchWith(object, source, customizer) {
7845             customizer = typeof customizer == "function" ? customizer : undefined2;
7846             return baseIsMatch(object, source, getMatchData(source), customizer);
7847           }
7848           function isNaN2(value) {
7849             return isNumber2(value) && value != +value;
7850           }
7851           function isNative(value) {
7852             if (isMaskable(value)) {
7853               throw new Error2(CORE_ERROR_TEXT);
7854             }
7855             return baseIsNative2(value);
7856           }
7857           function isNull(value) {
7858             return value === null;
7859           }
7860           function isNil(value) {
7861             return value == null;
7862           }
7863           function isNumber2(value) {
7864             return typeof value == "number" || isObjectLike2(value) && baseGetTag2(value) == numberTag4;
7865           }
7866           function isPlainObject2(value) {
7867             if (!isObjectLike2(value) || baseGetTag2(value) != objectTag5) {
7868               return false;
7869             }
7870             var proto = getPrototype2(value);
7871             if (proto === null) {
7872               return true;
7873             }
7874             var Ctor = hasOwnProperty13.call(proto, "constructor") && proto.constructor;
7875             return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString4.call(Ctor) == objectCtorString2;
7876           }
7877           var isRegExp = nodeIsRegExp ? baseUnary2(nodeIsRegExp) : baseIsRegExp;
7878           function isSafeInteger(value) {
7879             return isInteger(value) && value >= -MAX_SAFE_INTEGER4 && value <= MAX_SAFE_INTEGER4;
7880           }
7881           var isSet = nodeIsSet ? baseUnary2(nodeIsSet) : baseIsSet;
7882           function isString(value) {
7883             return typeof value == "string" || !isArray2(value) && isObjectLike2(value) && baseGetTag2(value) == stringTag3;
7884           }
7885           function isSymbol2(value) {
7886             return typeof value == "symbol" || isObjectLike2(value) && baseGetTag2(value) == symbolTag3;
7887           }
7888           var isTypedArray2 = nodeIsTypedArray2 ? baseUnary2(nodeIsTypedArray2) : baseIsTypedArray2;
7889           function isUndefined(value) {
7890             return value === undefined2;
7891           }
7892           function isWeakMap(value) {
7893             return isObjectLike2(value) && getTag2(value) == weakMapTag3;
7894           }
7895           function isWeakSet(value) {
7896             return isObjectLike2(value) && baseGetTag2(value) == weakSetTag;
7897           }
7898           var lt2 = createRelationalOperation(baseLt);
7899           var lte = createRelationalOperation(function(value, other2) {
7900             return value <= other2;
7901           });
7902           function toArray(value) {
7903             if (!value) {
7904               return [];
7905             }
7906             if (isArrayLike2(value)) {
7907               return isString(value) ? stringToArray(value) : copyArray2(value);
7908             }
7909             if (symIterator && value[symIterator]) {
7910               return iteratorToArray(value[symIterator]());
7911             }
7912             var tag2 = getTag2(value), func = tag2 == mapTag4 ? mapToArray2 : tag2 == setTag4 ? setToArray2 : values;
7913             return func(value);
7914           }
7915           function toFinite(value) {
7916             if (!value) {
7917               return value === 0 ? value : 0;
7918             }
7919             value = toNumber3(value);
7920             if (value === INFINITY2 || value === -INFINITY2) {
7921               var sign2 = value < 0 ? -1 : 1;
7922               return sign2 * MAX_INTEGER;
7923             }
7924             return value === value ? value : 0;
7925           }
7926           function toInteger(value) {
7927             var result2 = toFinite(value), remainder = result2 % 1;
7928             return result2 === result2 ? remainder ? result2 - remainder : result2 : 0;
7929           }
7930           function toLength(value) {
7931             return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
7932           }
7933           function toNumber3(value) {
7934             if (typeof value == "number") {
7935               return value;
7936             }
7937             if (isSymbol2(value)) {
7938               return NAN2;
7939             }
7940             if (isObject2(value)) {
7941               var other2 = typeof value.valueOf == "function" ? value.valueOf() : value;
7942               value = isObject2(other2) ? other2 + "" : other2;
7943             }
7944             if (typeof value != "string") {
7945               return value === 0 ? value : +value;
7946             }
7947             value = baseTrim2(value);
7948             var isBinary = reIsBinary2.test(value);
7949             return isBinary || reIsOctal2.test(value) ? freeParseInt2(value.slice(2), isBinary ? 2 : 8) : reIsBadHex2.test(value) ? NAN2 : +value;
7950           }
7951           function toPlainObject2(value) {
7952             return copyObject2(value, keysIn2(value));
7953           }
7954           function toSafeInteger(value) {
7955             return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER4, MAX_SAFE_INTEGER4) : value === 0 ? value : 0;
7956           }
7957           function toString2(value) {
7958             return value == null ? "" : baseToString2(value);
7959           }
7960           var assign = createAssigner2(function(object, source) {
7961             if (isPrototype2(source) || isArrayLike2(source)) {
7962               copyObject2(source, keys2(source), object);
7963               return;
7964             }
7965             for (var key in source) {
7966               if (hasOwnProperty13.call(source, key)) {
7967                 assignValue2(object, key, source[key]);
7968               }
7969             }
7970           });
7971           var assignIn = createAssigner2(function(object, source) {
7972             copyObject2(source, keysIn2(source), object);
7973           });
7974           var assignInWith = createAssigner2(function(object, source, srcIndex, customizer) {
7975             copyObject2(source, keysIn2(source), object, customizer);
7976           });
7977           var assignWith = createAssigner2(function(object, source, srcIndex, customizer) {
7978             copyObject2(source, keys2(source), object, customizer);
7979           });
7980           var at2 = flatRest(baseAt);
7981           function create2(prototype4, properties) {
7982             var result2 = baseCreate2(prototype4);
7983             return properties == null ? result2 : baseAssign(result2, properties);
7984           }
7985           var defaults = baseRest2(function(object, sources) {
7986             object = Object2(object);
7987             var index = -1;
7988             var length2 = sources.length;
7989             var guard = length2 > 2 ? sources[2] : undefined2;
7990             if (guard && isIterateeCall2(sources[0], sources[1], guard)) {
7991               length2 = 1;
7992             }
7993             while (++index < length2) {
7994               var source = sources[index];
7995               var props = keysIn2(source);
7996               var propsIndex = -1;
7997               var propsLength = props.length;
7998               while (++propsIndex < propsLength) {
7999                 var key = props[propsIndex];
8000                 var value = object[key];
8001                 if (value === undefined2 || eq2(value, objectProto16[key]) && !hasOwnProperty13.call(object, key)) {
8002                   object[key] = source[key];
8003                 }
8004               }
8005             }
8006             return object;
8007           });
8008           var defaultsDeep = baseRest2(function(args) {
8009             args.push(undefined2, customDefaultsMerge);
8010             return apply2(mergeWith, undefined2, args);
8011           });
8012           function findKey(object, predicate) {
8013             return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
8014           }
8015           function findLastKey(object, predicate) {
8016             return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
8017           }
8018           function forIn(object, iteratee2) {
8019             return object == null ? object : baseFor2(object, getIteratee(iteratee2, 3), keysIn2);
8020           }
8021           function forInRight(object, iteratee2) {
8022             return object == null ? object : baseForRight(object, getIteratee(iteratee2, 3), keysIn2);
8023           }
8024           function forOwn(object, iteratee2) {
8025             return object && baseForOwn(object, getIteratee(iteratee2, 3));
8026           }
8027           function forOwnRight(object, iteratee2) {
8028             return object && baseForOwnRight(object, getIteratee(iteratee2, 3));
8029           }
8030           function functions(object) {
8031             return object == null ? [] : baseFunctions(object, keys2(object));
8032           }
8033           function functionsIn(object) {
8034             return object == null ? [] : baseFunctions(object, keysIn2(object));
8035           }
8036           function get4(object, path, defaultValue) {
8037             var result2 = object == null ? undefined2 : baseGet(object, path);
8038             return result2 === undefined2 ? defaultValue : result2;
8039           }
8040           function has(object, path) {
8041             return object != null && hasPath(object, path, baseHas);
8042           }
8043           function hasIn(object, path) {
8044             return object != null && hasPath(object, path, baseHasIn);
8045           }
8046           var invert = createInverter(function(result2, value, key) {
8047             if (value != null && typeof value.toString != "function") {
8048               value = nativeObjectToString3.call(value);
8049             }
8050             result2[value] = key;
8051           }, constant2(identity5));
8052           var invertBy = createInverter(function(result2, value, key) {
8053             if (value != null && typeof value.toString != "function") {
8054               value = nativeObjectToString3.call(value);
8055             }
8056             if (hasOwnProperty13.call(result2, value)) {
8057               result2[value].push(key);
8058             } else {
8059               result2[value] = [key];
8060             }
8061           }, getIteratee);
8062           var invoke = baseRest2(baseInvoke);
8063           function keys2(object) {
8064             return isArrayLike2(object) ? arrayLikeKeys2(object) : baseKeys2(object);
8065           }
8066           function keysIn2(object) {
8067             return isArrayLike2(object) ? arrayLikeKeys2(object, true) : baseKeysIn2(object);
8068           }
8069           function mapKeys(object, iteratee2) {
8070             var result2 = {};
8071             iteratee2 = getIteratee(iteratee2, 3);
8072             baseForOwn(object, function(value, key, object2) {
8073               baseAssignValue2(result2, iteratee2(value, key, object2), value);
8074             });
8075             return result2;
8076           }
8077           function mapValues(object, iteratee2) {
8078             var result2 = {};
8079             iteratee2 = getIteratee(iteratee2, 3);
8080             baseForOwn(object, function(value, key, object2) {
8081               baseAssignValue2(result2, key, iteratee2(value, key, object2));
8082             });
8083             return result2;
8084           }
8085           var merge3 = createAssigner2(function(object, source, srcIndex) {
8086             baseMerge2(object, source, srcIndex);
8087           });
8088           var mergeWith = createAssigner2(function(object, source, srcIndex, customizer) {
8089             baseMerge2(object, source, srcIndex, customizer);
8090           });
8091           var omit = flatRest(function(object, paths) {
8092             var result2 = {};
8093             if (object == null) {
8094               return result2;
8095             }
8096             var isDeep = false;
8097             paths = arrayMap2(paths, function(path) {
8098               path = castPath(path, object);
8099               isDeep || (isDeep = path.length > 1);
8100               return path;
8101             });
8102             copyObject2(object, getAllKeysIn(object), result2);
8103             if (isDeep) {
8104               result2 = baseClone(result2, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
8105             }
8106             var length2 = paths.length;
8107             while (length2--) {
8108               baseUnset(result2, paths[length2]);
8109             }
8110             return result2;
8111           });
8112           function omitBy(object, predicate) {
8113             return pickBy(object, negate(getIteratee(predicate)));
8114           }
8115           var pick = flatRest(function(object, paths) {
8116             return object == null ? {} : basePick(object, paths);
8117           });
8118           function pickBy(object, predicate) {
8119             if (object == null) {
8120               return {};
8121             }
8122             var props = arrayMap2(getAllKeysIn(object), function(prop) {
8123               return [prop];
8124             });
8125             predicate = getIteratee(predicate);
8126             return basePickBy(object, props, function(value, path) {
8127               return predicate(value, path[0]);
8128             });
8129           }
8130           function result(object, path, defaultValue) {
8131             path = castPath(path, object);
8132             var index = -1, length2 = path.length;
8133             if (!length2) {
8134               length2 = 1;
8135               object = undefined2;
8136             }
8137             while (++index < length2) {
8138               var value = object == null ? undefined2 : object[toKey(path[index])];
8139               if (value === undefined2) {
8140                 index = length2;
8141                 value = defaultValue;
8142               }
8143               object = isFunction2(value) ? value.call(object) : value;
8144             }
8145             return object;
8146           }
8147           function set4(object, path, value) {
8148             return object == null ? object : baseSet(object, path, value);
8149           }
8150           function setWith(object, path, value, customizer) {
8151             customizer = typeof customizer == "function" ? customizer : undefined2;
8152             return object == null ? object : baseSet(object, path, value, customizer);
8153           }
8154           var toPairs = createToPairs(keys2);
8155           var toPairsIn = createToPairs(keysIn2);
8156           function transform2(object, iteratee2, accumulator) {
8157             var isArr = isArray2(object), isArrLike = isArr || isBuffer2(object) || isTypedArray2(object);
8158             iteratee2 = getIteratee(iteratee2, 4);
8159             if (accumulator == null) {
8160               var Ctor = object && object.constructor;
8161               if (isArrLike) {
8162                 accumulator = isArr ? new Ctor() : [];
8163               } else if (isObject2(object)) {
8164                 accumulator = isFunction2(Ctor) ? baseCreate2(getPrototype2(object)) : {};
8165               } else {
8166                 accumulator = {};
8167               }
8168             }
8169             (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object2) {
8170               return iteratee2(accumulator, value, index, object2);
8171             });
8172             return accumulator;
8173           }
8174           function unset(object, path) {
8175             return object == null ? true : baseUnset(object, path);
8176           }
8177           function update(object, path, updater) {
8178             return object == null ? object : baseUpdate(object, path, castFunction(updater));
8179           }
8180           function updateWith(object, path, updater, customizer) {
8181             customizer = typeof customizer == "function" ? customizer : undefined2;
8182             return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
8183           }
8184           function values(object) {
8185             return object == null ? [] : baseValues(object, keys2(object));
8186           }
8187           function valuesIn(object) {
8188             return object == null ? [] : baseValues(object, keysIn2(object));
8189           }
8190           function clamp3(number3, lower2, upper) {
8191             if (upper === undefined2) {
8192               upper = lower2;
8193               lower2 = undefined2;
8194             }
8195             if (upper !== undefined2) {
8196               upper = toNumber3(upper);
8197               upper = upper === upper ? upper : 0;
8198             }
8199             if (lower2 !== undefined2) {
8200               lower2 = toNumber3(lower2);
8201               lower2 = lower2 === lower2 ? lower2 : 0;
8202             }
8203             return baseClamp(toNumber3(number3), lower2, upper);
8204           }
8205           function inRange(number3, start2, end) {
8206             start2 = toFinite(start2);
8207             if (end === undefined2) {
8208               end = start2;
8209               start2 = 0;
8210             } else {
8211               end = toFinite(end);
8212             }
8213             number3 = toNumber3(number3);
8214             return baseInRange(number3, start2, end);
8215           }
8216           function random(lower2, upper, floating) {
8217             if (floating && typeof floating != "boolean" && isIterateeCall2(lower2, upper, floating)) {
8218               upper = floating = undefined2;
8219             }
8220             if (floating === undefined2) {
8221               if (typeof upper == "boolean") {
8222                 floating = upper;
8223                 upper = undefined2;
8224               } else if (typeof lower2 == "boolean") {
8225                 floating = lower2;
8226                 lower2 = undefined2;
8227               }
8228             }
8229             if (lower2 === undefined2 && upper === undefined2) {
8230               lower2 = 0;
8231               upper = 1;
8232             } else {
8233               lower2 = toFinite(lower2);
8234               if (upper === undefined2) {
8235                 upper = lower2;
8236                 lower2 = 0;
8237               } else {
8238                 upper = toFinite(upper);
8239               }
8240             }
8241             if (lower2 > upper) {
8242               var temp = lower2;
8243               lower2 = upper;
8244               upper = temp;
8245             }
8246             if (floating || lower2 % 1 || upper % 1) {
8247               var rand = nativeRandom();
8248               return nativeMin2(lower2 + rand * (upper - lower2 + freeParseFloat("1e-" + ((rand + "").length - 1))), upper);
8249             }
8250             return baseRandom(lower2, upper);
8251           }
8252           var camelCase = createCompounder(function(result2, word, index) {
8253             word = word.toLowerCase();
8254             return result2 + (index ? capitalize(word) : word);
8255           });
8256           function capitalize(string) {
8257             return upperFirst(toString2(string).toLowerCase());
8258           }
8259           function deburr(string) {
8260             string = toString2(string);
8261             return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
8262           }
8263           function endsWith(string, target, position) {
8264             string = toString2(string);
8265             target = baseToString2(target);
8266             var length2 = string.length;
8267             position = position === undefined2 ? length2 : baseClamp(toInteger(position), 0, length2);
8268             var end = position;
8269             position -= target.length;
8270             return position >= 0 && string.slice(position, end) == target;
8271           }
8272           function escape6(string) {
8273             string = toString2(string);
8274             return string && reHasUnescapedHtml2.test(string) ? string.replace(reUnescapedHtml2, escapeHtmlChar2) : string;
8275           }
8276           function escapeRegExp(string) {
8277             string = toString2(string);
8278             return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar2, "\\$&") : string;
8279           }
8280           var kebabCase = createCompounder(function(result2, word, index) {
8281             return result2 + (index ? "-" : "") + word.toLowerCase();
8282           });
8283           var lowerCase = createCompounder(function(result2, word, index) {
8284             return result2 + (index ? " " : "") + word.toLowerCase();
8285           });
8286           var lowerFirst = createCaseFirst("toLowerCase");
8287           function pad2(string, length2, chars) {
8288             string = toString2(string);
8289             length2 = toInteger(length2);
8290             var strLength = length2 ? stringSize(string) : 0;
8291             if (!length2 || strLength >= length2) {
8292               return string;
8293             }
8294             var mid = (length2 - strLength) / 2;
8295             return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil(mid), chars);
8296           }
8297           function padEnd(string, length2, chars) {
8298             string = toString2(string);
8299             length2 = toInteger(length2);
8300             var strLength = length2 ? stringSize(string) : 0;
8301             return length2 && strLength < length2 ? string + createPadding(length2 - strLength, chars) : string;
8302           }
8303           function padStart(string, length2, chars) {
8304             string = toString2(string);
8305             length2 = toInteger(length2);
8306             var strLength = length2 ? stringSize(string) : 0;
8307             return length2 && strLength < length2 ? createPadding(length2 - strLength, chars) + string : string;
8308           }
8309           function parseInt2(string, radix, guard) {
8310             if (guard || radix == null) {
8311               radix = 0;
8312             } else if (radix) {
8313               radix = +radix;
8314             }
8315             return nativeParseInt(toString2(string).replace(reTrimStart2, ""), radix || 0);
8316           }
8317           function repeat(string, n3, guard) {
8318             if (guard ? isIterateeCall2(string, n3, guard) : n3 === undefined2) {
8319               n3 = 1;
8320             } else {
8321               n3 = toInteger(n3);
8322             }
8323             return baseRepeat(toString2(string), n3);
8324           }
8325           function replace() {
8326             var args = arguments, string = toString2(args[0]);
8327             return args.length < 3 ? string : string.replace(args[1], args[2]);
8328           }
8329           var snakeCase = createCompounder(function(result2, word, index) {
8330             return result2 + (index ? "_" : "") + word.toLowerCase();
8331           });
8332           function split(string, separator, limit) {
8333             if (limit && typeof limit != "number" && isIterateeCall2(string, separator, limit)) {
8334               separator = limit = undefined2;
8335             }
8336             limit = limit === undefined2 ? MAX_ARRAY_LENGTH : limit >>> 0;
8337             if (!limit) {
8338               return [];
8339             }
8340             string = toString2(string);
8341             if (string && (typeof separator == "string" || separator != null && !isRegExp(separator))) {
8342               separator = baseToString2(separator);
8343               if (!separator && hasUnicode(string)) {
8344                 return castSlice(stringToArray(string), 0, limit);
8345               }
8346             }
8347             return string.split(separator, limit);
8348           }
8349           var startCase = createCompounder(function(result2, word, index) {
8350             return result2 + (index ? " " : "") + upperFirst(word);
8351           });
8352           function startsWith(string, target, position) {
8353             string = toString2(string);
8354             position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length);
8355             target = baseToString2(target);
8356             return string.slice(position, position + target.length) == target;
8357           }
8358           function template(string, options2, guard) {
8359             var settings = lodash.templateSettings;
8360             if (guard && isIterateeCall2(string, options2, guard)) {
8361               options2 = undefined2;
8362             }
8363             string = toString2(string);
8364             options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
8365             var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys2(imports), importsValues = baseValues(imports, importsKeys);
8366             var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
8367             var reDelimiters = RegExp2(
8368               (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
8369               "g"
8370             );
8371             var sourceURL = "//# sourceURL=" + (hasOwnProperty13.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
8372             string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
8373               interpolateValue || (interpolateValue = esTemplateValue);
8374               source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
8375               if (escapeValue) {
8376                 isEscaping = true;
8377                 source += "' +\n__e(" + escapeValue + ") +\n'";
8378               }
8379               if (evaluateValue) {
8380                 isEvaluating = true;
8381                 source += "';\n" + evaluateValue + ";\n__p += '";
8382               }
8383               if (interpolateValue) {
8384                 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
8385               }
8386               index = offset + match.length;
8387               return match;
8388             });
8389             source += "';\n";
8390             var variable = hasOwnProperty13.call(options2, "variable") && options2.variable;
8391             if (!variable) {
8392               source = "with (obj) {\n" + source + "\n}\n";
8393             } else if (reForbiddenIdentifierChars.test(variable)) {
8394               throw new Error2(INVALID_TEMPL_VAR_ERROR_TEXT);
8395             }
8396             source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;");
8397             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}";
8398             var result2 = attempt(function() {
8399               return Function2(importsKeys, sourceURL + "return " + source).apply(undefined2, importsValues);
8400             });
8401             result2.source = source;
8402             if (isError(result2)) {
8403               throw result2;
8404             }
8405             return result2;
8406           }
8407           function toLower(value) {
8408             return toString2(value).toLowerCase();
8409           }
8410           function toUpper(value) {
8411             return toString2(value).toUpperCase();
8412           }
8413           function trim(string, chars, guard) {
8414             string = toString2(string);
8415             if (string && (guard || chars === undefined2)) {
8416               return baseTrim2(string);
8417             }
8418             if (!string || !(chars = baseToString2(chars))) {
8419               return string;
8420             }
8421             var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars), start2 = charsStartIndex(strSymbols, chrSymbols), end = charsEndIndex(strSymbols, chrSymbols) + 1;
8422             return castSlice(strSymbols, start2, end).join("");
8423           }
8424           function trimEnd(string, chars, guard) {
8425             string = toString2(string);
8426             if (string && (guard || chars === undefined2)) {
8427               return string.slice(0, trimmedEndIndex2(string) + 1);
8428             }
8429             if (!string || !(chars = baseToString2(chars))) {
8430               return string;
8431             }
8432             var strSymbols = stringToArray(string), end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
8433             return castSlice(strSymbols, 0, end).join("");
8434           }
8435           function trimStart(string, chars, guard) {
8436             string = toString2(string);
8437             if (string && (guard || chars === undefined2)) {
8438               return string.replace(reTrimStart2, "");
8439             }
8440             if (!string || !(chars = baseToString2(chars))) {
8441               return string;
8442             }
8443             var strSymbols = stringToArray(string), start2 = charsStartIndex(strSymbols, stringToArray(chars));
8444             return castSlice(strSymbols, start2).join("");
8445           }
8446           function truncate(string, options2) {
8447             var length2 = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
8448             if (isObject2(options2)) {
8449               var separator = "separator" in options2 ? options2.separator : separator;
8450               length2 = "length" in options2 ? toInteger(options2.length) : length2;
8451               omission = "omission" in options2 ? baseToString2(options2.omission) : omission;
8452             }
8453             string = toString2(string);
8454             var strLength = string.length;
8455             if (hasUnicode(string)) {
8456               var strSymbols = stringToArray(string);
8457               strLength = strSymbols.length;
8458             }
8459             if (length2 >= strLength) {
8460               return string;
8461             }
8462             var end = length2 - stringSize(omission);
8463             if (end < 1) {
8464               return omission;
8465             }
8466             var result2 = strSymbols ? castSlice(strSymbols, 0, end).join("") : string.slice(0, end);
8467             if (separator === undefined2) {
8468               return result2 + omission;
8469             }
8470             if (strSymbols) {
8471               end += result2.length - end;
8472             }
8473             if (isRegExp(separator)) {
8474               if (string.slice(end).search(separator)) {
8475                 var match, substring = result2;
8476                 if (!separator.global) {
8477                   separator = RegExp2(separator.source, toString2(reFlags.exec(separator)) + "g");
8478                 }
8479                 separator.lastIndex = 0;
8480                 while (match = separator.exec(substring)) {
8481                   var newEnd = match.index;
8482                 }
8483                 result2 = result2.slice(0, newEnd === undefined2 ? end : newEnd);
8484               }
8485             } else if (string.indexOf(baseToString2(separator), end) != end) {
8486               var index = result2.lastIndexOf(separator);
8487               if (index > -1) {
8488                 result2 = result2.slice(0, index);
8489               }
8490             }
8491             return result2 + omission;
8492           }
8493           function unescape2(string) {
8494             string = toString2(string);
8495             return string && reHasEscapedHtml2.test(string) ? string.replace(reEscapedHtml2, unescapeHtmlChar2) : string;
8496           }
8497           var upperCase = createCompounder(function(result2, word, index) {
8498             return result2 + (index ? " " : "") + word.toUpperCase();
8499           });
8500           var upperFirst = createCaseFirst("toUpperCase");
8501           function words(string, pattern, guard) {
8502             string = toString2(string);
8503             pattern = guard ? undefined2 : pattern;
8504             if (pattern === undefined2) {
8505               return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
8506             }
8507             return string.match(pattern) || [];
8508           }
8509           var attempt = baseRest2(function(func, args) {
8510             try {
8511               return apply2(func, undefined2, args);
8512             } catch (e3) {
8513               return isError(e3) ? e3 : new Error2(e3);
8514             }
8515           });
8516           var bindAll = flatRest(function(object, methodNames) {
8517             arrayEach(methodNames, function(key) {
8518               key = toKey(key);
8519               baseAssignValue2(object, key, bind(object[key], object));
8520             });
8521             return object;
8522           });
8523           function cond(pairs2) {
8524             var length2 = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee();
8525             pairs2 = !length2 ? [] : arrayMap2(pairs2, function(pair3) {
8526               if (typeof pair3[1] != "function") {
8527                 throw new TypeError2(FUNC_ERROR_TEXT3);
8528               }
8529               return [toIteratee(pair3[0]), pair3[1]];
8530             });
8531             return baseRest2(function(args) {
8532               var index = -1;
8533               while (++index < length2) {
8534                 var pair3 = pairs2[index];
8535                 if (apply2(pair3[0], this, args)) {
8536                   return apply2(pair3[1], this, args);
8537                 }
8538               }
8539             });
8540           }
8541           function conforms(source) {
8542             return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
8543           }
8544           function constant2(value) {
8545             return function() {
8546               return value;
8547             };
8548           }
8549           function defaultTo(value, defaultValue) {
8550             return value == null || value !== value ? defaultValue : value;
8551           }
8552           var flow = createFlow();
8553           var flowRight = createFlow(true);
8554           function identity5(value) {
8555             return value;
8556           }
8557           function iteratee(func) {
8558             return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
8559           }
8560           function matches(source) {
8561             return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
8562           }
8563           function matchesProperty(path, srcValue) {
8564             return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
8565           }
8566           var method = baseRest2(function(path, args) {
8567             return function(object) {
8568               return baseInvoke(object, path, args);
8569             };
8570           });
8571           var methodOf = baseRest2(function(object, args) {
8572             return function(path) {
8573               return baseInvoke(object, path, args);
8574             };
8575           });
8576           function mixin(object, source, options2) {
8577             var props = keys2(source), methodNames = baseFunctions(source, props);
8578             if (options2 == null && !(isObject2(source) && (methodNames.length || !props.length))) {
8579               options2 = source;
8580               source = object;
8581               object = this;
8582               methodNames = baseFunctions(source, keys2(source));
8583             }
8584             var chain2 = !(isObject2(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction2(object);
8585             arrayEach(methodNames, function(methodName) {
8586               var func = source[methodName];
8587               object[methodName] = func;
8588               if (isFunc) {
8589                 object.prototype[methodName] = function() {
8590                   var chainAll = this.__chain__;
8591                   if (chain2 || chainAll) {
8592                     var result2 = object(this.__wrapped__), actions = result2.__actions__ = copyArray2(this.__actions__);
8593                     actions.push({ "func": func, "args": arguments, "thisArg": object });
8594                     result2.__chain__ = chainAll;
8595                     return result2;
8596                   }
8597                   return func.apply(object, arrayPush2([this.value()], arguments));
8598                 };
8599               }
8600             });
8601             return object;
8602           }
8603           function noConflict() {
8604             if (root3._ === this) {
8605               root3._ = oldDash;
8606             }
8607             return this;
8608           }
8609           function noop3() {
8610           }
8611           function nthArg(n3) {
8612             n3 = toInteger(n3);
8613             return baseRest2(function(args) {
8614               return baseNth(args, n3);
8615             });
8616           }
8617           var over = createOver(arrayMap2);
8618           var overEvery = createOver(arrayEvery);
8619           var overSome = createOver(arraySome2);
8620           function property(path) {
8621             return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
8622           }
8623           function propertyOf(object) {
8624             return function(path) {
8625               return object == null ? undefined2 : baseGet(object, path);
8626             };
8627           }
8628           var range3 = createRange();
8629           var rangeRight = createRange(true);
8630           function stubArray2() {
8631             return [];
8632           }
8633           function stubFalse2() {
8634             return false;
8635           }
8636           function stubObject() {
8637             return {};
8638           }
8639           function stubString() {
8640             return "";
8641           }
8642           function stubTrue() {
8643             return true;
8644           }
8645           function times(n3, iteratee2) {
8646             n3 = toInteger(n3);
8647             if (n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
8648               return [];
8649             }
8650             var index = MAX_ARRAY_LENGTH, length2 = nativeMin2(n3, MAX_ARRAY_LENGTH);
8651             iteratee2 = getIteratee(iteratee2);
8652             n3 -= MAX_ARRAY_LENGTH;
8653             var result2 = baseTimes2(length2, iteratee2);
8654             while (++index < n3) {
8655               iteratee2(index);
8656             }
8657             return result2;
8658           }
8659           function toPath(value) {
8660             if (isArray2(value)) {
8661               return arrayMap2(value, toKey);
8662             }
8663             return isSymbol2(value) ? [value] : copyArray2(stringToPath(toString2(value)));
8664           }
8665           function uniqueId(prefix) {
8666             var id2 = ++idCounter;
8667             return toString2(prefix) + id2;
8668           }
8669           var add = createMathOperation(function(augend, addend) {
8670             return augend + addend;
8671           }, 0);
8672           var ceil = createRound("ceil");
8673           var divide = createMathOperation(function(dividend, divisor) {
8674             return dividend / divisor;
8675           }, 1);
8676           var floor = createRound("floor");
8677           function max3(array2) {
8678             return array2 && array2.length ? baseExtremum(array2, identity5, baseGt) : undefined2;
8679           }
8680           function maxBy(array2, iteratee2) {
8681             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseGt) : undefined2;
8682           }
8683           function mean(array2) {
8684             return baseMean(array2, identity5);
8685           }
8686           function meanBy(array2, iteratee2) {
8687             return baseMean(array2, getIteratee(iteratee2, 2));
8688           }
8689           function min3(array2) {
8690             return array2 && array2.length ? baseExtremum(array2, identity5, baseLt) : undefined2;
8691           }
8692           function minBy(array2, iteratee2) {
8693             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseLt) : undefined2;
8694           }
8695           var multiply = createMathOperation(function(multiplier, multiplicand) {
8696             return multiplier * multiplicand;
8697           }, 1);
8698           var round = createRound("round");
8699           var subtract = createMathOperation(function(minuend, subtrahend) {
8700             return minuend - subtrahend;
8701           }, 0);
8702           function sum(array2) {
8703             return array2 && array2.length ? baseSum(array2, identity5) : 0;
8704           }
8705           function sumBy(array2, iteratee2) {
8706             return array2 && array2.length ? baseSum(array2, getIteratee(iteratee2, 2)) : 0;
8707           }
8708           lodash.after = after;
8709           lodash.ary = ary;
8710           lodash.assign = assign;
8711           lodash.assignIn = assignIn;
8712           lodash.assignInWith = assignInWith;
8713           lodash.assignWith = assignWith;
8714           lodash.at = at2;
8715           lodash.before = before;
8716           lodash.bind = bind;
8717           lodash.bindAll = bindAll;
8718           lodash.bindKey = bindKey2;
8719           lodash.castArray = castArray;
8720           lodash.chain = chain;
8721           lodash.chunk = chunk;
8722           lodash.compact = compact;
8723           lodash.concat = concat;
8724           lodash.cond = cond;
8725           lodash.conforms = conforms;
8726           lodash.constant = constant2;
8727           lodash.countBy = countBy;
8728           lodash.create = create2;
8729           lodash.curry = curry;
8730           lodash.curryRight = curryRight;
8731           lodash.debounce = debounce2;
8732           lodash.defaults = defaults;
8733           lodash.defaultsDeep = defaultsDeep;
8734           lodash.defer = defer;
8735           lodash.delay = delay;
8736           lodash.difference = difference2;
8737           lodash.differenceBy = differenceBy;
8738           lodash.differenceWith = differenceWith;
8739           lodash.drop = drop;
8740           lodash.dropRight = dropRight;
8741           lodash.dropRightWhile = dropRightWhile;
8742           lodash.dropWhile = dropWhile;
8743           lodash.fill = fill;
8744           lodash.filter = filter2;
8745           lodash.flatMap = flatMap;
8746           lodash.flatMapDeep = flatMapDeep;
8747           lodash.flatMapDepth = flatMapDepth;
8748           lodash.flatten = flatten2;
8749           lodash.flattenDeep = flattenDeep;
8750           lodash.flattenDepth = flattenDepth;
8751           lodash.flip = flip;
8752           lodash.flow = flow;
8753           lodash.flowRight = flowRight;
8754           lodash.fromPairs = fromPairs;
8755           lodash.functions = functions;
8756           lodash.functionsIn = functionsIn;
8757           lodash.groupBy = groupBy;
8758           lodash.initial = initial;
8759           lodash.intersection = intersection2;
8760           lodash.intersectionBy = intersectionBy;
8761           lodash.intersectionWith = intersectionWith;
8762           lodash.invert = invert;
8763           lodash.invertBy = invertBy;
8764           lodash.invokeMap = invokeMap;
8765           lodash.iteratee = iteratee;
8766           lodash.keyBy = keyBy;
8767           lodash.keys = keys2;
8768           lodash.keysIn = keysIn2;
8769           lodash.map = map2;
8770           lodash.mapKeys = mapKeys;
8771           lodash.mapValues = mapValues;
8772           lodash.matches = matches;
8773           lodash.matchesProperty = matchesProperty;
8774           lodash.memoize = memoize;
8775           lodash.merge = merge3;
8776           lodash.mergeWith = mergeWith;
8777           lodash.method = method;
8778           lodash.methodOf = methodOf;
8779           lodash.mixin = mixin;
8780           lodash.negate = negate;
8781           lodash.nthArg = nthArg;
8782           lodash.omit = omit;
8783           lodash.omitBy = omitBy;
8784           lodash.once = once;
8785           lodash.orderBy = orderBy;
8786           lodash.over = over;
8787           lodash.overArgs = overArgs;
8788           lodash.overEvery = overEvery;
8789           lodash.overSome = overSome;
8790           lodash.partial = partial;
8791           lodash.partialRight = partialRight;
8792           lodash.partition = partition;
8793           lodash.pick = pick;
8794           lodash.pickBy = pickBy;
8795           lodash.property = property;
8796           lodash.propertyOf = propertyOf;
8797           lodash.pull = pull;
8798           lodash.pullAll = pullAll;
8799           lodash.pullAllBy = pullAllBy;
8800           lodash.pullAllWith = pullAllWith;
8801           lodash.pullAt = pullAt;
8802           lodash.range = range3;
8803           lodash.rangeRight = rangeRight;
8804           lodash.rearg = rearg;
8805           lodash.reject = reject;
8806           lodash.remove = remove2;
8807           lodash.rest = rest;
8808           lodash.reverse = reverse;
8809           lodash.sampleSize = sampleSize;
8810           lodash.set = set4;
8811           lodash.setWith = setWith;
8812           lodash.shuffle = shuffle;
8813           lodash.slice = slice;
8814           lodash.sortBy = sortBy;
8815           lodash.sortedUniq = sortedUniq;
8816           lodash.sortedUniqBy = sortedUniqBy;
8817           lodash.split = split;
8818           lodash.spread = spread;
8819           lodash.tail = tail;
8820           lodash.take = take;
8821           lodash.takeRight = takeRight;
8822           lodash.takeRightWhile = takeRightWhile;
8823           lodash.takeWhile = takeWhile;
8824           lodash.tap = tap;
8825           lodash.throttle = throttle2;
8826           lodash.thru = thru;
8827           lodash.toArray = toArray;
8828           lodash.toPairs = toPairs;
8829           lodash.toPairsIn = toPairsIn;
8830           lodash.toPath = toPath;
8831           lodash.toPlainObject = toPlainObject2;
8832           lodash.transform = transform2;
8833           lodash.unary = unary;
8834           lodash.union = union2;
8835           lodash.unionBy = unionBy;
8836           lodash.unionWith = unionWith;
8837           lodash.uniq = uniq;
8838           lodash.uniqBy = uniqBy;
8839           lodash.uniqWith = uniqWith;
8840           lodash.unset = unset;
8841           lodash.unzip = unzip;
8842           lodash.unzipWith = unzipWith;
8843           lodash.update = update;
8844           lodash.updateWith = updateWith;
8845           lodash.values = values;
8846           lodash.valuesIn = valuesIn;
8847           lodash.without = without;
8848           lodash.words = words;
8849           lodash.wrap = wrap2;
8850           lodash.xor = xor;
8851           lodash.xorBy = xorBy;
8852           lodash.xorWith = xorWith;
8853           lodash.zip = zip;
8854           lodash.zipObject = zipObject;
8855           lodash.zipObjectDeep = zipObjectDeep;
8856           lodash.zipWith = zipWith;
8857           lodash.entries = toPairs;
8858           lodash.entriesIn = toPairsIn;
8859           lodash.extend = assignIn;
8860           lodash.extendWith = assignInWith;
8861           mixin(lodash, lodash);
8862           lodash.add = add;
8863           lodash.attempt = attempt;
8864           lodash.camelCase = camelCase;
8865           lodash.capitalize = capitalize;
8866           lodash.ceil = ceil;
8867           lodash.clamp = clamp3;
8868           lodash.clone = clone2;
8869           lodash.cloneDeep = cloneDeep;
8870           lodash.cloneDeepWith = cloneDeepWith;
8871           lodash.cloneWith = cloneWith;
8872           lodash.conformsTo = conformsTo;
8873           lodash.deburr = deburr;
8874           lodash.defaultTo = defaultTo;
8875           lodash.divide = divide;
8876           lodash.endsWith = endsWith;
8877           lodash.eq = eq2;
8878           lodash.escape = escape6;
8879           lodash.escapeRegExp = escapeRegExp;
8880           lodash.every = every;
8881           lodash.find = find2;
8882           lodash.findIndex = findIndex;
8883           lodash.findKey = findKey;
8884           lodash.findLast = findLast;
8885           lodash.findLastIndex = findLastIndex;
8886           lodash.findLastKey = findLastKey;
8887           lodash.floor = floor;
8888           lodash.forEach = forEach;
8889           lodash.forEachRight = forEachRight;
8890           lodash.forIn = forIn;
8891           lodash.forInRight = forInRight;
8892           lodash.forOwn = forOwn;
8893           lodash.forOwnRight = forOwnRight;
8894           lodash.get = get4;
8895           lodash.gt = gt2;
8896           lodash.gte = gte;
8897           lodash.has = has;
8898           lodash.hasIn = hasIn;
8899           lodash.head = head;
8900           lodash.identity = identity5;
8901           lodash.includes = includes;
8902           lodash.indexOf = indexOf;
8903           lodash.inRange = inRange;
8904           lodash.invoke = invoke;
8905           lodash.isArguments = isArguments2;
8906           lodash.isArray = isArray2;
8907           lodash.isArrayBuffer = isArrayBuffer;
8908           lodash.isArrayLike = isArrayLike2;
8909           lodash.isArrayLikeObject = isArrayLikeObject2;
8910           lodash.isBoolean = isBoolean;
8911           lodash.isBuffer = isBuffer2;
8912           lodash.isDate = isDate;
8913           lodash.isElement = isElement2;
8914           lodash.isEmpty = isEmpty;
8915           lodash.isEqual = isEqual5;
8916           lodash.isEqualWith = isEqualWith;
8917           lodash.isError = isError;
8918           lodash.isFinite = isFinite2;
8919           lodash.isFunction = isFunction2;
8920           lodash.isInteger = isInteger;
8921           lodash.isLength = isLength2;
8922           lodash.isMap = isMap;
8923           lodash.isMatch = isMatch;
8924           lodash.isMatchWith = isMatchWith;
8925           lodash.isNaN = isNaN2;
8926           lodash.isNative = isNative;
8927           lodash.isNil = isNil;
8928           lodash.isNull = isNull;
8929           lodash.isNumber = isNumber2;
8930           lodash.isObject = isObject2;
8931           lodash.isObjectLike = isObjectLike2;
8932           lodash.isPlainObject = isPlainObject2;
8933           lodash.isRegExp = isRegExp;
8934           lodash.isSafeInteger = isSafeInteger;
8935           lodash.isSet = isSet;
8936           lodash.isString = isString;
8937           lodash.isSymbol = isSymbol2;
8938           lodash.isTypedArray = isTypedArray2;
8939           lodash.isUndefined = isUndefined;
8940           lodash.isWeakMap = isWeakMap;
8941           lodash.isWeakSet = isWeakSet;
8942           lodash.join = join;
8943           lodash.kebabCase = kebabCase;
8944           lodash.last = last;
8945           lodash.lastIndexOf = lastIndexOf;
8946           lodash.lowerCase = lowerCase;
8947           lodash.lowerFirst = lowerFirst;
8948           lodash.lt = lt2;
8949           lodash.lte = lte;
8950           lodash.max = max3;
8951           lodash.maxBy = maxBy;
8952           lodash.mean = mean;
8953           lodash.meanBy = meanBy;
8954           lodash.min = min3;
8955           lodash.minBy = minBy;
8956           lodash.stubArray = stubArray2;
8957           lodash.stubFalse = stubFalse2;
8958           lodash.stubObject = stubObject;
8959           lodash.stubString = stubString;
8960           lodash.stubTrue = stubTrue;
8961           lodash.multiply = multiply;
8962           lodash.nth = nth;
8963           lodash.noConflict = noConflict;
8964           lodash.noop = noop3;
8965           lodash.now = now3;
8966           lodash.pad = pad2;
8967           lodash.padEnd = padEnd;
8968           lodash.padStart = padStart;
8969           lodash.parseInt = parseInt2;
8970           lodash.random = random;
8971           lodash.reduce = reduce;
8972           lodash.reduceRight = reduceRight;
8973           lodash.repeat = repeat;
8974           lodash.replace = replace;
8975           lodash.result = result;
8976           lodash.round = round;
8977           lodash.runInContext = runInContext2;
8978           lodash.sample = sample;
8979           lodash.size = size;
8980           lodash.snakeCase = snakeCase;
8981           lodash.some = some;
8982           lodash.sortedIndex = sortedIndex;
8983           lodash.sortedIndexBy = sortedIndexBy;
8984           lodash.sortedIndexOf = sortedIndexOf;
8985           lodash.sortedLastIndex = sortedLastIndex;
8986           lodash.sortedLastIndexBy = sortedLastIndexBy;
8987           lodash.sortedLastIndexOf = sortedLastIndexOf;
8988           lodash.startCase = startCase;
8989           lodash.startsWith = startsWith;
8990           lodash.subtract = subtract;
8991           lodash.sum = sum;
8992           lodash.sumBy = sumBy;
8993           lodash.template = template;
8994           lodash.times = times;
8995           lodash.toFinite = toFinite;
8996           lodash.toInteger = toInteger;
8997           lodash.toLength = toLength;
8998           lodash.toLower = toLower;
8999           lodash.toNumber = toNumber3;
9000           lodash.toSafeInteger = toSafeInteger;
9001           lodash.toString = toString2;
9002           lodash.toUpper = toUpper;
9003           lodash.trim = trim;
9004           lodash.trimEnd = trimEnd;
9005           lodash.trimStart = trimStart;
9006           lodash.truncate = truncate;
9007           lodash.unescape = unescape2;
9008           lodash.uniqueId = uniqueId;
9009           lodash.upperCase = upperCase;
9010           lodash.upperFirst = upperFirst;
9011           lodash.each = forEach;
9012           lodash.eachRight = forEachRight;
9013           lodash.first = head;
9014           mixin(lodash, function() {
9015             var source = {};
9016             baseForOwn(lodash, function(func, methodName) {
9017               if (!hasOwnProperty13.call(lodash.prototype, methodName)) {
9018                 source[methodName] = func;
9019               }
9020             });
9021             return source;
9022           }(), { "chain": false });
9023           lodash.VERSION = VERSION;
9024           arrayEach(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(methodName) {
9025             lodash[methodName].placeholder = lodash;
9026           });
9027           arrayEach(["drop", "take"], function(methodName, index) {
9028             LazyWrapper.prototype[methodName] = function(n3) {
9029               n3 = n3 === undefined2 ? 1 : nativeMax3(toInteger(n3), 0);
9030               var result2 = this.__filtered__ && !index ? new LazyWrapper(this) : this.clone();
9031               if (result2.__filtered__) {
9032                 result2.__takeCount__ = nativeMin2(n3, result2.__takeCount__);
9033               } else {
9034                 result2.__views__.push({
9035                   "size": nativeMin2(n3, MAX_ARRAY_LENGTH),
9036                   "type": methodName + (result2.__dir__ < 0 ? "Right" : "")
9037                 });
9038               }
9039               return result2;
9040             };
9041             LazyWrapper.prototype[methodName + "Right"] = function(n3) {
9042               return this.reverse()[methodName](n3).reverse();
9043             };
9044           });
9045           arrayEach(["filter", "map", "takeWhile"], function(methodName, index) {
9046             var type2 = index + 1, isFilter = type2 == LAZY_FILTER_FLAG || type2 == LAZY_WHILE_FLAG;
9047             LazyWrapper.prototype[methodName] = function(iteratee2) {
9048               var result2 = this.clone();
9049               result2.__iteratees__.push({
9050                 "iteratee": getIteratee(iteratee2, 3),
9051                 "type": type2
9052               });
9053               result2.__filtered__ = result2.__filtered__ || isFilter;
9054               return result2;
9055             };
9056           });
9057           arrayEach(["head", "last"], function(methodName, index) {
9058             var takeName = "take" + (index ? "Right" : "");
9059             LazyWrapper.prototype[methodName] = function() {
9060               return this[takeName](1).value()[0];
9061             };
9062           });
9063           arrayEach(["initial", "tail"], function(methodName, index) {
9064             var dropName = "drop" + (index ? "" : "Right");
9065             LazyWrapper.prototype[methodName] = function() {
9066               return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
9067             };
9068           });
9069           LazyWrapper.prototype.compact = function() {
9070             return this.filter(identity5);
9071           };
9072           LazyWrapper.prototype.find = function(predicate) {
9073             return this.filter(predicate).head();
9074           };
9075           LazyWrapper.prototype.findLast = function(predicate) {
9076             return this.reverse().find(predicate);
9077           };
9078           LazyWrapper.prototype.invokeMap = baseRest2(function(path, args) {
9079             if (typeof path == "function") {
9080               return new LazyWrapper(this);
9081             }
9082             return this.map(function(value) {
9083               return baseInvoke(value, path, args);
9084             });
9085           });
9086           LazyWrapper.prototype.reject = function(predicate) {
9087             return this.filter(negate(getIteratee(predicate)));
9088           };
9089           LazyWrapper.prototype.slice = function(start2, end) {
9090             start2 = toInteger(start2);
9091             var result2 = this;
9092             if (result2.__filtered__ && (start2 > 0 || end < 0)) {
9093               return new LazyWrapper(result2);
9094             }
9095             if (start2 < 0) {
9096               result2 = result2.takeRight(-start2);
9097             } else if (start2) {
9098               result2 = result2.drop(start2);
9099             }
9100             if (end !== undefined2) {
9101               end = toInteger(end);
9102               result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start2);
9103             }
9104             return result2;
9105           };
9106           LazyWrapper.prototype.takeRightWhile = function(predicate) {
9107             return this.reverse().takeWhile(predicate).reverse();
9108           };
9109           LazyWrapper.prototype.toArray = function() {
9110             return this.take(MAX_ARRAY_LENGTH);
9111           };
9112           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
9113             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);
9114             if (!lodashFunc) {
9115               return;
9116             }
9117             lodash.prototype[methodName] = function() {
9118               var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
9119               var interceptor = function(value2) {
9120                 var result3 = lodashFunc.apply(lodash, arrayPush2([value2], args));
9121                 return isTaker && chainAll ? result3[0] : result3;
9122               };
9123               if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
9124                 isLazy = useLazy = false;
9125               }
9126               var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
9127               if (!retUnwrapped && useLazy) {
9128                 value = onlyLazy ? value : new LazyWrapper(this);
9129                 var result2 = func.apply(value, args);
9130                 result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined2 });
9131                 return new LodashWrapper(result2, chainAll);
9132               }
9133               if (isUnwrapped && onlyLazy) {
9134                 return func.apply(this, args);
9135               }
9136               result2 = this.thru(interceptor);
9137               return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
9138             };
9139           });
9140           arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
9141             var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
9142             lodash.prototype[methodName] = function() {
9143               var args = arguments;
9144               if (retUnwrapped && !this.__chain__) {
9145                 var value = this.value();
9146                 return func.apply(isArray2(value) ? value : [], args);
9147               }
9148               return this[chainName](function(value2) {
9149                 return func.apply(isArray2(value2) ? value2 : [], args);
9150               });
9151             };
9152           });
9153           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
9154             var lodashFunc = lodash[methodName];
9155             if (lodashFunc) {
9156               var key = lodashFunc.name + "";
9157               if (!hasOwnProperty13.call(realNames, key)) {
9158                 realNames[key] = [];
9159               }
9160               realNames[key].push({ "name": methodName, "func": lodashFunc });
9161             }
9162           });
9163           realNames[createHybrid(undefined2, WRAP_BIND_KEY_FLAG).name] = [{
9164             "name": "wrapper",
9165             "func": undefined2
9166           }];
9167           LazyWrapper.prototype.clone = lazyClone;
9168           LazyWrapper.prototype.reverse = lazyReverse;
9169           LazyWrapper.prototype.value = lazyValue;
9170           lodash.prototype.at = wrapperAt;
9171           lodash.prototype.chain = wrapperChain;
9172           lodash.prototype.commit = wrapperCommit;
9173           lodash.prototype.next = wrapperNext;
9174           lodash.prototype.plant = wrapperPlant;
9175           lodash.prototype.reverse = wrapperReverse;
9176           lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
9177           lodash.prototype.first = lodash.prototype.head;
9178           if (symIterator) {
9179             lodash.prototype[symIterator] = wrapperToIterator;
9180           }
9181           return lodash;
9182         };
9183         var _2 = runInContext();
9184         if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
9185           root3._ = _2;
9186           define(function() {
9187             return _2;
9188           });
9189         } else if (freeModule4) {
9190           (freeModule4.exports = _2)._ = _2;
9191           freeExports4._ = _2;
9192         } else {
9193           root3._ = _2;
9194         }
9195       }).call(exports2);
9196     }
9197   });
9198
9199   // node_modules/which-polygon/node_modules/quickselect/quickselect.js
9200   var require_quickselect = __commonJS({
9201     "node_modules/which-polygon/node_modules/quickselect/quickselect.js"(exports2, module2) {
9202       (function(global2, factory) {
9203         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.quickselect = factory();
9204       })(exports2, function() {
9205         "use strict";
9206         function quickselect3(arr, k2, left, right, compare2) {
9207           quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare2 || defaultCompare2);
9208         }
9209         function quickselectStep(arr, k2, left, right, compare2) {
9210           while (right > left) {
9211             if (right - left > 600) {
9212               var n3 = right - left + 1;
9213               var m2 = k2 - left + 1;
9214               var z2 = Math.log(n3);
9215               var s2 = 0.5 * Math.exp(2 * z2 / 3);
9216               var sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
9217               var newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
9218               var newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
9219               quickselectStep(arr, k2, newLeft, newRight, compare2);
9220             }
9221             var t2 = arr[k2];
9222             var i3 = left;
9223             var j2 = right;
9224             swap3(arr, left, k2);
9225             if (compare2(arr[right], t2) > 0) swap3(arr, left, right);
9226             while (i3 < j2) {
9227               swap3(arr, i3, j2);
9228               i3++;
9229               j2--;
9230               while (compare2(arr[i3], t2) < 0) i3++;
9231               while (compare2(arr[j2], t2) > 0) j2--;
9232             }
9233             if (compare2(arr[left], t2) === 0) swap3(arr, left, j2);
9234             else {
9235               j2++;
9236               swap3(arr, j2, right);
9237             }
9238             if (j2 <= k2) left = j2 + 1;
9239             if (k2 <= j2) right = j2 - 1;
9240           }
9241         }
9242         function swap3(arr, i3, j2) {
9243           var tmp = arr[i3];
9244           arr[i3] = arr[j2];
9245           arr[j2] = tmp;
9246         }
9247         function defaultCompare2(a2, b2) {
9248           return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
9249         }
9250         return quickselect3;
9251       });
9252     }
9253   });
9254
9255   // node_modules/which-polygon/node_modules/rbush/index.js
9256   var require_rbush = __commonJS({
9257     "node_modules/which-polygon/node_modules/rbush/index.js"(exports2, module2) {
9258       "use strict";
9259       module2.exports = rbush;
9260       module2.exports.default = rbush;
9261       var quickselect3 = require_quickselect();
9262       function rbush(maxEntries, format2) {
9263         if (!(this instanceof rbush)) return new rbush(maxEntries, format2);
9264         this._maxEntries = Math.max(4, maxEntries || 9);
9265         this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
9266         if (format2) {
9267           this._initFormat(format2);
9268         }
9269         this.clear();
9270       }
9271       rbush.prototype = {
9272         all: function() {
9273           return this._all(this.data, []);
9274         },
9275         search: function(bbox2) {
9276           var node = this.data, result = [], toBBox = this.toBBox;
9277           if (!intersects2(bbox2, node)) return result;
9278           var nodesToSearch = [], i3, len, child, childBBox;
9279           while (node) {
9280             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9281               child = node.children[i3];
9282               childBBox = node.leaf ? toBBox(child) : child;
9283               if (intersects2(bbox2, childBBox)) {
9284                 if (node.leaf) result.push(child);
9285                 else if (contains2(bbox2, childBBox)) this._all(child, result);
9286                 else nodesToSearch.push(child);
9287               }
9288             }
9289             node = nodesToSearch.pop();
9290           }
9291           return result;
9292         },
9293         collides: function(bbox2) {
9294           var node = this.data, toBBox = this.toBBox;
9295           if (!intersects2(bbox2, node)) return false;
9296           var nodesToSearch = [], i3, len, child, childBBox;
9297           while (node) {
9298             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9299               child = node.children[i3];
9300               childBBox = node.leaf ? toBBox(child) : child;
9301               if (intersects2(bbox2, childBBox)) {
9302                 if (node.leaf || contains2(bbox2, childBBox)) return true;
9303                 nodesToSearch.push(child);
9304               }
9305             }
9306             node = nodesToSearch.pop();
9307           }
9308           return false;
9309         },
9310         load: function(data) {
9311           if (!(data && data.length)) return this;
9312           if (data.length < this._minEntries) {
9313             for (var i3 = 0, len = data.length; i3 < len; i3++) {
9314               this.insert(data[i3]);
9315             }
9316             return this;
9317           }
9318           var node = this._build(data.slice(), 0, data.length - 1, 0);
9319           if (!this.data.children.length) {
9320             this.data = node;
9321           } else if (this.data.height === node.height) {
9322             this._splitRoot(this.data, node);
9323           } else {
9324             if (this.data.height < node.height) {
9325               var tmpNode = this.data;
9326               this.data = node;
9327               node = tmpNode;
9328             }
9329             this._insert(node, this.data.height - node.height - 1, true);
9330           }
9331           return this;
9332         },
9333         insert: function(item) {
9334           if (item) this._insert(item, this.data.height - 1);
9335           return this;
9336         },
9337         clear: function() {
9338           this.data = createNode2([]);
9339           return this;
9340         },
9341         remove: function(item, equalsFn) {
9342           if (!item) return this;
9343           var node = this.data, bbox2 = this.toBBox(item), path = [], indexes = [], i3, parent, index, goingUp;
9344           while (node || path.length) {
9345             if (!node) {
9346               node = path.pop();
9347               parent = path[path.length - 1];
9348               i3 = indexes.pop();
9349               goingUp = true;
9350             }
9351             if (node.leaf) {
9352               index = findItem2(item, node.children, equalsFn);
9353               if (index !== -1) {
9354                 node.children.splice(index, 1);
9355                 path.push(node);
9356                 this._condense(path);
9357                 return this;
9358               }
9359             }
9360             if (!goingUp && !node.leaf && contains2(node, bbox2)) {
9361               path.push(node);
9362               indexes.push(i3);
9363               i3 = 0;
9364               parent = node;
9365               node = node.children[0];
9366             } else if (parent) {
9367               i3++;
9368               node = parent.children[i3];
9369               goingUp = false;
9370             } else node = null;
9371           }
9372           return this;
9373         },
9374         toBBox: function(item) {
9375           return item;
9376         },
9377         compareMinX: compareNodeMinX2,
9378         compareMinY: compareNodeMinY2,
9379         toJSON: function() {
9380           return this.data;
9381         },
9382         fromJSON: function(data) {
9383           this.data = data;
9384           return this;
9385         },
9386         _all: function(node, result) {
9387           var nodesToSearch = [];
9388           while (node) {
9389             if (node.leaf) result.push.apply(result, node.children);
9390             else nodesToSearch.push.apply(nodesToSearch, node.children);
9391             node = nodesToSearch.pop();
9392           }
9393           return result;
9394         },
9395         _build: function(items, left, right, height) {
9396           var N2 = right - left + 1, M2 = this._maxEntries, node;
9397           if (N2 <= M2) {
9398             node = createNode2(items.slice(left, right + 1));
9399             calcBBox2(node, this.toBBox);
9400             return node;
9401           }
9402           if (!height) {
9403             height = Math.ceil(Math.log(N2) / Math.log(M2));
9404             M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
9405           }
9406           node = createNode2([]);
9407           node.leaf = false;
9408           node.height = height;
9409           var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j2, right2, right3;
9410           multiSelect2(items, left, right, N1, this.compareMinX);
9411           for (i3 = left; i3 <= right; i3 += N1) {
9412             right2 = Math.min(i3 + N1 - 1, right);
9413             multiSelect2(items, i3, right2, N22, this.compareMinY);
9414             for (j2 = i3; j2 <= right2; j2 += N22) {
9415               right3 = Math.min(j2 + N22 - 1, right2);
9416               node.children.push(this._build(items, j2, right3, height - 1));
9417             }
9418           }
9419           calcBBox2(node, this.toBBox);
9420           return node;
9421         },
9422         _chooseSubtree: function(bbox2, node, level, path) {
9423           var i3, len, child, targetNode, area, enlargement, minArea, minEnlargement;
9424           while (true) {
9425             path.push(node);
9426             if (node.leaf || path.length - 1 === level) break;
9427             minArea = minEnlargement = Infinity;
9428             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9429               child = node.children[i3];
9430               area = bboxArea2(child);
9431               enlargement = enlargedArea2(bbox2, child) - area;
9432               if (enlargement < minEnlargement) {
9433                 minEnlargement = enlargement;
9434                 minArea = area < minArea ? area : minArea;
9435                 targetNode = child;
9436               } else if (enlargement === minEnlargement) {
9437                 if (area < minArea) {
9438                   minArea = area;
9439                   targetNode = child;
9440                 }
9441               }
9442             }
9443             node = targetNode || node.children[0];
9444           }
9445           return node;
9446         },
9447         _insert: function(item, level, isNode) {
9448           var toBBox = this.toBBox, bbox2 = isNode ? item : toBBox(item), insertPath = [];
9449           var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
9450           node.children.push(item);
9451           extend3(node, bbox2);
9452           while (level >= 0) {
9453             if (insertPath[level].children.length > this._maxEntries) {
9454               this._split(insertPath, level);
9455               level--;
9456             } else break;
9457           }
9458           this._adjustParentBBoxes(bbox2, insertPath, level);
9459         },
9460         // split overflowed node into two
9461         _split: function(insertPath, level) {
9462           var node = insertPath[level], M2 = node.children.length, m2 = this._minEntries;
9463           this._chooseSplitAxis(node, m2, M2);
9464           var splitIndex = this._chooseSplitIndex(node, m2, M2);
9465           var newNode = createNode2(node.children.splice(splitIndex, node.children.length - splitIndex));
9466           newNode.height = node.height;
9467           newNode.leaf = node.leaf;
9468           calcBBox2(node, this.toBBox);
9469           calcBBox2(newNode, this.toBBox);
9470           if (level) insertPath[level - 1].children.push(newNode);
9471           else this._splitRoot(node, newNode);
9472         },
9473         _splitRoot: function(node, newNode) {
9474           this.data = createNode2([node, newNode]);
9475           this.data.height = node.height + 1;
9476           this.data.leaf = false;
9477           calcBBox2(this.data, this.toBBox);
9478         },
9479         _chooseSplitIndex: function(node, m2, M2) {
9480           var i3, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
9481           minOverlap = minArea = Infinity;
9482           for (i3 = m2; i3 <= M2 - m2; i3++) {
9483             bbox1 = distBBox2(node, 0, i3, this.toBBox);
9484             bbox2 = distBBox2(node, i3, M2, this.toBBox);
9485             overlap = intersectionArea2(bbox1, bbox2);
9486             area = bboxArea2(bbox1) + bboxArea2(bbox2);
9487             if (overlap < minOverlap) {
9488               minOverlap = overlap;
9489               index = i3;
9490               minArea = area < minArea ? area : minArea;
9491             } else if (overlap === minOverlap) {
9492               if (area < minArea) {
9493                 minArea = area;
9494                 index = i3;
9495               }
9496             }
9497           }
9498           return index;
9499         },
9500         // sorts node children by the best axis for split
9501         _chooseSplitAxis: function(node, m2, M2) {
9502           var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX2, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY2, xMargin = this._allDistMargin(node, m2, M2, compareMinX), yMargin = this._allDistMargin(node, m2, M2, compareMinY);
9503           if (xMargin < yMargin) node.children.sort(compareMinX);
9504         },
9505         // total margin of all possible split distributions where each node is at least m full
9506         _allDistMargin: function(node, m2, M2, compare2) {
9507           node.children.sort(compare2);
9508           var toBBox = this.toBBox, leftBBox = distBBox2(node, 0, m2, toBBox), rightBBox = distBBox2(node, M2 - m2, M2, toBBox), margin = bboxMargin2(leftBBox) + bboxMargin2(rightBBox), i3, child;
9509           for (i3 = m2; i3 < M2 - m2; i3++) {
9510             child = node.children[i3];
9511             extend3(leftBBox, node.leaf ? toBBox(child) : child);
9512             margin += bboxMargin2(leftBBox);
9513           }
9514           for (i3 = M2 - m2 - 1; i3 >= m2; i3--) {
9515             child = node.children[i3];
9516             extend3(rightBBox, node.leaf ? toBBox(child) : child);
9517             margin += bboxMargin2(rightBBox);
9518           }
9519           return margin;
9520         },
9521         _adjustParentBBoxes: function(bbox2, path, level) {
9522           for (var i3 = level; i3 >= 0; i3--) {
9523             extend3(path[i3], bbox2);
9524           }
9525         },
9526         _condense: function(path) {
9527           for (var i3 = path.length - 1, siblings; i3 >= 0; i3--) {
9528             if (path[i3].children.length === 0) {
9529               if (i3 > 0) {
9530                 siblings = path[i3 - 1].children;
9531                 siblings.splice(siblings.indexOf(path[i3]), 1);
9532               } else this.clear();
9533             } else calcBBox2(path[i3], this.toBBox);
9534           }
9535         },
9536         _initFormat: function(format2) {
9537           var compareArr = ["return a", " - b", ";"];
9538           this.compareMinX = new Function("a", "b", compareArr.join(format2[0]));
9539           this.compareMinY = new Function("a", "b", compareArr.join(format2[1]));
9540           this.toBBox = new Function(
9541             "a",
9542             "return {minX: a" + format2[0] + ", minY: a" + format2[1] + ", maxX: a" + format2[2] + ", maxY: a" + format2[3] + "};"
9543           );
9544         }
9545       };
9546       function findItem2(item, items, equalsFn) {
9547         if (!equalsFn) return items.indexOf(item);
9548         for (var i3 = 0; i3 < items.length; i3++) {
9549           if (equalsFn(item, items[i3])) return i3;
9550         }
9551         return -1;
9552       }
9553       function calcBBox2(node, toBBox) {
9554         distBBox2(node, 0, node.children.length, toBBox, node);
9555       }
9556       function distBBox2(node, k2, p2, toBBox, destNode) {
9557         if (!destNode) destNode = createNode2(null);
9558         destNode.minX = Infinity;
9559         destNode.minY = Infinity;
9560         destNode.maxX = -Infinity;
9561         destNode.maxY = -Infinity;
9562         for (var i3 = k2, child; i3 < p2; i3++) {
9563           child = node.children[i3];
9564           extend3(destNode, node.leaf ? toBBox(child) : child);
9565         }
9566         return destNode;
9567       }
9568       function extend3(a2, b2) {
9569         a2.minX = Math.min(a2.minX, b2.minX);
9570         a2.minY = Math.min(a2.minY, b2.minY);
9571         a2.maxX = Math.max(a2.maxX, b2.maxX);
9572         a2.maxY = Math.max(a2.maxY, b2.maxY);
9573         return a2;
9574       }
9575       function compareNodeMinX2(a2, b2) {
9576         return a2.minX - b2.minX;
9577       }
9578       function compareNodeMinY2(a2, b2) {
9579         return a2.minY - b2.minY;
9580       }
9581       function bboxArea2(a2) {
9582         return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
9583       }
9584       function bboxMargin2(a2) {
9585         return a2.maxX - a2.minX + (a2.maxY - a2.minY);
9586       }
9587       function enlargedArea2(a2, b2) {
9588         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));
9589       }
9590       function intersectionArea2(a2, b2) {
9591         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);
9592         return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
9593       }
9594       function contains2(a2, b2) {
9595         return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
9596       }
9597       function intersects2(a2, b2) {
9598         return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
9599       }
9600       function createNode2(children2) {
9601         return {
9602           children: children2,
9603           height: 1,
9604           leaf: true,
9605           minX: Infinity,
9606           minY: Infinity,
9607           maxX: -Infinity,
9608           maxY: -Infinity
9609         };
9610       }
9611       function multiSelect2(arr, left, right, n3, compare2) {
9612         var stack = [left, right], mid;
9613         while (stack.length) {
9614           right = stack.pop();
9615           left = stack.pop();
9616           if (right - left <= n3) continue;
9617           mid = left + Math.ceil((right - left) / n3 / 2) * n3;
9618           quickselect3(arr, mid, left, right, compare2);
9619           stack.push(left, mid, mid, right);
9620         }
9621       }
9622     }
9623   });
9624
9625   // node_modules/lineclip/index.js
9626   var require_lineclip = __commonJS({
9627     "node_modules/lineclip/index.js"(exports2, module2) {
9628       "use strict";
9629       module2.exports = lineclip2;
9630       lineclip2.polyline = lineclip2;
9631       lineclip2.polygon = polygonclip2;
9632       function lineclip2(points, bbox2, result) {
9633         var len = points.length, codeA = bitCode2(points[0], bbox2), part = [], i3, a2, b2, codeB, lastCode;
9634         if (!result) result = [];
9635         for (i3 = 1; i3 < len; i3++) {
9636           a2 = points[i3 - 1];
9637           b2 = points[i3];
9638           codeB = lastCode = bitCode2(b2, bbox2);
9639           while (true) {
9640             if (!(codeA | codeB)) {
9641               part.push(a2);
9642               if (codeB !== lastCode) {
9643                 part.push(b2);
9644                 if (i3 < len - 1) {
9645                   result.push(part);
9646                   part = [];
9647                 }
9648               } else if (i3 === len - 1) {
9649                 part.push(b2);
9650               }
9651               break;
9652             } else if (codeA & codeB) {
9653               break;
9654             } else if (codeA) {
9655               a2 = intersect2(a2, b2, codeA, bbox2);
9656               codeA = bitCode2(a2, bbox2);
9657             } else {
9658               b2 = intersect2(a2, b2, codeB, bbox2);
9659               codeB = bitCode2(b2, bbox2);
9660             }
9661           }
9662           codeA = lastCode;
9663         }
9664         if (part.length) result.push(part);
9665         return result;
9666       }
9667       function polygonclip2(points, bbox2) {
9668         var result, edge, prev, prevInside, i3, p2, inside;
9669         for (edge = 1; edge <= 8; edge *= 2) {
9670           result = [];
9671           prev = points[points.length - 1];
9672           prevInside = !(bitCode2(prev, bbox2) & edge);
9673           for (i3 = 0; i3 < points.length; i3++) {
9674             p2 = points[i3];
9675             inside = !(bitCode2(p2, bbox2) & edge);
9676             if (inside !== prevInside) result.push(intersect2(prev, p2, edge, bbox2));
9677             if (inside) result.push(p2);
9678             prev = p2;
9679             prevInside = inside;
9680           }
9681           points = result;
9682           if (!points.length) break;
9683         }
9684         return result;
9685       }
9686       function intersect2(a2, b2, edge, bbox2) {
9687         return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : (
9688           // top
9689           edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : (
9690             // bottom
9691             edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : (
9692               // right
9693               edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : (
9694                 // left
9695                 null
9696               )
9697             )
9698           )
9699         );
9700       }
9701       function bitCode2(p2, bbox2) {
9702         var code = 0;
9703         if (p2[0] < bbox2[0]) code |= 1;
9704         else if (p2[0] > bbox2[2]) code |= 2;
9705         if (p2[1] < bbox2[1]) code |= 4;
9706         else if (p2[1] > bbox2[3]) code |= 8;
9707         return code;
9708       }
9709     }
9710   });
9711
9712   // node_modules/which-polygon/index.js
9713   var require_which_polygon = __commonJS({
9714     "node_modules/which-polygon/index.js"(exports2, module2) {
9715       "use strict";
9716       var rbush = require_rbush();
9717       var lineclip2 = require_lineclip();
9718       module2.exports = whichPolygon5;
9719       function whichPolygon5(data) {
9720         var bboxes = [];
9721         for (var i3 = 0; i3 < data.features.length; i3++) {
9722           var feature3 = data.features[i3];
9723           if (!feature3.geometry) continue;
9724           var coords = feature3.geometry.coordinates;
9725           if (feature3.geometry.type === "Polygon") {
9726             bboxes.push(treeItem(coords, feature3.properties));
9727           } else if (feature3.geometry.type === "MultiPolygon") {
9728             for (var j2 = 0; j2 < coords.length; j2++) {
9729               bboxes.push(treeItem(coords[j2], feature3.properties));
9730             }
9731           }
9732         }
9733         var tree = rbush().load(bboxes);
9734         function query(p2, multi) {
9735           var output = [], result = tree.search({
9736             minX: p2[0],
9737             minY: p2[1],
9738             maxX: p2[0],
9739             maxY: p2[1]
9740           });
9741           for (var i4 = 0; i4 < result.length; i4++) {
9742             if (insidePolygon(result[i4].coords, p2)) {
9743               if (multi)
9744                 output.push(result[i4].props);
9745               else
9746                 return result[i4].props;
9747             }
9748           }
9749           return multi && output.length ? output : null;
9750         }
9751         query.tree = tree;
9752         query.bbox = function queryBBox(bbox2) {
9753           var output = [];
9754           var result = tree.search({
9755             minX: bbox2[0],
9756             minY: bbox2[1],
9757             maxX: bbox2[2],
9758             maxY: bbox2[3]
9759           });
9760           for (var i4 = 0; i4 < result.length; i4++) {
9761             if (polygonIntersectsBBox(result[i4].coords, bbox2)) {
9762               output.push(result[i4].props);
9763             }
9764           }
9765           return output;
9766         };
9767         return query;
9768       }
9769       function polygonIntersectsBBox(polygon2, bbox2) {
9770         var bboxCenter = [
9771           (bbox2[0] + bbox2[2]) / 2,
9772           (bbox2[1] + bbox2[3]) / 2
9773         ];
9774         if (insidePolygon(polygon2, bboxCenter)) return true;
9775         for (var i3 = 0; i3 < polygon2.length; i3++) {
9776           if (lineclip2(polygon2[i3], bbox2).length > 0) return true;
9777         }
9778         return false;
9779       }
9780       function insidePolygon(rings, p2) {
9781         var inside = false;
9782         for (var i3 = 0, len = rings.length; i3 < len; i3++) {
9783           var ring = rings[i3];
9784           for (var j2 = 0, len2 = ring.length, k2 = len2 - 1; j2 < len2; k2 = j2++) {
9785             if (rayIntersect(p2, ring[j2], ring[k2])) inside = !inside;
9786           }
9787         }
9788         return inside;
9789       }
9790       function rayIntersect(p2, p1, p22) {
9791         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];
9792       }
9793       function treeItem(coords, props) {
9794         var item = {
9795           minX: Infinity,
9796           minY: Infinity,
9797           maxX: -Infinity,
9798           maxY: -Infinity,
9799           coords,
9800           props
9801         };
9802         for (var i3 = 0; i3 < coords[0].length; i3++) {
9803           var p2 = coords[0][i3];
9804           item.minX = Math.min(item.minX, p2[0]);
9805           item.minY = Math.min(item.minY, p2[1]);
9806           item.maxX = Math.max(item.maxX, p2[0]);
9807           item.maxY = Math.max(item.maxY, p2[1]);
9808         }
9809         return item;
9810       }
9811     }
9812   });
9813
9814   // node_modules/wgs84/index.js
9815   var require_wgs84 = __commonJS({
9816     "node_modules/wgs84/index.js"(exports2, module2) {
9817       module2.exports.RADIUS = 6378137;
9818       module2.exports.FLATTENING = 1 / 298.257223563;
9819       module2.exports.POLAR_RADIUS = 63567523142e-4;
9820     }
9821   });
9822
9823   // node_modules/@mapbox/geojson-area/index.js
9824   var require_geojson_area = __commonJS({
9825     "node_modules/@mapbox/geojson-area/index.js"(exports2, module2) {
9826       var wgs84 = require_wgs84();
9827       module2.exports.geometry = geometry;
9828       module2.exports.ring = ringArea;
9829       function geometry(_2) {
9830         var area = 0, i3;
9831         switch (_2.type) {
9832           case "Polygon":
9833             return polygonArea(_2.coordinates);
9834           case "MultiPolygon":
9835             for (i3 = 0; i3 < _2.coordinates.length; i3++) {
9836               area += polygonArea(_2.coordinates[i3]);
9837             }
9838             return area;
9839           case "Point":
9840           case "MultiPoint":
9841           case "LineString":
9842           case "MultiLineString":
9843             return 0;
9844           case "GeometryCollection":
9845             for (i3 = 0; i3 < _2.geometries.length; i3++) {
9846               area += geometry(_2.geometries[i3]);
9847             }
9848             return area;
9849         }
9850       }
9851       function polygonArea(coords) {
9852         var area = 0;
9853         if (coords && coords.length > 0) {
9854           area += Math.abs(ringArea(coords[0]));
9855           for (var i3 = 1; i3 < coords.length; i3++) {
9856             area -= Math.abs(ringArea(coords[i3]));
9857           }
9858         }
9859         return area;
9860       }
9861       function ringArea(coords) {
9862         var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i3, area = 0, coordsLength = coords.length;
9863         if (coordsLength > 2) {
9864           for (i3 = 0; i3 < coordsLength; i3++) {
9865             if (i3 === coordsLength - 2) {
9866               lowerIndex = coordsLength - 2;
9867               middleIndex = coordsLength - 1;
9868               upperIndex = 0;
9869             } else if (i3 === coordsLength - 1) {
9870               lowerIndex = coordsLength - 1;
9871               middleIndex = 0;
9872               upperIndex = 1;
9873             } else {
9874               lowerIndex = i3;
9875               middleIndex = i3 + 1;
9876               upperIndex = i3 + 2;
9877             }
9878             p1 = coords[lowerIndex];
9879             p2 = coords[middleIndex];
9880             p3 = coords[upperIndex];
9881             area += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
9882           }
9883           area = area * wgs84.RADIUS * wgs84.RADIUS / 2;
9884         }
9885         return area;
9886       }
9887       function rad(_2) {
9888         return _2 * Math.PI / 180;
9889       }
9890     }
9891   });
9892
9893   // node_modules/circle-to-polygon/input-validation/validateCenter.js
9894   var require_validateCenter = __commonJS({
9895     "node_modules/circle-to-polygon/input-validation/validateCenter.js"(exports2) {
9896       exports2.validateCenter = function validateCenter(center) {
9897         var validCenterLengths = [2, 3];
9898         if (!Array.isArray(center) || !validCenterLengths.includes(center.length)) {
9899           throw new Error("ERROR! Center has to be an array of length two or three");
9900         }
9901         var [lng, lat] = center;
9902         if (typeof lng !== "number" || typeof lat !== "number") {
9903           throw new Error(
9904             "ERROR! Longitude and Latitude has to be numbers but where ".concat(typeof lng, " and ").concat(typeof lat)
9905           );
9906         }
9907         if (lng > 180 || lng < -180) {
9908           throw new Error("ERROR! Longitude has to be between -180 and 180 but was ".concat(lng));
9909         }
9910         if (lat > 90 || lat < -90) {
9911           throw new Error("ERROR! Latitude has to be between -90 and 90 but was ".concat(lat));
9912         }
9913       };
9914     }
9915   });
9916
9917   // node_modules/circle-to-polygon/input-validation/validateRadius.js
9918   var require_validateRadius = __commonJS({
9919     "node_modules/circle-to-polygon/input-validation/validateRadius.js"(exports2) {
9920       exports2.validateRadius = function validateRadius(radius) {
9921         if (typeof radius !== "number") {
9922           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(typeof radius));
9923         }
9924         if (radius <= 0) {
9925           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(radius));
9926         }
9927       };
9928     }
9929   });
9930
9931   // node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js
9932   var require_validateNumberOfEdges = __commonJS({
9933     "node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js"(exports2) {
9934       exports2.validateNumberOfEdges = function validateNumberOfEdges(numberOfEdges) {
9935         if (typeof numberOfEdges !== "number") {
9936           const ARGUMENT_TYPE = Array.isArray(numberOfEdges) ? "array" : typeof numberOfEdges;
9937           throw new Error("ERROR! Number of edges has to be a number but was: ".concat(ARGUMENT_TYPE));
9938         }
9939         if (numberOfEdges < 3) {
9940           throw new Error("ERROR! Number of edges has to be at least 3 but was: ".concat(numberOfEdges));
9941         }
9942       };
9943     }
9944   });
9945
9946   // node_modules/circle-to-polygon/input-validation/validateEarthRadius.js
9947   var require_validateEarthRadius = __commonJS({
9948     "node_modules/circle-to-polygon/input-validation/validateEarthRadius.js"(exports2) {
9949       exports2.validateEarthRadius = function validateEarthRadius(earthRadius2) {
9950         if (typeof earthRadius2 !== "number") {
9951           const ARGUMENT_TYPE = Array.isArray(earthRadius2) ? "array" : typeof earthRadius2;
9952           throw new Error("ERROR! Earth radius has to be a number but was: ".concat(ARGUMENT_TYPE));
9953         }
9954         if (earthRadius2 <= 0) {
9955           throw new Error("ERROR! Earth radius has to be a positive number but was: ".concat(earthRadius2));
9956         }
9957       };
9958     }
9959   });
9960
9961   // node_modules/circle-to-polygon/input-validation/validateBearing.js
9962   var require_validateBearing = __commonJS({
9963     "node_modules/circle-to-polygon/input-validation/validateBearing.js"(exports2) {
9964       exports2.validateBearing = function validateBearing(bearing) {
9965         if (typeof bearing !== "number") {
9966           const ARGUMENT_TYPE = Array.isArray(bearing) ? "array" : typeof bearing;
9967           throw new Error("ERROR! Bearing has to be a number but was: ".concat(ARGUMENT_TYPE));
9968         }
9969       };
9970     }
9971   });
9972
9973   // node_modules/circle-to-polygon/input-validation/index.js
9974   var require_input_validation = __commonJS({
9975     "node_modules/circle-to-polygon/input-validation/index.js"(exports2) {
9976       var validateCenter = require_validateCenter().validateCenter;
9977       var validateRadius = require_validateRadius().validateRadius;
9978       var validateNumberOfEdges = require_validateNumberOfEdges().validateNumberOfEdges;
9979       var validateEarthRadius = require_validateEarthRadius().validateEarthRadius;
9980       var validateBearing = require_validateBearing().validateBearing;
9981       function validateInput({ center, radius, numberOfEdges, earthRadius: earthRadius2, bearing }) {
9982         validateCenter(center);
9983         validateRadius(radius);
9984         validateNumberOfEdges(numberOfEdges);
9985         validateEarthRadius(earthRadius2);
9986         validateBearing(bearing);
9987       }
9988       exports2.validateCenter = validateCenter;
9989       exports2.validateRadius = validateRadius;
9990       exports2.validateNumberOfEdges = validateNumberOfEdges;
9991       exports2.validateEarthRadius = validateEarthRadius;
9992       exports2.validateBearing = validateBearing;
9993       exports2.validateInput = validateInput;
9994     }
9995   });
9996
9997   // node_modules/circle-to-polygon/index.js
9998   var require_circle_to_polygon = __commonJS({
9999     "node_modules/circle-to-polygon/index.js"(exports2, module2) {
10000       "use strict";
10001       var { validateInput } = require_input_validation();
10002       var defaultEarthRadius = 6378137;
10003       function toRadians(angleInDegrees) {
10004         return angleInDegrees * Math.PI / 180;
10005       }
10006       function toDegrees(angleInRadians) {
10007         return angleInRadians * 180 / Math.PI;
10008       }
10009       function offset(c1, distance, earthRadius2, bearing) {
10010         var lat1 = toRadians(c1[1]);
10011         var lon1 = toRadians(c1[0]);
10012         var dByR = distance / earthRadius2;
10013         var lat = Math.asin(
10014           Math.sin(lat1) * Math.cos(dByR) + Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)
10015         );
10016         var lon = lon1 + Math.atan2(
10017           Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
10018           Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)
10019         );
10020         return [toDegrees(lon), toDegrees(lat)];
10021       }
10022       module2.exports = function circleToPolygon2(center, radius, options2) {
10023         var n3 = getNumberOfEdges(options2);
10024         var earthRadius2 = getEarthRadius(options2);
10025         var bearing = getBearing(options2);
10026         var direction = getDirection(options2);
10027         validateInput({ center, radius, numberOfEdges: n3, earthRadius: earthRadius2, bearing });
10028         var start2 = toRadians(bearing);
10029         var coordinates = [];
10030         for (var i3 = 0; i3 < n3; ++i3) {
10031           coordinates.push(
10032             offset(
10033               center,
10034               radius,
10035               earthRadius2,
10036               start2 + direction * 2 * Math.PI * -i3 / n3
10037             )
10038           );
10039         }
10040         coordinates.push(coordinates[0]);
10041         return {
10042           type: "Polygon",
10043           coordinates: [coordinates]
10044         };
10045       };
10046       function getNumberOfEdges(options2) {
10047         if (isUndefinedOrNull(options2)) {
10048           return 32;
10049         } else if (isObjectNotArray(options2)) {
10050           var numberOfEdges = options2.numberOfEdges;
10051           return numberOfEdges === void 0 ? 32 : numberOfEdges;
10052         }
10053         return options2;
10054       }
10055       function getEarthRadius(options2) {
10056         if (isUndefinedOrNull(options2)) {
10057           return defaultEarthRadius;
10058         } else if (isObjectNotArray(options2)) {
10059           var earthRadius2 = options2.earthRadius;
10060           return earthRadius2 === void 0 ? defaultEarthRadius : earthRadius2;
10061         }
10062         return defaultEarthRadius;
10063       }
10064       function getDirection(options2) {
10065         if (isObjectNotArray(options2) && options2.rightHandRule) {
10066           return -1;
10067         }
10068         return 1;
10069       }
10070       function getBearing(options2) {
10071         if (isUndefinedOrNull(options2)) {
10072           return 0;
10073         } else if (isObjectNotArray(options2)) {
10074           var bearing = options2.bearing;
10075           return bearing === void 0 ? 0 : bearing;
10076         }
10077         return 0;
10078       }
10079       function isObjectNotArray(argument) {
10080         return argument !== null && typeof argument === "object" && !Array.isArray(argument);
10081       }
10082       function isUndefinedOrNull(argument) {
10083         return argument === null || argument === void 0;
10084       }
10085     }
10086   });
10087
10088   // node_modules/geojson-precision/index.js
10089   var require_geojson_precision = __commonJS({
10090     "node_modules/geojson-precision/index.js"(exports2, module2) {
10091       (function() {
10092         function parse(t2, coordinatePrecision, extrasPrecision) {
10093           function point(p2) {
10094             return p2.map(function(e3, index) {
10095               if (index < 2) {
10096                 return 1 * e3.toFixed(coordinatePrecision);
10097               } else {
10098                 return 1 * e3.toFixed(extrasPrecision);
10099               }
10100             });
10101           }
10102           function multi(l2) {
10103             return l2.map(point);
10104           }
10105           function poly(p2) {
10106             return p2.map(multi);
10107           }
10108           function multiPoly(m2) {
10109             return m2.map(poly);
10110           }
10111           function geometry(obj) {
10112             if (!obj) {
10113               return {};
10114             }
10115             switch (obj.type) {
10116               case "Point":
10117                 obj.coordinates = point(obj.coordinates);
10118                 return obj;
10119               case "LineString":
10120               case "MultiPoint":
10121                 obj.coordinates = multi(obj.coordinates);
10122                 return obj;
10123               case "Polygon":
10124               case "MultiLineString":
10125                 obj.coordinates = poly(obj.coordinates);
10126                 return obj;
10127               case "MultiPolygon":
10128                 obj.coordinates = multiPoly(obj.coordinates);
10129                 return obj;
10130               case "GeometryCollection":
10131                 obj.geometries = obj.geometries.map(geometry);
10132                 return obj;
10133               default:
10134                 return {};
10135             }
10136           }
10137           function feature3(obj) {
10138             obj.geometry = geometry(obj.geometry);
10139             return obj;
10140           }
10141           function featureCollection(f2) {
10142             f2.features = f2.features.map(feature3);
10143             return f2;
10144           }
10145           function geometryCollection(g3) {
10146             g3.geometries = g3.geometries.map(geometry);
10147             return g3;
10148           }
10149           if (!t2) {
10150             return t2;
10151           }
10152           switch (t2.type) {
10153             case "Feature":
10154               return feature3(t2);
10155             case "GeometryCollection":
10156               return geometryCollection(t2);
10157             case "FeatureCollection":
10158               return featureCollection(t2);
10159             case "Point":
10160             case "LineString":
10161             case "Polygon":
10162             case "MultiPoint":
10163             case "MultiPolygon":
10164             case "MultiLineString":
10165               return geometry(t2);
10166             default:
10167               return t2;
10168           }
10169         }
10170         module2.exports = parse;
10171         module2.exports.parse = parse;
10172       })();
10173     }
10174   });
10175
10176   // node_modules/@aitodotai/json-stringify-pretty-compact/index.js
10177   var require_json_stringify_pretty_compact = __commonJS({
10178     "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) {
10179       function isObject2(obj) {
10180         return typeof obj === "object" && obj !== null;
10181       }
10182       function forEach(obj, cb) {
10183         if (Array.isArray(obj)) {
10184           obj.forEach(cb);
10185         } else if (isObject2(obj)) {
10186           Object.keys(obj).forEach(function(key) {
10187             var val = obj[key];
10188             cb(val, key);
10189           });
10190         }
10191       }
10192       function getTreeDepth(obj) {
10193         var depth = 0;
10194         if (Array.isArray(obj) || isObject2(obj)) {
10195           forEach(obj, function(val) {
10196             if (Array.isArray(val) || isObject2(val)) {
10197               var tmpDepth = getTreeDepth(val);
10198               if (tmpDepth > depth) {
10199                 depth = tmpDepth;
10200               }
10201             }
10202           });
10203           return depth + 1;
10204         }
10205         return depth;
10206       }
10207       function stringify3(obj, options2) {
10208         options2 = options2 || {};
10209         var indent = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3);
10210         var addMargin = get4(options2, "margins", false);
10211         var addArrayMargin = get4(options2, "arrayMargins", false);
10212         var addObjectMargin = get4(options2, "objectMargins", false);
10213         var maxLength = indent === "" ? Infinity : get4(options2, "maxLength", 80);
10214         var maxNesting = get4(options2, "maxNesting", Infinity);
10215         return function _stringify(obj2, currentIndent, reserved) {
10216           if (obj2 && typeof obj2.toJSON === "function") {
10217             obj2 = obj2.toJSON();
10218           }
10219           var string = JSON.stringify(obj2);
10220           if (string === void 0) {
10221             return string;
10222           }
10223           var length2 = maxLength - currentIndent.length - reserved;
10224           var treeDepth = getTreeDepth(obj2);
10225           if (treeDepth <= maxNesting && string.length <= length2) {
10226             var prettified = prettify(string, {
10227               addMargin,
10228               addArrayMargin,
10229               addObjectMargin
10230             });
10231             if (prettified.length <= length2) {
10232               return prettified;
10233             }
10234           }
10235           if (isObject2(obj2)) {
10236             var nextIndent = currentIndent + indent;
10237             var items = [];
10238             var delimiters;
10239             var comma = function(array2, index2) {
10240               return index2 === array2.length - 1 ? 0 : 1;
10241             };
10242             if (Array.isArray(obj2)) {
10243               for (var index = 0; index < obj2.length; index++) {
10244                 items.push(
10245                   _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null"
10246                 );
10247               }
10248               delimiters = "[]";
10249             } else {
10250               Object.keys(obj2).forEach(function(key, index2, array2) {
10251                 var keyPart = JSON.stringify(key) + ": ";
10252                 var value = _stringify(
10253                   obj2[key],
10254                   nextIndent,
10255                   keyPart.length + comma(array2, index2)
10256                 );
10257                 if (value !== void 0) {
10258                   items.push(keyPart + value);
10259                 }
10260               });
10261               delimiters = "{}";
10262             }
10263             if (items.length > 0) {
10264               return [
10265                 delimiters[0],
10266                 indent + items.join(",\n" + nextIndent),
10267                 delimiters[1]
10268               ].join("\n" + currentIndent);
10269             }
10270           }
10271           return string;
10272         }(obj, "", 0);
10273       }
10274       var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g;
10275       function prettify(string, options2) {
10276         options2 = options2 || {};
10277         var tokens = {
10278           "{": "{",
10279           "}": "}",
10280           "[": "[",
10281           "]": "]",
10282           ",": ", ",
10283           ":": ": "
10284         };
10285         if (options2.addMargin || options2.addObjectMargin) {
10286           tokens["{"] = "{ ";
10287           tokens["}"] = " }";
10288         }
10289         if (options2.addMargin || options2.addArrayMargin) {
10290           tokens["["] = "[ ";
10291           tokens["]"] = " ]";
10292         }
10293         return string.replace(stringOrChar, function(match, string2) {
10294           return string2 ? match : tokens[match];
10295         });
10296       }
10297       function get4(options2, name, defaultValue) {
10298         return name in options2 ? options2[name] : defaultValue;
10299       }
10300       module2.exports = stringify3;
10301     }
10302   });
10303
10304   // node_modules/fast-json-stable-stringify/index.js
10305   var require_fast_json_stable_stringify = __commonJS({
10306     "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) {
10307       "use strict";
10308       module2.exports = function(data, opts) {
10309         if (!opts) opts = {};
10310         if (typeof opts === "function") opts = { cmp: opts };
10311         var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
10312         var cmp = opts.cmp && /* @__PURE__ */ function(f2) {
10313           return function(node) {
10314             return function(a2, b2) {
10315               var aobj = { key: a2, value: node[a2] };
10316               var bobj = { key: b2, value: node[b2] };
10317               return f2(aobj, bobj);
10318             };
10319           };
10320         }(opts.cmp);
10321         var seen = [];
10322         return function stringify3(node) {
10323           if (node && node.toJSON && typeof node.toJSON === "function") {
10324             node = node.toJSON();
10325           }
10326           if (node === void 0) return;
10327           if (typeof node == "number") return isFinite(node) ? "" + node : "null";
10328           if (typeof node !== "object") return JSON.stringify(node);
10329           var i3, out;
10330           if (Array.isArray(node)) {
10331             out = "[";
10332             for (i3 = 0; i3 < node.length; i3++) {
10333               if (i3) out += ",";
10334               out += stringify3(node[i3]) || "null";
10335             }
10336             return out + "]";
10337           }
10338           if (node === null) return "null";
10339           if (seen.indexOf(node) !== -1) {
10340             if (cycles) return JSON.stringify("__cycle__");
10341             throw new TypeError("Converting circular structure to JSON");
10342           }
10343           var seenIndex = seen.push(node) - 1;
10344           var keys2 = Object.keys(node).sort(cmp && cmp(node));
10345           out = "";
10346           for (i3 = 0; i3 < keys2.length; i3++) {
10347             var key = keys2[i3];
10348             var value = stringify3(node[key]);
10349             if (!value) continue;
10350             if (out) out += ",";
10351             out += JSON.stringify(key) + ":" + value;
10352           }
10353           seen.splice(seenIndex, 1);
10354           return "{" + out + "}";
10355         }(data);
10356       };
10357     }
10358   });
10359
10360   // node_modules/@mapbox/sexagesimal/index.js
10361   var require_sexagesimal = __commonJS({
10362     "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) {
10363       module2.exports = element;
10364       module2.exports.pair = pair3;
10365       module2.exports.format = format2;
10366       module2.exports.formatPair = formatPair;
10367       module2.exports.coordToDMS = coordToDMS;
10368       function element(input, dims) {
10369         var result = search(input, dims);
10370         return result === null ? null : result.val;
10371       }
10372       function formatPair(input) {
10373         return format2(input.lat, "lat") + " " + format2(input.lon, "lon");
10374       }
10375       function format2(input, dim) {
10376         var dms = coordToDMS(input, dim);
10377         return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir;
10378       }
10379       function coordToDMS(input, dim) {
10380         var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || "";
10381         var dir = dirs[input >= 0 ? 0 : 1];
10382         var abs3 = Math.abs(input);
10383         var whole = Math.floor(abs3);
10384         var fraction = abs3 - whole;
10385         var fractionMinutes = fraction * 60;
10386         var minutes = Math.floor(fractionMinutes);
10387         var seconds = Math.floor((fractionMinutes - minutes) * 60);
10388         return {
10389           whole,
10390           minutes,
10391           seconds,
10392           dir
10393         };
10394       }
10395       function search(input, dims) {
10396         if (!dims) dims = "NSEW";
10397         if (typeof input !== "string") return null;
10398         input = input.toUpperCase();
10399         var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/;
10400         var m2 = input.match(regex);
10401         if (!m2) return null;
10402         var matched = m2[0];
10403         var dim;
10404         if (m2[1] && m2[5]) {
10405           dim = m2[1];
10406           matched = matched.slice(0, -1);
10407         } else {
10408           dim = m2[1] || m2[5];
10409         }
10410         if (dim && dims.indexOf(dim) === -1) return null;
10411         var deg = m2[2] ? parseFloat(m2[2]) : 0;
10412         var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0;
10413         var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0;
10414         var sign2 = deg < 0 ? -1 : 1;
10415         if (dim === "S" || dim === "W") sign2 *= -1;
10416         return {
10417           val: (Math.abs(deg) + min3 + sec) * sign2,
10418           dim,
10419           matched,
10420           remain: input.slice(matched.length)
10421         };
10422       }
10423       function pair3(input, dims) {
10424         input = input.trim();
10425         var one2 = search(input, dims);
10426         if (!one2) return null;
10427         input = one2.remain.trim();
10428         var two = search(input, dims);
10429         if (!two || two.remain) return null;
10430         if (one2.dim) {
10431           return swapdim(one2.val, two.val, one2.dim);
10432         } else {
10433           return [one2.val, two.val];
10434         }
10435       }
10436       function swapdim(a2, b2, dim) {
10437         if (dim === "N" || dim === "S") return [a2, b2];
10438         if (dim === "W" || dim === "E") return [b2, a2];
10439       }
10440     }
10441   });
10442
10443   // node_modules/polygon-clipping/dist/polygon-clipping.umd.js
10444   var require_polygon_clipping_umd = __commonJS({
10445     "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) {
10446       (function(global2, factory) {
10447         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());
10448       })(exports2, function() {
10449         "use strict";
10450         function __generator(thisArg, body) {
10451           var _2 = {
10452             label: 0,
10453             sent: function() {
10454               if (t2[0] & 1) throw t2[1];
10455               return t2[1];
10456             },
10457             trys: [],
10458             ops: []
10459           }, f2, y2, t2, g3;
10460           return g3 = {
10461             next: verb(0),
10462             "throw": verb(1),
10463             "return": verb(2)
10464           }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() {
10465             return this;
10466           }), g3;
10467           function verb(n3) {
10468             return function(v2) {
10469               return step([n3, v2]);
10470             };
10471           }
10472           function step(op) {
10473             if (f2) throw new TypeError("Generator is already executing.");
10474             while (_2) try {
10475               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) return t2;
10476               if (y2 = 0, t2) op = [op[0] & 2, t2.value];
10477               switch (op[0]) {
10478                 case 0:
10479                 case 1:
10480                   t2 = op;
10481                   break;
10482                 case 4:
10483                   _2.label++;
10484                   return {
10485                     value: op[1],
10486                     done: false
10487                   };
10488                 case 5:
10489                   _2.label++;
10490                   y2 = op[1];
10491                   op = [0];
10492                   continue;
10493                 case 7:
10494                   op = _2.ops.pop();
10495                   _2.trys.pop();
10496                   continue;
10497                 default:
10498                   if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
10499                     _2 = 0;
10500                     continue;
10501                   }
10502                   if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
10503                     _2.label = op[1];
10504                     break;
10505                   }
10506                   if (op[0] === 6 && _2.label < t2[1]) {
10507                     _2.label = t2[1];
10508                     t2 = op;
10509                     break;
10510                   }
10511                   if (t2 && _2.label < t2[2]) {
10512                     _2.label = t2[2];
10513                     _2.ops.push(op);
10514                     break;
10515                   }
10516                   if (t2[2]) _2.ops.pop();
10517                   _2.trys.pop();
10518                   continue;
10519               }
10520               op = body.call(thisArg, _2);
10521             } catch (e3) {
10522               op = [6, e3];
10523               y2 = 0;
10524             } finally {
10525               f2 = t2 = 0;
10526             }
10527             if (op[0] & 5) throw op[1];
10528             return {
10529               value: op[0] ? op[1] : void 0,
10530               done: true
10531             };
10532           }
10533         }
10534         var Node = (
10535           /** @class */
10536           /* @__PURE__ */ function() {
10537             function Node2(key, data) {
10538               this.next = null;
10539               this.key = key;
10540               this.data = data;
10541               this.left = null;
10542               this.right = null;
10543             }
10544             return Node2;
10545           }()
10546         );
10547         function DEFAULT_COMPARE(a2, b2) {
10548           return a2 > b2 ? 1 : a2 < b2 ? -1 : 0;
10549         }
10550         function splay(i3, t2, comparator) {
10551           var N2 = new Node(null, null);
10552           var l2 = N2;
10553           var r2 = N2;
10554           while (true) {
10555             var cmp2 = comparator(i3, t2.key);
10556             if (cmp2 < 0) {
10557               if (t2.left === null) break;
10558               if (comparator(i3, t2.left.key) < 0) {
10559                 var y2 = t2.left;
10560                 t2.left = y2.right;
10561                 y2.right = t2;
10562                 t2 = y2;
10563                 if (t2.left === null) break;
10564               }
10565               r2.left = t2;
10566               r2 = t2;
10567               t2 = t2.left;
10568             } else if (cmp2 > 0) {
10569               if (t2.right === null) break;
10570               if (comparator(i3, t2.right.key) > 0) {
10571                 var y2 = t2.right;
10572                 t2.right = y2.left;
10573                 y2.left = t2;
10574                 t2 = y2;
10575                 if (t2.right === null) break;
10576               }
10577               l2.right = t2;
10578               l2 = t2;
10579               t2 = t2.right;
10580             } else break;
10581           }
10582           l2.right = t2.left;
10583           r2.left = t2.right;
10584           t2.left = N2.right;
10585           t2.right = N2.left;
10586           return t2;
10587         }
10588         function insert(i3, data, t2, comparator) {
10589           var node = new Node(i3, data);
10590           if (t2 === null) {
10591             node.left = node.right = null;
10592             return node;
10593           }
10594           t2 = splay(i3, t2, comparator);
10595           var cmp2 = comparator(i3, t2.key);
10596           if (cmp2 < 0) {
10597             node.left = t2.left;
10598             node.right = t2;
10599             t2.left = null;
10600           } else if (cmp2 >= 0) {
10601             node.right = t2.right;
10602             node.left = t2;
10603             t2.right = null;
10604           }
10605           return node;
10606         }
10607         function split(key, v2, comparator) {
10608           var left = null;
10609           var right = null;
10610           if (v2) {
10611             v2 = splay(key, v2, comparator);
10612             var cmp2 = comparator(v2.key, key);
10613             if (cmp2 === 0) {
10614               left = v2.left;
10615               right = v2.right;
10616             } else if (cmp2 < 0) {
10617               right = v2.right;
10618               v2.right = null;
10619               left = v2;
10620             } else {
10621               left = v2.left;
10622               v2.left = null;
10623               right = v2;
10624             }
10625           }
10626           return {
10627             left,
10628             right
10629           };
10630         }
10631         function merge3(left, right, comparator) {
10632           if (right === null) return left;
10633           if (left === null) return right;
10634           right = splay(left.key, right, comparator);
10635           right.left = left;
10636           return right;
10637         }
10638         function printRow(root3, prefix, isTail, out, printNode) {
10639           if (root3) {
10640             out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n");
10641             var indent = prefix + (isTail ? "    " : "\u2502   ");
10642             if (root3.left) printRow(root3.left, indent, false, out, printNode);
10643             if (root3.right) printRow(root3.right, indent, true, out, printNode);
10644           }
10645         }
10646         var Tree = (
10647           /** @class */
10648           function() {
10649             function Tree2(comparator) {
10650               if (comparator === void 0) {
10651                 comparator = DEFAULT_COMPARE;
10652               }
10653               this._root = null;
10654               this._size = 0;
10655               this._comparator = comparator;
10656             }
10657             Tree2.prototype.insert = function(key, data) {
10658               this._size++;
10659               return this._root = insert(key, data, this._root, this._comparator);
10660             };
10661             Tree2.prototype.add = function(key, data) {
10662               var node = new Node(key, data);
10663               if (this._root === null) {
10664                 node.left = node.right = null;
10665                 this._size++;
10666                 this._root = node;
10667               }
10668               var comparator = this._comparator;
10669               var t2 = splay(key, this._root, comparator);
10670               var cmp2 = comparator(key, t2.key);
10671               if (cmp2 === 0) this._root = t2;
10672               else {
10673                 if (cmp2 < 0) {
10674                   node.left = t2.left;
10675                   node.right = t2;
10676                   t2.left = null;
10677                 } else if (cmp2 > 0) {
10678                   node.right = t2.right;
10679                   node.left = t2;
10680                   t2.right = null;
10681                 }
10682                 this._size++;
10683                 this._root = node;
10684               }
10685               return this._root;
10686             };
10687             Tree2.prototype.remove = function(key) {
10688               this._root = this._remove(key, this._root, this._comparator);
10689             };
10690             Tree2.prototype._remove = function(i3, t2, comparator) {
10691               var x2;
10692               if (t2 === null) return null;
10693               t2 = splay(i3, t2, comparator);
10694               var cmp2 = comparator(i3, t2.key);
10695               if (cmp2 === 0) {
10696                 if (t2.left === null) {
10697                   x2 = t2.right;
10698                 } else {
10699                   x2 = splay(i3, t2.left, comparator);
10700                   x2.right = t2.right;
10701                 }
10702                 this._size--;
10703                 return x2;
10704               }
10705               return t2;
10706             };
10707             Tree2.prototype.pop = function() {
10708               var node = this._root;
10709               if (node) {
10710                 while (node.left) node = node.left;
10711                 this._root = splay(node.key, this._root, this._comparator);
10712                 this._root = this._remove(node.key, this._root, this._comparator);
10713                 return {
10714                   key: node.key,
10715                   data: node.data
10716                 };
10717               }
10718               return null;
10719             };
10720             Tree2.prototype.findStatic = function(key) {
10721               var current = this._root;
10722               var compare2 = this._comparator;
10723               while (current) {
10724                 var cmp2 = compare2(key, current.key);
10725                 if (cmp2 === 0) return current;
10726                 else if (cmp2 < 0) current = current.left;
10727                 else current = current.right;
10728               }
10729               return null;
10730             };
10731             Tree2.prototype.find = function(key) {
10732               if (this._root) {
10733                 this._root = splay(key, this._root, this._comparator);
10734                 if (this._comparator(key, this._root.key) !== 0) return null;
10735               }
10736               return this._root;
10737             };
10738             Tree2.prototype.contains = function(key) {
10739               var current = this._root;
10740               var compare2 = this._comparator;
10741               while (current) {
10742                 var cmp2 = compare2(key, current.key);
10743                 if (cmp2 === 0) return true;
10744                 else if (cmp2 < 0) current = current.left;
10745                 else current = current.right;
10746               }
10747               return false;
10748             };
10749             Tree2.prototype.forEach = function(visitor, ctx) {
10750               var current = this._root;
10751               var Q2 = [];
10752               var done = false;
10753               while (!done) {
10754                 if (current !== null) {
10755                   Q2.push(current);
10756                   current = current.left;
10757                 } else {
10758                   if (Q2.length !== 0) {
10759                     current = Q2.pop();
10760                     visitor.call(ctx, current);
10761                     current = current.right;
10762                   } else done = true;
10763                 }
10764               }
10765               return this;
10766             };
10767             Tree2.prototype.range = function(low, high, fn, ctx) {
10768               var Q2 = [];
10769               var compare2 = this._comparator;
10770               var node = this._root;
10771               var cmp2;
10772               while (Q2.length !== 0 || node) {
10773                 if (node) {
10774                   Q2.push(node);
10775                   node = node.left;
10776                 } else {
10777                   node = Q2.pop();
10778                   cmp2 = compare2(node.key, high);
10779                   if (cmp2 > 0) {
10780                     break;
10781                   } else if (compare2(node.key, low) >= 0) {
10782                     if (fn.call(ctx, node)) return this;
10783                   }
10784                   node = node.right;
10785                 }
10786               }
10787               return this;
10788             };
10789             Tree2.prototype.keys = function() {
10790               var keys2 = [];
10791               this.forEach(function(_a4) {
10792                 var key = _a4.key;
10793                 return keys2.push(key);
10794               });
10795               return keys2;
10796             };
10797             Tree2.prototype.values = function() {
10798               var values = [];
10799               this.forEach(function(_a4) {
10800                 var data = _a4.data;
10801                 return values.push(data);
10802               });
10803               return values;
10804             };
10805             Tree2.prototype.min = function() {
10806               if (this._root) return this.minNode(this._root).key;
10807               return null;
10808             };
10809             Tree2.prototype.max = function() {
10810               if (this._root) return this.maxNode(this._root).key;
10811               return null;
10812             };
10813             Tree2.prototype.minNode = function(t2) {
10814               if (t2 === void 0) {
10815                 t2 = this._root;
10816               }
10817               if (t2) while (t2.left) t2 = t2.left;
10818               return t2;
10819             };
10820             Tree2.prototype.maxNode = function(t2) {
10821               if (t2 === void 0) {
10822                 t2 = this._root;
10823               }
10824               if (t2) while (t2.right) t2 = t2.right;
10825               return t2;
10826             };
10827             Tree2.prototype.at = function(index2) {
10828               var current = this._root;
10829               var done = false;
10830               var i3 = 0;
10831               var Q2 = [];
10832               while (!done) {
10833                 if (current) {
10834                   Q2.push(current);
10835                   current = current.left;
10836                 } else {
10837                   if (Q2.length > 0) {
10838                     current = Q2.pop();
10839                     if (i3 === index2) return current;
10840                     i3++;
10841                     current = current.right;
10842                   } else done = true;
10843                 }
10844               }
10845               return null;
10846             };
10847             Tree2.prototype.next = function(d2) {
10848               var root3 = this._root;
10849               var successor = null;
10850               if (d2.right) {
10851                 successor = d2.right;
10852                 while (successor.left) successor = successor.left;
10853                 return successor;
10854               }
10855               var comparator = this._comparator;
10856               while (root3) {
10857                 var cmp2 = comparator(d2.key, root3.key);
10858                 if (cmp2 === 0) break;
10859                 else if (cmp2 < 0) {
10860                   successor = root3;
10861                   root3 = root3.left;
10862                 } else root3 = root3.right;
10863               }
10864               return successor;
10865             };
10866             Tree2.prototype.prev = function(d2) {
10867               var root3 = this._root;
10868               var predecessor = null;
10869               if (d2.left !== null) {
10870                 predecessor = d2.left;
10871                 while (predecessor.right) predecessor = predecessor.right;
10872                 return predecessor;
10873               }
10874               var comparator = this._comparator;
10875               while (root3) {
10876                 var cmp2 = comparator(d2.key, root3.key);
10877                 if (cmp2 === 0) break;
10878                 else if (cmp2 < 0) root3 = root3.left;
10879                 else {
10880                   predecessor = root3;
10881                   root3 = root3.right;
10882                 }
10883               }
10884               return predecessor;
10885             };
10886             Tree2.prototype.clear = function() {
10887               this._root = null;
10888               this._size = 0;
10889               return this;
10890             };
10891             Tree2.prototype.toList = function() {
10892               return toList(this._root);
10893             };
10894             Tree2.prototype.load = function(keys2, values, presort) {
10895               if (values === void 0) {
10896                 values = [];
10897               }
10898               if (presort === void 0) {
10899                 presort = false;
10900               }
10901               var size = keys2.length;
10902               var comparator = this._comparator;
10903               if (presort) sort(keys2, values, 0, size - 1, comparator);
10904               if (this._root === null) {
10905                 this._root = loadRecursive(keys2, values, 0, size);
10906                 this._size = size;
10907               } else {
10908                 var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator);
10909                 size = this._size + size;
10910                 this._root = sortedListToBST({
10911                   head: mergedList
10912                 }, 0, size);
10913               }
10914               return this;
10915             };
10916             Tree2.prototype.isEmpty = function() {
10917               return this._root === null;
10918             };
10919             Object.defineProperty(Tree2.prototype, "size", {
10920               get: function() {
10921                 return this._size;
10922               },
10923               enumerable: true,
10924               configurable: true
10925             });
10926             Object.defineProperty(Tree2.prototype, "root", {
10927               get: function() {
10928                 return this._root;
10929               },
10930               enumerable: true,
10931               configurable: true
10932             });
10933             Tree2.prototype.toString = function(printNode) {
10934               if (printNode === void 0) {
10935                 printNode = function(n3) {
10936                   return String(n3.key);
10937                 };
10938               }
10939               var out = [];
10940               printRow(this._root, "", true, function(v2) {
10941                 return out.push(v2);
10942               }, printNode);
10943               return out.join("");
10944             };
10945             Tree2.prototype.update = function(key, newKey, newData) {
10946               var comparator = this._comparator;
10947               var _a4 = split(key, this._root, comparator), left = _a4.left, right = _a4.right;
10948               if (comparator(key, newKey) < 0) {
10949                 right = insert(newKey, newData, right, comparator);
10950               } else {
10951                 left = insert(newKey, newData, left, comparator);
10952               }
10953               this._root = merge3(left, right, comparator);
10954             };
10955             Tree2.prototype.split = function(key) {
10956               return split(key, this._root, this._comparator);
10957             };
10958             Tree2.prototype[Symbol.iterator] = function() {
10959               var current, Q2, done;
10960               return __generator(this, function(_a4) {
10961                 switch (_a4.label) {
10962                   case 0:
10963                     current = this._root;
10964                     Q2 = [];
10965                     done = false;
10966                     _a4.label = 1;
10967                   case 1:
10968                     if (!!done) return [3, 6];
10969                     if (!(current !== null)) return [3, 2];
10970                     Q2.push(current);
10971                     current = current.left;
10972                     return [3, 5];
10973                   case 2:
10974                     if (!(Q2.length !== 0)) return [3, 4];
10975                     current = Q2.pop();
10976                     return [4, current];
10977                   case 3:
10978                     _a4.sent();
10979                     current = current.right;
10980                     return [3, 5];
10981                   case 4:
10982                     done = true;
10983                     _a4.label = 5;
10984                   case 5:
10985                     return [3, 1];
10986                   case 6:
10987                     return [
10988                       2
10989                       /*return*/
10990                     ];
10991                 }
10992               });
10993             };
10994             return Tree2;
10995           }()
10996         );
10997         function loadRecursive(keys2, values, start2, end) {
10998           var size = end - start2;
10999           if (size > 0) {
11000             var middle = start2 + Math.floor(size / 2);
11001             var key = keys2[middle];
11002             var data = values[middle];
11003             var node = new Node(key, data);
11004             node.left = loadRecursive(keys2, values, start2, middle);
11005             node.right = loadRecursive(keys2, values, middle + 1, end);
11006             return node;
11007           }
11008           return null;
11009         }
11010         function createList(keys2, values) {
11011           var head = new Node(null, null);
11012           var p2 = head;
11013           for (var i3 = 0; i3 < keys2.length; i3++) {
11014             p2 = p2.next = new Node(keys2[i3], values[i3]);
11015           }
11016           p2.next = null;
11017           return head.next;
11018         }
11019         function toList(root3) {
11020           var current = root3;
11021           var Q2 = [];
11022           var done = false;
11023           var head = new Node(null, null);
11024           var p2 = head;
11025           while (!done) {
11026             if (current) {
11027               Q2.push(current);
11028               current = current.left;
11029             } else {
11030               if (Q2.length > 0) {
11031                 current = p2 = p2.next = Q2.pop();
11032                 current = current.right;
11033               } else done = true;
11034             }
11035           }
11036           p2.next = null;
11037           return head.next;
11038         }
11039         function sortedListToBST(list2, start2, end) {
11040           var size = end - start2;
11041           if (size > 0) {
11042             var middle = start2 + Math.floor(size / 2);
11043             var left = sortedListToBST(list2, start2, middle);
11044             var root3 = list2.head;
11045             root3.left = left;
11046             list2.head = list2.head.next;
11047             root3.right = sortedListToBST(list2, middle + 1, end);
11048             return root3;
11049           }
11050           return null;
11051         }
11052         function mergeLists(l1, l2, compare2) {
11053           var head = new Node(null, null);
11054           var p2 = head;
11055           var p1 = l1;
11056           var p22 = l2;
11057           while (p1 !== null && p22 !== null) {
11058             if (compare2(p1.key, p22.key) < 0) {
11059               p2.next = p1;
11060               p1 = p1.next;
11061             } else {
11062               p2.next = p22;
11063               p22 = p22.next;
11064             }
11065             p2 = p2.next;
11066           }
11067           if (p1 !== null) {
11068             p2.next = p1;
11069           } else if (p22 !== null) {
11070             p2.next = p22;
11071           }
11072           return head.next;
11073         }
11074         function sort(keys2, values, left, right, compare2) {
11075           if (left >= right) return;
11076           var pivot = keys2[left + right >> 1];
11077           var i3 = left - 1;
11078           var j2 = right + 1;
11079           while (true) {
11080             do
11081               i3++;
11082             while (compare2(keys2[i3], pivot) < 0);
11083             do
11084               j2--;
11085             while (compare2(keys2[j2], pivot) > 0);
11086             if (i3 >= j2) break;
11087             var tmp = keys2[i3];
11088             keys2[i3] = keys2[j2];
11089             keys2[j2] = tmp;
11090             tmp = values[i3];
11091             values[i3] = values[j2];
11092             values[j2] = tmp;
11093           }
11094           sort(keys2, values, left, j2, compare2);
11095           sort(keys2, values, j2 + 1, right, compare2);
11096         }
11097         const isInBbox2 = (bbox2, point) => {
11098           return bbox2.ll.x <= point.x && point.x <= bbox2.ur.x && bbox2.ll.y <= point.y && point.y <= bbox2.ur.y;
11099         };
11100         const getBboxOverlap2 = (b1, b2) => {
11101           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) return null;
11102           const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
11103           const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
11104           const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
11105           const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
11106           return {
11107             ll: {
11108               x: lowerX,
11109               y: lowerY
11110             },
11111             ur: {
11112               x: upperX,
11113               y: upperY
11114             }
11115           };
11116         };
11117         let epsilon$1 = Number.EPSILON;
11118         if (epsilon$1 === void 0) epsilon$1 = Math.pow(2, -52);
11119         const EPSILON_SQ = epsilon$1 * epsilon$1;
11120         const cmp = (a2, b2) => {
11121           if (-epsilon$1 < a2 && a2 < epsilon$1) {
11122             if (-epsilon$1 < b2 && b2 < epsilon$1) {
11123               return 0;
11124             }
11125           }
11126           const ab = a2 - b2;
11127           if (ab * ab < EPSILON_SQ * a2 * b2) {
11128             return 0;
11129           }
11130           return a2 < b2 ? -1 : 1;
11131         };
11132         class PtRounder {
11133           constructor() {
11134             this.reset();
11135           }
11136           reset() {
11137             this.xRounder = new CoordRounder();
11138             this.yRounder = new CoordRounder();
11139           }
11140           round(x2, y2) {
11141             return {
11142               x: this.xRounder.round(x2),
11143               y: this.yRounder.round(y2)
11144             };
11145           }
11146         }
11147         class CoordRounder {
11148           constructor() {
11149             this.tree = new Tree();
11150             this.round(0);
11151           }
11152           // Note: this can rounds input values backwards or forwards.
11153           //       You might ask, why not restrict this to just rounding
11154           //       forwards? Wouldn't that allow left endpoints to always
11155           //       remain left endpoints during splitting (never change to
11156           //       right). No - it wouldn't, because we snap intersections
11157           //       to endpoints (to establish independence from the segment
11158           //       angle for t-intersections).
11159           round(coord2) {
11160             const node = this.tree.add(coord2);
11161             const prevNode = this.tree.prev(node);
11162             if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
11163               this.tree.remove(coord2);
11164               return prevNode.key;
11165             }
11166             const nextNode = this.tree.next(node);
11167             if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
11168               this.tree.remove(coord2);
11169               return nextNode.key;
11170             }
11171             return coord2;
11172           }
11173         }
11174         const rounder = new PtRounder();
11175         const epsilon3 = 11102230246251565e-32;
11176         const splitter = 134217729;
11177         const resulterrbound = (3 + 8 * epsilon3) * epsilon3;
11178         function sum(elen, e3, flen, f2, h2) {
11179           let Q2, Qnew, hh, bvirt;
11180           let enow = e3[0];
11181           let fnow = f2[0];
11182           let eindex = 0;
11183           let findex = 0;
11184           if (fnow > enow === fnow > -enow) {
11185             Q2 = enow;
11186             enow = e3[++eindex];
11187           } else {
11188             Q2 = fnow;
11189             fnow = f2[++findex];
11190           }
11191           let hindex = 0;
11192           if (eindex < elen && findex < flen) {
11193             if (fnow > enow === fnow > -enow) {
11194               Qnew = enow + Q2;
11195               hh = Q2 - (Qnew - enow);
11196               enow = e3[++eindex];
11197             } else {
11198               Qnew = fnow + Q2;
11199               hh = Q2 - (Qnew - fnow);
11200               fnow = f2[++findex];
11201             }
11202             Q2 = Qnew;
11203             if (hh !== 0) {
11204               h2[hindex++] = hh;
11205             }
11206             while (eindex < elen && findex < flen) {
11207               if (fnow > enow === fnow > -enow) {
11208                 Qnew = Q2 + enow;
11209                 bvirt = Qnew - Q2;
11210                 hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
11211                 enow = e3[++eindex];
11212               } else {
11213                 Qnew = Q2 + fnow;
11214                 bvirt = Qnew - Q2;
11215                 hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
11216                 fnow = f2[++findex];
11217               }
11218               Q2 = Qnew;
11219               if (hh !== 0) {
11220                 h2[hindex++] = hh;
11221               }
11222             }
11223           }
11224           while (eindex < elen) {
11225             Qnew = Q2 + enow;
11226             bvirt = Qnew - Q2;
11227             hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
11228             enow = e3[++eindex];
11229             Q2 = Qnew;
11230             if (hh !== 0) {
11231               h2[hindex++] = hh;
11232             }
11233           }
11234           while (findex < flen) {
11235             Qnew = Q2 + fnow;
11236             bvirt = Qnew - Q2;
11237             hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
11238             fnow = f2[++findex];
11239             Q2 = Qnew;
11240             if (hh !== 0) {
11241               h2[hindex++] = hh;
11242             }
11243           }
11244           if (Q2 !== 0 || hindex === 0) {
11245             h2[hindex++] = Q2;
11246           }
11247           return hindex;
11248         }
11249         function estimate(elen, e3) {
11250           let Q2 = e3[0];
11251           for (let i3 = 1; i3 < elen; i3++) Q2 += e3[i3];
11252           return Q2;
11253         }
11254         function vec(n3) {
11255           return new Float64Array(n3);
11256         }
11257         const ccwerrboundA = (3 + 16 * epsilon3) * epsilon3;
11258         const ccwerrboundB = (2 + 12 * epsilon3) * epsilon3;
11259         const ccwerrboundC = (9 + 64 * epsilon3) * epsilon3 * epsilon3;
11260         const B2 = vec(4);
11261         const C1 = vec(8);
11262         const C2 = vec(12);
11263         const D2 = vec(16);
11264         const u2 = vec(4);
11265         function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
11266           let acxtail, acytail, bcxtail, bcytail;
11267           let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
11268           const acx = ax - cx;
11269           const bcx = bx - cx;
11270           const acy = ay - cy;
11271           const bcy = by - cy;
11272           s1 = acx * bcy;
11273           c2 = splitter * acx;
11274           ahi = c2 - (c2 - acx);
11275           alo = acx - ahi;
11276           c2 = splitter * bcy;
11277           bhi = c2 - (c2 - bcy);
11278           blo = bcy - bhi;
11279           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11280           t1 = acy * bcx;
11281           c2 = splitter * acy;
11282           ahi = c2 - (c2 - acy);
11283           alo = acy - ahi;
11284           c2 = splitter * bcx;
11285           bhi = c2 - (c2 - bcx);
11286           blo = bcx - bhi;
11287           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11288           _i = s0 - t0;
11289           bvirt = s0 - _i;
11290           B2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11291           _j = s1 + _i;
11292           bvirt = _j - s1;
11293           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11294           _i = _0 - t1;
11295           bvirt = _0 - _i;
11296           B2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11297           u3 = _j + _i;
11298           bvirt = u3 - _j;
11299           B2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11300           B2[3] = u3;
11301           let det = estimate(4, B2);
11302           let errbound = ccwerrboundB * detsum;
11303           if (det >= errbound || -det >= errbound) {
11304             return det;
11305           }
11306           bvirt = ax - acx;
11307           acxtail = ax - (acx + bvirt) + (bvirt - cx);
11308           bvirt = bx - bcx;
11309           bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
11310           bvirt = ay - acy;
11311           acytail = ay - (acy + bvirt) + (bvirt - cy);
11312           bvirt = by - bcy;
11313           bcytail = by - (bcy + bvirt) + (bvirt - cy);
11314           if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
11315             return det;
11316           }
11317           errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
11318           det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
11319           if (det >= errbound || -det >= errbound) return det;
11320           s1 = acxtail * bcy;
11321           c2 = splitter * acxtail;
11322           ahi = c2 - (c2 - acxtail);
11323           alo = acxtail - ahi;
11324           c2 = splitter * bcy;
11325           bhi = c2 - (c2 - bcy);
11326           blo = bcy - bhi;
11327           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11328           t1 = acytail * bcx;
11329           c2 = splitter * acytail;
11330           ahi = c2 - (c2 - acytail);
11331           alo = acytail - ahi;
11332           c2 = splitter * bcx;
11333           bhi = c2 - (c2 - bcx);
11334           blo = bcx - bhi;
11335           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11336           _i = s0 - t0;
11337           bvirt = s0 - _i;
11338           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11339           _j = s1 + _i;
11340           bvirt = _j - s1;
11341           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11342           _i = _0 - t1;
11343           bvirt = _0 - _i;
11344           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11345           u3 = _j + _i;
11346           bvirt = u3 - _j;
11347           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11348           u2[3] = u3;
11349           const C1len = sum(4, B2, 4, u2, C1);
11350           s1 = acx * bcytail;
11351           c2 = splitter * acx;
11352           ahi = c2 - (c2 - acx);
11353           alo = acx - ahi;
11354           c2 = splitter * bcytail;
11355           bhi = c2 - (c2 - bcytail);
11356           blo = bcytail - bhi;
11357           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11358           t1 = acy * bcxtail;
11359           c2 = splitter * acy;
11360           ahi = c2 - (c2 - acy);
11361           alo = acy - ahi;
11362           c2 = splitter * bcxtail;
11363           bhi = c2 - (c2 - bcxtail);
11364           blo = bcxtail - bhi;
11365           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11366           _i = s0 - t0;
11367           bvirt = s0 - _i;
11368           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11369           _j = s1 + _i;
11370           bvirt = _j - s1;
11371           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11372           _i = _0 - t1;
11373           bvirt = _0 - _i;
11374           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11375           u3 = _j + _i;
11376           bvirt = u3 - _j;
11377           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11378           u2[3] = u3;
11379           const C2len = sum(C1len, C1, 4, u2, C2);
11380           s1 = acxtail * bcytail;
11381           c2 = splitter * acxtail;
11382           ahi = c2 - (c2 - acxtail);
11383           alo = acxtail - ahi;
11384           c2 = splitter * bcytail;
11385           bhi = c2 - (c2 - bcytail);
11386           blo = bcytail - bhi;
11387           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11388           t1 = acytail * bcxtail;
11389           c2 = splitter * acytail;
11390           ahi = c2 - (c2 - acytail);
11391           alo = acytail - ahi;
11392           c2 = splitter * bcxtail;
11393           bhi = c2 - (c2 - bcxtail);
11394           blo = bcxtail - bhi;
11395           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11396           _i = s0 - t0;
11397           bvirt = s0 - _i;
11398           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11399           _j = s1 + _i;
11400           bvirt = _j - s1;
11401           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11402           _i = _0 - t1;
11403           bvirt = _0 - _i;
11404           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11405           u3 = _j + _i;
11406           bvirt = u3 - _j;
11407           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11408           u2[3] = u3;
11409           const Dlen = sum(C2len, C2, 4, u2, D2);
11410           return D2[Dlen - 1];
11411         }
11412         function orient2d(ax, ay, bx, by, cx, cy) {
11413           const detleft = (ay - cy) * (bx - cx);
11414           const detright = (ax - cx) * (by - cy);
11415           const det = detleft - detright;
11416           const detsum = Math.abs(detleft + detright);
11417           if (Math.abs(det) >= ccwerrboundA * detsum) return det;
11418           return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
11419         }
11420         const crossProduct2 = (a2, b2) => a2.x * b2.y - a2.y * b2.x;
11421         const dotProduct2 = (a2, b2) => a2.x * b2.x + a2.y * b2.y;
11422         const compareVectorAngles = (basePt, endPt1, endPt2) => {
11423           const res = orient2d(basePt.x, basePt.y, endPt1.x, endPt1.y, endPt2.x, endPt2.y);
11424           if (res > 0) return -1;
11425           if (res < 0) return 1;
11426           return 0;
11427         };
11428         const length2 = (v2) => Math.sqrt(dotProduct2(v2, v2));
11429         const sineOfAngle2 = (pShared, pBase, pAngle) => {
11430           const vBase = {
11431             x: pBase.x - pShared.x,
11432             y: pBase.y - pShared.y
11433           };
11434           const vAngle = {
11435             x: pAngle.x - pShared.x,
11436             y: pAngle.y - pShared.y
11437           };
11438           return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
11439         };
11440         const cosineOfAngle2 = (pShared, pBase, pAngle) => {
11441           const vBase = {
11442             x: pBase.x - pShared.x,
11443             y: pBase.y - pShared.y
11444           };
11445           const vAngle = {
11446             x: pAngle.x - pShared.x,
11447             y: pAngle.y - pShared.y
11448           };
11449           return dotProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
11450         };
11451         const horizontalIntersection2 = (pt2, v2, y2) => {
11452           if (v2.y === 0) return null;
11453           return {
11454             x: pt2.x + v2.x / v2.y * (y2 - pt2.y),
11455             y: y2
11456           };
11457         };
11458         const verticalIntersection2 = (pt2, v2, x2) => {
11459           if (v2.x === 0) return null;
11460           return {
11461             x: x2,
11462             y: pt2.y + v2.y / v2.x * (x2 - pt2.x)
11463           };
11464         };
11465         const intersection$1 = (pt1, v1, pt2, v2) => {
11466           if (v1.x === 0) return verticalIntersection2(pt2, v2, pt1.x);
11467           if (v2.x === 0) return verticalIntersection2(pt1, v1, pt2.x);
11468           if (v1.y === 0) return horizontalIntersection2(pt2, v2, pt1.y);
11469           if (v2.y === 0) return horizontalIntersection2(pt1, v1, pt2.y);
11470           const kross = crossProduct2(v1, v2);
11471           if (kross == 0) return null;
11472           const ve2 = {
11473             x: pt2.x - pt1.x,
11474             y: pt2.y - pt1.y
11475           };
11476           const d1 = crossProduct2(ve2, v1) / kross;
11477           const d2 = crossProduct2(ve2, v2) / kross;
11478           const x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
11479           const y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
11480           const x3 = (x12 + x2) / 2;
11481           const y3 = (y12 + y2) / 2;
11482           return {
11483             x: x3,
11484             y: y3
11485           };
11486         };
11487         class SweepEvent2 {
11488           // for ordering sweep events in the sweep event queue
11489           static compare(a2, b2) {
11490             const ptCmp = SweepEvent2.comparePoints(a2.point, b2.point);
11491             if (ptCmp !== 0) return ptCmp;
11492             if (a2.point !== b2.point) a2.link(b2);
11493             if (a2.isLeft !== b2.isLeft) return a2.isLeft ? 1 : -1;
11494             return Segment2.compare(a2.segment, b2.segment);
11495           }
11496           // for ordering points in sweep line order
11497           static comparePoints(aPt, bPt) {
11498             if (aPt.x < bPt.x) return -1;
11499             if (aPt.x > bPt.x) return 1;
11500             if (aPt.y < bPt.y) return -1;
11501             if (aPt.y > bPt.y) return 1;
11502             return 0;
11503           }
11504           // Warning: 'point' input will be modified and re-used (for performance)
11505           constructor(point, isLeft) {
11506             if (point.events === void 0) point.events = [this];
11507             else point.events.push(this);
11508             this.point = point;
11509             this.isLeft = isLeft;
11510           }
11511           link(other2) {
11512             if (other2.point === this.point) {
11513               throw new Error("Tried to link already linked events");
11514             }
11515             const otherEvents = other2.point.events;
11516             for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
11517               const evt = otherEvents[i3];
11518               this.point.events.push(evt);
11519               evt.point = this.point;
11520             }
11521             this.checkForConsuming();
11522           }
11523           /* Do a pass over our linked events and check to see if any pair
11524            * of segments match, and should be consumed. */
11525           checkForConsuming() {
11526             const numEvents = this.point.events.length;
11527             for (let i3 = 0; i3 < numEvents; i3++) {
11528               const evt1 = this.point.events[i3];
11529               if (evt1.segment.consumedBy !== void 0) continue;
11530               for (let j2 = i3 + 1; j2 < numEvents; j2++) {
11531                 const evt2 = this.point.events[j2];
11532                 if (evt2.consumedBy !== void 0) continue;
11533                 if (evt1.otherSE.point.events !== evt2.otherSE.point.events) continue;
11534                 evt1.segment.consume(evt2.segment);
11535               }
11536             }
11537           }
11538           getAvailableLinkedEvents() {
11539             const events = [];
11540             for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
11541               const evt = this.point.events[i3];
11542               if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
11543                 events.push(evt);
11544               }
11545             }
11546             return events;
11547           }
11548           /**
11549            * Returns a comparator function for sorting linked events that will
11550            * favor the event that will give us the smallest left-side angle.
11551            * All ring construction starts as low as possible heading to the right,
11552            * so by always turning left as sharp as possible we'll get polygons
11553            * without uncessary loops & holes.
11554            *
11555            * The comparator function has a compute cache such that it avoids
11556            * re-computing already-computed values.
11557            */
11558           getLeftmostComparator(baseEvent) {
11559             const cache = /* @__PURE__ */ new Map();
11560             const fillCache = (linkedEvent) => {
11561               const nextEvent = linkedEvent.otherSE;
11562               cache.set(linkedEvent, {
11563                 sine: sineOfAngle2(this.point, baseEvent.point, nextEvent.point),
11564                 cosine: cosineOfAngle2(this.point, baseEvent.point, nextEvent.point)
11565               });
11566             };
11567             return (a2, b2) => {
11568               if (!cache.has(a2)) fillCache(a2);
11569               if (!cache.has(b2)) fillCache(b2);
11570               const {
11571                 sine: asine,
11572                 cosine: acosine
11573               } = cache.get(a2);
11574               const {
11575                 sine: bsine,
11576                 cosine: bcosine
11577               } = cache.get(b2);
11578               if (asine >= 0 && bsine >= 0) {
11579                 if (acosine < bcosine) return 1;
11580                 if (acosine > bcosine) return -1;
11581                 return 0;
11582               }
11583               if (asine < 0 && bsine < 0) {
11584                 if (acosine < bcosine) return -1;
11585                 if (acosine > bcosine) return 1;
11586                 return 0;
11587               }
11588               if (bsine < asine) return -1;
11589               if (bsine > asine) return 1;
11590               return 0;
11591             };
11592           }
11593         }
11594         let segmentId2 = 0;
11595         class Segment2 {
11596           /* This compare() function is for ordering segments in the sweep
11597            * line tree, and does so according to the following criteria:
11598            *
11599            * Consider the vertical line that lies an infinestimal step to the
11600            * right of the right-more of the two left endpoints of the input
11601            * segments. Imagine slowly moving a point up from negative infinity
11602            * in the increasing y direction. Which of the two segments will that
11603            * point intersect first? That segment comes 'before' the other one.
11604            *
11605            * If neither segment would be intersected by such a line, (if one
11606            * or more of the segments are vertical) then the line to be considered
11607            * is directly on the right-more of the two left inputs.
11608            */
11609           static compare(a2, b2) {
11610             const alx = a2.leftSE.point.x;
11611             const blx = b2.leftSE.point.x;
11612             const arx = a2.rightSE.point.x;
11613             const brx = b2.rightSE.point.x;
11614             if (brx < alx) return 1;
11615             if (arx < blx) return -1;
11616             const aly = a2.leftSE.point.y;
11617             const bly = b2.leftSE.point.y;
11618             const ary = a2.rightSE.point.y;
11619             const bry = b2.rightSE.point.y;
11620             if (alx < blx) {
11621               if (bly < aly && bly < ary) return 1;
11622               if (bly > aly && bly > ary) return -1;
11623               const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
11624               if (aCmpBLeft < 0) return 1;
11625               if (aCmpBLeft > 0) return -1;
11626               const bCmpARight = b2.comparePoint(a2.rightSE.point);
11627               if (bCmpARight !== 0) return bCmpARight;
11628               return -1;
11629             }
11630             if (alx > blx) {
11631               if (aly < bly && aly < bry) return -1;
11632               if (aly > bly && aly > bry) return 1;
11633               const bCmpALeft = b2.comparePoint(a2.leftSE.point);
11634               if (bCmpALeft !== 0) return bCmpALeft;
11635               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
11636               if (aCmpBRight < 0) return 1;
11637               if (aCmpBRight > 0) return -1;
11638               return 1;
11639             }
11640             if (aly < bly) return -1;
11641             if (aly > bly) return 1;
11642             if (arx < brx) {
11643               const bCmpARight = b2.comparePoint(a2.rightSE.point);
11644               if (bCmpARight !== 0) return bCmpARight;
11645             }
11646             if (arx > brx) {
11647               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
11648               if (aCmpBRight < 0) return 1;
11649               if (aCmpBRight > 0) return -1;
11650             }
11651             if (arx !== brx) {
11652               const ay = ary - aly;
11653               const ax = arx - alx;
11654               const by = bry - bly;
11655               const bx = brx - blx;
11656               if (ay > ax && by < bx) return 1;
11657               if (ay < ax && by > bx) return -1;
11658             }
11659             if (arx > brx) return 1;
11660             if (arx < brx) return -1;
11661             if (ary < bry) return -1;
11662             if (ary > bry) return 1;
11663             if (a2.id < b2.id) return -1;
11664             if (a2.id > b2.id) return 1;
11665             return 0;
11666           }
11667           /* Warning: a reference to ringWindings input will be stored,
11668            *  and possibly will be later modified */
11669           constructor(leftSE, rightSE, rings, windings) {
11670             this.id = ++segmentId2;
11671             this.leftSE = leftSE;
11672             leftSE.segment = this;
11673             leftSE.otherSE = rightSE;
11674             this.rightSE = rightSE;
11675             rightSE.segment = this;
11676             rightSE.otherSE = leftSE;
11677             this.rings = rings;
11678             this.windings = windings;
11679           }
11680           static fromRing(pt1, pt2, ring) {
11681             let leftPt, rightPt, winding;
11682             const cmpPts = SweepEvent2.comparePoints(pt1, pt2);
11683             if (cmpPts < 0) {
11684               leftPt = pt1;
11685               rightPt = pt2;
11686               winding = 1;
11687             } else if (cmpPts > 0) {
11688               leftPt = pt2;
11689               rightPt = pt1;
11690               winding = -1;
11691             } else throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
11692             const leftSE = new SweepEvent2(leftPt, true);
11693             const rightSE = new SweepEvent2(rightPt, false);
11694             return new Segment2(leftSE, rightSE, [ring], [winding]);
11695           }
11696           /* When a segment is split, the rightSE is replaced with a new sweep event */
11697           replaceRightSE(newRightSE) {
11698             this.rightSE = newRightSE;
11699             this.rightSE.segment = this;
11700             this.rightSE.otherSE = this.leftSE;
11701             this.leftSE.otherSE = this.rightSE;
11702           }
11703           bbox() {
11704             const y12 = this.leftSE.point.y;
11705             const y2 = this.rightSE.point.y;
11706             return {
11707               ll: {
11708                 x: this.leftSE.point.x,
11709                 y: y12 < y2 ? y12 : y2
11710               },
11711               ur: {
11712                 x: this.rightSE.point.x,
11713                 y: y12 > y2 ? y12 : y2
11714               }
11715             };
11716           }
11717           /* A vector from the left point to the right */
11718           vector() {
11719             return {
11720               x: this.rightSE.point.x - this.leftSE.point.x,
11721               y: this.rightSE.point.y - this.leftSE.point.y
11722             };
11723           }
11724           isAnEndpoint(pt2) {
11725             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;
11726           }
11727           /* Compare this segment with a point.
11728            *
11729            * A point P is considered to be colinear to a segment if there
11730            * exists a distance D such that if we travel along the segment
11731            * from one * endpoint towards the other a distance D, we find
11732            * ourselves at point P.
11733            *
11734            * Return value indicates:
11735            *
11736            *   1: point lies above the segment (to the left of vertical)
11737            *   0: point is colinear to segment
11738            *  -1: point lies below the segment (to the right of vertical)
11739            */
11740           comparePoint(point) {
11741             if (this.isAnEndpoint(point)) return 0;
11742             const lPt = this.leftSE.point;
11743             const rPt = this.rightSE.point;
11744             const v2 = this.vector();
11745             if (lPt.x === rPt.x) {
11746               if (point.x === lPt.x) return 0;
11747               return point.x < lPt.x ? 1 : -1;
11748             }
11749             const yDist = (point.y - lPt.y) / v2.y;
11750             const xFromYDist = lPt.x + yDist * v2.x;
11751             if (point.x === xFromYDist) return 0;
11752             const xDist = (point.x - lPt.x) / v2.x;
11753             const yFromXDist = lPt.y + xDist * v2.y;
11754             if (point.y === yFromXDist) return 0;
11755             return point.y < yFromXDist ? -1 : 1;
11756           }
11757           /**
11758            * Given another segment, returns the first non-trivial intersection
11759            * between the two segments (in terms of sweep line ordering), if it exists.
11760            *
11761            * A 'non-trivial' intersection is one that will cause one or both of the
11762            * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
11763            *
11764            *   * endpoint of segA with endpoint of segB --> trivial
11765            *   * endpoint of segA with point along segB --> non-trivial
11766            *   * endpoint of segB with point along segA --> non-trivial
11767            *   * point along segA with point along segB --> non-trivial
11768            *
11769            * If no non-trivial intersection exists, return null
11770            * Else, return null.
11771            */
11772           getIntersection(other2) {
11773             const tBbox = this.bbox();
11774             const oBbox = other2.bbox();
11775             const bboxOverlap = getBboxOverlap2(tBbox, oBbox);
11776             if (bboxOverlap === null) return null;
11777             const tlp = this.leftSE.point;
11778             const trp = this.rightSE.point;
11779             const olp = other2.leftSE.point;
11780             const orp = other2.rightSE.point;
11781             const touchesOtherLSE = isInBbox2(tBbox, olp) && this.comparePoint(olp) === 0;
11782             const touchesThisLSE = isInBbox2(oBbox, tlp) && other2.comparePoint(tlp) === 0;
11783             const touchesOtherRSE = isInBbox2(tBbox, orp) && this.comparePoint(orp) === 0;
11784             const touchesThisRSE = isInBbox2(oBbox, trp) && other2.comparePoint(trp) === 0;
11785             if (touchesThisLSE && touchesOtherLSE) {
11786               if (touchesThisRSE && !touchesOtherRSE) return trp;
11787               if (!touchesThisRSE && touchesOtherRSE) return orp;
11788               return null;
11789             }
11790             if (touchesThisLSE) {
11791               if (touchesOtherRSE) {
11792                 if (tlp.x === orp.x && tlp.y === orp.y) return null;
11793               }
11794               return tlp;
11795             }
11796             if (touchesOtherLSE) {
11797               if (touchesThisRSE) {
11798                 if (trp.x === olp.x && trp.y === olp.y) return null;
11799               }
11800               return olp;
11801             }
11802             if (touchesThisRSE && touchesOtherRSE) return null;
11803             if (touchesThisRSE) return trp;
11804             if (touchesOtherRSE) return orp;
11805             const pt2 = intersection$1(tlp, this.vector(), olp, other2.vector());
11806             if (pt2 === null) return null;
11807             if (!isInBbox2(bboxOverlap, pt2)) return null;
11808             return rounder.round(pt2.x, pt2.y);
11809           }
11810           /**
11811            * Split the given segment into multiple segments on the given points.
11812            *  * Each existing segment will retain its leftSE and a new rightSE will be
11813            *    generated for it.
11814            *  * A new segment will be generated which will adopt the original segment's
11815            *    rightSE, and a new leftSE will be generated for it.
11816            *  * If there are more than two points given to split on, new segments
11817            *    in the middle will be generated with new leftSE and rightSE's.
11818            *  * An array of the newly generated SweepEvents will be returned.
11819            *
11820            * Warning: input array of points is modified
11821            */
11822           split(point) {
11823             const newEvents = [];
11824             const alreadyLinked = point.events !== void 0;
11825             const newLeftSE = new SweepEvent2(point, true);
11826             const newRightSE = new SweepEvent2(point, false);
11827             const oldRightSE = this.rightSE;
11828             this.replaceRightSE(newRightSE);
11829             newEvents.push(newRightSE);
11830             newEvents.push(newLeftSE);
11831             const newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
11832             if (SweepEvent2.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
11833               newSeg.swapEvents();
11834             }
11835             if (SweepEvent2.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
11836               this.swapEvents();
11837             }
11838             if (alreadyLinked) {
11839               newLeftSE.checkForConsuming();
11840               newRightSE.checkForConsuming();
11841             }
11842             return newEvents;
11843           }
11844           /* Swap which event is left and right */
11845           swapEvents() {
11846             const tmpEvt = this.rightSE;
11847             this.rightSE = this.leftSE;
11848             this.leftSE = tmpEvt;
11849             this.leftSE.isLeft = true;
11850             this.rightSE.isLeft = false;
11851             for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
11852               this.windings[i3] *= -1;
11853             }
11854           }
11855           /* Consume another segment. We take their rings under our wing
11856            * and mark them as consumed. Use for perfectly overlapping segments */
11857           consume(other2) {
11858             let consumer = this;
11859             let consumee = other2;
11860             while (consumer.consumedBy) consumer = consumer.consumedBy;
11861             while (consumee.consumedBy) consumee = consumee.consumedBy;
11862             const cmp2 = Segment2.compare(consumer, consumee);
11863             if (cmp2 === 0) return;
11864             if (cmp2 > 0) {
11865               const tmp = consumer;
11866               consumer = consumee;
11867               consumee = tmp;
11868             }
11869             if (consumer.prev === consumee) {
11870               const tmp = consumer;
11871               consumer = consumee;
11872               consumee = tmp;
11873             }
11874             for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
11875               const ring = consumee.rings[i3];
11876               const winding = consumee.windings[i3];
11877               const index2 = consumer.rings.indexOf(ring);
11878               if (index2 === -1) {
11879                 consumer.rings.push(ring);
11880                 consumer.windings.push(winding);
11881               } else consumer.windings[index2] += winding;
11882             }
11883             consumee.rings = null;
11884             consumee.windings = null;
11885             consumee.consumedBy = consumer;
11886             consumee.leftSE.consumedBy = consumer.leftSE;
11887             consumee.rightSE.consumedBy = consumer.rightSE;
11888           }
11889           /* The first segment previous segment chain that is in the result */
11890           prevInResult() {
11891             if (this._prevInResult !== void 0) return this._prevInResult;
11892             if (!this.prev) this._prevInResult = null;
11893             else if (this.prev.isInResult()) this._prevInResult = this.prev;
11894             else this._prevInResult = this.prev.prevInResult();
11895             return this._prevInResult;
11896           }
11897           beforeState() {
11898             if (this._beforeState !== void 0) return this._beforeState;
11899             if (!this.prev) this._beforeState = {
11900               rings: [],
11901               windings: [],
11902               multiPolys: []
11903             };
11904             else {
11905               const seg = this.prev.consumedBy || this.prev;
11906               this._beforeState = seg.afterState();
11907             }
11908             return this._beforeState;
11909           }
11910           afterState() {
11911             if (this._afterState !== void 0) return this._afterState;
11912             const beforeState = this.beforeState();
11913             this._afterState = {
11914               rings: beforeState.rings.slice(0),
11915               windings: beforeState.windings.slice(0),
11916               multiPolys: []
11917             };
11918             const ringsAfter = this._afterState.rings;
11919             const windingsAfter = this._afterState.windings;
11920             const mpsAfter = this._afterState.multiPolys;
11921             for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
11922               const ring = this.rings[i3];
11923               const winding = this.windings[i3];
11924               const index2 = ringsAfter.indexOf(ring);
11925               if (index2 === -1) {
11926                 ringsAfter.push(ring);
11927                 windingsAfter.push(winding);
11928               } else windingsAfter[index2] += winding;
11929             }
11930             const polysAfter = [];
11931             const polysExclude = [];
11932             for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
11933               if (windingsAfter[i3] === 0) continue;
11934               const ring = ringsAfter[i3];
11935               const poly = ring.poly;
11936               if (polysExclude.indexOf(poly) !== -1) continue;
11937               if (ring.isExterior) polysAfter.push(poly);
11938               else {
11939                 if (polysExclude.indexOf(poly) === -1) polysExclude.push(poly);
11940                 const index2 = polysAfter.indexOf(ring.poly);
11941                 if (index2 !== -1) polysAfter.splice(index2, 1);
11942               }
11943             }
11944             for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
11945               const mp = polysAfter[i3].multiPoly;
11946               if (mpsAfter.indexOf(mp) === -1) mpsAfter.push(mp);
11947             }
11948             return this._afterState;
11949           }
11950           /* Is this segment part of the final result? */
11951           isInResult() {
11952             if (this.consumedBy) return false;
11953             if (this._isInResult !== void 0) return this._isInResult;
11954             const mpsBefore = this.beforeState().multiPolys;
11955             const mpsAfter = this.afterState().multiPolys;
11956             switch (operation2.type) {
11957               case "union": {
11958                 const noBefores = mpsBefore.length === 0;
11959                 const noAfters = mpsAfter.length === 0;
11960                 this._isInResult = noBefores !== noAfters;
11961                 break;
11962               }
11963               case "intersection": {
11964                 let least;
11965                 let most;
11966                 if (mpsBefore.length < mpsAfter.length) {
11967                   least = mpsBefore.length;
11968                   most = mpsAfter.length;
11969                 } else {
11970                   least = mpsAfter.length;
11971                   most = mpsBefore.length;
11972                 }
11973                 this._isInResult = most === operation2.numMultiPolys && least < most;
11974                 break;
11975               }
11976               case "xor": {
11977                 const diff = Math.abs(mpsBefore.length - mpsAfter.length);
11978                 this._isInResult = diff % 2 === 1;
11979                 break;
11980               }
11981               case "difference": {
11982                 const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
11983                 this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
11984                 break;
11985               }
11986               default:
11987                 throw new Error("Unrecognized operation type found ".concat(operation2.type));
11988             }
11989             return this._isInResult;
11990           }
11991         }
11992         class RingIn2 {
11993           constructor(geomRing, poly, isExterior) {
11994             if (!Array.isArray(geomRing) || geomRing.length === 0) {
11995               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
11996             }
11997             this.poly = poly;
11998             this.isExterior = isExterior;
11999             this.segments = [];
12000             if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
12001               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12002             }
12003             const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
12004             this.bbox = {
12005               ll: {
12006                 x: firstPoint.x,
12007                 y: firstPoint.y
12008               },
12009               ur: {
12010                 x: firstPoint.x,
12011                 y: firstPoint.y
12012               }
12013             };
12014             let prevPoint = firstPoint;
12015             for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
12016               if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
12017                 throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12018               }
12019               let point = rounder.round(geomRing[i3][0], geomRing[i3][1]);
12020               if (point.x === prevPoint.x && point.y === prevPoint.y) continue;
12021               this.segments.push(Segment2.fromRing(prevPoint, point, this));
12022               if (point.x < this.bbox.ll.x) this.bbox.ll.x = point.x;
12023               if (point.y < this.bbox.ll.y) this.bbox.ll.y = point.y;
12024               if (point.x > this.bbox.ur.x) this.bbox.ur.x = point.x;
12025               if (point.y > this.bbox.ur.y) this.bbox.ur.y = point.y;
12026               prevPoint = point;
12027             }
12028             if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
12029               this.segments.push(Segment2.fromRing(prevPoint, firstPoint, this));
12030             }
12031           }
12032           getSweepEvents() {
12033             const sweepEvents = [];
12034             for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
12035               const segment = this.segments[i3];
12036               sweepEvents.push(segment.leftSE);
12037               sweepEvents.push(segment.rightSE);
12038             }
12039             return sweepEvents;
12040           }
12041         }
12042         class PolyIn2 {
12043           constructor(geomPoly, multiPoly) {
12044             if (!Array.isArray(geomPoly)) {
12045               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12046             }
12047             this.exteriorRing = new RingIn2(geomPoly[0], this, true);
12048             this.bbox = {
12049               ll: {
12050                 x: this.exteriorRing.bbox.ll.x,
12051                 y: this.exteriorRing.bbox.ll.y
12052               },
12053               ur: {
12054                 x: this.exteriorRing.bbox.ur.x,
12055                 y: this.exteriorRing.bbox.ur.y
12056               }
12057             };
12058             this.interiorRings = [];
12059             for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
12060               const ring = new RingIn2(geomPoly[i3], this, false);
12061               if (ring.bbox.ll.x < this.bbox.ll.x) this.bbox.ll.x = ring.bbox.ll.x;
12062               if (ring.bbox.ll.y < this.bbox.ll.y) this.bbox.ll.y = ring.bbox.ll.y;
12063               if (ring.bbox.ur.x > this.bbox.ur.x) this.bbox.ur.x = ring.bbox.ur.x;
12064               if (ring.bbox.ur.y > this.bbox.ur.y) this.bbox.ur.y = ring.bbox.ur.y;
12065               this.interiorRings.push(ring);
12066             }
12067             this.multiPoly = multiPoly;
12068           }
12069           getSweepEvents() {
12070             const sweepEvents = this.exteriorRing.getSweepEvents();
12071             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
12072               const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
12073               for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
12074                 sweepEvents.push(ringSweepEvents[j2]);
12075               }
12076             }
12077             return sweepEvents;
12078           }
12079         }
12080         class MultiPolyIn2 {
12081           constructor(geom, isSubject) {
12082             if (!Array.isArray(geom)) {
12083               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12084             }
12085             try {
12086               if (typeof geom[0][0][0] === "number") geom = [geom];
12087             } catch (ex) {
12088             }
12089             this.polys = [];
12090             this.bbox = {
12091               ll: {
12092                 x: Number.POSITIVE_INFINITY,
12093                 y: Number.POSITIVE_INFINITY
12094               },
12095               ur: {
12096                 x: Number.NEGATIVE_INFINITY,
12097                 y: Number.NEGATIVE_INFINITY
12098               }
12099             };
12100             for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
12101               const poly = new PolyIn2(geom[i3], this);
12102               if (poly.bbox.ll.x < this.bbox.ll.x) this.bbox.ll.x = poly.bbox.ll.x;
12103               if (poly.bbox.ll.y < this.bbox.ll.y) this.bbox.ll.y = poly.bbox.ll.y;
12104               if (poly.bbox.ur.x > this.bbox.ur.x) this.bbox.ur.x = poly.bbox.ur.x;
12105               if (poly.bbox.ur.y > this.bbox.ur.y) this.bbox.ur.y = poly.bbox.ur.y;
12106               this.polys.push(poly);
12107             }
12108             this.isSubject = isSubject;
12109           }
12110           getSweepEvents() {
12111             const sweepEvents = [];
12112             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
12113               const polySweepEvents = this.polys[i3].getSweepEvents();
12114               for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
12115                 sweepEvents.push(polySweepEvents[j2]);
12116               }
12117             }
12118             return sweepEvents;
12119           }
12120         }
12121         class RingOut2 {
12122           /* Given the segments from the sweep line pass, compute & return a series
12123            * of closed rings from all the segments marked to be part of the result */
12124           static factory(allSegments) {
12125             const ringsOut = [];
12126             for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
12127               const segment = allSegments[i3];
12128               if (!segment.isInResult() || segment.ringOut) continue;
12129               let prevEvent = null;
12130               let event = segment.leftSE;
12131               let nextEvent = segment.rightSE;
12132               const events = [event];
12133               const startingPoint = event.point;
12134               const intersectionLEs = [];
12135               while (true) {
12136                 prevEvent = event;
12137                 event = nextEvent;
12138                 events.push(event);
12139                 if (event.point === startingPoint) break;
12140                 while (true) {
12141                   const availableLEs = event.getAvailableLinkedEvents();
12142                   if (availableLEs.length === 0) {
12143                     const firstPt = events[0].point;
12144                     const lastPt = events[events.length - 1].point;
12145                     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, "]."));
12146                   }
12147                   if (availableLEs.length === 1) {
12148                     nextEvent = availableLEs[0].otherSE;
12149                     break;
12150                   }
12151                   let indexLE = null;
12152                   for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
12153                     if (intersectionLEs[j2].point === event.point) {
12154                       indexLE = j2;
12155                       break;
12156                     }
12157                   }
12158                   if (indexLE !== null) {
12159                     const intersectionLE = intersectionLEs.splice(indexLE)[0];
12160                     const ringEvents = events.splice(intersectionLE.index);
12161                     ringEvents.unshift(ringEvents[0].otherSE);
12162                     ringsOut.push(new RingOut2(ringEvents.reverse()));
12163                     continue;
12164                   }
12165                   intersectionLEs.push({
12166                     index: events.length,
12167                     point: event.point
12168                   });
12169                   const comparator = event.getLeftmostComparator(prevEvent);
12170                   nextEvent = availableLEs.sort(comparator)[0].otherSE;
12171                   break;
12172                 }
12173               }
12174               ringsOut.push(new RingOut2(events));
12175             }
12176             return ringsOut;
12177           }
12178           constructor(events) {
12179             this.events = events;
12180             for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
12181               events[i3].segment.ringOut = this;
12182             }
12183             this.poly = null;
12184           }
12185           getGeom() {
12186             let prevPt = this.events[0].point;
12187             const points = [prevPt];
12188             for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
12189               const pt3 = this.events[i3].point;
12190               const nextPt2 = this.events[i3 + 1].point;
12191               if (compareVectorAngles(pt3, prevPt, nextPt2) === 0) continue;
12192               points.push(pt3);
12193               prevPt = pt3;
12194             }
12195             if (points.length === 1) return null;
12196             const pt2 = points[0];
12197             const nextPt = points[1];
12198             if (compareVectorAngles(pt2, prevPt, nextPt) === 0) points.shift();
12199             points.push(points[0]);
12200             const step = this.isExteriorRing() ? 1 : -1;
12201             const iStart = this.isExteriorRing() ? 0 : points.length - 1;
12202             const iEnd = this.isExteriorRing() ? points.length : -1;
12203             const orderedPoints = [];
12204             for (let i3 = iStart; i3 != iEnd; i3 += step) orderedPoints.push([points[i3].x, points[i3].y]);
12205             return orderedPoints;
12206           }
12207           isExteriorRing() {
12208             if (this._isExteriorRing === void 0) {
12209               const enclosing = this.enclosingRing();
12210               this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
12211             }
12212             return this._isExteriorRing;
12213           }
12214           enclosingRing() {
12215             if (this._enclosingRing === void 0) {
12216               this._enclosingRing = this._calcEnclosingRing();
12217             }
12218             return this._enclosingRing;
12219           }
12220           /* Returns the ring that encloses this one, if any */
12221           _calcEnclosingRing() {
12222             let leftMostEvt = this.events[0];
12223             for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
12224               const evt = this.events[i3];
12225               if (SweepEvent2.compare(leftMostEvt, evt) > 0) leftMostEvt = evt;
12226             }
12227             let prevSeg = leftMostEvt.segment.prevInResult();
12228             let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
12229             while (true) {
12230               if (!prevSeg) return null;
12231               if (!prevPrevSeg) return prevSeg.ringOut;
12232               if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
12233                 if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
12234                   return prevSeg.ringOut;
12235                 } else return prevSeg.ringOut.enclosingRing();
12236               }
12237               prevSeg = prevPrevSeg.prevInResult();
12238               prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
12239             }
12240           }
12241         }
12242         class PolyOut2 {
12243           constructor(exteriorRing) {
12244             this.exteriorRing = exteriorRing;
12245             exteriorRing.poly = this;
12246             this.interiorRings = [];
12247           }
12248           addInterior(ring) {
12249             this.interiorRings.push(ring);
12250             ring.poly = this;
12251           }
12252           getGeom() {
12253             const geom = [this.exteriorRing.getGeom()];
12254             if (geom[0] === null) return null;
12255             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
12256               const ringGeom = this.interiorRings[i3].getGeom();
12257               if (ringGeom === null) continue;
12258               geom.push(ringGeom);
12259             }
12260             return geom;
12261           }
12262         }
12263         class MultiPolyOut2 {
12264           constructor(rings) {
12265             this.rings = rings;
12266             this.polys = this._composePolys(rings);
12267           }
12268           getGeom() {
12269             const geom = [];
12270             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
12271               const polyGeom = this.polys[i3].getGeom();
12272               if (polyGeom === null) continue;
12273               geom.push(polyGeom);
12274             }
12275             return geom;
12276           }
12277           _composePolys(rings) {
12278             const polys = [];
12279             for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
12280               const ring = rings[i3];
12281               if (ring.poly) continue;
12282               if (ring.isExteriorRing()) polys.push(new PolyOut2(ring));
12283               else {
12284                 const enclosingRing = ring.enclosingRing();
12285                 if (!enclosingRing.poly) polys.push(new PolyOut2(enclosingRing));
12286                 enclosingRing.poly.addInterior(ring);
12287               }
12288             }
12289             return polys;
12290           }
12291         }
12292         class SweepLine2 {
12293           constructor(queue) {
12294             let comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment2.compare;
12295             this.queue = queue;
12296             this.tree = new Tree(comparator);
12297             this.segments = [];
12298           }
12299           process(event) {
12300             const segment = event.segment;
12301             const newEvents = [];
12302             if (event.consumedBy) {
12303               if (event.isLeft) this.queue.remove(event.otherSE);
12304               else this.tree.remove(segment);
12305               return newEvents;
12306             }
12307             const node = event.isLeft ? this.tree.add(segment) : this.tree.find(segment);
12308             if (!node) 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.");
12309             let prevNode = node;
12310             let nextNode = node;
12311             let prevSeg = void 0;
12312             let nextSeg = void 0;
12313             while (prevSeg === void 0) {
12314               prevNode = this.tree.prev(prevNode);
12315               if (prevNode === null) prevSeg = null;
12316               else if (prevNode.key.consumedBy === void 0) prevSeg = prevNode.key;
12317             }
12318             while (nextSeg === void 0) {
12319               nextNode = this.tree.next(nextNode);
12320               if (nextNode === null) nextSeg = null;
12321               else if (nextNode.key.consumedBy === void 0) nextSeg = nextNode.key;
12322             }
12323             if (event.isLeft) {
12324               let prevMySplitter = null;
12325               if (prevSeg) {
12326                 const prevInter = prevSeg.getIntersection(segment);
12327                 if (prevInter !== null) {
12328                   if (!segment.isAnEndpoint(prevInter)) prevMySplitter = prevInter;
12329                   if (!prevSeg.isAnEndpoint(prevInter)) {
12330                     const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
12331                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12332                       newEvents.push(newEventsFromSplit[i3]);
12333                     }
12334                   }
12335                 }
12336               }
12337               let nextMySplitter = null;
12338               if (nextSeg) {
12339                 const nextInter = nextSeg.getIntersection(segment);
12340                 if (nextInter !== null) {
12341                   if (!segment.isAnEndpoint(nextInter)) nextMySplitter = nextInter;
12342                   if (!nextSeg.isAnEndpoint(nextInter)) {
12343                     const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
12344                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12345                       newEvents.push(newEventsFromSplit[i3]);
12346                     }
12347                   }
12348                 }
12349               }
12350               if (prevMySplitter !== null || nextMySplitter !== null) {
12351                 let mySplitter = null;
12352                 if (prevMySplitter === null) mySplitter = nextMySplitter;
12353                 else if (nextMySplitter === null) mySplitter = prevMySplitter;
12354                 else {
12355                   const cmpSplitters = SweepEvent2.comparePoints(prevMySplitter, nextMySplitter);
12356                   mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
12357                 }
12358                 this.queue.remove(segment.rightSE);
12359                 newEvents.push(segment.rightSE);
12360                 const newEventsFromSplit = segment.split(mySplitter);
12361                 for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12362                   newEvents.push(newEventsFromSplit[i3]);
12363                 }
12364               }
12365               if (newEvents.length > 0) {
12366                 this.tree.remove(segment);
12367                 newEvents.push(event);
12368               } else {
12369                 this.segments.push(segment);
12370                 segment.prev = prevSeg;
12371               }
12372             } else {
12373               if (prevSeg && nextSeg) {
12374                 const inter = prevSeg.getIntersection(nextSeg);
12375                 if (inter !== null) {
12376                   if (!prevSeg.isAnEndpoint(inter)) {
12377                     const newEventsFromSplit = this._splitSafely(prevSeg, inter);
12378                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12379                       newEvents.push(newEventsFromSplit[i3]);
12380                     }
12381                   }
12382                   if (!nextSeg.isAnEndpoint(inter)) {
12383                     const newEventsFromSplit = this._splitSafely(nextSeg, inter);
12384                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12385                       newEvents.push(newEventsFromSplit[i3]);
12386                     }
12387                   }
12388                 }
12389               }
12390               this.tree.remove(segment);
12391             }
12392             return newEvents;
12393           }
12394           /* Safely split a segment that is currently in the datastructures
12395            * IE - a segment other than the one that is currently being processed. */
12396           _splitSafely(seg, pt2) {
12397             this.tree.remove(seg);
12398             const rightSE = seg.rightSE;
12399             this.queue.remove(rightSE);
12400             const newEvents = seg.split(pt2);
12401             newEvents.push(rightSE);
12402             if (seg.consumedBy === void 0) this.tree.add(seg);
12403             return newEvents;
12404           }
12405         }
12406         const POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
12407         const POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
12408         class Operation2 {
12409           run(type2, geom, moreGeoms) {
12410             operation2.type = type2;
12411             rounder.reset();
12412             const multipolys = [new MultiPolyIn2(geom, true)];
12413             for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
12414               multipolys.push(new MultiPolyIn2(moreGeoms[i3], false));
12415             }
12416             operation2.numMultiPolys = multipolys.length;
12417             if (operation2.type === "difference") {
12418               const subject = multipolys[0];
12419               let i3 = 1;
12420               while (i3 < multipolys.length) {
12421                 if (getBboxOverlap2(multipolys[i3].bbox, subject.bbox) !== null) i3++;
12422                 else multipolys.splice(i3, 1);
12423               }
12424             }
12425             if (operation2.type === "intersection") {
12426               for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
12427                 const mpA = multipolys[i3];
12428                 for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
12429                   if (getBboxOverlap2(mpA.bbox, multipolys[j2].bbox) === null) return [];
12430                 }
12431               }
12432             }
12433             const queue = new Tree(SweepEvent2.compare);
12434             for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
12435               const sweepEvents = multipolys[i3].getSweepEvents();
12436               for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
12437                 queue.insert(sweepEvents[j2]);
12438                 if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
12439                   throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
12440                 }
12441               }
12442             }
12443             const sweepLine = new SweepLine2(queue);
12444             let prevQueueSize = queue.size;
12445             let node = queue.pop();
12446             while (node) {
12447               const evt = node.key;
12448               if (queue.size === prevQueueSize) {
12449                 const seg = evt.segment;
12450                 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."));
12451               }
12452               if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
12453                 throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
12454               }
12455               if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
12456                 throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
12457               }
12458               const newEvents = sweepLine.process(evt);
12459               for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
12460                 const evt2 = newEvents[i3];
12461                 if (evt2.consumedBy === void 0) queue.insert(evt2);
12462               }
12463               prevQueueSize = queue.size;
12464               node = queue.pop();
12465             }
12466             rounder.reset();
12467             const ringsOut = RingOut2.factory(sweepLine.segments);
12468             const result = new MultiPolyOut2(ringsOut);
12469             return result.getGeom();
12470           }
12471         }
12472         const operation2 = new Operation2();
12473         const union2 = function(geom) {
12474           for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12475             moreGeoms[_key - 1] = arguments[_key];
12476           }
12477           return operation2.run("union", geom, moreGeoms);
12478         };
12479         const intersection2 = function(geom) {
12480           for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
12481             moreGeoms[_key2 - 1] = arguments[_key2];
12482           }
12483           return operation2.run("intersection", geom, moreGeoms);
12484         };
12485         const xor = function(geom) {
12486           for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
12487             moreGeoms[_key3 - 1] = arguments[_key3];
12488           }
12489           return operation2.run("xor", geom, moreGeoms);
12490         };
12491         const difference2 = function(subjectGeom) {
12492           for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
12493             clippingGeoms[_key4 - 1] = arguments[_key4];
12494           }
12495           return operation2.run("difference", subjectGeom, clippingGeoms);
12496         };
12497         var index = {
12498           union: union2,
12499           intersection: intersection2,
12500           xor,
12501           difference: difference2
12502         };
12503         return index;
12504       });
12505     }
12506   });
12507
12508   // node_modules/whatwg-fetch/fetch.js
12509   var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
12510   typeof global !== "undefined" && global || {};
12511   var support = {
12512     searchParams: "URLSearchParams" in g,
12513     iterable: "Symbol" in g && "iterator" in Symbol,
12514     blob: "FileReader" in g && "Blob" in g && function() {
12515       try {
12516         new Blob();
12517         return true;
12518       } catch (e3) {
12519         return false;
12520       }
12521     }(),
12522     formData: "FormData" in g,
12523     arrayBuffer: "ArrayBuffer" in g
12524   };
12525   function isDataView(obj) {
12526     return obj && DataView.prototype.isPrototypeOf(obj);
12527   }
12528   if (support.arrayBuffer) {
12529     viewClasses = [
12530       "[object Int8Array]",
12531       "[object Uint8Array]",
12532       "[object Uint8ClampedArray]",
12533       "[object Int16Array]",
12534       "[object Uint16Array]",
12535       "[object Int32Array]",
12536       "[object Uint32Array]",
12537       "[object Float32Array]",
12538       "[object Float64Array]"
12539     ];
12540     isArrayBufferView = ArrayBuffer.isView || function(obj) {
12541       return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
12542     };
12543   }
12544   var viewClasses;
12545   var isArrayBufferView;
12546   function normalizeName(name) {
12547     if (typeof name !== "string") {
12548       name = String(name);
12549     }
12550     if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
12551       throw new TypeError('Invalid character in header field name: "' + name + '"');
12552     }
12553     return name.toLowerCase();
12554   }
12555   function normalizeValue(value) {
12556     if (typeof value !== "string") {
12557       value = String(value);
12558     }
12559     return value;
12560   }
12561   function iteratorFor(items) {
12562     var iterator = {
12563       next: function() {
12564         var value = items.shift();
12565         return { done: value === void 0, value };
12566       }
12567     };
12568     if (support.iterable) {
12569       iterator[Symbol.iterator] = function() {
12570         return iterator;
12571       };
12572     }
12573     return iterator;
12574   }
12575   function Headers(headers) {
12576     this.map = {};
12577     if (headers instanceof Headers) {
12578       headers.forEach(function(value, name) {
12579         this.append(name, value);
12580       }, this);
12581     } else if (Array.isArray(headers)) {
12582       headers.forEach(function(header) {
12583         if (header.length != 2) {
12584           throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
12585         }
12586         this.append(header[0], header[1]);
12587       }, this);
12588     } else if (headers) {
12589       Object.getOwnPropertyNames(headers).forEach(function(name) {
12590         this.append(name, headers[name]);
12591       }, this);
12592     }
12593   }
12594   Headers.prototype.append = function(name, value) {
12595     name = normalizeName(name);
12596     value = normalizeValue(value);
12597     var oldValue = this.map[name];
12598     this.map[name] = oldValue ? oldValue + ", " + value : value;
12599   };
12600   Headers.prototype["delete"] = function(name) {
12601     delete this.map[normalizeName(name)];
12602   };
12603   Headers.prototype.get = function(name) {
12604     name = normalizeName(name);
12605     return this.has(name) ? this.map[name] : null;
12606   };
12607   Headers.prototype.has = function(name) {
12608     return this.map.hasOwnProperty(normalizeName(name));
12609   };
12610   Headers.prototype.set = function(name, value) {
12611     this.map[normalizeName(name)] = normalizeValue(value);
12612   };
12613   Headers.prototype.forEach = function(callback, thisArg) {
12614     for (var name in this.map) {
12615       if (this.map.hasOwnProperty(name)) {
12616         callback.call(thisArg, this.map[name], name, this);
12617       }
12618     }
12619   };
12620   Headers.prototype.keys = function() {
12621     var items = [];
12622     this.forEach(function(value, name) {
12623       items.push(name);
12624     });
12625     return iteratorFor(items);
12626   };
12627   Headers.prototype.values = function() {
12628     var items = [];
12629     this.forEach(function(value) {
12630       items.push(value);
12631     });
12632     return iteratorFor(items);
12633   };
12634   Headers.prototype.entries = function() {
12635     var items = [];
12636     this.forEach(function(value, name) {
12637       items.push([name, value]);
12638     });
12639     return iteratorFor(items);
12640   };
12641   if (support.iterable) {
12642     Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
12643   }
12644   function consumed(body) {
12645     if (body._noBody) return;
12646     if (body.bodyUsed) {
12647       return Promise.reject(new TypeError("Already read"));
12648     }
12649     body.bodyUsed = true;
12650   }
12651   function fileReaderReady(reader) {
12652     return new Promise(function(resolve, reject) {
12653       reader.onload = function() {
12654         resolve(reader.result);
12655       };
12656       reader.onerror = function() {
12657         reject(reader.error);
12658       };
12659     });
12660   }
12661   function readBlobAsArrayBuffer(blob) {
12662     var reader = new FileReader();
12663     var promise = fileReaderReady(reader);
12664     reader.readAsArrayBuffer(blob);
12665     return promise;
12666   }
12667   function readBlobAsText(blob) {
12668     var reader = new FileReader();
12669     var promise = fileReaderReady(reader);
12670     var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
12671     var encoding = match ? match[1] : "utf-8";
12672     reader.readAsText(blob, encoding);
12673     return promise;
12674   }
12675   function readArrayBufferAsText(buf) {
12676     var view = new Uint8Array(buf);
12677     var chars = new Array(view.length);
12678     for (var i3 = 0; i3 < view.length; i3++) {
12679       chars[i3] = String.fromCharCode(view[i3]);
12680     }
12681     return chars.join("");
12682   }
12683   function bufferClone(buf) {
12684     if (buf.slice) {
12685       return buf.slice(0);
12686     } else {
12687       var view = new Uint8Array(buf.byteLength);
12688       view.set(new Uint8Array(buf));
12689       return view.buffer;
12690     }
12691   }
12692   function Body() {
12693     this.bodyUsed = false;
12694     this._initBody = function(body) {
12695       this.bodyUsed = this.bodyUsed;
12696       this._bodyInit = body;
12697       if (!body) {
12698         this._noBody = true;
12699         this._bodyText = "";
12700       } else if (typeof body === "string") {
12701         this._bodyText = body;
12702       } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
12703         this._bodyBlob = body;
12704       } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
12705         this._bodyFormData = body;
12706       } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
12707         this._bodyText = body.toString();
12708       } else if (support.arrayBuffer && support.blob && isDataView(body)) {
12709         this._bodyArrayBuffer = bufferClone(body.buffer);
12710         this._bodyInit = new Blob([this._bodyArrayBuffer]);
12711       } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
12712         this._bodyArrayBuffer = bufferClone(body);
12713       } else {
12714         this._bodyText = body = Object.prototype.toString.call(body);
12715       }
12716       if (!this.headers.get("content-type")) {
12717         if (typeof body === "string") {
12718           this.headers.set("content-type", "text/plain;charset=UTF-8");
12719         } else if (this._bodyBlob && this._bodyBlob.type) {
12720           this.headers.set("content-type", this._bodyBlob.type);
12721         } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
12722           this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
12723         }
12724       }
12725     };
12726     if (support.blob) {
12727       this.blob = function() {
12728         var rejected = consumed(this);
12729         if (rejected) {
12730           return rejected;
12731         }
12732         if (this._bodyBlob) {
12733           return Promise.resolve(this._bodyBlob);
12734         } else if (this._bodyArrayBuffer) {
12735           return Promise.resolve(new Blob([this._bodyArrayBuffer]));
12736         } else if (this._bodyFormData) {
12737           throw new Error("could not read FormData body as blob");
12738         } else {
12739           return Promise.resolve(new Blob([this._bodyText]));
12740         }
12741       };
12742     }
12743     this.arrayBuffer = function() {
12744       if (this._bodyArrayBuffer) {
12745         var isConsumed = consumed(this);
12746         if (isConsumed) {
12747           return isConsumed;
12748         } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
12749           return Promise.resolve(
12750             this._bodyArrayBuffer.buffer.slice(
12751               this._bodyArrayBuffer.byteOffset,
12752               this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
12753             )
12754           );
12755         } else {
12756           return Promise.resolve(this._bodyArrayBuffer);
12757         }
12758       } else if (support.blob) {
12759         return this.blob().then(readBlobAsArrayBuffer);
12760       } else {
12761         throw new Error("could not read as ArrayBuffer");
12762       }
12763     };
12764     this.text = function() {
12765       var rejected = consumed(this);
12766       if (rejected) {
12767         return rejected;
12768       }
12769       if (this._bodyBlob) {
12770         return readBlobAsText(this._bodyBlob);
12771       } else if (this._bodyArrayBuffer) {
12772         return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
12773       } else if (this._bodyFormData) {
12774         throw new Error("could not read FormData body as text");
12775       } else {
12776         return Promise.resolve(this._bodyText);
12777       }
12778     };
12779     if (support.formData) {
12780       this.formData = function() {
12781         return this.text().then(decode);
12782       };
12783     }
12784     this.json = function() {
12785       return this.text().then(JSON.parse);
12786     };
12787     return this;
12788   }
12789   var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
12790   function normalizeMethod(method) {
12791     var upcased = method.toUpperCase();
12792     return methods.indexOf(upcased) > -1 ? upcased : method;
12793   }
12794   function Request(input, options2) {
12795     if (!(this instanceof Request)) {
12796       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
12797     }
12798     options2 = options2 || {};
12799     var body = options2.body;
12800     if (input instanceof Request) {
12801       if (input.bodyUsed) {
12802         throw new TypeError("Already read");
12803       }
12804       this.url = input.url;
12805       this.credentials = input.credentials;
12806       if (!options2.headers) {
12807         this.headers = new Headers(input.headers);
12808       }
12809       this.method = input.method;
12810       this.mode = input.mode;
12811       this.signal = input.signal;
12812       if (!body && input._bodyInit != null) {
12813         body = input._bodyInit;
12814         input.bodyUsed = true;
12815       }
12816     } else {
12817       this.url = String(input);
12818     }
12819     this.credentials = options2.credentials || this.credentials || "same-origin";
12820     if (options2.headers || !this.headers) {
12821       this.headers = new Headers(options2.headers);
12822     }
12823     this.method = normalizeMethod(options2.method || this.method || "GET");
12824     this.mode = options2.mode || this.mode || null;
12825     this.signal = options2.signal || this.signal || function() {
12826       if ("AbortController" in g) {
12827         var ctrl = new AbortController();
12828         return ctrl.signal;
12829       }
12830     }();
12831     this.referrer = null;
12832     if ((this.method === "GET" || this.method === "HEAD") && body) {
12833       throw new TypeError("Body not allowed for GET or HEAD requests");
12834     }
12835     this._initBody(body);
12836     if (this.method === "GET" || this.method === "HEAD") {
12837       if (options2.cache === "no-store" || options2.cache === "no-cache") {
12838         var reParamSearch = /([?&])_=[^&]*/;
12839         if (reParamSearch.test(this.url)) {
12840           this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
12841         } else {
12842           var reQueryString = /\?/;
12843           this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
12844         }
12845       }
12846     }
12847   }
12848   Request.prototype.clone = function() {
12849     return new Request(this, { body: this._bodyInit });
12850   };
12851   function decode(body) {
12852     var form = new FormData();
12853     body.trim().split("&").forEach(function(bytes) {
12854       if (bytes) {
12855         var split = bytes.split("=");
12856         var name = split.shift().replace(/\+/g, " ");
12857         var value = split.join("=").replace(/\+/g, " ");
12858         form.append(decodeURIComponent(name), decodeURIComponent(value));
12859       }
12860     });
12861     return form;
12862   }
12863   function parseHeaders(rawHeaders) {
12864     var headers = new Headers();
12865     var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
12866     preProcessedHeaders.split("\r").map(function(header) {
12867       return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
12868     }).forEach(function(line) {
12869       var parts = line.split(":");
12870       var key = parts.shift().trim();
12871       if (key) {
12872         var value = parts.join(":").trim();
12873         try {
12874           headers.append(key, value);
12875         } catch (error) {
12876           console.warn("Response " + error.message);
12877         }
12878       }
12879     });
12880     return headers;
12881   }
12882   Body.call(Request.prototype);
12883   function Response(bodyInit, options2) {
12884     if (!(this instanceof Response)) {
12885       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
12886     }
12887     if (!options2) {
12888       options2 = {};
12889     }
12890     this.type = "default";
12891     this.status = options2.status === void 0 ? 200 : options2.status;
12892     if (this.status < 200 || this.status > 599) {
12893       throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
12894     }
12895     this.ok = this.status >= 200 && this.status < 300;
12896     this.statusText = options2.statusText === void 0 ? "" : "" + options2.statusText;
12897     this.headers = new Headers(options2.headers);
12898     this.url = options2.url || "";
12899     this._initBody(bodyInit);
12900   }
12901   Body.call(Response.prototype);
12902   Response.prototype.clone = function() {
12903     return new Response(this._bodyInit, {
12904       status: this.status,
12905       statusText: this.statusText,
12906       headers: new Headers(this.headers),
12907       url: this.url
12908     });
12909   };
12910   Response.error = function() {
12911     var response = new Response(null, { status: 200, statusText: "" });
12912     response.ok = false;
12913     response.status = 0;
12914     response.type = "error";
12915     return response;
12916   };
12917   var redirectStatuses = [301, 302, 303, 307, 308];
12918   Response.redirect = function(url, status) {
12919     if (redirectStatuses.indexOf(status) === -1) {
12920       throw new RangeError("Invalid status code");
12921     }
12922     return new Response(null, { status, headers: { location: url } });
12923   };
12924   var DOMException2 = g.DOMException;
12925   try {
12926     new DOMException2();
12927   } catch (err) {
12928     DOMException2 = function(message, name) {
12929       this.message = message;
12930       this.name = name;
12931       var error = Error(message);
12932       this.stack = error.stack;
12933     };
12934     DOMException2.prototype = Object.create(Error.prototype);
12935     DOMException2.prototype.constructor = DOMException2;
12936   }
12937   function fetch2(input, init2) {
12938     return new Promise(function(resolve, reject) {
12939       var request3 = new Request(input, init2);
12940       if (request3.signal && request3.signal.aborted) {
12941         return reject(new DOMException2("Aborted", "AbortError"));
12942       }
12943       var xhr = new XMLHttpRequest();
12944       function abortXhr() {
12945         xhr.abort();
12946       }
12947       xhr.onload = function() {
12948         var options2 = {
12949           statusText: xhr.statusText,
12950           headers: parseHeaders(xhr.getAllResponseHeaders() || "")
12951         };
12952         if (request3.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
12953           options2.status = 200;
12954         } else {
12955           options2.status = xhr.status;
12956         }
12957         options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL");
12958         var body = "response" in xhr ? xhr.response : xhr.responseText;
12959         setTimeout(function() {
12960           resolve(new Response(body, options2));
12961         }, 0);
12962       };
12963       xhr.onerror = function() {
12964         setTimeout(function() {
12965           reject(new TypeError("Network request failed"));
12966         }, 0);
12967       };
12968       xhr.ontimeout = function() {
12969         setTimeout(function() {
12970           reject(new TypeError("Network request timed out"));
12971         }, 0);
12972       };
12973       xhr.onabort = function() {
12974         setTimeout(function() {
12975           reject(new DOMException2("Aborted", "AbortError"));
12976         }, 0);
12977       };
12978       function fixUrl(url) {
12979         try {
12980           return url === "" && g.location.href ? g.location.href : url;
12981         } catch (e3) {
12982           return url;
12983         }
12984       }
12985       xhr.open(request3.method, fixUrl(request3.url), true);
12986       if (request3.credentials === "include") {
12987         xhr.withCredentials = true;
12988       } else if (request3.credentials === "omit") {
12989         xhr.withCredentials = false;
12990       }
12991       if ("responseType" in xhr) {
12992         if (support.blob) {
12993           xhr.responseType = "blob";
12994         } else if (support.arrayBuffer) {
12995           xhr.responseType = "arraybuffer";
12996         }
12997       }
12998       if (init2 && typeof init2.headers === "object" && !(init2.headers instanceof Headers || g.Headers && init2.headers instanceof g.Headers)) {
12999         var names = [];
13000         Object.getOwnPropertyNames(init2.headers).forEach(function(name) {
13001           names.push(normalizeName(name));
13002           xhr.setRequestHeader(name, normalizeValue(init2.headers[name]));
13003         });
13004         request3.headers.forEach(function(value, name) {
13005           if (names.indexOf(name) === -1) {
13006             xhr.setRequestHeader(name, value);
13007           }
13008         });
13009       } else {
13010         request3.headers.forEach(function(value, name) {
13011           xhr.setRequestHeader(name, value);
13012         });
13013       }
13014       if (request3.signal) {
13015         request3.signal.addEventListener("abort", abortXhr);
13016         xhr.onreadystatechange = function() {
13017           if (xhr.readyState === 4) {
13018             request3.signal.removeEventListener("abort", abortXhr);
13019           }
13020         };
13021       }
13022       xhr.send(typeof request3._bodyInit === "undefined" ? null : request3._bodyInit);
13023     });
13024   }
13025   fetch2.polyfill = true;
13026   if (!g.fetch) {
13027     g.fetch = fetch2;
13028     g.Headers = Headers;
13029     g.Request = Request;
13030     g.Response = Response;
13031   }
13032
13033   // node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js
13034   (function(factory) {
13035     typeof define === "function" && define.amd ? define(factory) : factory();
13036   })(function() {
13037     "use strict";
13038     function _arrayLikeToArray(r2, a2) {
13039       (null == a2 || a2 > r2.length) && (a2 = r2.length);
13040       for (var e3 = 0, n3 = Array(a2); e3 < a2; e3++) n3[e3] = r2[e3];
13041       return n3;
13042     }
13043     function _assertThisInitialized(e3) {
13044       if (void 0 === e3) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
13045       return e3;
13046     }
13047     function _callSuper(t2, o2, e3) {
13048       return o2 = _getPrototypeOf(o2), _possibleConstructorReturn(t2, _isNativeReflectConstruct() ? Reflect.construct(o2, e3 || [], _getPrototypeOf(t2).constructor) : o2.apply(t2, e3));
13049     }
13050     function _classCallCheck(a2, n3) {
13051       if (!(a2 instanceof n3)) throw new TypeError("Cannot call a class as a function");
13052     }
13053     function _defineProperties(e3, r2) {
13054       for (var t2 = 0; t2 < r2.length; t2++) {
13055         var o2 = r2[t2];
13056         o2.enumerable = o2.enumerable || false, o2.configurable = true, "value" in o2 && (o2.writable = true), Object.defineProperty(e3, _toPropertyKey(o2.key), o2);
13057       }
13058     }
13059     function _createClass(e3, r2, t2) {
13060       return r2 && _defineProperties(e3.prototype, r2), t2 && _defineProperties(e3, t2), Object.defineProperty(e3, "prototype", {
13061         writable: false
13062       }), e3;
13063     }
13064     function _createForOfIteratorHelper(r2, e3) {
13065       var t2 = "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
13066       if (!t2) {
13067         if (Array.isArray(r2) || (t2 = _unsupportedIterableToArray(r2)) || e3 && r2 && "number" == typeof r2.length) {
13068           t2 && (r2 = t2);
13069           var n3 = 0, F2 = function() {
13070           };
13071           return {
13072             s: F2,
13073             n: function() {
13074               return n3 >= r2.length ? {
13075                 done: true
13076               } : {
13077                 done: false,
13078                 value: r2[n3++]
13079               };
13080             },
13081             e: function(r3) {
13082               throw r3;
13083             },
13084             f: F2
13085           };
13086         }
13087         throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13088       }
13089       var o2, a2 = true, u2 = false;
13090       return {
13091         s: function() {
13092           t2 = t2.call(r2);
13093         },
13094         n: function() {
13095           var r3 = t2.next();
13096           return a2 = r3.done, r3;
13097         },
13098         e: function(r3) {
13099           u2 = true, o2 = r3;
13100         },
13101         f: function() {
13102           try {
13103             a2 || null == t2.return || t2.return();
13104           } finally {
13105             if (u2) throw o2;
13106           }
13107         }
13108       };
13109     }
13110     function _get() {
13111       return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function(e3, t2, r2) {
13112         var p2 = _superPropBase(e3, t2);
13113         if (p2) {
13114           var n3 = Object.getOwnPropertyDescriptor(p2, t2);
13115           return n3.get ? n3.get.call(arguments.length < 3 ? e3 : r2) : n3.value;
13116         }
13117       }, _get.apply(null, arguments);
13118     }
13119     function _getPrototypeOf(t2) {
13120       return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t3) {
13121         return t3.__proto__ || Object.getPrototypeOf(t3);
13122       }, _getPrototypeOf(t2);
13123     }
13124     function _inherits(t2, e3) {
13125       if ("function" != typeof e3 && null !== e3) throw new TypeError("Super expression must either be null or a function");
13126       t2.prototype = Object.create(e3 && e3.prototype, {
13127         constructor: {
13128           value: t2,
13129           writable: true,
13130           configurable: true
13131         }
13132       }), Object.defineProperty(t2, "prototype", {
13133         writable: false
13134       }), e3 && _setPrototypeOf(t2, e3);
13135     }
13136     function _isNativeReflectConstruct() {
13137       try {
13138         var t2 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
13139         }));
13140       } catch (t3) {
13141       }
13142       return (_isNativeReflectConstruct = function() {
13143         return !!t2;
13144       })();
13145     }
13146     function _possibleConstructorReturn(t2, e3) {
13147       if (e3 && ("object" == typeof e3 || "function" == typeof e3)) return e3;
13148       if (void 0 !== e3) throw new TypeError("Derived constructors may only return object or undefined");
13149       return _assertThisInitialized(t2);
13150     }
13151     function _setPrototypeOf(t2, e3) {
13152       return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e4) {
13153         return t3.__proto__ = e4, t3;
13154       }, _setPrototypeOf(t2, e3);
13155     }
13156     function _superPropBase(t2, o2) {
13157       for (; !{}.hasOwnProperty.call(t2, o2) && null !== (t2 = _getPrototypeOf(t2)); ) ;
13158       return t2;
13159     }
13160     function _superPropGet(t2, o2, e3, r2) {
13161       var p2 = _get(_getPrototypeOf(1 & r2 ? t2.prototype : t2), o2, e3);
13162       return 2 & r2 && "function" == typeof p2 ? function(t3) {
13163         return p2.apply(e3, t3);
13164       } : p2;
13165     }
13166     function _toPrimitive(t2, r2) {
13167       if ("object" != typeof t2 || !t2) return t2;
13168       var e3 = t2[Symbol.toPrimitive];
13169       if (void 0 !== e3) {
13170         var i3 = e3.call(t2, r2 || "default");
13171         if ("object" != typeof i3) return i3;
13172         throw new TypeError("@@toPrimitive must return a primitive value.");
13173       }
13174       return ("string" === r2 ? String : Number)(t2);
13175     }
13176     function _toPropertyKey(t2) {
13177       var i3 = _toPrimitive(t2, "string");
13178       return "symbol" == typeof i3 ? i3 : i3 + "";
13179     }
13180     function _unsupportedIterableToArray(r2, a2) {
13181       if (r2) {
13182         if ("string" == typeof r2) return _arrayLikeToArray(r2, a2);
13183         var t2 = {}.toString.call(r2).slice(8, -1);
13184         return "Object" === t2 && r2.constructor && (t2 = r2.constructor.name), "Map" === t2 || "Set" === t2 ? Array.from(r2) : "Arguments" === t2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t2) ? _arrayLikeToArray(r2, a2) : void 0;
13185       }
13186     }
13187     (function(self2) {
13188       return {
13189         NativeAbortSignal: self2.AbortSignal,
13190         NativeAbortController: self2.AbortController
13191       };
13192     })(typeof self !== "undefined" ? self : global);
13193     function createAbortEvent(reason) {
13194       var event;
13195       try {
13196         event = new Event("abort");
13197       } catch (e3) {
13198         if (typeof document !== "undefined") {
13199           if (!document.createEvent) {
13200             event = document.createEventObject();
13201             event.type = "abort";
13202           } else {
13203             event = document.createEvent("Event");
13204             event.initEvent("abort", false, false);
13205           }
13206         } else {
13207           event = {
13208             type: "abort",
13209             bubbles: false,
13210             cancelable: false
13211           };
13212         }
13213       }
13214       event.reason = reason;
13215       return event;
13216     }
13217     function normalizeAbortReason(reason) {
13218       if (reason === void 0) {
13219         if (typeof document === "undefined") {
13220           reason = new Error("This operation was aborted");
13221           reason.name = "AbortError";
13222         } else {
13223           try {
13224             reason = new DOMException("signal is aborted without reason");
13225             Object.defineProperty(reason, "name", {
13226               value: "AbortError"
13227             });
13228           } catch (err) {
13229             reason = new Error("This operation was aborted");
13230             reason.name = "AbortError";
13231           }
13232         }
13233       }
13234       return reason;
13235     }
13236     var Emitter = /* @__PURE__ */ function() {
13237       function Emitter2() {
13238         _classCallCheck(this, Emitter2);
13239         Object.defineProperty(this, "listeners", {
13240           value: {},
13241           writable: true,
13242           configurable: true
13243         });
13244       }
13245       return _createClass(Emitter2, [{
13246         key: "addEventListener",
13247         value: function addEventListener(type2, callback, options2) {
13248           if (!(type2 in this.listeners)) {
13249             this.listeners[type2] = [];
13250           }
13251           this.listeners[type2].push({
13252             callback,
13253             options: options2
13254           });
13255         }
13256       }, {
13257         key: "removeEventListener",
13258         value: function removeEventListener(type2, callback) {
13259           if (!(type2 in this.listeners)) {
13260             return;
13261           }
13262           var stack = this.listeners[type2];
13263           for (var i3 = 0, l2 = stack.length; i3 < l2; i3++) {
13264             if (stack[i3].callback === callback) {
13265               stack.splice(i3, 1);
13266               return;
13267             }
13268           }
13269         }
13270       }, {
13271         key: "dispatchEvent",
13272         value: function dispatchEvent2(event) {
13273           var _this = this;
13274           if (!(event.type in this.listeners)) {
13275             return;
13276           }
13277           var stack = this.listeners[event.type];
13278           var stackToCall = stack.slice();
13279           var _loop = function _loop2() {
13280             var listener = stackToCall[i3];
13281             try {
13282               listener.callback.call(_this, event);
13283             } catch (e3) {
13284               Promise.resolve().then(function() {
13285                 throw e3;
13286               });
13287             }
13288             if (listener.options && listener.options.once) {
13289               _this.removeEventListener(event.type, listener.callback);
13290             }
13291           };
13292           for (var i3 = 0, l2 = stackToCall.length; i3 < l2; i3++) {
13293             _loop();
13294           }
13295           return !event.defaultPrevented;
13296         }
13297       }]);
13298     }();
13299     var AbortSignal = /* @__PURE__ */ function(_Emitter) {
13300       function AbortSignal2() {
13301         var _this2;
13302         _classCallCheck(this, AbortSignal2);
13303         _this2 = _callSuper(this, AbortSignal2);
13304         if (!_this2.listeners) {
13305           Emitter.call(_this2);
13306         }
13307         Object.defineProperty(_this2, "aborted", {
13308           value: false,
13309           writable: true,
13310           configurable: true
13311         });
13312         Object.defineProperty(_this2, "onabort", {
13313           value: null,
13314           writable: true,
13315           configurable: true
13316         });
13317         Object.defineProperty(_this2, "reason", {
13318           value: void 0,
13319           writable: true,
13320           configurable: true
13321         });
13322         return _this2;
13323       }
13324       _inherits(AbortSignal2, _Emitter);
13325       return _createClass(AbortSignal2, [{
13326         key: "toString",
13327         value: function toString2() {
13328           return "[object AbortSignal]";
13329         }
13330       }, {
13331         key: "dispatchEvent",
13332         value: function dispatchEvent2(event) {
13333           if (event.type === "abort") {
13334             this.aborted = true;
13335             if (typeof this.onabort === "function") {
13336               this.onabort.call(this, event);
13337             }
13338           }
13339           _superPropGet(AbortSignal2, "dispatchEvent", this, 3)([event]);
13340         }
13341         /**
13342          * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
13343          */
13344       }, {
13345         key: "throwIfAborted",
13346         value: function throwIfAborted() {
13347           var aborted = this.aborted, _this$reason = this.reason, reason = _this$reason === void 0 ? "Aborted" : _this$reason;
13348           if (!aborted) return;
13349           throw reason;
13350         }
13351         /**
13352          * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
13353          * @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
13354          *                      The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
13355          * @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
13356          *                        or an `AbortError` {@link DOMException} if the operation was user-triggered.
13357          */
13358       }], [{
13359         key: "timeout",
13360         value: function timeout2(time) {
13361           var controller = new AbortController2();
13362           setTimeout(function() {
13363             return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), "TimeoutError"));
13364           }, time);
13365           return controller.signal;
13366         }
13367         /**
13368          * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
13369          * @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
13370          * @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
13371          *                          The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
13372          *                        - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
13373          *                          The `reason` will be set to the reason of the first abort signal that is aborted.
13374          */
13375       }, {
13376         key: "any",
13377         value: function any(iterable) {
13378           var controller = new AbortController2();
13379           function abort() {
13380             controller.abort(this.reason);
13381             clean2();
13382           }
13383           function clean2() {
13384             var _iterator = _createForOfIteratorHelper(iterable), _step;
13385             try {
13386               for (_iterator.s(); !(_step = _iterator.n()).done; ) {
13387                 var signal2 = _step.value;
13388                 signal2.removeEventListener("abort", abort);
13389               }
13390             } catch (err) {
13391               _iterator.e(err);
13392             } finally {
13393               _iterator.f();
13394             }
13395           }
13396           var _iterator2 = _createForOfIteratorHelper(iterable), _step2;
13397           try {
13398             for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
13399               var signal = _step2.value;
13400               if (signal.aborted) {
13401                 controller.abort(signal.reason);
13402                 break;
13403               } else signal.addEventListener("abort", abort);
13404             }
13405           } catch (err) {
13406             _iterator2.e(err);
13407           } finally {
13408             _iterator2.f();
13409           }
13410           return controller.signal;
13411         }
13412       }]);
13413     }(Emitter);
13414     var AbortController2 = /* @__PURE__ */ function() {
13415       function AbortController3() {
13416         _classCallCheck(this, AbortController3);
13417         Object.defineProperty(this, "signal", {
13418           value: new AbortSignal(),
13419           writable: true,
13420           configurable: true
13421         });
13422       }
13423       return _createClass(AbortController3, [{
13424         key: "abort",
13425         value: function abort(reason) {
13426           var signalReason = normalizeAbortReason(reason);
13427           var event = createAbortEvent(signalReason);
13428           this.signal.reason = signalReason;
13429           this.signal.dispatchEvent(event);
13430         }
13431       }, {
13432         key: "toString",
13433         value: function toString2() {
13434           return "[object AbortController]";
13435         }
13436       }]);
13437     }();
13438     if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
13439       AbortController2.prototype[Symbol.toStringTag] = "AbortController";
13440       AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
13441     }
13442     function polyfillNeeded(self2) {
13443       if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
13444         console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
13445         return true;
13446       }
13447       return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
13448     }
13449     function abortableFetchDecorator(patchTargets) {
13450       if ("function" === typeof patchTargets) {
13451         patchTargets = {
13452           fetch: patchTargets
13453         };
13454       }
13455       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;
13456       if (!polyfillNeeded({
13457         fetch: fetch3,
13458         Request: NativeRequest,
13459         AbortController: NativeAbortController,
13460         __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
13461       })) {
13462         return {
13463           fetch: fetch3,
13464           Request: Request2
13465         };
13466       }
13467       var Request2 = NativeRequest;
13468       if (Request2 && !Request2.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
13469         Request2 = function Request3(input, init2) {
13470           var signal;
13471           if (init2 && init2.signal) {
13472             signal = init2.signal;
13473             delete init2.signal;
13474           }
13475           var request3 = new NativeRequest(input, init2);
13476           if (signal) {
13477             Object.defineProperty(request3, "signal", {
13478               writable: false,
13479               enumerable: false,
13480               configurable: true,
13481               value: signal
13482             });
13483           }
13484           return request3;
13485         };
13486         Request2.prototype = NativeRequest.prototype;
13487       }
13488       var realFetch = fetch3;
13489       var abortableFetch = function abortableFetch2(input, init2) {
13490         var signal = Request2 && Request2.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
13491         if (signal) {
13492           var abortError;
13493           try {
13494             abortError = new DOMException("Aborted", "AbortError");
13495           } catch (err) {
13496             abortError = new Error("Aborted");
13497             abortError.name = "AbortError";
13498           }
13499           if (signal.aborted) {
13500             return Promise.reject(abortError);
13501           }
13502           var cancellation = new Promise(function(_2, reject) {
13503             signal.addEventListener("abort", function() {
13504               return reject(abortError);
13505             }, {
13506               once: true
13507             });
13508           });
13509           if (init2 && init2.signal) {
13510             delete init2.signal;
13511           }
13512           return Promise.race([cancellation, realFetch(input, init2)]);
13513         }
13514         return realFetch(input, init2);
13515       };
13516       return {
13517         fetch: abortableFetch,
13518         Request: Request2
13519       };
13520     }
13521     (function(self2) {
13522       if (!polyfillNeeded(self2)) {
13523         return;
13524       }
13525       if (!self2.fetch) {
13526         console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
13527         return;
13528       }
13529       var _abortableFetch = abortableFetchDecorator(self2), fetch3 = _abortableFetch.fetch, Request2 = _abortableFetch.Request;
13530       self2.fetch = fetch3;
13531       self2.Request = Request2;
13532       Object.defineProperty(self2, "AbortController", {
13533         writable: true,
13534         enumerable: false,
13535         configurable: true,
13536         value: AbortController2
13537       });
13538       Object.defineProperty(self2, "AbortSignal", {
13539         writable: true,
13540         enumerable: false,
13541         configurable: true,
13542         value: AbortSignal
13543       });
13544     })(typeof self !== "undefined" ? self : global);
13545   });
13546
13547   // modules/index.js
13548   var index_exports = {};
13549   __export(index_exports, {
13550     LANGUAGE_SUFFIX_REGEX: () => LANGUAGE_SUFFIX_REGEX,
13551     LocationManager: () => LocationManager,
13552     QAItem: () => QAItem,
13553     actionAddEntity: () => actionAddEntity,
13554     actionAddMember: () => actionAddMember,
13555     actionAddMidpoint: () => actionAddMidpoint,
13556     actionAddVertex: () => actionAddVertex,
13557     actionChangeMember: () => actionChangeMember,
13558     actionChangePreset: () => actionChangePreset,
13559     actionChangeTags: () => actionChangeTags,
13560     actionCircularize: () => actionCircularize,
13561     actionConnect: () => actionConnect,
13562     actionCopyEntities: () => actionCopyEntities,
13563     actionDeleteMember: () => actionDeleteMember,
13564     actionDeleteMultiple: () => actionDeleteMultiple,
13565     actionDeleteNode: () => actionDeleteNode,
13566     actionDeleteRelation: () => actionDeleteRelation,
13567     actionDeleteWay: () => actionDeleteWay,
13568     actionDiscardTags: () => actionDiscardTags,
13569     actionDisconnect: () => actionDisconnect,
13570     actionExtract: () => actionExtract,
13571     actionJoin: () => actionJoin,
13572     actionMerge: () => actionMerge,
13573     actionMergeNodes: () => actionMergeNodes,
13574     actionMergePolygon: () => actionMergePolygon,
13575     actionMergeRemoteChanges: () => actionMergeRemoteChanges,
13576     actionMove: () => actionMove,
13577     actionMoveMember: () => actionMoveMember,
13578     actionMoveNode: () => actionMoveNode,
13579     actionNoop: () => actionNoop,
13580     actionOrthogonalize: () => actionOrthogonalize,
13581     actionReflect: () => actionReflect,
13582     actionRestrictTurn: () => actionRestrictTurn,
13583     actionReverse: () => actionReverse,
13584     actionRevert: () => actionRevert,
13585     actionRotate: () => actionRotate,
13586     actionScale: () => actionScale,
13587     actionSplit: () => actionSplit,
13588     actionStraightenNodes: () => actionStraightenNodes,
13589     actionStraightenWay: () => actionStraightenWay,
13590     actionUnrestrictTurn: () => actionUnrestrictTurn,
13591     actionUpgradeTags: () => actionUpgradeTags,
13592     behaviorAddWay: () => behaviorAddWay,
13593     behaviorBreathe: () => behaviorBreathe,
13594     behaviorDrag: () => behaviorDrag,
13595     behaviorDraw: () => behaviorDraw,
13596     behaviorDrawWay: () => behaviorDrawWay,
13597     behaviorEdit: () => behaviorEdit,
13598     behaviorHash: () => behaviorHash,
13599     behaviorHover: () => behaviorHover,
13600     behaviorLasso: () => behaviorLasso,
13601     behaviorOperation: () => behaviorOperation,
13602     behaviorPaste: () => behaviorPaste,
13603     behaviorSelect: () => behaviorSelect,
13604     coreContext: () => coreContext,
13605     coreDifference: () => coreDifference,
13606     coreFileFetcher: () => coreFileFetcher,
13607     coreGraph: () => coreGraph,
13608     coreHistory: () => coreHistory,
13609     coreLocalizer: () => coreLocalizer,
13610     coreTree: () => coreTree,
13611     coreUploader: () => coreUploader,
13612     coreValidator: () => coreValidator,
13613     d3: () => d3,
13614     debug: () => debug,
13615     dmsCoordinatePair: () => dmsCoordinatePair,
13616     dmsMatcher: () => dmsMatcher,
13617     fileFetcher: () => _mainFileFetcher,
13618     geoAngle: () => geoAngle,
13619     geoChooseEdge: () => geoChooseEdge,
13620     geoEdgeEqual: () => geoEdgeEqual,
13621     geoExtent: () => geoExtent,
13622     geoGetSmallestSurroundingRectangle: () => geoGetSmallestSurroundingRectangle,
13623     geoHasLineIntersections: () => geoHasLineIntersections,
13624     geoHasSelfIntersections: () => geoHasSelfIntersections,
13625     geoLatToMeters: () => geoLatToMeters,
13626     geoLineIntersection: () => geoLineIntersection,
13627     geoLonToMeters: () => geoLonToMeters,
13628     geoMetersToLat: () => geoMetersToLat,
13629     geoMetersToLon: () => geoMetersToLon,
13630     geoMetersToOffset: () => geoMetersToOffset,
13631     geoOffsetToMeters: () => geoOffsetToMeters,
13632     geoOrthoCalcScore: () => geoOrthoCalcScore,
13633     geoOrthoCanOrthogonalize: () => geoOrthoCanOrthogonalize,
13634     geoOrthoMaxOffsetAngle: () => geoOrthoMaxOffsetAngle,
13635     geoOrthoNormalizedDotProduct: () => geoOrthoNormalizedDotProduct,
13636     geoPathHasIntersections: () => geoPathHasIntersections,
13637     geoPathIntersections: () => geoPathIntersections,
13638     geoPathLength: () => geoPathLength,
13639     geoPointInPolygon: () => geoPointInPolygon,
13640     geoPolygonContainsPolygon: () => geoPolygonContainsPolygon,
13641     geoPolygonIntersectsPolygon: () => geoPolygonIntersectsPolygon,
13642     geoRawMercator: () => geoRawMercator,
13643     geoRotate: () => geoRotate,
13644     geoScaleToZoom: () => geoScaleToZoom,
13645     geoSphericalClosestNode: () => geoSphericalClosestNode,
13646     geoSphericalDistance: () => geoSphericalDistance,
13647     geoVecAdd: () => geoVecAdd,
13648     geoVecAngle: () => geoVecAngle,
13649     geoVecCross: () => geoVecCross,
13650     geoVecDot: () => geoVecDot,
13651     geoVecEqual: () => geoVecEqual,
13652     geoVecFloor: () => geoVecFloor,
13653     geoVecInterp: () => geoVecInterp,
13654     geoVecLength: () => geoVecLength,
13655     geoVecLengthSquare: () => geoVecLengthSquare,
13656     geoVecNormalize: () => geoVecNormalize,
13657     geoVecNormalizedDot: () => geoVecNormalizedDot,
13658     geoVecProject: () => geoVecProject,
13659     geoVecScale: () => geoVecScale,
13660     geoVecSubtract: () => geoVecSubtract,
13661     geoViewportEdge: () => geoViewportEdge,
13662     geoZoomToScale: () => geoZoomToScale,
13663     likelyRawNumberFormat: () => likelyRawNumberFormat,
13664     localizer: () => _mainLocalizer,
13665     locationManager: () => _sharedLocationManager,
13666     modeAddArea: () => modeAddArea,
13667     modeAddLine: () => modeAddLine,
13668     modeAddNote: () => modeAddNote,
13669     modeAddPoint: () => modeAddPoint,
13670     modeBrowse: () => modeBrowse,
13671     modeDragNode: () => modeDragNode,
13672     modeDragNote: () => modeDragNote,
13673     modeDrawArea: () => modeDrawArea,
13674     modeDrawLine: () => modeDrawLine,
13675     modeMove: () => modeMove,
13676     modeRotate: () => modeRotate,
13677     modeSave: () => modeSave,
13678     modeSelect: () => modeSelect,
13679     modeSelectData: () => modeSelectData,
13680     modeSelectError: () => modeSelectError,
13681     modeSelectNote: () => modeSelectNote,
13682     operationCircularize: () => operationCircularize,
13683     operationContinue: () => operationContinue,
13684     operationCopy: () => operationCopy,
13685     operationDelete: () => operationDelete,
13686     operationDisconnect: () => operationDisconnect,
13687     operationDowngrade: () => operationDowngrade,
13688     operationExtract: () => operationExtract,
13689     operationMerge: () => operationMerge,
13690     operationMove: () => operationMove,
13691     operationOrthogonalize: () => operationOrthogonalize,
13692     operationPaste: () => operationPaste,
13693     operationReflectLong: () => operationReflectLong,
13694     operationReflectShort: () => operationReflectShort,
13695     operationReverse: () => operationReverse,
13696     operationRotate: () => operationRotate,
13697     operationSplit: () => operationSplit,
13698     operationStraighten: () => operationStraighten,
13699     osmAreaKeys: () => osmAreaKeys,
13700     osmChangeset: () => osmChangeset,
13701     osmEntity: () => osmEntity,
13702     osmFlowingWaterwayTagValues: () => osmFlowingWaterwayTagValues,
13703     osmInferRestriction: () => osmInferRestriction,
13704     osmIntersection: () => osmIntersection,
13705     osmIsInterestingTag: () => osmIsInterestingTag,
13706     osmJoinWays: () => osmJoinWays,
13707     osmLanes: () => osmLanes,
13708     osmLifecyclePrefixes: () => osmLifecyclePrefixes,
13709     osmNode: () => osmNode,
13710     osmNodeGeometriesForTags: () => osmNodeGeometriesForTags,
13711     osmNote: () => osmNote,
13712     osmPavedTags: () => osmPavedTags,
13713     osmPointTags: () => osmPointTags,
13714     osmRailwayTrackTagValues: () => osmRailwayTrackTagValues,
13715     osmRelation: () => osmRelation,
13716     osmRemoveLifecyclePrefix: () => osmRemoveLifecyclePrefix,
13717     osmRoutableHighwayTagValues: () => osmRoutableHighwayTagValues,
13718     osmSetAreaKeys: () => osmSetAreaKeys,
13719     osmSetPointTags: () => osmSetPointTags,
13720     osmSetVertexTags: () => osmSetVertexTags,
13721     osmTagSuggestingArea: () => osmTagSuggestingArea,
13722     osmTurn: () => osmTurn,
13723     osmVertexTags: () => osmVertexTags,
13724     osmWay: () => osmWay,
13725     prefs: () => corePreferences,
13726     presetCategory: () => presetCategory,
13727     presetCollection: () => presetCollection,
13728     presetField: () => presetField,
13729     presetIndex: () => presetIndex,
13730     presetManager: () => _mainPresetIndex,
13731     presetPreset: () => presetPreset,
13732     rendererBackground: () => rendererBackground,
13733     rendererBackgroundSource: () => rendererBackgroundSource,
13734     rendererFeatures: () => rendererFeatures,
13735     rendererMap: () => rendererMap,
13736     rendererPhotos: () => rendererPhotos,
13737     rendererTileLayer: () => rendererTileLayer,
13738     serviceKartaview: () => kartaview_default,
13739     serviceKeepRight: () => keepRight_default,
13740     serviceMapRules: () => maprules_default,
13741     serviceMapilio: () => mapilio_default,
13742     serviceMapillary: () => mapillary_default,
13743     serviceNominatim: () => nominatim_default,
13744     serviceNsi: () => nsi_default,
13745     serviceOsm: () => osm_default,
13746     serviceOsmWikibase: () => osm_wikibase_default,
13747     serviceOsmose: () => osmose_default,
13748     servicePanoramax: () => panoramax_default,
13749     serviceStreetside: () => streetside_default,
13750     serviceTaginfo: () => taginfo_default,
13751     serviceVectorTile: () => vector_tile_default,
13752     serviceVegbilder: () => vegbilder_default,
13753     serviceWikidata: () => wikidata_default,
13754     serviceWikipedia: () => wikipedia_default,
13755     services: () => services,
13756     setDebug: () => setDebug,
13757     svgAreas: () => svgAreas,
13758     svgData: () => svgData,
13759     svgDebug: () => svgDebug,
13760     svgDefs: () => svgDefs,
13761     svgGeolocate: () => svgGeolocate,
13762     svgIcon: () => svgIcon,
13763     svgKartaviewImages: () => svgKartaviewImages,
13764     svgKeepRight: () => svgKeepRight,
13765     svgLabels: () => svgLabels,
13766     svgLayers: () => svgLayers,
13767     svgLines: () => svgLines,
13768     svgMapilioImages: () => svgMapilioImages,
13769     svgMapillaryImages: () => svgMapillaryImages,
13770     svgMapillarySigns: () => svgMapillarySigns,
13771     svgMarkerSegments: () => svgMarkerSegments,
13772     svgMidpoints: () => svgMidpoints,
13773     svgNotes: () => svgNotes,
13774     svgOsm: () => svgOsm,
13775     svgPanoramaxImages: () => svgPanoramaxImages,
13776     svgPassiveVertex: () => svgPassiveVertex,
13777     svgPath: () => svgPath,
13778     svgPointTransform: () => svgPointTransform,
13779     svgPoints: () => svgPoints,
13780     svgRelationMemberTags: () => svgRelationMemberTags,
13781     svgSegmentWay: () => svgSegmentWay,
13782     svgStreetside: () => svgStreetside,
13783     svgTagClasses: () => svgTagClasses,
13784     svgTagPattern: () => svgTagPattern,
13785     svgTouch: () => svgTouch,
13786     svgTurns: () => svgTurns,
13787     svgVegbilder: () => svgVegbilder,
13788     svgVertices: () => svgVertices,
13789     t: () => _t,
13790     uiAccount: () => uiAccount,
13791     uiAttribution: () => uiAttribution,
13792     uiChangesetEditor: () => uiChangesetEditor,
13793     uiCmd: () => uiCmd,
13794     uiCombobox: () => uiCombobox,
13795     uiCommit: () => uiCommit,
13796     uiCommitWarnings: () => uiCommitWarnings,
13797     uiConfirm: () => uiConfirm,
13798     uiConflicts: () => uiConflicts,
13799     uiContributors: () => uiContributors,
13800     uiCurtain: () => uiCurtain,
13801     uiDataEditor: () => uiDataEditor,
13802     uiDataHeader: () => uiDataHeader,
13803     uiDisclosure: () => uiDisclosure,
13804     uiEditMenu: () => uiEditMenu,
13805     uiEntityEditor: () => uiEntityEditor,
13806     uiFeatureInfo: () => uiFeatureInfo,
13807     uiFeatureList: () => uiFeatureList,
13808     uiField: () => uiField,
13809     uiFieldAccess: () => uiFieldAccess,
13810     uiFieldAddress: () => uiFieldAddress,
13811     uiFieldCheck: () => uiFieldCheck,
13812     uiFieldColour: () => uiFieldText,
13813     uiFieldCombo: () => uiFieldCombo,
13814     uiFieldDefaultCheck: () => uiFieldCheck,
13815     uiFieldDirectionalCombo: () => uiFieldDirectionalCombo,
13816     uiFieldEmail: () => uiFieldText,
13817     uiFieldHelp: () => uiFieldHelp,
13818     uiFieldIdentifier: () => uiFieldText,
13819     uiFieldLanes: () => uiFieldLanes,
13820     uiFieldLocalized: () => uiFieldLocalized,
13821     uiFieldManyCombo: () => uiFieldCombo,
13822     uiFieldMultiCombo: () => uiFieldCombo,
13823     uiFieldNetworkCombo: () => uiFieldCombo,
13824     uiFieldNumber: () => uiFieldText,
13825     uiFieldOnewayCheck: () => uiFieldCheck,
13826     uiFieldRadio: () => uiFieldRadio,
13827     uiFieldRestrictions: () => uiFieldRestrictions,
13828     uiFieldRoadheight: () => uiFieldRoadheight,
13829     uiFieldRoadspeed: () => uiFieldRoadspeed,
13830     uiFieldSemiCombo: () => uiFieldCombo,
13831     uiFieldStructureRadio: () => uiFieldRadio,
13832     uiFieldTel: () => uiFieldText,
13833     uiFieldText: () => uiFieldText,
13834     uiFieldTextarea: () => uiFieldTextarea,
13835     uiFieldTypeCombo: () => uiFieldCombo,
13836     uiFieldUrl: () => uiFieldText,
13837     uiFieldWikidata: () => uiFieldWikidata,
13838     uiFieldWikipedia: () => uiFieldWikipedia,
13839     uiFields: () => uiFields,
13840     uiFlash: () => uiFlash,
13841     uiFormFields: () => uiFormFields,
13842     uiFullScreen: () => uiFullScreen,
13843     uiGeolocate: () => uiGeolocate,
13844     uiInfo: () => uiInfo,
13845     uiInfoPanels: () => uiInfoPanels,
13846     uiInit: () => uiInit,
13847     uiInspector: () => uiInspector,
13848     uiIntro: () => uiIntro,
13849     uiIssuesInfo: () => uiIssuesInfo,
13850     uiKeepRightDetails: () => uiKeepRightDetails,
13851     uiKeepRightEditor: () => uiKeepRightEditor,
13852     uiKeepRightHeader: () => uiKeepRightHeader,
13853     uiLasso: () => uiLasso,
13854     uiLengthIndicator: () => uiLengthIndicator,
13855     uiLoading: () => uiLoading,
13856     uiMapInMap: () => uiMapInMap,
13857     uiModal: () => uiModal,
13858     uiNoteComments: () => uiNoteComments,
13859     uiNoteEditor: () => uiNoteEditor,
13860     uiNoteHeader: () => uiNoteHeader,
13861     uiNoteReport: () => uiNoteReport,
13862     uiNotice: () => uiNotice,
13863     uiPaneBackground: () => uiPaneBackground,
13864     uiPaneHelp: () => uiPaneHelp,
13865     uiPaneIssues: () => uiPaneIssues,
13866     uiPaneMapData: () => uiPaneMapData,
13867     uiPanePreferences: () => uiPanePreferences,
13868     uiPanelBackground: () => uiPanelBackground,
13869     uiPanelHistory: () => uiPanelHistory,
13870     uiPanelLocation: () => uiPanelLocation,
13871     uiPanelMeasurement: () => uiPanelMeasurement,
13872     uiPopover: () => uiPopover,
13873     uiPresetIcon: () => uiPresetIcon,
13874     uiPresetList: () => uiPresetList,
13875     uiRestore: () => uiRestore,
13876     uiScale: () => uiScale,
13877     uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions,
13878     uiSectionBackgroundList: () => uiSectionBackgroundList,
13879     uiSectionBackgroundOffset: () => uiSectionBackgroundOffset,
13880     uiSectionChanges: () => uiSectionChanges,
13881     uiSectionDataLayers: () => uiSectionDataLayers,
13882     uiSectionEntityIssues: () => uiSectionEntityIssues,
13883     uiSectionFeatureType: () => uiSectionFeatureType,
13884     uiSectionMapFeatures: () => uiSectionMapFeatures,
13885     uiSectionMapStyleOptions: () => uiSectionMapStyleOptions,
13886     uiSectionOverlayList: () => uiSectionOverlayList,
13887     uiSectionPhotoOverlays: () => uiSectionPhotoOverlays,
13888     uiSectionPresetFields: () => uiSectionPresetFields,
13889     uiSectionPrivacy: () => uiSectionPrivacy,
13890     uiSectionRawMemberEditor: () => uiSectionRawMemberEditor,
13891     uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor,
13892     uiSectionRawTagEditor: () => uiSectionRawTagEditor,
13893     uiSectionSelectionList: () => uiSectionSelectionList,
13894     uiSectionValidationIssues: () => uiSectionValidationIssues,
13895     uiSectionValidationOptions: () => uiSectionValidationOptions,
13896     uiSectionValidationRules: () => uiSectionValidationRules,
13897     uiSectionValidationStatus: () => uiSectionValidationStatus,
13898     uiSettingsCustomBackground: () => uiSettingsCustomBackground,
13899     uiSettingsCustomData: () => uiSettingsCustomData,
13900     uiSidebar: () => uiSidebar,
13901     uiSourceSwitch: () => uiSourceSwitch,
13902     uiSpinner: () => uiSpinner,
13903     uiSplash: () => uiSplash,
13904     uiStatus: () => uiStatus,
13905     uiSuccess: () => uiSuccess,
13906     uiTagReference: () => uiTagReference,
13907     uiToggle: () => uiToggle,
13908     uiTooltip: () => uiTooltip,
13909     uiVersion: () => uiVersion,
13910     uiViewOnKeepRight: () => uiViewOnKeepRight,
13911     uiViewOnOSM: () => uiViewOnOSM,
13912     uiZoom: () => uiZoom,
13913     utilAesDecrypt: () => utilAesDecrypt,
13914     utilAesEncrypt: () => utilAesEncrypt,
13915     utilArrayChunk: () => utilArrayChunk,
13916     utilArrayDifference: () => utilArrayDifference,
13917     utilArrayFlatten: () => utilArrayFlatten,
13918     utilArrayGroupBy: () => utilArrayGroupBy,
13919     utilArrayIdentical: () => utilArrayIdentical,
13920     utilArrayIntersection: () => utilArrayIntersection,
13921     utilArrayUnion: () => utilArrayUnion,
13922     utilArrayUniq: () => utilArrayUniq,
13923     utilArrayUniqBy: () => utilArrayUniqBy,
13924     utilAsyncMap: () => utilAsyncMap,
13925     utilCheckTagDictionary: () => utilCheckTagDictionary,
13926     utilCleanOsmString: () => utilCleanOsmString,
13927     utilCleanTags: () => utilCleanTags,
13928     utilCombinedTags: () => utilCombinedTags,
13929     utilCompareIDs: () => utilCompareIDs,
13930     utilDeepMemberSelector: () => utilDeepMemberSelector,
13931     utilDetect: () => utilDetect,
13932     utilDisplayName: () => utilDisplayName,
13933     utilDisplayNameForPath: () => utilDisplayNameForPath,
13934     utilDisplayType: () => utilDisplayType,
13935     utilEditDistance: () => utilEditDistance,
13936     utilEntityAndDeepMemberIDs: () => utilEntityAndDeepMemberIDs,
13937     utilEntityOrDeepMemberSelector: () => utilEntityOrDeepMemberSelector,
13938     utilEntityOrMemberSelector: () => utilEntityOrMemberSelector,
13939     utilEntityRoot: () => utilEntityRoot,
13940     utilEntitySelector: () => utilEntitySelector,
13941     utilFastMouse: () => utilFastMouse,
13942     utilFunctor: () => utilFunctor,
13943     utilGetAllNodes: () => utilGetAllNodes,
13944     utilGetSetValue: () => utilGetSetValue,
13945     utilHashcode: () => utilHashcode,
13946     utilHighlightEntities: () => utilHighlightEntities,
13947     utilKeybinding: () => utilKeybinding,
13948     utilNoAuto: () => utilNoAuto,
13949     utilObjectOmit: () => utilObjectOmit,
13950     utilOldestID: () => utilOldestID,
13951     utilPrefixCSSProperty: () => utilPrefixCSSProperty,
13952     utilPrefixDOMProperty: () => utilPrefixDOMProperty,
13953     utilQsString: () => utilQsString,
13954     utilRebind: () => utilRebind,
13955     utilSafeClassName: () => utilSafeClassName,
13956     utilSessionMutex: () => utilSessionMutex,
13957     utilSetTransform: () => utilSetTransform,
13958     utilStringQs: () => utilStringQs,
13959     utilTagDiff: () => utilTagDiff,
13960     utilTagText: () => utilTagText,
13961     utilTiler: () => utilTiler,
13962     utilTotalExtent: () => utilTotalExtent,
13963     utilTriggerEvent: () => utilTriggerEvent,
13964     utilUnicodeCharsCount: () => utilUnicodeCharsCount,
13965     utilUnicodeCharsTruncated: () => utilUnicodeCharsTruncated,
13966     utilUniqueDomId: () => utilUniqueDomId,
13967     utilWrap: () => utilWrap,
13968     validationAlmostJunction: () => validationAlmostJunction,
13969     validationCloseNodes: () => validationCloseNodes,
13970     validationCrossingWays: () => validationCrossingWays,
13971     validationDisconnectedWay: () => validationDisconnectedWay,
13972     validationFormatting: () => validationFormatting,
13973     validationHelpRequest: () => validationHelpRequest,
13974     validationImpossibleOneway: () => validationImpossibleOneway,
13975     validationIncompatibleSource: () => validationIncompatibleSource,
13976     validationMaprules: () => validationMaprules,
13977     validationMismatchedGeometry: () => validationMismatchedGeometry,
13978     validationMissingRole: () => validationMissingRole,
13979     validationMissingTag: () => validationMissingTag,
13980     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
13981     validationOsmApiLimits: () => validationOsmApiLimits,
13982     validationOutdatedTags: () => validationOutdatedTags,
13983     validationPrivateData: () => validationPrivateData,
13984     validationSuspiciousName: () => validationSuspiciousName,
13985     validationUnsquareWay: () => validationUnsquareWay
13986   });
13987
13988   // modules/actions/add_entity.js
13989   function actionAddEntity(way) {
13990     return function(graph) {
13991       return graph.replace(way);
13992     };
13993   }
13994
13995   // modules/actions/reverse.js
13996   function actionReverse(entityID, options2) {
13997     var numeric = /^([+\-]?)(?=[\d.])/;
13998     var directionKey = /direction$/;
13999     var keyReplacements = [
14000       [/:right$/, ":left"],
14001       [/:left$/, ":right"],
14002       [/:forward$/, ":backward"],
14003       [/:backward$/, ":forward"],
14004       [/:right:/, ":left:"],
14005       [/:left:/, ":right:"],
14006       [/:forward:/, ":backward:"],
14007       [/:backward:/, ":forward:"]
14008     ];
14009     var valueReplacements = {
14010       left: "right",
14011       right: "left",
14012       up: "down",
14013       down: "up",
14014       forward: "backward",
14015       backward: "forward",
14016       forwards: "backward",
14017       backwards: "forward"
14018     };
14019     const keysToKeepUnchanged = [
14020       // https://github.com/openstreetmap/iD/issues/10736
14021       /^red_turn:(right|left):?/
14022     ];
14023     const keyValuesToKeepUnchanged = [
14024       {
14025         keyRegex: /^.*(_|:)?(description|name|note|website|ref|source|comment|watch|attribution)(_|:)?/,
14026         prerequisiteTags: [{}]
14027       },
14028       {
14029         // Turn lanes are left/right to key (not way) direction - #5674
14030         keyRegex: /^turn:lanes:?/,
14031         prerequisiteTags: [{}]
14032       },
14033       {
14034         // https://github.com/openstreetmap/iD/issues/10128
14035         keyRegex: /^side$/,
14036         prerequisiteTags: [{ highway: "cyclist_waiting_aid" }]
14037       }
14038     ];
14039     var roleReplacements = {
14040       forward: "backward",
14041       backward: "forward",
14042       forwards: "backward",
14043       backwards: "forward"
14044     };
14045     var onewayReplacements = {
14046       yes: "-1",
14047       "1": "-1",
14048       "-1": "yes"
14049     };
14050     var compassReplacements = {
14051       N: "S",
14052       NNE: "SSW",
14053       NE: "SW",
14054       ENE: "WSW",
14055       E: "W",
14056       ESE: "WNW",
14057       SE: "NW",
14058       SSE: "NNW",
14059       S: "N",
14060       SSW: "NNE",
14061       SW: "NE",
14062       WSW: "ENE",
14063       W: "E",
14064       WNW: "ESE",
14065       NW: "SE",
14066       NNW: "SSE"
14067     };
14068     function reverseKey(key) {
14069       if (keysToKeepUnchanged.some((keyRegex) => keyRegex.test(key))) {
14070         return key;
14071       }
14072       for (var i3 = 0; i3 < keyReplacements.length; ++i3) {
14073         var replacement = keyReplacements[i3];
14074         if (replacement[0].test(key)) {
14075           return key.replace(replacement[0], replacement[1]);
14076         }
14077       }
14078       return key;
14079     }
14080     function reverseValue(key, value, includeAbsolute, allTags) {
14081       for (let { keyRegex, prerequisiteTags } of keyValuesToKeepUnchanged) {
14082         if (keyRegex.test(key) && prerequisiteTags.some(
14083           (expectedTags) => Object.entries(expectedTags).every(([k2, v2]) => {
14084             return allTags[k2] && (v2 === "*" || allTags[k2] === v2);
14085           })
14086         )) {
14087           return value;
14088         }
14089       }
14090       if (key === "incline" && numeric.test(value)) {
14091         return value.replace(numeric, function(_2, sign2) {
14092           return sign2 === "-" ? "" : "-";
14093         });
14094       } else if (options2 && options2.reverseOneway && key === "oneway") {
14095         return onewayReplacements[value] || value;
14096       } else if (includeAbsolute && directionKey.test(key)) {
14097         return value.split(";").map((value2) => {
14098           if (compassReplacements[value2]) return compassReplacements[value2];
14099           var degrees3 = Number(value2);
14100           if (isFinite(degrees3)) {
14101             if (degrees3 < 180) {
14102               degrees3 += 180;
14103             } else {
14104               degrees3 -= 180;
14105             }
14106             return degrees3.toString();
14107           } else {
14108             return valueReplacements[value2] || value2;
14109           }
14110         }).join(";");
14111       }
14112       return valueReplacements[value] || value;
14113     }
14114     function reverseNodeTags(graph, nodeIDs) {
14115       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
14116         var node = graph.hasEntity(nodeIDs[i3]);
14117         if (!node || !Object.keys(node.tags).length) continue;
14118         var tags = {};
14119         for (var key in node.tags) {
14120           tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags);
14121         }
14122         graph = graph.replace(node.update({ tags }));
14123       }
14124       return graph;
14125     }
14126     function reverseWay(graph, way) {
14127       var nodes = way.nodes.slice().reverse();
14128       var tags = {};
14129       var role;
14130       for (var key in way.tags) {
14131         tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags);
14132       }
14133       graph.parentRelations(way).forEach(function(relation) {
14134         relation.members.forEach(function(member, index) {
14135           if (member.id === way.id && (role = roleReplacements[member.role])) {
14136             relation = relation.updateMember({ role }, index);
14137             graph = graph.replace(relation);
14138           }
14139         });
14140       });
14141       return reverseNodeTags(graph, nodes).replace(way.update({ nodes, tags }));
14142     }
14143     var action = function(graph) {
14144       var entity = graph.entity(entityID);
14145       if (entity.type === "way") {
14146         return reverseWay(graph, entity);
14147       }
14148       return reverseNodeTags(graph, [entityID]);
14149     };
14150     action.disabled = function(graph) {
14151       var entity = graph.hasEntity(entityID);
14152       if (!entity || entity.type === "way") return false;
14153       for (var key in entity.tags) {
14154         var value = entity.tags[key];
14155         if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) {
14156           return false;
14157         }
14158       }
14159       return "nondirectional_node";
14160     };
14161     action.entityID = function() {
14162       return entityID;
14163     };
14164     return action;
14165   }
14166
14167   // node_modules/d3-array/src/ascending.js
14168   function ascending(a2, b2) {
14169     return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
14170   }
14171
14172   // node_modules/d3-array/src/descending.js
14173   function descending(a2, b2) {
14174     return a2 == null || b2 == null ? NaN : b2 < a2 ? -1 : b2 > a2 ? 1 : b2 >= a2 ? 0 : NaN;
14175   }
14176
14177   // node_modules/d3-array/src/bisector.js
14178   function bisector(f2) {
14179     let compare1, compare2, delta;
14180     if (f2.length !== 2) {
14181       compare1 = ascending;
14182       compare2 = (d2, x2) => ascending(f2(d2), x2);
14183       delta = (d2, x2) => f2(d2) - x2;
14184     } else {
14185       compare1 = f2 === ascending || f2 === descending ? f2 : zero;
14186       compare2 = f2;
14187       delta = f2;
14188     }
14189     function left(a2, x2, lo = 0, hi = a2.length) {
14190       if (lo < hi) {
14191         if (compare1(x2, x2) !== 0) return hi;
14192         do {
14193           const mid = lo + hi >>> 1;
14194           if (compare2(a2[mid], x2) < 0) lo = mid + 1;
14195           else hi = mid;
14196         } while (lo < hi);
14197       }
14198       return lo;
14199     }
14200     function right(a2, x2, lo = 0, hi = a2.length) {
14201       if (lo < hi) {
14202         if (compare1(x2, x2) !== 0) return hi;
14203         do {
14204           const mid = lo + hi >>> 1;
14205           if (compare2(a2[mid], x2) <= 0) lo = mid + 1;
14206           else hi = mid;
14207         } while (lo < hi);
14208       }
14209       return lo;
14210     }
14211     function center(a2, x2, lo = 0, hi = a2.length) {
14212       const i3 = left(a2, x2, lo, hi - 1);
14213       return i3 > lo && delta(a2[i3 - 1], x2) > -delta(a2[i3], x2) ? i3 - 1 : i3;
14214     }
14215     return { left, center, right };
14216   }
14217   function zero() {
14218     return 0;
14219   }
14220
14221   // node_modules/d3-array/src/number.js
14222   function number(x2) {
14223     return x2 === null ? NaN : +x2;
14224   }
14225   function* numbers(values, valueof) {
14226     if (valueof === void 0) {
14227       for (let value of values) {
14228         if (value != null && (value = +value) >= value) {
14229           yield value;
14230         }
14231       }
14232     } else {
14233       let index = -1;
14234       for (let value of values) {
14235         if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
14236           yield value;
14237         }
14238       }
14239     }
14240   }
14241
14242   // node_modules/d3-array/src/bisect.js
14243   var ascendingBisect = bisector(ascending);
14244   var bisectRight = ascendingBisect.right;
14245   var bisectLeft = ascendingBisect.left;
14246   var bisectCenter = bisector(number).center;
14247   var bisect_default = bisectRight;
14248
14249   // node_modules/d3-array/src/fsum.js
14250   var Adder = class {
14251     constructor() {
14252       this._partials = new Float64Array(32);
14253       this._n = 0;
14254     }
14255     add(x2) {
14256       const p2 = this._partials;
14257       let i3 = 0;
14258       for (let j2 = 0; j2 < this._n && j2 < 32; j2++) {
14259         const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2);
14260         if (lo) p2[i3++] = lo;
14261         x2 = hi;
14262       }
14263       p2[i3] = x2;
14264       this._n = i3 + 1;
14265       return this;
14266     }
14267     valueOf() {
14268       const p2 = this._partials;
14269       let n3 = this._n, x2, y2, lo, hi = 0;
14270       if (n3 > 0) {
14271         hi = p2[--n3];
14272         while (n3 > 0) {
14273           x2 = hi;
14274           y2 = p2[--n3];
14275           hi = x2 + y2;
14276           lo = y2 - (hi - x2);
14277           if (lo) break;
14278         }
14279         if (n3 > 0 && (lo < 0 && p2[n3 - 1] < 0 || lo > 0 && p2[n3 - 1] > 0)) {
14280           y2 = lo * 2;
14281           x2 = hi + y2;
14282           if (y2 == x2 - hi) hi = x2;
14283         }
14284       }
14285       return hi;
14286     }
14287   };
14288
14289   // node_modules/d3-array/src/sort.js
14290   function compareDefined(compare2 = ascending) {
14291     if (compare2 === ascending) return ascendingDefined;
14292     if (typeof compare2 !== "function") throw new TypeError("compare is not a function");
14293     return (a2, b2) => {
14294       const x2 = compare2(a2, b2);
14295       if (x2 || x2 === 0) return x2;
14296       return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0);
14297     };
14298   }
14299   function ascendingDefined(a2, b2) {
14300     return (a2 == null || !(a2 >= a2)) - (b2 == null || !(b2 >= b2)) || (a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
14301   }
14302
14303   // node_modules/d3-array/src/ticks.js
14304   var e10 = Math.sqrt(50);
14305   var e5 = Math.sqrt(10);
14306   var e2 = Math.sqrt(2);
14307   function tickSpec(start2, stop, count) {
14308     const step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
14309     let i1, i22, inc;
14310     if (power < 0) {
14311       inc = Math.pow(10, -power) / factor;
14312       i1 = Math.round(start2 * inc);
14313       i22 = Math.round(stop * inc);
14314       if (i1 / inc < start2) ++i1;
14315       if (i22 / inc > stop) --i22;
14316       inc = -inc;
14317     } else {
14318       inc = Math.pow(10, power) * factor;
14319       i1 = Math.round(start2 / inc);
14320       i22 = Math.round(stop / inc);
14321       if (i1 * inc < start2) ++i1;
14322       if (i22 * inc > stop) --i22;
14323     }
14324     if (i22 < i1 && 0.5 <= count && count < 2) return tickSpec(start2, stop, count * 2);
14325     return [i1, i22, inc];
14326   }
14327   function ticks(start2, stop, count) {
14328     stop = +stop, start2 = +start2, count = +count;
14329     if (!(count > 0)) return [];
14330     if (start2 === stop) return [start2];
14331     const reverse = stop < start2, [i1, i22, inc] = reverse ? tickSpec(stop, start2, count) : tickSpec(start2, stop, count);
14332     if (!(i22 >= i1)) return [];
14333     const n3 = i22 - i1 + 1, ticks2 = new Array(n3);
14334     if (reverse) {
14335       if (inc < 0) for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i22 - i3) / -inc;
14336       else for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i22 - i3) * inc;
14337     } else {
14338       if (inc < 0) for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i1 + i3) / -inc;
14339       else for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i1 + i3) * inc;
14340     }
14341     return ticks2;
14342   }
14343   function tickIncrement(start2, stop, count) {
14344     stop = +stop, start2 = +start2, count = +count;
14345     return tickSpec(start2, stop, count)[2];
14346   }
14347   function tickStep(start2, stop, count) {
14348     stop = +stop, start2 = +start2, count = +count;
14349     const reverse = stop < start2, inc = reverse ? tickIncrement(stop, start2, count) : tickIncrement(start2, stop, count);
14350     return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
14351   }
14352
14353   // node_modules/d3-array/src/max.js
14354   function max(values, valueof) {
14355     let max3;
14356     if (valueof === void 0) {
14357       for (const value of values) {
14358         if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
14359           max3 = value;
14360         }
14361       }
14362     } else {
14363       let index = -1;
14364       for (let value of values) {
14365         if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
14366           max3 = value;
14367         }
14368       }
14369     }
14370     return max3;
14371   }
14372
14373   // node_modules/d3-array/src/min.js
14374   function min(values, valueof) {
14375     let min3;
14376     if (valueof === void 0) {
14377       for (const value of values) {
14378         if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
14379           min3 = value;
14380         }
14381       }
14382     } else {
14383       let index = -1;
14384       for (let value of values) {
14385         if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
14386           min3 = value;
14387         }
14388       }
14389     }
14390     return min3;
14391   }
14392
14393   // node_modules/d3-array/src/quickselect.js
14394   function quickselect(array2, k2, left = 0, right = Infinity, compare2) {
14395     k2 = Math.floor(k2);
14396     left = Math.floor(Math.max(0, left));
14397     right = Math.floor(Math.min(array2.length - 1, right));
14398     if (!(left <= k2 && k2 <= right)) return array2;
14399     compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
14400     while (right > left) {
14401       if (right - left > 600) {
14402         const n3 = right - left + 1;
14403         const m2 = k2 - left + 1;
14404         const z2 = Math.log(n3);
14405         const s2 = 0.5 * Math.exp(2 * z2 / 3);
14406         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
14407         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
14408         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
14409         quickselect(array2, k2, newLeft, newRight, compare2);
14410       }
14411       const t2 = array2[k2];
14412       let i3 = left;
14413       let j2 = right;
14414       swap(array2, left, k2);
14415       if (compare2(array2[right], t2) > 0) swap(array2, left, right);
14416       while (i3 < j2) {
14417         swap(array2, i3, j2), ++i3, --j2;
14418         while (compare2(array2[i3], t2) < 0) ++i3;
14419         while (compare2(array2[j2], t2) > 0) --j2;
14420       }
14421       if (compare2(array2[left], t2) === 0) swap(array2, left, j2);
14422       else ++j2, swap(array2, j2, right);
14423       if (j2 <= k2) left = j2 + 1;
14424       if (k2 <= j2) right = j2 - 1;
14425     }
14426     return array2;
14427   }
14428   function swap(array2, i3, j2) {
14429     const t2 = array2[i3];
14430     array2[i3] = array2[j2];
14431     array2[j2] = t2;
14432   }
14433
14434   // node_modules/d3-array/src/quantile.js
14435   function quantile(values, p2, valueof) {
14436     values = Float64Array.from(numbers(values, valueof));
14437     if (!(n3 = values.length) || isNaN(p2 = +p2)) return;
14438     if (p2 <= 0 || n3 < 2) return min(values);
14439     if (p2 >= 1) return max(values);
14440     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));
14441     return value0 + (value1 - value0) * (i3 - i0);
14442   }
14443
14444   // node_modules/d3-array/src/median.js
14445   function median(values, valueof) {
14446     return quantile(values, 0.5, valueof);
14447   }
14448
14449   // node_modules/d3-array/src/merge.js
14450   function* flatten(arrays) {
14451     for (const array2 of arrays) {
14452       yield* __yieldStar(array2);
14453     }
14454   }
14455   function merge(arrays) {
14456     return Array.from(flatten(arrays));
14457   }
14458
14459   // node_modules/d3-array/src/pairs.js
14460   function pairs(values, pairof = pair) {
14461     const pairs2 = [];
14462     let previous;
14463     let first = false;
14464     for (const value of values) {
14465       if (first) pairs2.push(pairof(previous, value));
14466       previous = value;
14467       first = true;
14468     }
14469     return pairs2;
14470   }
14471   function pair(a2, b2) {
14472     return [a2, b2];
14473   }
14474
14475   // node_modules/d3-array/src/range.js
14476   function range(start2, stop, step) {
14477     start2 = +start2, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n3 < 3 ? 1 : +step;
14478     var i3 = -1, n3 = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range3 = new Array(n3);
14479     while (++i3 < n3) {
14480       range3[i3] = start2 + i3 * step;
14481     }
14482     return range3;
14483   }
14484
14485   // node_modules/d3-geo/src/math.js
14486   var epsilon = 1e-6;
14487   var epsilon2 = 1e-12;
14488   var pi = Math.PI;
14489   var halfPi = pi / 2;
14490   var quarterPi = pi / 4;
14491   var tau = pi * 2;
14492   var degrees = 180 / pi;
14493   var radians = pi / 180;
14494   var abs = Math.abs;
14495   var atan = Math.atan;
14496   var atan2 = Math.atan2;
14497   var cos = Math.cos;
14498   var exp = Math.exp;
14499   var log = Math.log;
14500   var sin = Math.sin;
14501   var sign = Math.sign || function(x2) {
14502     return x2 > 0 ? 1 : x2 < 0 ? -1 : 0;
14503   };
14504   var sqrt = Math.sqrt;
14505   var tan = Math.tan;
14506   function acos(x2) {
14507     return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
14508   }
14509   function asin(x2) {
14510     return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
14511   }
14512
14513   // node_modules/d3-geo/src/noop.js
14514   function noop() {
14515   }
14516
14517   // node_modules/d3-geo/src/stream.js
14518   function streamGeometry(geometry, stream) {
14519     if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
14520       streamGeometryType[geometry.type](geometry, stream);
14521     }
14522   }
14523   var streamObjectType = {
14524     Feature: function(object, stream) {
14525       streamGeometry(object.geometry, stream);
14526     },
14527     FeatureCollection: function(object, stream) {
14528       var features = object.features, i3 = -1, n3 = features.length;
14529       while (++i3 < n3) streamGeometry(features[i3].geometry, stream);
14530     }
14531   };
14532   var streamGeometryType = {
14533     Sphere: function(object, stream) {
14534       stream.sphere();
14535     },
14536     Point: function(object, stream) {
14537       object = object.coordinates;
14538       stream.point(object[0], object[1], object[2]);
14539     },
14540     MultiPoint: function(object, stream) {
14541       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14542       while (++i3 < n3) object = coordinates[i3], stream.point(object[0], object[1], object[2]);
14543     },
14544     LineString: function(object, stream) {
14545       streamLine(object.coordinates, stream, 0);
14546     },
14547     MultiLineString: function(object, stream) {
14548       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14549       while (++i3 < n3) streamLine(coordinates[i3], stream, 0);
14550     },
14551     Polygon: function(object, stream) {
14552       streamPolygon(object.coordinates, stream);
14553     },
14554     MultiPolygon: function(object, stream) {
14555       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14556       while (++i3 < n3) streamPolygon(coordinates[i3], stream);
14557     },
14558     GeometryCollection: function(object, stream) {
14559       var geometries = object.geometries, i3 = -1, n3 = geometries.length;
14560       while (++i3 < n3) streamGeometry(geometries[i3], stream);
14561     }
14562   };
14563   function streamLine(coordinates, stream, closed) {
14564     var i3 = -1, n3 = coordinates.length - closed, coordinate;
14565     stream.lineStart();
14566     while (++i3 < n3) coordinate = coordinates[i3], stream.point(coordinate[0], coordinate[1], coordinate[2]);
14567     stream.lineEnd();
14568   }
14569   function streamPolygon(coordinates, stream) {
14570     var i3 = -1, n3 = coordinates.length;
14571     stream.polygonStart();
14572     while (++i3 < n3) streamLine(coordinates[i3], stream, 1);
14573     stream.polygonEnd();
14574   }
14575   function stream_default(object, stream) {
14576     if (object && streamObjectType.hasOwnProperty(object.type)) {
14577       streamObjectType[object.type](object, stream);
14578     } else {
14579       streamGeometry(object, stream);
14580     }
14581   }
14582
14583   // node_modules/d3-geo/src/area.js
14584   var areaRingSum = new Adder();
14585   var areaSum = new Adder();
14586   var lambda00;
14587   var phi00;
14588   var lambda0;
14589   var cosPhi0;
14590   var sinPhi0;
14591   var areaStream = {
14592     point: noop,
14593     lineStart: noop,
14594     lineEnd: noop,
14595     polygonStart: function() {
14596       areaRingSum = new Adder();
14597       areaStream.lineStart = areaRingStart;
14598       areaStream.lineEnd = areaRingEnd;
14599     },
14600     polygonEnd: function() {
14601       var areaRing = +areaRingSum;
14602       areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
14603       this.lineStart = this.lineEnd = this.point = noop;
14604     },
14605     sphere: function() {
14606       areaSum.add(tau);
14607     }
14608   };
14609   function areaRingStart() {
14610     areaStream.point = areaPointFirst;
14611   }
14612   function areaRingEnd() {
14613     areaPoint(lambda00, phi00);
14614   }
14615   function areaPointFirst(lambda, phi) {
14616     areaStream.point = areaPoint;
14617     lambda00 = lambda, phi00 = phi;
14618     lambda *= radians, phi *= radians;
14619     lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
14620   }
14621   function areaPoint(lambda, phi) {
14622     lambda *= radians, phi *= radians;
14623     phi = phi / 2 + quarterPi;
14624     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);
14625     areaRingSum.add(atan2(v2, u2));
14626     lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
14627   }
14628   function area_default(object) {
14629     areaSum = new Adder();
14630     stream_default(object, areaStream);
14631     return areaSum * 2;
14632   }
14633
14634   // node_modules/d3-geo/src/cartesian.js
14635   function spherical(cartesian2) {
14636     return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
14637   }
14638   function cartesian(spherical2) {
14639     var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
14640     return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
14641   }
14642   function cartesianDot(a2, b2) {
14643     return a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
14644   }
14645   function cartesianCross(a2, b2) {
14646     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]];
14647   }
14648   function cartesianAddInPlace(a2, b2) {
14649     a2[0] += b2[0], a2[1] += b2[1], a2[2] += b2[2];
14650   }
14651   function cartesianScale(vector, k2) {
14652     return [vector[0] * k2, vector[1] * k2, vector[2] * k2];
14653   }
14654   function cartesianNormalizeInPlace(d2) {
14655     var l2 = sqrt(d2[0] * d2[0] + d2[1] * d2[1] + d2[2] * d2[2]);
14656     d2[0] /= l2, d2[1] /= l2, d2[2] /= l2;
14657   }
14658
14659   // node_modules/d3-geo/src/bounds.js
14660   var lambda02;
14661   var phi0;
14662   var lambda1;
14663   var phi1;
14664   var lambda2;
14665   var lambda002;
14666   var phi002;
14667   var p0;
14668   var deltaSum;
14669   var ranges;
14670   var range2;
14671   var boundsStream = {
14672     point: boundsPoint,
14673     lineStart: boundsLineStart,
14674     lineEnd: boundsLineEnd,
14675     polygonStart: function() {
14676       boundsStream.point = boundsRingPoint;
14677       boundsStream.lineStart = boundsRingStart;
14678       boundsStream.lineEnd = boundsRingEnd;
14679       deltaSum = new Adder();
14680       areaStream.polygonStart();
14681     },
14682     polygonEnd: function() {
14683       areaStream.polygonEnd();
14684       boundsStream.point = boundsPoint;
14685       boundsStream.lineStart = boundsLineStart;
14686       boundsStream.lineEnd = boundsLineEnd;
14687       if (areaRingSum < 0) lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
14688       else if (deltaSum > epsilon) phi1 = 90;
14689       else if (deltaSum < -epsilon) phi0 = -90;
14690       range2[0] = lambda02, range2[1] = lambda1;
14691     },
14692     sphere: function() {
14693       lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
14694     }
14695   };
14696   function boundsPoint(lambda, phi) {
14697     ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
14698     if (phi < phi0) phi0 = phi;
14699     if (phi > phi1) phi1 = phi;
14700   }
14701   function linePoint(lambda, phi) {
14702     var p2 = cartesian([lambda * radians, phi * radians]);
14703     if (p0) {
14704       var normal = cartesianCross(p0, p2), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
14705       cartesianNormalizeInPlace(inflection);
14706       inflection = spherical(inflection);
14707       var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs(delta) > 180;
14708       if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
14709         phii = inflection[1] * degrees;
14710         if (phii > phi1) phi1 = phii;
14711       } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
14712         phii = -inflection[1] * degrees;
14713         if (phii < phi0) phi0 = phii;
14714       } else {
14715         if (phi < phi0) phi0 = phi;
14716         if (phi > phi1) phi1 = phi;
14717       }
14718       if (antimeridian) {
14719         if (lambda < lambda2) {
14720           if (angle(lambda02, lambda) > angle(lambda02, lambda1)) lambda1 = lambda;
14721         } else {
14722           if (angle(lambda, lambda1) > angle(lambda02, lambda1)) lambda02 = lambda;
14723         }
14724       } else {
14725         if (lambda1 >= lambda02) {
14726           if (lambda < lambda02) lambda02 = lambda;
14727           if (lambda > lambda1) lambda1 = lambda;
14728         } else {
14729           if (lambda > lambda2) {
14730             if (angle(lambda02, lambda) > angle(lambda02, lambda1)) lambda1 = lambda;
14731           } else {
14732             if (angle(lambda, lambda1) > angle(lambda02, lambda1)) lambda02 = lambda;
14733           }
14734         }
14735       }
14736     } else {
14737       ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
14738     }
14739     if (phi < phi0) phi0 = phi;
14740     if (phi > phi1) phi1 = phi;
14741     p0 = p2, lambda2 = lambda;
14742   }
14743   function boundsLineStart() {
14744     boundsStream.point = linePoint;
14745   }
14746   function boundsLineEnd() {
14747     range2[0] = lambda02, range2[1] = lambda1;
14748     boundsStream.point = boundsPoint;
14749     p0 = null;
14750   }
14751   function boundsRingPoint(lambda, phi) {
14752     if (p0) {
14753       var delta = lambda - lambda2;
14754       deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
14755     } else {
14756       lambda002 = lambda, phi002 = phi;
14757     }
14758     areaStream.point(lambda, phi);
14759     linePoint(lambda, phi);
14760   }
14761   function boundsRingStart() {
14762     areaStream.lineStart();
14763   }
14764   function boundsRingEnd() {
14765     boundsRingPoint(lambda002, phi002);
14766     areaStream.lineEnd();
14767     if (abs(deltaSum) > epsilon) lambda02 = -(lambda1 = 180);
14768     range2[0] = lambda02, range2[1] = lambda1;
14769     p0 = null;
14770   }
14771   function angle(lambda04, lambda12) {
14772     return (lambda12 -= lambda04) < 0 ? lambda12 + 360 : lambda12;
14773   }
14774   function rangeCompare(a2, b2) {
14775     return a2[0] - b2[0];
14776   }
14777   function rangeContains(range3, x2) {
14778     return range3[0] <= range3[1] ? range3[0] <= x2 && x2 <= range3[1] : x2 < range3[0] || range3[1] < x2;
14779   }
14780   function bounds_default(feature3) {
14781     var i3, n3, a2, b2, merged, deltaMax, delta;
14782     phi1 = lambda1 = -(lambda02 = phi0 = Infinity);
14783     ranges = [];
14784     stream_default(feature3, boundsStream);
14785     if (n3 = ranges.length) {
14786       ranges.sort(rangeCompare);
14787       for (i3 = 1, a2 = ranges[0], merged = [a2]; i3 < n3; ++i3) {
14788         b2 = ranges[i3];
14789         if (rangeContains(a2, b2[0]) || rangeContains(a2, b2[1])) {
14790           if (angle(a2[0], b2[1]) > angle(a2[0], a2[1])) a2[1] = b2[1];
14791           if (angle(b2[0], a2[1]) > angle(a2[0], a2[1])) a2[0] = b2[0];
14792         } else {
14793           merged.push(a2 = b2);
14794         }
14795       }
14796       for (deltaMax = -Infinity, n3 = merged.length - 1, i3 = 0, a2 = merged[n3]; i3 <= n3; a2 = b2, ++i3) {
14797         b2 = merged[i3];
14798         if ((delta = angle(a2[1], b2[0])) > deltaMax) deltaMax = delta, lambda02 = b2[0], lambda1 = a2[1];
14799       }
14800     }
14801     ranges = range2 = null;
14802     return lambda02 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda02, phi0], [lambda1, phi1]];
14803   }
14804
14805   // node_modules/d3-geo/src/compose.js
14806   function compose_default(a2, b2) {
14807     function compose(x2, y2) {
14808       return x2 = a2(x2, y2), b2(x2[0], x2[1]);
14809     }
14810     if (a2.invert && b2.invert) compose.invert = function(x2, y2) {
14811       return x2 = b2.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]);
14812     };
14813     return compose;
14814   }
14815
14816   // node_modules/d3-geo/src/rotation.js
14817   function rotationIdentity(lambda, phi) {
14818     if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
14819     return [lambda, phi];
14820   }
14821   rotationIdentity.invert = rotationIdentity;
14822   function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
14823     return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
14824   }
14825   function forwardRotationLambda(deltaLambda) {
14826     return function(lambda, phi) {
14827       lambda += deltaLambda;
14828       if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
14829       return [lambda, phi];
14830     };
14831   }
14832   function rotationLambda(deltaLambda) {
14833     var rotation = forwardRotationLambda(deltaLambda);
14834     rotation.invert = forwardRotationLambda(-deltaLambda);
14835     return rotation;
14836   }
14837   function rotationPhiGamma(deltaPhi, deltaGamma) {
14838     var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
14839     function rotation(lambda, phi) {
14840       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaPhi + x2 * sinDeltaPhi;
14841       return [
14842         atan2(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z2 * sinDeltaPhi),
14843         asin(k2 * cosDeltaGamma + y2 * sinDeltaGamma)
14844       ];
14845     }
14846     rotation.invert = function(lambda, phi) {
14847       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaGamma - y2 * sinDeltaGamma;
14848       return [
14849         atan2(y2 * cosDeltaGamma + z2 * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi),
14850         asin(k2 * cosDeltaPhi - x2 * sinDeltaPhi)
14851       ];
14852     };
14853     return rotation;
14854   }
14855   function rotation_default(rotate) {
14856     rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
14857     function forward(coordinates) {
14858       coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
14859       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
14860     }
14861     forward.invert = function(coordinates) {
14862       coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
14863       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
14864     };
14865     return forward;
14866   }
14867
14868   // node_modules/d3-geo/src/circle.js
14869   function circleStream(stream, radius, delta, direction, t0, t1) {
14870     if (!delta) return;
14871     var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
14872     if (t0 == null) {
14873       t0 = radius + direction * tau;
14874       t1 = radius - step / 2;
14875     } else {
14876       t0 = circleRadius(cosRadius, t0);
14877       t1 = circleRadius(cosRadius, t1);
14878       if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau;
14879     }
14880     for (var point, t2 = t0; direction > 0 ? t2 > t1 : t2 < t1; t2 -= step) {
14881       point = spherical([cosRadius, -sinRadius * cos(t2), -sinRadius * sin(t2)]);
14882       stream.point(point[0], point[1]);
14883     }
14884   }
14885   function circleRadius(cosRadius, point) {
14886     point = cartesian(point), point[0] -= cosRadius;
14887     cartesianNormalizeInPlace(point);
14888     var radius = acos(-point[1]);
14889     return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
14890   }
14891
14892   // node_modules/d3-geo/src/clip/buffer.js
14893   function buffer_default() {
14894     var lines = [], line;
14895     return {
14896       point: function(x2, y2, m2) {
14897         line.push([x2, y2, m2]);
14898       },
14899       lineStart: function() {
14900         lines.push(line = []);
14901       },
14902       lineEnd: noop,
14903       rejoin: function() {
14904         if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
14905       },
14906       result: function() {
14907         var result = lines;
14908         lines = [];
14909         line = null;
14910         return result;
14911       }
14912     };
14913   }
14914
14915   // node_modules/d3-geo/src/pointEqual.js
14916   function pointEqual_default(a2, b2) {
14917     return abs(a2[0] - b2[0]) < epsilon && abs(a2[1] - b2[1]) < epsilon;
14918   }
14919
14920   // node_modules/d3-geo/src/clip/rejoin.js
14921   function Intersection(point, points, other2, entry) {
14922     this.x = point;
14923     this.z = points;
14924     this.o = other2;
14925     this.e = entry;
14926     this.v = false;
14927     this.n = this.p = null;
14928   }
14929   function rejoin_default(segments, compareIntersection2, startInside, interpolate, stream) {
14930     var subject = [], clip = [], i3, n3;
14931     segments.forEach(function(segment) {
14932       if ((n4 = segment.length - 1) <= 0) return;
14933       var n4, p02 = segment[0], p1 = segment[n4], x2;
14934       if (pointEqual_default(p02, p1)) {
14935         if (!p02[2] && !p1[2]) {
14936           stream.lineStart();
14937           for (i3 = 0; i3 < n4; ++i3) stream.point((p02 = segment[i3])[0], p02[1]);
14938           stream.lineEnd();
14939           return;
14940         }
14941         p1[0] += 2 * epsilon;
14942       }
14943       subject.push(x2 = new Intersection(p02, segment, null, true));
14944       clip.push(x2.o = new Intersection(p02, null, x2, false));
14945       subject.push(x2 = new Intersection(p1, segment, null, false));
14946       clip.push(x2.o = new Intersection(p1, null, x2, true));
14947     });
14948     if (!subject.length) return;
14949     clip.sort(compareIntersection2);
14950     link(subject);
14951     link(clip);
14952     for (i3 = 0, n3 = clip.length; i3 < n3; ++i3) {
14953       clip[i3].e = startInside = !startInside;
14954     }
14955     var start2 = subject[0], points, point;
14956     while (1) {
14957       var current = start2, isSubject = true;
14958       while (current.v) if ((current = current.n) === start2) return;
14959       points = current.z;
14960       stream.lineStart();
14961       do {
14962         current.v = current.o.v = true;
14963         if (current.e) {
14964           if (isSubject) {
14965             for (i3 = 0, n3 = points.length; i3 < n3; ++i3) stream.point((point = points[i3])[0], point[1]);
14966           } else {
14967             interpolate(current.x, current.n.x, 1, stream);
14968           }
14969           current = current.n;
14970         } else {
14971           if (isSubject) {
14972             points = current.p.z;
14973             for (i3 = points.length - 1; i3 >= 0; --i3) stream.point((point = points[i3])[0], point[1]);
14974           } else {
14975             interpolate(current.x, current.p.x, -1, stream);
14976           }
14977           current = current.p;
14978         }
14979         current = current.o;
14980         points = current.z;
14981         isSubject = !isSubject;
14982       } while (!current.v);
14983       stream.lineEnd();
14984     }
14985   }
14986   function link(array2) {
14987     if (!(n3 = array2.length)) return;
14988     var n3, i3 = 0, a2 = array2[0], b2;
14989     while (++i3 < n3) {
14990       a2.n = b2 = array2[i3];
14991       b2.p = a2;
14992       a2 = b2;
14993     }
14994     a2.n = b2 = array2[0];
14995     b2.p = a2;
14996   }
14997
14998   // node_modules/d3-geo/src/polygonContains.js
14999   function longitude(point) {
15000     return abs(point[0]) <= pi ? point[0] : sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
15001   }
15002   function polygonContains_default(polygon2, point) {
15003     var lambda = longitude(point), phi = point[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
15004     var sum = new Adder();
15005     if (sinPhi === 1) phi = halfPi + epsilon;
15006     else if (sinPhi === -1) phi = -halfPi - epsilon;
15007     for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
15008       if (!(m2 = (ring = polygon2[i3]).length)) continue;
15009       var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02);
15010       for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) {
15011         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;
15012         sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta)));
15013         angle2 += antimeridian ? delta + sign2 * tau : delta;
15014         if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) {
15015           var arc = cartesianCross(cartesian(point0), cartesian(point1));
15016           cartesianNormalizeInPlace(arc);
15017           var intersection2 = cartesianCross(normal, arc);
15018           cartesianNormalizeInPlace(intersection2);
15019           var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]);
15020           if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
15021             winding += antimeridian ^ delta >= 0 ? 1 : -1;
15022           }
15023         }
15024       }
15025     }
15026     return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon2) ^ winding & 1;
15027   }
15028
15029   // node_modules/d3-geo/src/clip/index.js
15030   function clip_default(pointVisible, clipLine, interpolate, start2) {
15031     return function(sink) {
15032       var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon2, segments, ring;
15033       var clip = {
15034         point,
15035         lineStart,
15036         lineEnd,
15037         polygonStart: function() {
15038           clip.point = pointRing;
15039           clip.lineStart = ringStart;
15040           clip.lineEnd = ringEnd;
15041           segments = [];
15042           polygon2 = [];
15043         },
15044         polygonEnd: function() {
15045           clip.point = point;
15046           clip.lineStart = lineStart;
15047           clip.lineEnd = lineEnd;
15048           segments = merge(segments);
15049           var startInside = polygonContains_default(polygon2, start2);
15050           if (segments.length) {
15051             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15052             rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
15053           } else if (startInside) {
15054             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15055             sink.lineStart();
15056             interpolate(null, null, 1, sink);
15057             sink.lineEnd();
15058           }
15059           if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
15060           segments = polygon2 = null;
15061         },
15062         sphere: function() {
15063           sink.polygonStart();
15064           sink.lineStart();
15065           interpolate(null, null, 1, sink);
15066           sink.lineEnd();
15067           sink.polygonEnd();
15068         }
15069       };
15070       function point(lambda, phi) {
15071         if (pointVisible(lambda, phi)) sink.point(lambda, phi);
15072       }
15073       function pointLine(lambda, phi) {
15074         line.point(lambda, phi);
15075       }
15076       function lineStart() {
15077         clip.point = pointLine;
15078         line.lineStart();
15079       }
15080       function lineEnd() {
15081         clip.point = point;
15082         line.lineEnd();
15083       }
15084       function pointRing(lambda, phi) {
15085         ring.push([lambda, phi]);
15086         ringSink.point(lambda, phi);
15087       }
15088       function ringStart() {
15089         ringSink.lineStart();
15090         ring = [];
15091       }
15092       function ringEnd() {
15093         pointRing(ring[0][0], ring[0][1]);
15094         ringSink.lineEnd();
15095         var clean2 = ringSink.clean(), ringSegments = ringBuffer.result(), i3, n3 = ringSegments.length, m2, segment, point2;
15096         ring.pop();
15097         polygon2.push(ring);
15098         ring = null;
15099         if (!n3) return;
15100         if (clean2 & 1) {
15101           segment = ringSegments[0];
15102           if ((m2 = segment.length - 1) > 0) {
15103             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15104             sink.lineStart();
15105             for (i3 = 0; i3 < m2; ++i3) sink.point((point2 = segment[i3])[0], point2[1]);
15106             sink.lineEnd();
15107           }
15108           return;
15109         }
15110         if (n3 > 1 && clean2 & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
15111         segments.push(ringSegments.filter(validSegment));
15112       }
15113       return clip;
15114     };
15115   }
15116   function validSegment(segment) {
15117     return segment.length > 1;
15118   }
15119   function compareIntersection(a2, b2) {
15120     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]);
15121   }
15122
15123   // node_modules/d3-geo/src/clip/antimeridian.js
15124   var antimeridian_default = clip_default(
15125     function() {
15126       return true;
15127     },
15128     clipAntimeridianLine,
15129     clipAntimeridianInterpolate,
15130     [-pi, -halfPi]
15131   );
15132   function clipAntimeridianLine(stream) {
15133     var lambda04 = NaN, phi02 = NaN, sign0 = NaN, clean2;
15134     return {
15135       lineStart: function() {
15136         stream.lineStart();
15137         clean2 = 1;
15138       },
15139       point: function(lambda12, phi12) {
15140         var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda04);
15141         if (abs(delta - pi) < epsilon) {
15142           stream.point(lambda04, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
15143           stream.point(sign0, phi02);
15144           stream.lineEnd();
15145           stream.lineStart();
15146           stream.point(sign1, phi02);
15147           stream.point(lambda12, phi02);
15148           clean2 = 0;
15149         } else if (sign0 !== sign1 && delta >= pi) {
15150           if (abs(lambda04 - sign0) < epsilon) lambda04 -= sign0 * epsilon;
15151           if (abs(lambda12 - sign1) < epsilon) lambda12 -= sign1 * epsilon;
15152           phi02 = clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12);
15153           stream.point(sign0, phi02);
15154           stream.lineEnd();
15155           stream.lineStart();
15156           stream.point(sign1, phi02);
15157           clean2 = 0;
15158         }
15159         stream.point(lambda04 = lambda12, phi02 = phi12);
15160         sign0 = sign1;
15161       },
15162       lineEnd: function() {
15163         stream.lineEnd();
15164         lambda04 = phi02 = NaN;
15165       },
15166       clean: function() {
15167         return 2 - clean2;
15168       }
15169     };
15170   }
15171   function clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12) {
15172     var cosPhi03, cosPhi1, sinLambda0Lambda1 = sin(lambda04 - lambda12);
15173     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;
15174   }
15175   function clipAntimeridianInterpolate(from, to, direction, stream) {
15176     var phi;
15177     if (from == null) {
15178       phi = direction * halfPi;
15179       stream.point(-pi, phi);
15180       stream.point(0, phi);
15181       stream.point(pi, phi);
15182       stream.point(pi, 0);
15183       stream.point(pi, -phi);
15184       stream.point(0, -phi);
15185       stream.point(-pi, -phi);
15186       stream.point(-pi, 0);
15187       stream.point(-pi, phi);
15188     } else if (abs(from[0] - to[0]) > epsilon) {
15189       var lambda = from[0] < to[0] ? pi : -pi;
15190       phi = direction * lambda / 2;
15191       stream.point(-lambda, phi);
15192       stream.point(0, phi);
15193       stream.point(lambda, phi);
15194     } else {
15195       stream.point(to[0], to[1]);
15196     }
15197   }
15198
15199   // node_modules/d3-geo/src/clip/circle.js
15200   function circle_default(radius) {
15201     var cr = cos(radius), delta = 2 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
15202     function interpolate(from, to, direction, stream) {
15203       circleStream(stream, radius, delta, direction, from, to);
15204     }
15205     function visible(lambda, phi) {
15206       return cos(lambda) * cos(phi) > cr;
15207     }
15208     function clipLine(stream) {
15209       var point0, c0, v0, v00, clean2;
15210       return {
15211         lineStart: function() {
15212           v00 = v0 = false;
15213           clean2 = 1;
15214         },
15215         point: function(lambda, phi) {
15216           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;
15217           if (!point0 && (v00 = v0 = v2)) stream.lineStart();
15218           if (v2 !== v0) {
15219             point2 = intersect2(point0, point1);
15220             if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2))
15221               point1[2] = 1;
15222           }
15223           if (v2 !== v0) {
15224             clean2 = 0;
15225             if (v2) {
15226               stream.lineStart();
15227               point2 = intersect2(point1, point0);
15228               stream.point(point2[0], point2[1]);
15229             } else {
15230               point2 = intersect2(point0, point1);
15231               stream.point(point2[0], point2[1], 2);
15232               stream.lineEnd();
15233             }
15234             point0 = point2;
15235           } else if (notHemisphere && point0 && smallRadius ^ v2) {
15236             var t2;
15237             if (!(c2 & c0) && (t2 = intersect2(point1, point0, true))) {
15238               clean2 = 0;
15239               if (smallRadius) {
15240                 stream.lineStart();
15241                 stream.point(t2[0][0], t2[0][1]);
15242                 stream.point(t2[1][0], t2[1][1]);
15243                 stream.lineEnd();
15244               } else {
15245                 stream.point(t2[1][0], t2[1][1]);
15246                 stream.lineEnd();
15247                 stream.lineStart();
15248                 stream.point(t2[0][0], t2[0][1], 3);
15249               }
15250             }
15251           }
15252           if (v2 && (!point0 || !pointEqual_default(point0, point1))) {
15253             stream.point(point1[0], point1[1]);
15254           }
15255           point0 = point1, v0 = v2, c0 = c2;
15256         },
15257         lineEnd: function() {
15258           if (v0) stream.lineEnd();
15259           point0 = null;
15260         },
15261         // Rejoin first and last segments if there were intersections and the first
15262         // and last points were visible.
15263         clean: function() {
15264           return clean2 | (v00 && v0) << 1;
15265         }
15266       };
15267     }
15268     function intersect2(a2, b2, two) {
15269       var pa = cartesian(a2), pb = cartesian(b2);
15270       var n1 = [1, 0, 0], n22 = cartesianCross(pa, pb), n2n2 = cartesianDot(n22, n22), n1n2 = n22[0], determinant = n2n2 - n1n2 * n1n2;
15271       if (!determinant) return !two && a2;
15272       var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n22), A2 = cartesianScale(n1, c1), B2 = cartesianScale(n22, c2);
15273       cartesianAddInPlace(A2, B2);
15274       var u2 = n1xn2, w2 = cartesianDot(A2, u2), uu = cartesianDot(u2, u2), t2 = w2 * w2 - uu * (cartesianDot(A2, A2) - 1);
15275       if (t2 < 0) return;
15276       var t3 = sqrt(t2), q2 = cartesianScale(u2, (-w2 - t3) / uu);
15277       cartesianAddInPlace(q2, A2);
15278       q2 = spherical(q2);
15279       if (!two) return q2;
15280       var lambda04 = a2[0], lambda12 = b2[0], phi02 = a2[1], phi12 = b2[1], z2;
15281       if (lambda12 < lambda04) z2 = lambda04, lambda04 = lambda12, lambda12 = z2;
15282       var delta2 = lambda12 - lambda04, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
15283       if (!polar && phi12 < phi02) z2 = phi02, phi02 = phi12, phi12 = z2;
15284       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)) {
15285         var q1 = cartesianScale(u2, (-w2 + t3) / uu);
15286         cartesianAddInPlace(q1, A2);
15287         return [q2, spherical(q1)];
15288       }
15289     }
15290     function code(lambda, phi) {
15291       var r2 = smallRadius ? radius : pi - radius, code2 = 0;
15292       if (lambda < -r2) code2 |= 1;
15293       else if (lambda > r2) code2 |= 2;
15294       if (phi < -r2) code2 |= 4;
15295       else if (phi > r2) code2 |= 8;
15296       return code2;
15297     }
15298     return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
15299   }
15300
15301   // node_modules/d3-geo/src/clip/line.js
15302   function line_default(a2, b2, x05, y05, x12, y12) {
15303     var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r2;
15304     r2 = x05 - ax;
15305     if (!dx && r2 > 0) return;
15306     r2 /= dx;
15307     if (dx < 0) {
15308       if (r2 < t0) return;
15309       if (r2 < t1) t1 = r2;
15310     } else if (dx > 0) {
15311       if (r2 > t1) return;
15312       if (r2 > t0) t0 = r2;
15313     }
15314     r2 = x12 - ax;
15315     if (!dx && r2 < 0) return;
15316     r2 /= dx;
15317     if (dx < 0) {
15318       if (r2 > t1) return;
15319       if (r2 > t0) t0 = r2;
15320     } else if (dx > 0) {
15321       if (r2 < t0) return;
15322       if (r2 < t1) t1 = r2;
15323     }
15324     r2 = y05 - ay;
15325     if (!dy && r2 > 0) return;
15326     r2 /= dy;
15327     if (dy < 0) {
15328       if (r2 < t0) return;
15329       if (r2 < t1) t1 = r2;
15330     } else if (dy > 0) {
15331       if (r2 > t1) return;
15332       if (r2 > t0) t0 = r2;
15333     }
15334     r2 = y12 - ay;
15335     if (!dy && r2 < 0) return;
15336     r2 /= dy;
15337     if (dy < 0) {
15338       if (r2 > t1) return;
15339       if (r2 > t0) t0 = r2;
15340     } else if (dy > 0) {
15341       if (r2 < t0) return;
15342       if (r2 < t1) t1 = r2;
15343     }
15344     if (t0 > 0) a2[0] = ax + t0 * dx, a2[1] = ay + t0 * dy;
15345     if (t1 < 1) b2[0] = ax + t1 * dx, b2[1] = ay + t1 * dy;
15346     return true;
15347   }
15348
15349   // node_modules/d3-geo/src/clip/rectangle.js
15350   var clipMax = 1e9;
15351   var clipMin = -clipMax;
15352   function clipRectangle(x05, y05, x12, y12) {
15353     function visible(x2, y2) {
15354       return x05 <= x2 && x2 <= x12 && y05 <= y2 && y2 <= y12;
15355     }
15356     function interpolate(from, to, direction, stream) {
15357       var a2 = 0, a1 = 0;
15358       if (from == null || (a2 = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
15359         do
15360           stream.point(a2 === 0 || a2 === 3 ? x05 : x12, a2 > 1 ? y12 : y05);
15361         while ((a2 = (a2 + direction + 4) % 4) !== a1);
15362       } else {
15363         stream.point(to[0], to[1]);
15364       }
15365     }
15366     function corner(p2, direction) {
15367       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;
15368     }
15369     function compareIntersection2(a2, b2) {
15370       return comparePoint(a2.x, b2.x);
15371     }
15372     function comparePoint(a2, b2) {
15373       var ca = corner(a2, 1), cb = corner(b2, 1);
15374       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];
15375     }
15376     return function(stream) {
15377       var activeStream = stream, bufferStream = buffer_default(), segments, polygon2, ring, x__, y__, v__, x_, y_, v_, first, clean2;
15378       var clipStream = {
15379         point,
15380         lineStart,
15381         lineEnd,
15382         polygonStart,
15383         polygonEnd
15384       };
15385       function point(x2, y2) {
15386         if (visible(x2, y2)) activeStream.point(x2, y2);
15387       }
15388       function polygonInside() {
15389         var winding = 0;
15390         for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
15391           for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point2 = ring2[0], a0, a1, b0 = point2[0], b1 = point2[1]; j2 < m2; ++j2) {
15392             a0 = b0, a1 = b1, point2 = ring2[j2], b0 = point2[0], b1 = point2[1];
15393             if (a1 <= y12) {
15394               if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0)) ++winding;
15395             } else {
15396               if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x05 - a0)) --winding;
15397             }
15398           }
15399         }
15400         return winding;
15401       }
15402       function polygonStart() {
15403         activeStream = bufferStream, segments = [], polygon2 = [], clean2 = true;
15404       }
15405       function polygonEnd() {
15406         var startInside = polygonInside(), cleanInside = clean2 && startInside, visible2 = (segments = merge(segments)).length;
15407         if (cleanInside || visible2) {
15408           stream.polygonStart();
15409           if (cleanInside) {
15410             stream.lineStart();
15411             interpolate(null, null, 1, stream);
15412             stream.lineEnd();
15413           }
15414           if (visible2) {
15415             rejoin_default(segments, compareIntersection2, startInside, interpolate, stream);
15416           }
15417           stream.polygonEnd();
15418         }
15419         activeStream = stream, segments = polygon2 = ring = null;
15420       }
15421       function lineStart() {
15422         clipStream.point = linePoint2;
15423         if (polygon2) polygon2.push(ring = []);
15424         first = true;
15425         v_ = false;
15426         x_ = y_ = NaN;
15427       }
15428       function lineEnd() {
15429         if (segments) {
15430           linePoint2(x__, y__);
15431           if (v__ && v_) bufferStream.rejoin();
15432           segments.push(bufferStream.result());
15433         }
15434         clipStream.point = point;
15435         if (v_) activeStream.lineEnd();
15436       }
15437       function linePoint2(x2, y2) {
15438         var v2 = visible(x2, y2);
15439         if (polygon2) ring.push([x2, y2]);
15440         if (first) {
15441           x__ = x2, y__ = y2, v__ = v2;
15442           first = false;
15443           if (v2) {
15444             activeStream.lineStart();
15445             activeStream.point(x2, y2);
15446           }
15447         } else {
15448           if (v2 && v_) activeStream.point(x2, y2);
15449           else {
15450             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))];
15451             if (line_default(a2, b2, x05, y05, x12, y12)) {
15452               if (!v_) {
15453                 activeStream.lineStart();
15454                 activeStream.point(a2[0], a2[1]);
15455               }
15456               activeStream.point(b2[0], b2[1]);
15457               if (!v2) activeStream.lineEnd();
15458               clean2 = false;
15459             } else if (v2) {
15460               activeStream.lineStart();
15461               activeStream.point(x2, y2);
15462               clean2 = false;
15463             }
15464           }
15465         }
15466         x_ = x2, y_ = y2, v_ = v2;
15467       }
15468       return clipStream;
15469     };
15470   }
15471
15472   // node_modules/d3-geo/src/length.js
15473   var lengthSum;
15474   var lambda03;
15475   var sinPhi02;
15476   var cosPhi02;
15477   var lengthStream = {
15478     sphere: noop,
15479     point: noop,
15480     lineStart: lengthLineStart,
15481     lineEnd: noop,
15482     polygonStart: noop,
15483     polygonEnd: noop
15484   };
15485   function lengthLineStart() {
15486     lengthStream.point = lengthPointFirst;
15487     lengthStream.lineEnd = lengthLineEnd;
15488   }
15489   function lengthLineEnd() {
15490     lengthStream.point = lengthStream.lineEnd = noop;
15491   }
15492   function lengthPointFirst(lambda, phi) {
15493     lambda *= radians, phi *= radians;
15494     lambda03 = lambda, sinPhi02 = sin(phi), cosPhi02 = cos(phi);
15495     lengthStream.point = lengthPoint;
15496   }
15497   function lengthPoint(lambda, phi) {
15498     lambda *= radians, phi *= radians;
15499     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;
15500     lengthSum.add(atan2(sqrt(x2 * x2 + y2 * y2), z2));
15501     lambda03 = lambda, sinPhi02 = sinPhi, cosPhi02 = cosPhi;
15502   }
15503   function length_default(object) {
15504     lengthSum = new Adder();
15505     stream_default(object, lengthStream);
15506     return +lengthSum;
15507   }
15508
15509   // node_modules/d3-geo/src/identity.js
15510   var identity_default = (x2) => x2;
15511
15512   // node_modules/d3-geo/src/path/area.js
15513   var areaSum2 = new Adder();
15514   var areaRingSum2 = new Adder();
15515   var x00;
15516   var y00;
15517   var x0;
15518   var y0;
15519   var areaStream2 = {
15520     point: noop,
15521     lineStart: noop,
15522     lineEnd: noop,
15523     polygonStart: function() {
15524       areaStream2.lineStart = areaRingStart2;
15525       areaStream2.lineEnd = areaRingEnd2;
15526     },
15527     polygonEnd: function() {
15528       areaStream2.lineStart = areaStream2.lineEnd = areaStream2.point = noop;
15529       areaSum2.add(abs(areaRingSum2));
15530       areaRingSum2 = new Adder();
15531     },
15532     result: function() {
15533       var area = areaSum2 / 2;
15534       areaSum2 = new Adder();
15535       return area;
15536     }
15537   };
15538   function areaRingStart2() {
15539     areaStream2.point = areaPointFirst2;
15540   }
15541   function areaPointFirst2(x2, y2) {
15542     areaStream2.point = areaPoint2;
15543     x00 = x0 = x2, y00 = y0 = y2;
15544   }
15545   function areaPoint2(x2, y2) {
15546     areaRingSum2.add(y0 * x2 - x0 * y2);
15547     x0 = x2, y0 = y2;
15548   }
15549   function areaRingEnd2() {
15550     areaPoint2(x00, y00);
15551   }
15552   var area_default2 = areaStream2;
15553
15554   // node_modules/d3-geo/src/path/bounds.js
15555   var x02 = Infinity;
15556   var y02 = x02;
15557   var x1 = -x02;
15558   var y1 = x1;
15559   var boundsStream2 = {
15560     point: boundsPoint2,
15561     lineStart: noop,
15562     lineEnd: noop,
15563     polygonStart: noop,
15564     polygonEnd: noop,
15565     result: function() {
15566       var bounds = [[x02, y02], [x1, y1]];
15567       x1 = y1 = -(y02 = x02 = Infinity);
15568       return bounds;
15569     }
15570   };
15571   function boundsPoint2(x2, y2) {
15572     if (x2 < x02) x02 = x2;
15573     if (x2 > x1) x1 = x2;
15574     if (y2 < y02) y02 = y2;
15575     if (y2 > y1) y1 = y2;
15576   }
15577   var bounds_default2 = boundsStream2;
15578
15579   // node_modules/d3-geo/src/path/centroid.js
15580   var X0 = 0;
15581   var Y0 = 0;
15582   var Z0 = 0;
15583   var X1 = 0;
15584   var Y1 = 0;
15585   var Z1 = 0;
15586   var X2 = 0;
15587   var Y2 = 0;
15588   var Z2 = 0;
15589   var x002;
15590   var y002;
15591   var x03;
15592   var y03;
15593   var centroidStream = {
15594     point: centroidPoint,
15595     lineStart: centroidLineStart,
15596     lineEnd: centroidLineEnd,
15597     polygonStart: function() {
15598       centroidStream.lineStart = centroidRingStart;
15599       centroidStream.lineEnd = centroidRingEnd;
15600     },
15601     polygonEnd: function() {
15602       centroidStream.point = centroidPoint;
15603       centroidStream.lineStart = centroidLineStart;
15604       centroidStream.lineEnd = centroidLineEnd;
15605     },
15606     result: function() {
15607       var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
15608       X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
15609       return centroid;
15610     }
15611   };
15612   function centroidPoint(x2, y2) {
15613     X0 += x2;
15614     Y0 += y2;
15615     ++Z0;
15616   }
15617   function centroidLineStart() {
15618     centroidStream.point = centroidPointFirstLine;
15619   }
15620   function centroidPointFirstLine(x2, y2) {
15621     centroidStream.point = centroidPointLine;
15622     centroidPoint(x03 = x2, y03 = y2);
15623   }
15624   function centroidPointLine(x2, y2) {
15625     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
15626     X1 += z2 * (x03 + x2) / 2;
15627     Y1 += z2 * (y03 + y2) / 2;
15628     Z1 += z2;
15629     centroidPoint(x03 = x2, y03 = y2);
15630   }
15631   function centroidLineEnd() {
15632     centroidStream.point = centroidPoint;
15633   }
15634   function centroidRingStart() {
15635     centroidStream.point = centroidPointFirstRing;
15636   }
15637   function centroidRingEnd() {
15638     centroidPointRing(x002, y002);
15639   }
15640   function centroidPointFirstRing(x2, y2) {
15641     centroidStream.point = centroidPointRing;
15642     centroidPoint(x002 = x03 = x2, y002 = y03 = y2);
15643   }
15644   function centroidPointRing(x2, y2) {
15645     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
15646     X1 += z2 * (x03 + x2) / 2;
15647     Y1 += z2 * (y03 + y2) / 2;
15648     Z1 += z2;
15649     z2 = y03 * x2 - x03 * y2;
15650     X2 += z2 * (x03 + x2);
15651     Y2 += z2 * (y03 + y2);
15652     Z2 += z2 * 3;
15653     centroidPoint(x03 = x2, y03 = y2);
15654   }
15655   var centroid_default = centroidStream;
15656
15657   // node_modules/d3-geo/src/path/context.js
15658   function PathContext(context) {
15659     this._context = context;
15660   }
15661   PathContext.prototype = {
15662     _radius: 4.5,
15663     pointRadius: function(_2) {
15664       return this._radius = _2, this;
15665     },
15666     polygonStart: function() {
15667       this._line = 0;
15668     },
15669     polygonEnd: function() {
15670       this._line = NaN;
15671     },
15672     lineStart: function() {
15673       this._point = 0;
15674     },
15675     lineEnd: function() {
15676       if (this._line === 0) this._context.closePath();
15677       this._point = NaN;
15678     },
15679     point: function(x2, y2) {
15680       switch (this._point) {
15681         case 0: {
15682           this._context.moveTo(x2, y2);
15683           this._point = 1;
15684           break;
15685         }
15686         case 1: {
15687           this._context.lineTo(x2, y2);
15688           break;
15689         }
15690         default: {
15691           this._context.moveTo(x2 + this._radius, y2);
15692           this._context.arc(x2, y2, this._radius, 0, tau);
15693           break;
15694         }
15695       }
15696     },
15697     result: noop
15698   };
15699
15700   // node_modules/d3-geo/src/path/measure.js
15701   var lengthSum2 = new Adder();
15702   var lengthRing;
15703   var x003;
15704   var y003;
15705   var x04;
15706   var y04;
15707   var lengthStream2 = {
15708     point: noop,
15709     lineStart: function() {
15710       lengthStream2.point = lengthPointFirst2;
15711     },
15712     lineEnd: function() {
15713       if (lengthRing) lengthPoint2(x003, y003);
15714       lengthStream2.point = noop;
15715     },
15716     polygonStart: function() {
15717       lengthRing = true;
15718     },
15719     polygonEnd: function() {
15720       lengthRing = null;
15721     },
15722     result: function() {
15723       var length2 = +lengthSum2;
15724       lengthSum2 = new Adder();
15725       return length2;
15726     }
15727   };
15728   function lengthPointFirst2(x2, y2) {
15729     lengthStream2.point = lengthPoint2;
15730     x003 = x04 = x2, y003 = y04 = y2;
15731   }
15732   function lengthPoint2(x2, y2) {
15733     x04 -= x2, y04 -= y2;
15734     lengthSum2.add(sqrt(x04 * x04 + y04 * y04));
15735     x04 = x2, y04 = y2;
15736   }
15737   var measure_default = lengthStream2;
15738
15739   // node_modules/d3-geo/src/path/string.js
15740   var cacheDigits;
15741   var cacheAppend;
15742   var cacheRadius;
15743   var cacheCircle;
15744   var _a, _b, _c, _d;
15745   var PathString = class {
15746     constructor(digits) {
15747       this._append = digits == null ? append : appendRound(digits);
15748       this._radius = 4.5;
15749       this._ = "";
15750     }
15751     pointRadius(_2) {
15752       this._radius = +_2;
15753       return this;
15754     }
15755     polygonStart() {
15756       this._line = 0;
15757     }
15758     polygonEnd() {
15759       this._line = NaN;
15760     }
15761     lineStart() {
15762       this._point = 0;
15763     }
15764     lineEnd() {
15765       if (this._line === 0) this._ += "Z";
15766       this._point = NaN;
15767     }
15768     point(x2, y2) {
15769       switch (this._point) {
15770         case 0: {
15771           this._append(_a || (_a = __template(["M", ",", ""])), x2, y2);
15772           this._point = 1;
15773           break;
15774         }
15775         case 1: {
15776           this._append(_b || (_b = __template(["L", ",", ""])), x2, y2);
15777           break;
15778         }
15779         default: {
15780           this._append(_c || (_c = __template(["M", ",", ""])), x2, y2);
15781           if (this._radius !== cacheRadius || this._append !== cacheAppend) {
15782             const r2 = this._radius;
15783             const s2 = this._;
15784             this._ = "";
15785             this._append(_d || (_d = __template(["m0,", "a", ",", " 0 1,1 0,", "a", ",", " 0 1,1 0,", "z"])), r2, r2, r2, -2 * r2, r2, r2, 2 * r2);
15786             cacheRadius = r2;
15787             cacheAppend = this._append;
15788             cacheCircle = this._;
15789             this._ = s2;
15790           }
15791           this._ += cacheCircle;
15792           break;
15793         }
15794       }
15795     }
15796     result() {
15797       const result = this._;
15798       this._ = "";
15799       return result.length ? result : null;
15800     }
15801   };
15802   function append(strings) {
15803     let i3 = 1;
15804     this._ += strings[0];
15805     for (const j2 = strings.length; i3 < j2; ++i3) {
15806       this._ += arguments[i3] + strings[i3];
15807     }
15808   }
15809   function appendRound(digits) {
15810     const d2 = Math.floor(digits);
15811     if (!(d2 >= 0)) throw new RangeError("invalid digits: ".concat(digits));
15812     if (d2 > 15) return append;
15813     if (d2 !== cacheDigits) {
15814       const k2 = 10 ** d2;
15815       cacheDigits = d2;
15816       cacheAppend = function append2(strings) {
15817         let i3 = 1;
15818         this._ += strings[0];
15819         for (const j2 = strings.length; i3 < j2; ++i3) {
15820           this._ += Math.round(arguments[i3] * k2) / k2 + strings[i3];
15821         }
15822       };
15823     }
15824     return cacheAppend;
15825   }
15826
15827   // node_modules/d3-geo/src/path/index.js
15828   function path_default(projection2, context) {
15829     let digits = 3, pointRadius = 4.5, projectionStream, contextStream;
15830     function path(object) {
15831       if (object) {
15832         if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
15833         stream_default(object, projectionStream(contextStream));
15834       }
15835       return contextStream.result();
15836     }
15837     path.area = function(object) {
15838       stream_default(object, projectionStream(area_default2));
15839       return area_default2.result();
15840     };
15841     path.measure = function(object) {
15842       stream_default(object, projectionStream(measure_default));
15843       return measure_default.result();
15844     };
15845     path.bounds = function(object) {
15846       stream_default(object, projectionStream(bounds_default2));
15847       return bounds_default2.result();
15848     };
15849     path.centroid = function(object) {
15850       stream_default(object, projectionStream(centroid_default));
15851       return centroid_default.result();
15852     };
15853     path.projection = function(_2) {
15854       if (!arguments.length) return projection2;
15855       projectionStream = _2 == null ? (projection2 = null, identity_default) : (projection2 = _2).stream;
15856       return path;
15857     };
15858     path.context = function(_2) {
15859       if (!arguments.length) return context;
15860       contextStream = _2 == null ? (context = null, new PathString(digits)) : new PathContext(context = _2);
15861       if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
15862       return path;
15863     };
15864     path.pointRadius = function(_2) {
15865       if (!arguments.length) return pointRadius;
15866       pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2);
15867       return path;
15868     };
15869     path.digits = function(_2) {
15870       if (!arguments.length) return digits;
15871       if (_2 == null) digits = null;
15872       else {
15873         const d2 = Math.floor(_2);
15874         if (!(d2 >= 0)) throw new RangeError("invalid digits: ".concat(_2));
15875         digits = d2;
15876       }
15877       if (context === null) contextStream = new PathString(digits);
15878       return path;
15879     };
15880     return path.projection(projection2).digits(digits).context(context);
15881   }
15882
15883   // node_modules/d3-geo/src/transform.js
15884   function transform_default(methods2) {
15885     return {
15886       stream: transformer(methods2)
15887     };
15888   }
15889   function transformer(methods2) {
15890     return function(stream) {
15891       var s2 = new TransformStream();
15892       for (var key in methods2) s2[key] = methods2[key];
15893       s2.stream = stream;
15894       return s2;
15895     };
15896   }
15897   function TransformStream() {
15898   }
15899   TransformStream.prototype = {
15900     constructor: TransformStream,
15901     point: function(x2, y2) {
15902       this.stream.point(x2, y2);
15903     },
15904     sphere: function() {
15905       this.stream.sphere();
15906     },
15907     lineStart: function() {
15908       this.stream.lineStart();
15909     },
15910     lineEnd: function() {
15911       this.stream.lineEnd();
15912     },
15913     polygonStart: function() {
15914       this.stream.polygonStart();
15915     },
15916     polygonEnd: function() {
15917       this.stream.polygonEnd();
15918     }
15919   };
15920
15921   // node_modules/d3-geo/src/projection/fit.js
15922   function fit(projection2, fitBounds, object) {
15923     var clip = projection2.clipExtent && projection2.clipExtent();
15924     projection2.scale(150).translate([0, 0]);
15925     if (clip != null) projection2.clipExtent(null);
15926     stream_default(object, projection2.stream(bounds_default2));
15927     fitBounds(bounds_default2.result());
15928     if (clip != null) projection2.clipExtent(clip);
15929     return projection2;
15930   }
15931   function fitExtent(projection2, extent, object) {
15932     return fit(projection2, function(b2) {
15933       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;
15934       projection2.scale(150 * k2).translate([x2, y2]);
15935     }, object);
15936   }
15937   function fitSize(projection2, size, object) {
15938     return fitExtent(projection2, [[0, 0], size], object);
15939   }
15940   function fitWidth(projection2, width, object) {
15941     return fit(projection2, function(b2) {
15942       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];
15943       projection2.scale(150 * k2).translate([x2, y2]);
15944     }, object);
15945   }
15946   function fitHeight(projection2, height, object) {
15947     return fit(projection2, function(b2) {
15948       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;
15949       projection2.scale(150 * k2).translate([x2, y2]);
15950     }, object);
15951   }
15952
15953   // node_modules/d3-geo/src/projection/resample.js
15954   var maxDepth = 16;
15955   var cosMinDistance = cos(30 * radians);
15956   function resample_default(project, delta2) {
15957     return +delta2 ? resample(project, delta2) : resampleNone(project);
15958   }
15959   function resampleNone(project) {
15960     return transformer({
15961       point: function(x2, y2) {
15962         x2 = project(x2, y2);
15963         this.stream.point(x2[0], x2[1]);
15964       }
15965     });
15966   }
15967   function resample(project, delta2) {
15968     function resampleLineTo(x05, y05, lambda04, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
15969       var dx = x12 - x05, dy = y12 - y05, d2 = dx * dx + dy * dy;
15970       if (d2 > 4 * delta2 && depth--) {
15971         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;
15972         if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
15973           resampleLineTo(x05, y05, lambda04, a0, b0, c0, x2, y2, lambda22, a2 /= m2, b2 /= m2, c2, depth, stream);
15974           stream.point(x2, y2);
15975           resampleLineTo(x2, y2, lambda22, a2, b2, c2, x12, y12, lambda12, a1, b1, c1, depth, stream);
15976         }
15977       }
15978     }
15979     return function(stream) {
15980       var lambda003, x004, y004, a00, b00, c00, lambda04, x05, y05, a0, b0, c0;
15981       var resampleStream = {
15982         point,
15983         lineStart,
15984         lineEnd,
15985         polygonStart: function() {
15986           stream.polygonStart();
15987           resampleStream.lineStart = ringStart;
15988         },
15989         polygonEnd: function() {
15990           stream.polygonEnd();
15991           resampleStream.lineStart = lineStart;
15992         }
15993       };
15994       function point(x2, y2) {
15995         x2 = project(x2, y2);
15996         stream.point(x2[0], x2[1]);
15997       }
15998       function lineStart() {
15999         x05 = NaN;
16000         resampleStream.point = linePoint2;
16001         stream.lineStart();
16002       }
16003       function linePoint2(lambda, phi) {
16004         var c2 = cartesian([lambda, phi]), p2 = project(lambda, phi);
16005         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);
16006         stream.point(x05, y05);
16007       }
16008       function lineEnd() {
16009         resampleStream.point = point;
16010         stream.lineEnd();
16011       }
16012       function ringStart() {
16013         lineStart();
16014         resampleStream.point = ringPoint;
16015         resampleStream.lineEnd = ringEnd;
16016       }
16017       function ringPoint(lambda, phi) {
16018         linePoint2(lambda003 = lambda, phi), x004 = x05, y004 = y05, a00 = a0, b00 = b0, c00 = c0;
16019         resampleStream.point = linePoint2;
16020       }
16021       function ringEnd() {
16022         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x004, y004, lambda003, a00, b00, c00, maxDepth, stream);
16023         resampleStream.lineEnd = lineEnd;
16024         lineEnd();
16025       }
16026       return resampleStream;
16027     };
16028   }
16029
16030   // node_modules/d3-geo/src/projection/index.js
16031   var transformRadians = transformer({
16032     point: function(x2, y2) {
16033       this.stream.point(x2 * radians, y2 * radians);
16034     }
16035   });
16036   function transformRotate(rotate) {
16037     return transformer({
16038       point: function(x2, y2) {
16039         var r2 = rotate(x2, y2);
16040         return this.stream.point(r2[0], r2[1]);
16041       }
16042     });
16043   }
16044   function scaleTranslate(k2, dx, dy, sx, sy) {
16045     function transform2(x2, y2) {
16046       x2 *= sx;
16047       y2 *= sy;
16048       return [dx + k2 * x2, dy - k2 * y2];
16049     }
16050     transform2.invert = function(x2, y2) {
16051       return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy];
16052     };
16053     return transform2;
16054   }
16055   function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) {
16056     if (!alpha) return scaleTranslate(k2, dx, dy, sx, sy);
16057     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;
16058     function transform2(x2, y2) {
16059       x2 *= sx;
16060       y2 *= sy;
16061       return [a2 * x2 - b2 * y2 + dx, dy - b2 * x2 - a2 * y2];
16062     }
16063     transform2.invert = function(x2, y2) {
16064       return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)];
16065     };
16066     return transform2;
16067   }
16068   function projection(project) {
16069     return projectionMutator(function() {
16070       return project;
16071     })();
16072   }
16073   function projectionMutator(projectAt) {
16074     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;
16075     function projection2(point) {
16076       return projectRotateTransform(point[0] * radians, point[1] * radians);
16077     }
16078     function invert(point) {
16079       point = projectRotateTransform.invert(point[0], point[1]);
16080       return point && [point[0] * degrees, point[1] * degrees];
16081     }
16082     projection2.stream = function(stream) {
16083       return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
16084     };
16085     projection2.preclip = function(_2) {
16086       return arguments.length ? (preclip = _2, theta = void 0, reset()) : preclip;
16087     };
16088     projection2.postclip = function(_2) {
16089       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
16090     };
16091     projection2.clipAngle = function(_2) {
16092       return arguments.length ? (preclip = +_2 ? circle_default(theta = _2 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
16093     };
16094     projection2.clipExtent = function(_2) {
16095       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]];
16096     };
16097     projection2.scale = function(_2) {
16098       return arguments.length ? (k2 = +_2, recenter()) : k2;
16099     };
16100     projection2.translate = function(_2) {
16101       return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2];
16102     };
16103     projection2.center = function(_2) {
16104       return arguments.length ? (lambda = _2[0] % 360 * radians, phi = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
16105     };
16106     projection2.rotate = function(_2) {
16107       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];
16108     };
16109     projection2.angle = function(_2) {
16110       return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees;
16111     };
16112     projection2.reflectX = function(_2) {
16113       return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0;
16114     };
16115     projection2.reflectY = function(_2) {
16116       return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0;
16117     };
16118     projection2.precision = function(_2) {
16119       return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _2 * _2), reset()) : sqrt(delta2);
16120     };
16121     projection2.fitExtent = function(extent, object) {
16122       return fitExtent(projection2, extent, object);
16123     };
16124     projection2.fitSize = function(size, object) {
16125       return fitSize(projection2, size, object);
16126     };
16127     projection2.fitWidth = function(width, object) {
16128       return fitWidth(projection2, width, object);
16129     };
16130     projection2.fitHeight = function(height, object) {
16131       return fitHeight(projection2, height, object);
16132     };
16133     function recenter() {
16134       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);
16135       rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
16136       projectTransform = compose_default(project, transform2);
16137       projectRotateTransform = compose_default(rotate, projectTransform);
16138       projectResample = resample_default(projectTransform, delta2);
16139       return reset();
16140     }
16141     function reset() {
16142       cache = cacheStream = null;
16143       return projection2;
16144     }
16145     return function() {
16146       project = projectAt.apply(this, arguments);
16147       projection2.invert = project.invert && invert;
16148       return recenter();
16149     };
16150   }
16151
16152   // node_modules/d3-geo/src/projection/mercator.js
16153   function mercatorRaw(lambda, phi) {
16154     return [lambda, log(tan((halfPi + phi) / 2))];
16155   }
16156   mercatorRaw.invert = function(x2, y2) {
16157     return [x2, 2 * atan(exp(y2)) - halfPi];
16158   };
16159   function mercator_default() {
16160     return mercatorProjection(mercatorRaw).scale(961 / tau);
16161   }
16162   function mercatorProjection(project) {
16163     var m2 = projection(project), center = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x05 = null, y05, x12, y12;
16164     m2.scale = function(_2) {
16165       return arguments.length ? (scale(_2), reclip()) : scale();
16166     };
16167     m2.translate = function(_2) {
16168       return arguments.length ? (translate(_2), reclip()) : translate();
16169     };
16170     m2.center = function(_2) {
16171       return arguments.length ? (center(_2), reclip()) : center();
16172     };
16173     m2.clipExtent = function(_2) {
16174       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]];
16175     };
16176     function reclip() {
16177       var k2 = pi * scale(), t2 = m2(rotation_default(m2.rotate()).invert([0, 0]));
16178       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)]]);
16179     }
16180     return reclip();
16181   }
16182
16183   // node_modules/d3-geo/src/projection/identity.js
16184   function identity_default2() {
16185     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({
16186       point: function(x2, y2) {
16187         var p2 = projection2([x2, y2]);
16188         this.stream.point(p2[0], p2[1]);
16189       }
16190     }), postclip = identity_default, cache, cacheStream;
16191     function reset() {
16192       kx = k2 * sx;
16193       ky = k2 * sy;
16194       cache = cacheStream = null;
16195       return projection2;
16196     }
16197     function projection2(p2) {
16198       var x2 = p2[0] * kx, y2 = p2[1] * ky;
16199       if (alpha) {
16200         var t2 = y2 * ca - x2 * sa;
16201         x2 = x2 * ca + y2 * sa;
16202         y2 = t2;
16203       }
16204       return [x2 + tx, y2 + ty];
16205     }
16206     projection2.invert = function(p2) {
16207       var x2 = p2[0] - tx, y2 = p2[1] - ty;
16208       if (alpha) {
16209         var t2 = y2 * ca + x2 * sa;
16210         x2 = x2 * ca - y2 * sa;
16211         y2 = t2;
16212       }
16213       return [x2 / kx, y2 / ky];
16214     };
16215     projection2.stream = function(stream) {
16216       return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
16217     };
16218     projection2.postclip = function(_2) {
16219       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
16220     };
16221     projection2.clipExtent = function(_2) {
16222       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]];
16223     };
16224     projection2.scale = function(_2) {
16225       return arguments.length ? (k2 = +_2, reset()) : k2;
16226     };
16227     projection2.translate = function(_2) {
16228       return arguments.length ? (tx = +_2[0], ty = +_2[1], reset()) : [tx, ty];
16229     };
16230     projection2.angle = function(_2) {
16231       return arguments.length ? (alpha = _2 % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
16232     };
16233     projection2.reflectX = function(_2) {
16234       return arguments.length ? (sx = _2 ? -1 : 1, reset()) : sx < 0;
16235     };
16236     projection2.reflectY = function(_2) {
16237       return arguments.length ? (sy = _2 ? -1 : 1, reset()) : sy < 0;
16238     };
16239     projection2.fitExtent = function(extent, object) {
16240       return fitExtent(projection2, extent, object);
16241     };
16242     projection2.fitSize = function(size, object) {
16243       return fitSize(projection2, size, object);
16244     };
16245     projection2.fitWidth = function(width, object) {
16246       return fitWidth(projection2, width, object);
16247     };
16248     projection2.fitHeight = function(height, object) {
16249       return fitHeight(projection2, height, object);
16250     };
16251     return projection2;
16252   }
16253
16254   // modules/geo/geo.js
16255   var TAU = 2 * Math.PI;
16256   var EQUATORIAL_RADIUS = 6378137;
16257   var POLAR_RADIUS = 63567523e-1;
16258   function geoLatToMeters(dLat) {
16259     return dLat * (TAU * POLAR_RADIUS / 360);
16260   }
16261   function geoLonToMeters(dLon, atLat) {
16262     return Math.abs(atLat) >= 90 ? 0 : dLon * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(atLat * (Math.PI / 180)));
16263   }
16264   function geoMetersToLat(m2) {
16265     return m2 / (TAU * POLAR_RADIUS / 360);
16266   }
16267   function geoMetersToLon(m2, atLat) {
16268     return Math.abs(atLat) >= 90 ? 0 : m2 / (TAU * EQUATORIAL_RADIUS / 360) / Math.abs(Math.cos(atLat * (Math.PI / 180)));
16269   }
16270   function geoMetersToOffset(meters, tileSize) {
16271     tileSize = tileSize || 256;
16272     return [
16273       meters[0] * tileSize / (TAU * EQUATORIAL_RADIUS),
16274       -meters[1] * tileSize / (TAU * POLAR_RADIUS)
16275     ];
16276   }
16277   function geoOffsetToMeters(offset, tileSize) {
16278     tileSize = tileSize || 256;
16279     return [
16280       offset[0] * TAU * EQUATORIAL_RADIUS / tileSize,
16281       -offset[1] * TAU * POLAR_RADIUS / tileSize
16282     ];
16283   }
16284   function geoSphericalDistance(a2, b2) {
16285     var x2 = geoLonToMeters(a2[0] - b2[0], (a2[1] + b2[1]) / 2);
16286     var y2 = geoLatToMeters(a2[1] - b2[1]);
16287     return Math.sqrt(x2 * x2 + y2 * y2);
16288   }
16289   function geoScaleToZoom(k2, tileSize) {
16290     tileSize = tileSize || 256;
16291     var log2ts = Math.log(tileSize) * Math.LOG2E;
16292     return Math.log(k2 * TAU) / Math.LN2 - log2ts;
16293   }
16294   function geoZoomToScale(z2, tileSize) {
16295     tileSize = tileSize || 256;
16296     return tileSize * Math.pow(2, z2) / TAU;
16297   }
16298   function geoSphericalClosestNode(nodes, point) {
16299     var minDistance = Infinity, distance;
16300     var indexOfMin;
16301     for (var i3 in nodes) {
16302       distance = geoSphericalDistance(nodes[i3].loc, point);
16303       if (distance < minDistance) {
16304         minDistance = distance;
16305         indexOfMin = i3;
16306       }
16307     }
16308     if (indexOfMin !== void 0) {
16309       return { index: indexOfMin, distance: minDistance, node: nodes[indexOfMin] };
16310     } else {
16311       return null;
16312     }
16313   }
16314
16315   // modules/geo/extent.js
16316   function geoExtent(min3, max3) {
16317     if (!(this instanceof geoExtent)) {
16318       return new geoExtent(min3, max3);
16319     } else if (min3 instanceof geoExtent) {
16320       return min3;
16321     } else if (min3 && min3.length === 2 && min3[0].length === 2 && min3[1].length === 2) {
16322       this[0] = min3[0];
16323       this[1] = min3[1];
16324     } else {
16325       this[0] = min3 || [Infinity, Infinity];
16326       this[1] = max3 || min3 || [-Infinity, -Infinity];
16327     }
16328   }
16329   geoExtent.prototype = new Array(2);
16330   Object.assign(geoExtent.prototype, {
16331     equals: function(obj) {
16332       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];
16333     },
16334     extend: function(obj) {
16335       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16336       return geoExtent(
16337         [Math.min(obj[0][0], this[0][0]), Math.min(obj[0][1], this[0][1])],
16338         [Math.max(obj[1][0], this[1][0]), Math.max(obj[1][1], this[1][1])]
16339       );
16340     },
16341     _extend: function(extent) {
16342       this[0][0] = Math.min(extent[0][0], this[0][0]);
16343       this[0][1] = Math.min(extent[0][1], this[0][1]);
16344       this[1][0] = Math.max(extent[1][0], this[1][0]);
16345       this[1][1] = Math.max(extent[1][1], this[1][1]);
16346     },
16347     area: function() {
16348       return Math.abs((this[1][0] - this[0][0]) * (this[1][1] - this[0][1]));
16349     },
16350     center: function() {
16351       return [(this[0][0] + this[1][0]) / 2, (this[0][1] + this[1][1]) / 2];
16352     },
16353     rectangle: function() {
16354       return [this[0][0], this[0][1], this[1][0], this[1][1]];
16355     },
16356     bbox: function() {
16357       return { minX: this[0][0], minY: this[0][1], maxX: this[1][0], maxY: this[1][1] };
16358     },
16359     polygon: function() {
16360       return [
16361         [this[0][0], this[0][1]],
16362         [this[0][0], this[1][1]],
16363         [this[1][0], this[1][1]],
16364         [this[1][0], this[0][1]],
16365         [this[0][0], this[0][1]]
16366       ];
16367     },
16368     contains: function(obj) {
16369       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16370       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];
16371     },
16372     intersects: function(obj) {
16373       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16374       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];
16375     },
16376     intersection: function(obj) {
16377       if (!this.intersects(obj)) return new geoExtent();
16378       return new geoExtent(
16379         [Math.max(obj[0][0], this[0][0]), Math.max(obj[0][1], this[0][1])],
16380         [Math.min(obj[1][0], this[1][0]), Math.min(obj[1][1], this[1][1])]
16381       );
16382     },
16383     percentContainedIn: function(obj) {
16384       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16385       var a1 = this.intersection(obj).area();
16386       var a2 = this.area();
16387       if (a1 === Infinity || a2 === Infinity) {
16388         return 0;
16389       } else if (a1 === 0 || a2 === 0) {
16390         if (obj.contains(this)) {
16391           return 1;
16392         }
16393         return 0;
16394       } else {
16395         return a1 / a2;
16396       }
16397     },
16398     padByMeters: function(meters) {
16399       var dLat = geoMetersToLat(meters);
16400       var dLon = geoMetersToLon(meters, this.center()[1]);
16401       return geoExtent(
16402         [this[0][0] - dLon, this[0][1] - dLat],
16403         [this[1][0] + dLon, this[1][1] + dLat]
16404       );
16405     },
16406     toParam: function() {
16407       return this.rectangle().join(",");
16408     },
16409     split: function() {
16410       const center = this.center();
16411       return [
16412         geoExtent(this[0], center),
16413         geoExtent([center[0], this[0][1]], [this[1][0], center[1]]),
16414         geoExtent(center, this[1]),
16415         geoExtent([this[0][0], center[1]], [center[0], this[1][1]])
16416       ];
16417     }
16418   });
16419
16420   // node_modules/d3-polygon/src/area.js
16421   function area_default3(polygon2) {
16422     var i3 = -1, n3 = polygon2.length, a2, b2 = polygon2[n3 - 1], area = 0;
16423     while (++i3 < n3) {
16424       a2 = b2;
16425       b2 = polygon2[i3];
16426       area += a2[1] * b2[0] - a2[0] * b2[1];
16427     }
16428     return area / 2;
16429   }
16430
16431   // node_modules/d3-polygon/src/centroid.js
16432   function centroid_default2(polygon2) {
16433     var i3 = -1, n3 = polygon2.length, x2 = 0, y2 = 0, a2, b2 = polygon2[n3 - 1], c2, k2 = 0;
16434     while (++i3 < n3) {
16435       a2 = b2;
16436       b2 = polygon2[i3];
16437       k2 += c2 = a2[0] * b2[1] - b2[0] * a2[1];
16438       x2 += (a2[0] + b2[0]) * c2;
16439       y2 += (a2[1] + b2[1]) * c2;
16440     }
16441     return k2 *= 3, [x2 / k2, y2 / k2];
16442   }
16443
16444   // node_modules/d3-polygon/src/cross.js
16445   function cross_default(a2, b2, c2) {
16446     return (b2[0] - a2[0]) * (c2[1] - a2[1]) - (b2[1] - a2[1]) * (c2[0] - a2[0]);
16447   }
16448
16449   // node_modules/d3-polygon/src/hull.js
16450   function lexicographicOrder(a2, b2) {
16451     return a2[0] - b2[0] || a2[1] - b2[1];
16452   }
16453   function computeUpperHullIndexes(points) {
16454     const n3 = points.length, indexes = [0, 1];
16455     let size = 2, i3;
16456     for (i3 = 2; i3 < n3; ++i3) {
16457       while (size > 1 && cross_default(points[indexes[size - 2]], points[indexes[size - 1]], points[i3]) <= 0) --size;
16458       indexes[size++] = i3;
16459     }
16460     return indexes.slice(0, size);
16461   }
16462   function hull_default(points) {
16463     if ((n3 = points.length) < 3) return null;
16464     var i3, n3, sortedPoints = new Array(n3), flippedPoints = new Array(n3);
16465     for (i3 = 0; i3 < n3; ++i3) sortedPoints[i3] = [+points[i3][0], +points[i3][1], i3];
16466     sortedPoints.sort(lexicographicOrder);
16467     for (i3 = 0; i3 < n3; ++i3) flippedPoints[i3] = [sortedPoints[i3][0], -sortedPoints[i3][1]];
16468     var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints);
16469     var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull = [];
16470     for (i3 = upperIndexes.length - 1; i3 >= 0; --i3) hull.push(points[sortedPoints[upperIndexes[i3]][2]]);
16471     for (i3 = +skipLeft; i3 < lowerIndexes.length - skipRight; ++i3) hull.push(points[sortedPoints[lowerIndexes[i3]][2]]);
16472     return hull;
16473   }
16474
16475   // modules/geo/vector.js
16476   function geoVecEqual(a2, b2, epsilon3) {
16477     if (epsilon3) {
16478       return Math.abs(a2[0] - b2[0]) <= epsilon3 && Math.abs(a2[1] - b2[1]) <= epsilon3;
16479     } else {
16480       return a2[0] === b2[0] && a2[1] === b2[1];
16481     }
16482   }
16483   function geoVecAdd(a2, b2) {
16484     return [a2[0] + b2[0], a2[1] + b2[1]];
16485   }
16486   function geoVecSubtract(a2, b2) {
16487     return [a2[0] - b2[0], a2[1] - b2[1]];
16488   }
16489   function geoVecScale(a2, mag) {
16490     return [a2[0] * mag, a2[1] * mag];
16491   }
16492   function geoVecFloor(a2) {
16493     return [Math.floor(a2[0]), Math.floor(a2[1])];
16494   }
16495   function geoVecInterp(a2, b2, t2) {
16496     return [
16497       a2[0] + (b2[0] - a2[0]) * t2,
16498       a2[1] + (b2[1] - a2[1]) * t2
16499     ];
16500   }
16501   function geoVecLength(a2, b2) {
16502     return Math.sqrt(geoVecLengthSquare(a2, b2));
16503   }
16504   function geoVecLengthSquare(a2, b2) {
16505     b2 = b2 || [0, 0];
16506     var x2 = a2[0] - b2[0];
16507     var y2 = a2[1] - b2[1];
16508     return x2 * x2 + y2 * y2;
16509   }
16510   function geoVecNormalize(a2) {
16511     var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
16512     if (length2 !== 0) {
16513       return geoVecScale(a2, 1 / length2);
16514     }
16515     return [0, 0];
16516   }
16517   function geoVecAngle(a2, b2) {
16518     return Math.atan2(b2[1] - a2[1], b2[0] - a2[0]);
16519   }
16520   function geoVecDot(a2, b2, origin) {
16521     origin = origin || [0, 0];
16522     var p2 = geoVecSubtract(a2, origin);
16523     var q2 = geoVecSubtract(b2, origin);
16524     return p2[0] * q2[0] + p2[1] * q2[1];
16525   }
16526   function geoVecNormalizedDot(a2, b2, origin) {
16527     origin = origin || [0, 0];
16528     var p2 = geoVecNormalize(geoVecSubtract(a2, origin));
16529     var q2 = geoVecNormalize(geoVecSubtract(b2, origin));
16530     return geoVecDot(p2, q2);
16531   }
16532   function geoVecCross(a2, b2, origin) {
16533     origin = origin || [0, 0];
16534     var p2 = geoVecSubtract(a2, origin);
16535     var q2 = geoVecSubtract(b2, origin);
16536     return p2[0] * q2[1] - p2[1] * q2[0];
16537   }
16538   function geoVecProject(a2, points) {
16539     var min3 = Infinity;
16540     var idx;
16541     var target;
16542     for (var i3 = 0; i3 < points.length - 1; i3++) {
16543       var o2 = points[i3];
16544       var s2 = geoVecSubtract(points[i3 + 1], o2);
16545       var v2 = geoVecSubtract(a2, o2);
16546       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
16547       var p2;
16548       if (proj < 0) {
16549         p2 = o2;
16550       } else if (proj > 1) {
16551         p2 = points[i3 + 1];
16552       } else {
16553         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
16554       }
16555       var dist = geoVecLength(p2, a2);
16556       if (dist < min3) {
16557         min3 = dist;
16558         idx = i3 + 1;
16559         target = p2;
16560       }
16561     }
16562     if (idx !== void 0) {
16563       return { index: idx, distance: min3, target };
16564     } else {
16565       return null;
16566     }
16567   }
16568
16569   // modules/geo/geom.js
16570   function geoAngle(a2, b2, projection2) {
16571     return geoVecAngle(projection2(a2.loc), projection2(b2.loc));
16572   }
16573   function geoEdgeEqual(a2, b2) {
16574     return a2[0] === b2[0] && a2[1] === b2[1] || a2[0] === b2[1] && a2[1] === b2[0];
16575   }
16576   function geoRotate(points, angle2, around) {
16577     return points.map(function(point) {
16578       var radial = geoVecSubtract(point, around);
16579       return [
16580         radial[0] * Math.cos(angle2) - radial[1] * Math.sin(angle2) + around[0],
16581         radial[0] * Math.sin(angle2) + radial[1] * Math.cos(angle2) + around[1]
16582       ];
16583     });
16584   }
16585   function geoChooseEdge(nodes, point, projection2, activeID) {
16586     var dist = geoVecLength;
16587     var points = nodes.map(function(n3) {
16588       return projection2(n3.loc);
16589     });
16590     var ids = nodes.map(function(n3) {
16591       return n3.id;
16592     });
16593     var min3 = Infinity;
16594     var idx;
16595     var loc;
16596     for (var i3 = 0; i3 < points.length - 1; i3++) {
16597       if (ids[i3] === activeID || ids[i3 + 1] === activeID) continue;
16598       var o2 = points[i3];
16599       var s2 = geoVecSubtract(points[i3 + 1], o2);
16600       var v2 = geoVecSubtract(point, o2);
16601       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
16602       var p2;
16603       if (proj < 0) {
16604         p2 = o2;
16605       } else if (proj > 1) {
16606         p2 = points[i3 + 1];
16607       } else {
16608         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
16609       }
16610       var d2 = dist(p2, point);
16611       if (d2 < min3) {
16612         min3 = d2;
16613         idx = i3 + 1;
16614         loc = projection2.invert(p2);
16615       }
16616     }
16617     if (idx !== void 0) {
16618       return { index: idx, distance: min3, loc };
16619     } else {
16620       return null;
16621     }
16622   }
16623   function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) {
16624     var actives = [];
16625     var inactives = [];
16626     var j2, k2, n1, n22, segment;
16627     for (j2 = 0; j2 < activeNodes.length - 1; j2++) {
16628       n1 = activeNodes[j2];
16629       n22 = activeNodes[j2 + 1];
16630       segment = [n1.loc, n22.loc];
16631       if (n1.id === activeID || n22.id === activeID) {
16632         actives.push(segment);
16633       }
16634     }
16635     for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) {
16636       n1 = inactiveNodes[j2];
16637       n22 = inactiveNodes[j2 + 1];
16638       segment = [n1.loc, n22.loc];
16639       inactives.push(segment);
16640     }
16641     for (j2 = 0; j2 < actives.length; j2++) {
16642       for (k2 = 0; k2 < inactives.length; k2++) {
16643         var p2 = actives[j2];
16644         var q2 = inactives[k2];
16645         var hit = geoLineIntersection(p2, q2);
16646         if (hit) {
16647           return true;
16648         }
16649       }
16650     }
16651     return false;
16652   }
16653   function geoHasSelfIntersections(nodes, activeID) {
16654     var actives = [];
16655     var inactives = [];
16656     var j2, k2;
16657     for (j2 = 0; j2 < nodes.length - 1; j2++) {
16658       var n1 = nodes[j2];
16659       var n22 = nodes[j2 + 1];
16660       var segment = [n1.loc, n22.loc];
16661       if (n1.id === activeID || n22.id === activeID) {
16662         actives.push(segment);
16663       } else {
16664         inactives.push(segment);
16665       }
16666     }
16667     for (j2 = 0; j2 < actives.length; j2++) {
16668       for (k2 = 0; k2 < inactives.length; k2++) {
16669         var p2 = actives[j2];
16670         var q2 = inactives[k2];
16671         if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) {
16672           continue;
16673         }
16674         var hit = geoLineIntersection(p2, q2);
16675         if (hit) {
16676           var epsilon3 = 1e-8;
16677           if (geoVecEqual(p2[1], hit, epsilon3) || geoVecEqual(p2[0], hit, epsilon3) || geoVecEqual(q2[1], hit, epsilon3) || geoVecEqual(q2[0], hit, epsilon3)) {
16678             continue;
16679           } else {
16680             return true;
16681           }
16682         }
16683       }
16684     }
16685     return false;
16686   }
16687   function geoLineIntersection(a2, b2) {
16688     var p2 = [a2[0][0], a2[0][1]];
16689     var p22 = [a2[1][0], a2[1][1]];
16690     var q2 = [b2[0][0], b2[0][1]];
16691     var q22 = [b2[1][0], b2[1][1]];
16692     var r2 = geoVecSubtract(p22, p2);
16693     var s2 = geoVecSubtract(q22, q2);
16694     var uNumerator = geoVecCross(geoVecSubtract(q2, p2), r2);
16695     var denominator = geoVecCross(r2, s2);
16696     if (uNumerator && denominator) {
16697       var u2 = uNumerator / denominator;
16698       var t2 = geoVecCross(geoVecSubtract(q2, p2), s2) / denominator;
16699       if (t2 >= 0 && t2 <= 1 && u2 >= 0 && u2 <= 1) {
16700         return geoVecInterp(p2, p22, t2);
16701       }
16702     }
16703     return null;
16704   }
16705   function geoPathIntersections(path1, path2) {
16706     var intersections = [];
16707     for (var i3 = 0; i3 < path1.length - 1; i3++) {
16708       for (var j2 = 0; j2 < path2.length - 1; j2++) {
16709         var a2 = [path1[i3], path1[i3 + 1]];
16710         var b2 = [path2[j2], path2[j2 + 1]];
16711         var hit = geoLineIntersection(a2, b2);
16712         if (hit) {
16713           intersections.push(hit);
16714         }
16715       }
16716     }
16717     return intersections;
16718   }
16719   function geoPathHasIntersections(path1, path2) {
16720     for (var i3 = 0; i3 < path1.length - 1; i3++) {
16721       for (var j2 = 0; j2 < path2.length - 1; j2++) {
16722         var a2 = [path1[i3], path1[i3 + 1]];
16723         var b2 = [path2[j2], path2[j2 + 1]];
16724         var hit = geoLineIntersection(a2, b2);
16725         if (hit) {
16726           return true;
16727         }
16728       }
16729     }
16730     return false;
16731   }
16732   function geoPointInPolygon(point, polygon2) {
16733     var x2 = point[0];
16734     var y2 = point[1];
16735     var inside = false;
16736     for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) {
16737       var xi = polygon2[i3][0];
16738       var yi = polygon2[i3][1];
16739       var xj = polygon2[j2][0];
16740       var yj = polygon2[j2][1];
16741       var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
16742       if (intersect2) inside = !inside;
16743     }
16744     return inside;
16745   }
16746   function geoPolygonContainsPolygon(outer, inner) {
16747     return inner.every(function(point) {
16748       return geoPointInPolygon(point, outer);
16749     });
16750   }
16751   function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
16752     function testPoints(outer2, inner2) {
16753       return inner2.some(function(point) {
16754         return geoPointInPolygon(point, outer2);
16755       });
16756     }
16757     return testPoints(outer, inner) || !!checkSegments && geoPathHasIntersections(outer, inner);
16758   }
16759   function geoGetSmallestSurroundingRectangle(points) {
16760     var hull = hull_default(points);
16761     var centroid = centroid_default2(hull);
16762     var minArea = Infinity;
16763     var ssrExtent = [];
16764     var ssrAngle = 0;
16765     var c1 = hull[0];
16766     for (var i3 = 0; i3 <= hull.length - 1; i3++) {
16767       var c2 = i3 === hull.length - 1 ? hull[0] : hull[i3 + 1];
16768       var angle2 = Math.atan2(c2[1] - c1[1], c2[0] - c1[0]);
16769       var poly = geoRotate(hull, -angle2, centroid);
16770       var extent = poly.reduce(function(extent2, point) {
16771         return extent2.extend(geoExtent(point));
16772       }, geoExtent());
16773       var area = extent.area();
16774       if (area < minArea) {
16775         minArea = area;
16776         ssrExtent = extent;
16777         ssrAngle = angle2;
16778       }
16779       c1 = c2;
16780     }
16781     return {
16782       poly: geoRotate(ssrExtent.polygon(), ssrAngle, centroid),
16783       angle: ssrAngle
16784     };
16785   }
16786   function geoPathLength(path) {
16787     var length2 = 0;
16788     for (var i3 = 0; i3 < path.length - 1; i3++) {
16789       length2 += geoVecLength(path[i3], path[i3 + 1]);
16790     }
16791     return length2;
16792   }
16793   function geoViewportEdge(point, dimensions) {
16794     var pad2 = [80, 20, 50, 20];
16795     var x2 = 0;
16796     var y2 = 0;
16797     if (point[0] > dimensions[0] - pad2[1]) {
16798       x2 = -10;
16799     }
16800     if (point[0] < pad2[3]) {
16801       x2 = 10;
16802     }
16803     if (point[1] > dimensions[1] - pad2[2]) {
16804       y2 = -10;
16805     }
16806     if (point[1] < pad2[0]) {
16807       y2 = 10;
16808     }
16809     if (x2 || y2) {
16810       return [x2, y2];
16811     } else {
16812       return null;
16813     }
16814   }
16815
16816   // node_modules/d3-dispatch/src/dispatch.js
16817   var noop2 = { value: () => {
16818   } };
16819   function dispatch() {
16820     for (var i3 = 0, n3 = arguments.length, _2 = {}, t2; i3 < n3; ++i3) {
16821       if (!(t2 = arguments[i3] + "") || t2 in _2 || /[\s.]/.test(t2)) throw new Error("illegal type: " + t2);
16822       _2[t2] = [];
16823     }
16824     return new Dispatch(_2);
16825   }
16826   function Dispatch(_2) {
16827     this._ = _2;
16828   }
16829   function parseTypenames(typenames, types) {
16830     return typenames.trim().split(/^|\s+/).map(function(t2) {
16831       var name = "", i3 = t2.indexOf(".");
16832       if (i3 >= 0) name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
16833       if (t2 && !types.hasOwnProperty(t2)) throw new Error("unknown type: " + t2);
16834       return { type: t2, name };
16835     });
16836   }
16837   Dispatch.prototype = dispatch.prototype = {
16838     constructor: Dispatch,
16839     on: function(typename, callback) {
16840       var _2 = this._, T2 = parseTypenames(typename + "", _2), t2, i3 = -1, n3 = T2.length;
16841       if (arguments.length < 2) {
16842         while (++i3 < n3) if ((t2 = (typename = T2[i3]).type) && (t2 = get(_2[t2], typename.name))) return t2;
16843         return;
16844       }
16845       if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
16846       while (++i3 < n3) {
16847         if (t2 = (typename = T2[i3]).type) _2[t2] = set(_2[t2], typename.name, callback);
16848         else if (callback == null) for (t2 in _2) _2[t2] = set(_2[t2], typename.name, null);
16849       }
16850       return this;
16851     },
16852     copy: function() {
16853       var copy2 = {}, _2 = this._;
16854       for (var t2 in _2) copy2[t2] = _2[t2].slice();
16855       return new Dispatch(copy2);
16856     },
16857     call: function(type2, that) {
16858       if ((n3 = arguments.length - 2) > 0) for (var args = new Array(n3), i3 = 0, n3, t2; i3 < n3; ++i3) args[i3] = arguments[i3 + 2];
16859       if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2);
16860       for (t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3) t2[i3].value.apply(that, args);
16861     },
16862     apply: function(type2, that, args) {
16863       if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2);
16864       for (var t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3) t2[i3].value.apply(that, args);
16865     }
16866   };
16867   function get(type2, name) {
16868     for (var i3 = 0, n3 = type2.length, c2; i3 < n3; ++i3) {
16869       if ((c2 = type2[i3]).name === name) {
16870         return c2.value;
16871       }
16872     }
16873   }
16874   function set(type2, name, callback) {
16875     for (var i3 = 0, n3 = type2.length; i3 < n3; ++i3) {
16876       if (type2[i3].name === name) {
16877         type2[i3] = noop2, type2 = type2.slice(0, i3).concat(type2.slice(i3 + 1));
16878         break;
16879       }
16880     }
16881     if (callback != null) type2.push({ name, value: callback });
16882     return type2;
16883   }
16884   var dispatch_default = dispatch;
16885
16886   // node_modules/d3-selection/src/namespaces.js
16887   var xhtml = "http://www.w3.org/1999/xhtml";
16888   var namespaces_default = {
16889     svg: "http://www.w3.org/2000/svg",
16890     xhtml,
16891     xlink: "http://www.w3.org/1999/xlink",
16892     xml: "http://www.w3.org/XML/1998/namespace",
16893     xmlns: "http://www.w3.org/2000/xmlns/"
16894   };
16895
16896   // node_modules/d3-selection/src/namespace.js
16897   function namespace_default(name) {
16898     var prefix = name += "", i3 = prefix.indexOf(":");
16899     if (i3 >= 0 && (prefix = name.slice(0, i3)) !== "xmlns") name = name.slice(i3 + 1);
16900     return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name;
16901   }
16902
16903   // node_modules/d3-selection/src/creator.js
16904   function creatorInherit(name) {
16905     return function() {
16906       var document2 = this.ownerDocument, uri = this.namespaceURI;
16907       return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
16908     };
16909   }
16910   function creatorFixed(fullname) {
16911     return function() {
16912       return this.ownerDocument.createElementNS(fullname.space, fullname.local);
16913     };
16914   }
16915   function creator_default(name) {
16916     var fullname = namespace_default(name);
16917     return (fullname.local ? creatorFixed : creatorInherit)(fullname);
16918   }
16919
16920   // node_modules/d3-selection/src/selector.js
16921   function none() {
16922   }
16923   function selector_default(selector) {
16924     return selector == null ? none : function() {
16925       return this.querySelector(selector);
16926     };
16927   }
16928
16929   // node_modules/d3-selection/src/selection/select.js
16930   function select_default(select) {
16931     if (typeof select !== "function") select = selector_default(select);
16932     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
16933       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
16934         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
16935           if ("__data__" in node) subnode.__data__ = node.__data__;
16936           subgroup[i3] = subnode;
16937         }
16938       }
16939     }
16940     return new Selection(subgroups, this._parents);
16941   }
16942
16943   // node_modules/d3-selection/src/array.js
16944   function array(x2) {
16945     return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2);
16946   }
16947
16948   // node_modules/d3-selection/src/selectorAll.js
16949   function empty() {
16950     return [];
16951   }
16952   function selectorAll_default(selector) {
16953     return selector == null ? empty : function() {
16954       return this.querySelectorAll(selector);
16955     };
16956   }
16957
16958   // node_modules/d3-selection/src/selection/selectAll.js
16959   function arrayAll(select) {
16960     return function() {
16961       return array(select.apply(this, arguments));
16962     };
16963   }
16964   function selectAll_default(select) {
16965     if (typeof select === "function") select = arrayAll(select);
16966     else select = selectorAll_default(select);
16967     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
16968       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
16969         if (node = group[i3]) {
16970           subgroups.push(select.call(node, node.__data__, i3, group));
16971           parents.push(node);
16972         }
16973       }
16974     }
16975     return new Selection(subgroups, parents);
16976   }
16977
16978   // node_modules/d3-selection/src/matcher.js
16979   function matcher_default(selector) {
16980     return function() {
16981       return this.matches(selector);
16982     };
16983   }
16984   function childMatcher(selector) {
16985     return function(node) {
16986       return node.matches(selector);
16987     };
16988   }
16989
16990   // node_modules/d3-selection/src/selection/selectChild.js
16991   var find = Array.prototype.find;
16992   function childFind(match) {
16993     return function() {
16994       return find.call(this.children, match);
16995     };
16996   }
16997   function childFirst() {
16998     return this.firstElementChild;
16999   }
17000   function selectChild_default(match) {
17001     return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
17002   }
17003
17004   // node_modules/d3-selection/src/selection/selectChildren.js
17005   var filter = Array.prototype.filter;
17006   function children() {
17007     return Array.from(this.children);
17008   }
17009   function childrenFilter(match) {
17010     return function() {
17011       return filter.call(this.children, match);
17012     };
17013   }
17014   function selectChildren_default(match) {
17015     return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
17016   }
17017
17018   // node_modules/d3-selection/src/selection/filter.js
17019   function filter_default(match) {
17020     if (typeof match !== "function") match = matcher_default(match);
17021     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17022       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
17023         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
17024           subgroup.push(node);
17025         }
17026       }
17027     }
17028     return new Selection(subgroups, this._parents);
17029   }
17030
17031   // node_modules/d3-selection/src/selection/sparse.js
17032   function sparse_default(update) {
17033     return new Array(update.length);
17034   }
17035
17036   // node_modules/d3-selection/src/selection/enter.js
17037   function enter_default() {
17038     return new Selection(this._enter || this._groups.map(sparse_default), this._parents);
17039   }
17040   function EnterNode(parent, datum2) {
17041     this.ownerDocument = parent.ownerDocument;
17042     this.namespaceURI = parent.namespaceURI;
17043     this._next = null;
17044     this._parent = parent;
17045     this.__data__ = datum2;
17046   }
17047   EnterNode.prototype = {
17048     constructor: EnterNode,
17049     appendChild: function(child) {
17050       return this._parent.insertBefore(child, this._next);
17051     },
17052     insertBefore: function(child, next) {
17053       return this._parent.insertBefore(child, next);
17054     },
17055     querySelector: function(selector) {
17056       return this._parent.querySelector(selector);
17057     },
17058     querySelectorAll: function(selector) {
17059       return this._parent.querySelectorAll(selector);
17060     }
17061   };
17062
17063   // node_modules/d3-selection/src/constant.js
17064   function constant_default(x2) {
17065     return function() {
17066       return x2;
17067     };
17068   }
17069
17070   // node_modules/d3-selection/src/selection/data.js
17071   function bindIndex(parent, group, enter, update, exit, data) {
17072     var i3 = 0, node, groupLength = group.length, dataLength = data.length;
17073     for (; i3 < dataLength; ++i3) {
17074       if (node = group[i3]) {
17075         node.__data__ = data[i3];
17076         update[i3] = node;
17077       } else {
17078         enter[i3] = new EnterNode(parent, data[i3]);
17079       }
17080     }
17081     for (; i3 < groupLength; ++i3) {
17082       if (node = group[i3]) {
17083         exit[i3] = node;
17084       }
17085     }
17086   }
17087   function bindKey(parent, group, enter, update, exit, data, key) {
17088     var i3, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
17089     for (i3 = 0; i3 < groupLength; ++i3) {
17090       if (node = group[i3]) {
17091         keyValues[i3] = keyValue = key.call(node, node.__data__, i3, group) + "";
17092         if (nodeByKeyValue.has(keyValue)) {
17093           exit[i3] = node;
17094         } else {
17095           nodeByKeyValue.set(keyValue, node);
17096         }
17097       }
17098     }
17099     for (i3 = 0; i3 < dataLength; ++i3) {
17100       keyValue = key.call(parent, data[i3], i3, data) + "";
17101       if (node = nodeByKeyValue.get(keyValue)) {
17102         update[i3] = node;
17103         node.__data__ = data[i3];
17104         nodeByKeyValue.delete(keyValue);
17105       } else {
17106         enter[i3] = new EnterNode(parent, data[i3]);
17107       }
17108     }
17109     for (i3 = 0; i3 < groupLength; ++i3) {
17110       if ((node = group[i3]) && nodeByKeyValue.get(keyValues[i3]) === node) {
17111         exit[i3] = node;
17112       }
17113     }
17114   }
17115   function datum(node) {
17116     return node.__data__;
17117   }
17118   function data_default(value, key) {
17119     if (!arguments.length) return Array.from(this, datum);
17120     var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
17121     if (typeof value !== "function") value = constant_default(value);
17122     for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17123       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);
17124       bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
17125       for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
17126         if (previous = enterGroup[i0]) {
17127           if (i0 >= i1) i1 = i0 + 1;
17128           while (!(next = updateGroup[i1]) && ++i1 < dataLength) ;
17129           previous._next = next || null;
17130         }
17131       }
17132     }
17133     update = new Selection(update, parents);
17134     update._enter = enter;
17135     update._exit = exit;
17136     return update;
17137   }
17138   function arraylike(data) {
17139     return typeof data === "object" && "length" in data ? data : Array.from(data);
17140   }
17141
17142   // node_modules/d3-selection/src/selection/exit.js
17143   function exit_default() {
17144     return new Selection(this._exit || this._groups.map(sparse_default), this._parents);
17145   }
17146
17147   // node_modules/d3-selection/src/selection/join.js
17148   function join_default(onenter, onupdate, onexit) {
17149     var enter = this.enter(), update = this, exit = this.exit();
17150     if (typeof onenter === "function") {
17151       enter = onenter(enter);
17152       if (enter) enter = enter.selection();
17153     } else {
17154       enter = enter.append(onenter + "");
17155     }
17156     if (onupdate != null) {
17157       update = onupdate(update);
17158       if (update) update = update.selection();
17159     }
17160     if (onexit == null) exit.remove();
17161     else onexit(exit);
17162     return enter && update ? enter.merge(update).order() : update;
17163   }
17164
17165   // node_modules/d3-selection/src/selection/merge.js
17166   function merge_default(context) {
17167     var selection2 = context.selection ? context.selection() : context;
17168     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) {
17169       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge3 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
17170         if (node = group0[i3] || group1[i3]) {
17171           merge3[i3] = node;
17172         }
17173       }
17174     }
17175     for (; j2 < m0; ++j2) {
17176       merges[j2] = groups0[j2];
17177     }
17178     return new Selection(merges, this._parents);
17179   }
17180
17181   // node_modules/d3-selection/src/selection/order.js
17182   function order_default() {
17183     for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) {
17184       for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) {
17185         if (node = group[i3]) {
17186           if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
17187           next = node;
17188         }
17189       }
17190     }
17191     return this;
17192   }
17193
17194   // node_modules/d3-selection/src/selection/sort.js
17195   function sort_default(compare2) {
17196     if (!compare2) compare2 = ascending2;
17197     function compareNode(a2, b2) {
17198       return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2;
17199     }
17200     for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17201       for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
17202         if (node = group[i3]) {
17203           sortgroup[i3] = node;
17204         }
17205       }
17206       sortgroup.sort(compareNode);
17207     }
17208     return new Selection(sortgroups, this._parents).order();
17209   }
17210   function ascending2(a2, b2) {
17211     return a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
17212   }
17213
17214   // node_modules/d3-selection/src/selection/call.js
17215   function call_default() {
17216     var callback = arguments[0];
17217     arguments[0] = this;
17218     callback.apply(null, arguments);
17219     return this;
17220   }
17221
17222   // node_modules/d3-selection/src/selection/nodes.js
17223   function nodes_default() {
17224     return Array.from(this);
17225   }
17226
17227   // node_modules/d3-selection/src/selection/node.js
17228   function node_default() {
17229     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17230       for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) {
17231         var node = group[i3];
17232         if (node) return node;
17233       }
17234     }
17235     return null;
17236   }
17237
17238   // node_modules/d3-selection/src/selection/size.js
17239   function size_default() {
17240     let size = 0;
17241     for (const node of this) ++size;
17242     return size;
17243   }
17244
17245   // node_modules/d3-selection/src/selection/empty.js
17246   function empty_default() {
17247     return !this.node();
17248   }
17249
17250   // node_modules/d3-selection/src/selection/each.js
17251   function each_default(callback) {
17252     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17253       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
17254         if (node = group[i3]) callback.call(node, node.__data__, i3, group);
17255       }
17256     }
17257     return this;
17258   }
17259
17260   // node_modules/d3-selection/src/selection/attr.js
17261   function attrRemove(name) {
17262     return function() {
17263       this.removeAttribute(name);
17264     };
17265   }
17266   function attrRemoveNS(fullname) {
17267     return function() {
17268       this.removeAttributeNS(fullname.space, fullname.local);
17269     };
17270   }
17271   function attrConstant(name, value) {
17272     return function() {
17273       this.setAttribute(name, value);
17274     };
17275   }
17276   function attrConstantNS(fullname, value) {
17277     return function() {
17278       this.setAttributeNS(fullname.space, fullname.local, value);
17279     };
17280   }
17281   function attrFunction(name, value) {
17282     return function() {
17283       var v2 = value.apply(this, arguments);
17284       if (v2 == null) this.removeAttribute(name);
17285       else this.setAttribute(name, v2);
17286     };
17287   }
17288   function attrFunctionNS(fullname, value) {
17289     return function() {
17290       var v2 = value.apply(this, arguments);
17291       if (v2 == null) this.removeAttributeNS(fullname.space, fullname.local);
17292       else this.setAttributeNS(fullname.space, fullname.local, v2);
17293     };
17294   }
17295   function attr_default(name, value) {
17296     var fullname = namespace_default(name);
17297     if (arguments.length < 2) {
17298       var node = this.node();
17299       return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
17300     }
17301     return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value));
17302   }
17303
17304   // node_modules/d3-selection/src/window.js
17305   function window_default(node) {
17306     return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
17307   }
17308
17309   // node_modules/d3-selection/src/selection/style.js
17310   function styleRemove(name) {
17311     return function() {
17312       this.style.removeProperty(name);
17313     };
17314   }
17315   function styleConstant(name, value, priority) {
17316     return function() {
17317       this.style.setProperty(name, value, priority);
17318     };
17319   }
17320   function styleFunction(name, value, priority) {
17321     return function() {
17322       var v2 = value.apply(this, arguments);
17323       if (v2 == null) this.style.removeProperty(name);
17324       else this.style.setProperty(name, v2, priority);
17325     };
17326   }
17327   function style_default(name, value, priority) {
17328     return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
17329   }
17330   function styleValue(node, name) {
17331     return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name);
17332   }
17333
17334   // node_modules/d3-selection/src/selection/property.js
17335   function propertyRemove(name) {
17336     return function() {
17337       delete this[name];
17338     };
17339   }
17340   function propertyConstant(name, value) {
17341     return function() {
17342       this[name] = value;
17343     };
17344   }
17345   function propertyFunction(name, value) {
17346     return function() {
17347       var v2 = value.apply(this, arguments);
17348       if (v2 == null) delete this[name];
17349       else this[name] = v2;
17350     };
17351   }
17352   function property_default(name, value) {
17353     return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
17354   }
17355
17356   // node_modules/d3-selection/src/selection/classed.js
17357   function classArray(string) {
17358     return string.trim().split(/^|\s+/);
17359   }
17360   function classList(node) {
17361     return node.classList || new ClassList(node);
17362   }
17363   function ClassList(node) {
17364     this._node = node;
17365     this._names = classArray(node.getAttribute("class") || "");
17366   }
17367   ClassList.prototype = {
17368     add: function(name) {
17369       var i3 = this._names.indexOf(name);
17370       if (i3 < 0) {
17371         this._names.push(name);
17372         this._node.setAttribute("class", this._names.join(" "));
17373       }
17374     },
17375     remove: function(name) {
17376       var i3 = this._names.indexOf(name);
17377       if (i3 >= 0) {
17378         this._names.splice(i3, 1);
17379         this._node.setAttribute("class", this._names.join(" "));
17380       }
17381     },
17382     contains: function(name) {
17383       return this._names.indexOf(name) >= 0;
17384     }
17385   };
17386   function classedAdd(node, names) {
17387     var list2 = classList(node), i3 = -1, n3 = names.length;
17388     while (++i3 < n3) list2.add(names[i3]);
17389   }
17390   function classedRemove(node, names) {
17391     var list2 = classList(node), i3 = -1, n3 = names.length;
17392     while (++i3 < n3) list2.remove(names[i3]);
17393   }
17394   function classedTrue(names) {
17395     return function() {
17396       classedAdd(this, names);
17397     };
17398   }
17399   function classedFalse(names) {
17400     return function() {
17401       classedRemove(this, names);
17402     };
17403   }
17404   function classedFunction(names, value) {
17405     return function() {
17406       (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
17407     };
17408   }
17409   function classed_default(name, value) {
17410     var names = classArray(name + "");
17411     if (arguments.length < 2) {
17412       var list2 = classList(this.node()), i3 = -1, n3 = names.length;
17413       while (++i3 < n3) if (!list2.contains(names[i3])) return false;
17414       return true;
17415     }
17416     return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
17417   }
17418
17419   // node_modules/d3-selection/src/selection/text.js
17420   function textRemove() {
17421     this.textContent = "";
17422   }
17423   function textConstant(value) {
17424     return function() {
17425       this.textContent = value;
17426     };
17427   }
17428   function textFunction(value) {
17429     return function() {
17430       var v2 = value.apply(this, arguments);
17431       this.textContent = v2 == null ? "" : v2;
17432     };
17433   }
17434   function text_default(value) {
17435     return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent;
17436   }
17437
17438   // node_modules/d3-selection/src/selection/html.js
17439   function htmlRemove() {
17440     this.innerHTML = "";
17441   }
17442   function htmlConstant(value) {
17443     return function() {
17444       this.innerHTML = value;
17445     };
17446   }
17447   function htmlFunction(value) {
17448     return function() {
17449       var v2 = value.apply(this, arguments);
17450       this.innerHTML = v2 == null ? "" : v2;
17451     };
17452   }
17453   function html_default(value) {
17454     return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
17455   }
17456
17457   // node_modules/d3-selection/src/selection/raise.js
17458   function raise() {
17459     if (this.nextSibling) this.parentNode.appendChild(this);
17460   }
17461   function raise_default() {
17462     return this.each(raise);
17463   }
17464
17465   // node_modules/d3-selection/src/selection/lower.js
17466   function lower() {
17467     if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
17468   }
17469   function lower_default() {
17470     return this.each(lower);
17471   }
17472
17473   // node_modules/d3-selection/src/selection/append.js
17474   function append_default(name) {
17475     var create2 = typeof name === "function" ? name : creator_default(name);
17476     return this.select(function() {
17477       return this.appendChild(create2.apply(this, arguments));
17478     });
17479   }
17480
17481   // node_modules/d3-selection/src/selection/insert.js
17482   function constantNull() {
17483     return null;
17484   }
17485   function insert_default(name, before) {
17486     var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before);
17487     return this.select(function() {
17488       return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
17489     });
17490   }
17491
17492   // node_modules/d3-selection/src/selection/remove.js
17493   function remove() {
17494     var parent = this.parentNode;
17495     if (parent) parent.removeChild(this);
17496   }
17497   function remove_default() {
17498     return this.each(remove);
17499   }
17500
17501   // node_modules/d3-selection/src/selection/clone.js
17502   function selection_cloneShallow() {
17503     var clone2 = this.cloneNode(false), parent = this.parentNode;
17504     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
17505   }
17506   function selection_cloneDeep() {
17507     var clone2 = this.cloneNode(true), parent = this.parentNode;
17508     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
17509   }
17510   function clone_default(deep) {
17511     return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
17512   }
17513
17514   // node_modules/d3-selection/src/selection/datum.js
17515   function datum_default(value) {
17516     return arguments.length ? this.property("__data__", value) : this.node().__data__;
17517   }
17518
17519   // node_modules/d3-selection/src/selection/on.js
17520   function contextListener(listener) {
17521     return function(event) {
17522       listener.call(this, event, this.__data__);
17523     };
17524   }
17525   function parseTypenames2(typenames) {
17526     return typenames.trim().split(/^|\s+/).map(function(t2) {
17527       var name = "", i3 = t2.indexOf(".");
17528       if (i3 >= 0) name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
17529       return { type: t2, name };
17530     });
17531   }
17532   function onRemove(typename) {
17533     return function() {
17534       var on = this.__on;
17535       if (!on) return;
17536       for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) {
17537         if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) {
17538           this.removeEventListener(o2.type, o2.listener, o2.options);
17539         } else {
17540           on[++i3] = o2;
17541         }
17542       }
17543       if (++i3) on.length = i3;
17544       else delete this.__on;
17545     };
17546   }
17547   function onAdd(typename, value, options2) {
17548     return function() {
17549       var on = this.__on, o2, listener = contextListener(value);
17550       if (on) for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) {
17551         if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) {
17552           this.removeEventListener(o2.type, o2.listener, o2.options);
17553           this.addEventListener(o2.type, o2.listener = listener, o2.options = options2);
17554           o2.value = value;
17555           return;
17556         }
17557       }
17558       this.addEventListener(typename.type, listener, options2);
17559       o2 = { type: typename.type, name: typename.name, value, listener, options: options2 };
17560       if (!on) this.__on = [o2];
17561       else on.push(o2);
17562     };
17563   }
17564   function on_default(typename, value, options2) {
17565     var typenames = parseTypenames2(typename + ""), i3, n3 = typenames.length, t2;
17566     if (arguments.length < 2) {
17567       var on = this.node().__on;
17568       if (on) for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) {
17569         for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) {
17570           if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) {
17571             return o2.value;
17572           }
17573         }
17574       }
17575       return;
17576     }
17577     on = value ? onAdd : onRemove;
17578     for (i3 = 0; i3 < n3; ++i3) this.each(on(typenames[i3], value, options2));
17579     return this;
17580   }
17581
17582   // node_modules/d3-selection/src/selection/dispatch.js
17583   function dispatchEvent(node, type2, params) {
17584     var window2 = window_default(node), event = window2.CustomEvent;
17585     if (typeof event === "function") {
17586       event = new event(type2, params);
17587     } else {
17588       event = window2.document.createEvent("Event");
17589       if (params) event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail;
17590       else event.initEvent(type2, false, false);
17591     }
17592     node.dispatchEvent(event);
17593   }
17594   function dispatchConstant(type2, params) {
17595     return function() {
17596       return dispatchEvent(this, type2, params);
17597     };
17598   }
17599   function dispatchFunction(type2, params) {
17600     return function() {
17601       return dispatchEvent(this, type2, params.apply(this, arguments));
17602     };
17603   }
17604   function dispatch_default2(type2, params) {
17605     return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params));
17606   }
17607
17608   // node_modules/d3-selection/src/selection/iterator.js
17609   function* iterator_default() {
17610     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17611       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
17612         if (node = group[i3]) yield node;
17613       }
17614     }
17615   }
17616
17617   // node_modules/d3-selection/src/selection/index.js
17618   var root = [null];
17619   function Selection(groups, parents) {
17620     this._groups = groups;
17621     this._parents = parents;
17622   }
17623   function selection() {
17624     return new Selection([[document.documentElement]], root);
17625   }
17626   function selection_selection() {
17627     return this;
17628   }
17629   Selection.prototype = selection.prototype = {
17630     constructor: Selection,
17631     select: select_default,
17632     selectAll: selectAll_default,
17633     selectChild: selectChild_default,
17634     selectChildren: selectChildren_default,
17635     filter: filter_default,
17636     data: data_default,
17637     enter: enter_default,
17638     exit: exit_default,
17639     join: join_default,
17640     merge: merge_default,
17641     selection: selection_selection,
17642     order: order_default,
17643     sort: sort_default,
17644     call: call_default,
17645     nodes: nodes_default,
17646     node: node_default,
17647     size: size_default,
17648     empty: empty_default,
17649     each: each_default,
17650     attr: attr_default,
17651     style: style_default,
17652     property: property_default,
17653     classed: classed_default,
17654     text: text_default,
17655     html: html_default,
17656     raise: raise_default,
17657     lower: lower_default,
17658     append: append_default,
17659     insert: insert_default,
17660     remove: remove_default,
17661     clone: clone_default,
17662     datum: datum_default,
17663     on: on_default,
17664     dispatch: dispatch_default2,
17665     [Symbol.iterator]: iterator_default
17666   };
17667   var selection_default = selection;
17668
17669   // node_modules/d3-selection/src/select.js
17670   function select_default2(selector) {
17671     return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
17672   }
17673
17674   // node_modules/d3-selection/src/sourceEvent.js
17675   function sourceEvent_default(event) {
17676     let sourceEvent;
17677     while (sourceEvent = event.sourceEvent) event = sourceEvent;
17678     return event;
17679   }
17680
17681   // node_modules/d3-selection/src/pointer.js
17682   function pointer_default(event, node) {
17683     event = sourceEvent_default(event);
17684     if (node === void 0) node = event.currentTarget;
17685     if (node) {
17686       var svg2 = node.ownerSVGElement || node;
17687       if (svg2.createSVGPoint) {
17688         var point = svg2.createSVGPoint();
17689         point.x = event.clientX, point.y = event.clientY;
17690         point = point.matrixTransform(node.getScreenCTM().inverse());
17691         return [point.x, point.y];
17692       }
17693       if (node.getBoundingClientRect) {
17694         var rect = node.getBoundingClientRect();
17695         return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
17696       }
17697     }
17698     return [event.pageX, event.pageY];
17699   }
17700
17701   // node_modules/d3-selection/src/selectAll.js
17702   function selectAll_default2(selector) {
17703     return typeof selector === "string" ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) : new Selection([array(selector)], root);
17704   }
17705
17706   // node_modules/d3-drag/src/noevent.js
17707   var nonpassive = { passive: false };
17708   var nonpassivecapture = { capture: true, passive: false };
17709   function nopropagation(event) {
17710     event.stopImmediatePropagation();
17711   }
17712   function noevent_default(event) {
17713     event.preventDefault();
17714     event.stopImmediatePropagation();
17715   }
17716
17717   // node_modules/d3-drag/src/nodrag.js
17718   function nodrag_default(view) {
17719     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture);
17720     if ("onselectstart" in root3) {
17721       selection2.on("selectstart.drag", noevent_default, nonpassivecapture);
17722     } else {
17723       root3.__noselect = root3.style.MozUserSelect;
17724       root3.style.MozUserSelect = "none";
17725     }
17726   }
17727   function yesdrag(view, noclick) {
17728     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null);
17729     if (noclick) {
17730       selection2.on("click.drag", noevent_default, nonpassivecapture);
17731       setTimeout(function() {
17732         selection2.on("click.drag", null);
17733       }, 0);
17734     }
17735     if ("onselectstart" in root3) {
17736       selection2.on("selectstart.drag", null);
17737     } else {
17738       root3.style.MozUserSelect = root3.__noselect;
17739       delete root3.__noselect;
17740     }
17741   }
17742
17743   // node_modules/d3-drag/src/constant.js
17744   var constant_default2 = (x2) => () => x2;
17745
17746   // node_modules/d3-drag/src/event.js
17747   function DragEvent(type2, {
17748     sourceEvent,
17749     subject,
17750     target,
17751     identifier,
17752     active,
17753     x: x2,
17754     y: y2,
17755     dx,
17756     dy,
17757     dispatch: dispatch14
17758   }) {
17759     Object.defineProperties(this, {
17760       type: { value: type2, enumerable: true, configurable: true },
17761       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
17762       subject: { value: subject, enumerable: true, configurable: true },
17763       target: { value: target, enumerable: true, configurable: true },
17764       identifier: { value: identifier, enumerable: true, configurable: true },
17765       active: { value: active, enumerable: true, configurable: true },
17766       x: { value: x2, enumerable: true, configurable: true },
17767       y: { value: y2, enumerable: true, configurable: true },
17768       dx: { value: dx, enumerable: true, configurable: true },
17769       dy: { value: dy, enumerable: true, configurable: true },
17770       _: { value: dispatch14 }
17771     });
17772   }
17773   DragEvent.prototype.on = function() {
17774     var value = this._.on.apply(this._, arguments);
17775     return value === this._ ? this : value;
17776   };
17777
17778   // node_modules/d3-drag/src/drag.js
17779   function defaultFilter(event) {
17780     return !event.ctrlKey && !event.button;
17781   }
17782   function defaultContainer() {
17783     return this.parentNode;
17784   }
17785   function defaultSubject(event, d2) {
17786     return d2 == null ? { x: event.x, y: event.y } : d2;
17787   }
17788   function defaultTouchable() {
17789     return navigator.maxTouchPoints || "ontouchstart" in this;
17790   }
17791   function drag_default() {
17792     var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
17793     function drag(selection2) {
17794       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)");
17795     }
17796     function mousedowned(event, d2) {
17797       if (touchending || !filter2.call(this, event, d2)) return;
17798       var gesture = beforestart(this, container.call(this, event, d2), event, d2, "mouse");
17799       if (!gesture) return;
17800       select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture);
17801       nodrag_default(event.view);
17802       nopropagation(event);
17803       mousemoving = false;
17804       mousedownx = event.clientX;
17805       mousedowny = event.clientY;
17806       gesture("start", event);
17807     }
17808     function mousemoved(event) {
17809       noevent_default(event);
17810       if (!mousemoving) {
17811         var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
17812         mousemoving = dx * dx + dy * dy > clickDistance2;
17813       }
17814       gestures.mouse("drag", event);
17815     }
17816     function mouseupped(event) {
17817       select_default2(event.view).on("mousemove.drag mouseup.drag", null);
17818       yesdrag(event.view, mousemoving);
17819       noevent_default(event);
17820       gestures.mouse("end", event);
17821     }
17822     function touchstarted(event, d2) {
17823       if (!filter2.call(this, event, d2)) return;
17824       var touches = event.changedTouches, c2 = container.call(this, event, d2), n3 = touches.length, i3, gesture;
17825       for (i3 = 0; i3 < n3; ++i3) {
17826         if (gesture = beforestart(this, c2, event, d2, touches[i3].identifier, touches[i3])) {
17827           nopropagation(event);
17828           gesture("start", event, touches[i3]);
17829         }
17830       }
17831     }
17832     function touchmoved(event) {
17833       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
17834       for (i3 = 0; i3 < n3; ++i3) {
17835         if (gesture = gestures[touches[i3].identifier]) {
17836           noevent_default(event);
17837           gesture("drag", event, touches[i3]);
17838         }
17839       }
17840     }
17841     function touchended(event) {
17842       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
17843       if (touchending) clearTimeout(touchending);
17844       touchending = setTimeout(function() {
17845         touchending = null;
17846       }, 500);
17847       for (i3 = 0; i3 < n3; ++i3) {
17848         if (gesture = gestures[touches[i3].identifier]) {
17849           nopropagation(event);
17850           gesture("end", event, touches[i3]);
17851         }
17852       }
17853     }
17854     function beforestart(that, container2, event, d2, identifier, touch) {
17855       var dispatch14 = listeners.copy(), p2 = pointer_default(touch || event, container2), dx, dy, s2;
17856       if ((s2 = subject.call(that, new DragEvent("beforestart", {
17857         sourceEvent: event,
17858         target: drag,
17859         identifier,
17860         active,
17861         x: p2[0],
17862         y: p2[1],
17863         dx: 0,
17864         dy: 0,
17865         dispatch: dispatch14
17866       }), d2)) == null) return;
17867       dx = s2.x - p2[0] || 0;
17868       dy = s2.y - p2[1] || 0;
17869       return function gesture(type2, event2, touch2) {
17870         var p02 = p2, n3;
17871         switch (type2) {
17872           case "start":
17873             gestures[identifier] = gesture, n3 = active++;
17874             break;
17875           case "end":
17876             delete gestures[identifier], --active;
17877           // falls through
17878           case "drag":
17879             p2 = pointer_default(touch2 || event2, container2), n3 = active;
17880             break;
17881         }
17882         dispatch14.call(
17883           type2,
17884           that,
17885           new DragEvent(type2, {
17886             sourceEvent: event2,
17887             subject: s2,
17888             target: drag,
17889             identifier,
17890             active: n3,
17891             x: p2[0] + dx,
17892             y: p2[1] + dy,
17893             dx: p2[0] - p02[0],
17894             dy: p2[1] - p02[1],
17895             dispatch: dispatch14
17896           }),
17897           d2
17898         );
17899       };
17900     }
17901     drag.filter = function(_2) {
17902       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : filter2;
17903     };
17904     drag.container = function(_2) {
17905       return arguments.length ? (container = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : container;
17906     };
17907     drag.subject = function(_2) {
17908       return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : subject;
17909     };
17910     drag.touchable = function(_2) {
17911       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : touchable;
17912     };
17913     drag.on = function() {
17914       var value = listeners.on.apply(listeners, arguments);
17915       return value === listeners ? drag : value;
17916     };
17917     drag.clickDistance = function(_2) {
17918       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag) : Math.sqrt(clickDistance2);
17919     };
17920     return drag;
17921   }
17922
17923   // node_modules/d3-color/src/define.js
17924   function define_default(constructor, factory, prototype4) {
17925     constructor.prototype = factory.prototype = prototype4;
17926     prototype4.constructor = constructor;
17927   }
17928   function extend(parent, definition) {
17929     var prototype4 = Object.create(parent.prototype);
17930     for (var key in definition) prototype4[key] = definition[key];
17931     return prototype4;
17932   }
17933
17934   // node_modules/d3-color/src/color.js
17935   function Color() {
17936   }
17937   var darker = 0.7;
17938   var brighter = 1 / darker;
17939   var reI = "\\s*([+-]?\\d+)\\s*";
17940   var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
17941   var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
17942   var reHex = /^#([0-9a-f]{3,8})$/;
17943   var reRgbInteger = new RegExp("^rgb\\(".concat(reI, ",").concat(reI, ",").concat(reI, "\\)$"));
17944   var reRgbPercent = new RegExp("^rgb\\(".concat(reP, ",").concat(reP, ",").concat(reP, "\\)$"));
17945   var reRgbaInteger = new RegExp("^rgba\\(".concat(reI, ",").concat(reI, ",").concat(reI, ",").concat(reN, "\\)$"));
17946   var reRgbaPercent = new RegExp("^rgba\\(".concat(reP, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
17947   var reHslPercent = new RegExp("^hsl\\(".concat(reN, ",").concat(reP, ",").concat(reP, "\\)$"));
17948   var reHslaPercent = new RegExp("^hsla\\(".concat(reN, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
17949   var named = {
17950     aliceblue: 15792383,
17951     antiquewhite: 16444375,
17952     aqua: 65535,
17953     aquamarine: 8388564,
17954     azure: 15794175,
17955     beige: 16119260,
17956     bisque: 16770244,
17957     black: 0,
17958     blanchedalmond: 16772045,
17959     blue: 255,
17960     blueviolet: 9055202,
17961     brown: 10824234,
17962     burlywood: 14596231,
17963     cadetblue: 6266528,
17964     chartreuse: 8388352,
17965     chocolate: 13789470,
17966     coral: 16744272,
17967     cornflowerblue: 6591981,
17968     cornsilk: 16775388,
17969     crimson: 14423100,
17970     cyan: 65535,
17971     darkblue: 139,
17972     darkcyan: 35723,
17973     darkgoldenrod: 12092939,
17974     darkgray: 11119017,
17975     darkgreen: 25600,
17976     darkgrey: 11119017,
17977     darkkhaki: 12433259,
17978     darkmagenta: 9109643,
17979     darkolivegreen: 5597999,
17980     darkorange: 16747520,
17981     darkorchid: 10040012,
17982     darkred: 9109504,
17983     darksalmon: 15308410,
17984     darkseagreen: 9419919,
17985     darkslateblue: 4734347,
17986     darkslategray: 3100495,
17987     darkslategrey: 3100495,
17988     darkturquoise: 52945,
17989     darkviolet: 9699539,
17990     deeppink: 16716947,
17991     deepskyblue: 49151,
17992     dimgray: 6908265,
17993     dimgrey: 6908265,
17994     dodgerblue: 2003199,
17995     firebrick: 11674146,
17996     floralwhite: 16775920,
17997     forestgreen: 2263842,
17998     fuchsia: 16711935,
17999     gainsboro: 14474460,
18000     ghostwhite: 16316671,
18001     gold: 16766720,
18002     goldenrod: 14329120,
18003     gray: 8421504,
18004     green: 32768,
18005     greenyellow: 11403055,
18006     grey: 8421504,
18007     honeydew: 15794160,
18008     hotpink: 16738740,
18009     indianred: 13458524,
18010     indigo: 4915330,
18011     ivory: 16777200,
18012     khaki: 15787660,
18013     lavender: 15132410,
18014     lavenderblush: 16773365,
18015     lawngreen: 8190976,
18016     lemonchiffon: 16775885,
18017     lightblue: 11393254,
18018     lightcoral: 15761536,
18019     lightcyan: 14745599,
18020     lightgoldenrodyellow: 16448210,
18021     lightgray: 13882323,
18022     lightgreen: 9498256,
18023     lightgrey: 13882323,
18024     lightpink: 16758465,
18025     lightsalmon: 16752762,
18026     lightseagreen: 2142890,
18027     lightskyblue: 8900346,
18028     lightslategray: 7833753,
18029     lightslategrey: 7833753,
18030     lightsteelblue: 11584734,
18031     lightyellow: 16777184,
18032     lime: 65280,
18033     limegreen: 3329330,
18034     linen: 16445670,
18035     magenta: 16711935,
18036     maroon: 8388608,
18037     mediumaquamarine: 6737322,
18038     mediumblue: 205,
18039     mediumorchid: 12211667,
18040     mediumpurple: 9662683,
18041     mediumseagreen: 3978097,
18042     mediumslateblue: 8087790,
18043     mediumspringgreen: 64154,
18044     mediumturquoise: 4772300,
18045     mediumvioletred: 13047173,
18046     midnightblue: 1644912,
18047     mintcream: 16121850,
18048     mistyrose: 16770273,
18049     moccasin: 16770229,
18050     navajowhite: 16768685,
18051     navy: 128,
18052     oldlace: 16643558,
18053     olive: 8421376,
18054     olivedrab: 7048739,
18055     orange: 16753920,
18056     orangered: 16729344,
18057     orchid: 14315734,
18058     palegoldenrod: 15657130,
18059     palegreen: 10025880,
18060     paleturquoise: 11529966,
18061     palevioletred: 14381203,
18062     papayawhip: 16773077,
18063     peachpuff: 16767673,
18064     peru: 13468991,
18065     pink: 16761035,
18066     plum: 14524637,
18067     powderblue: 11591910,
18068     purple: 8388736,
18069     rebeccapurple: 6697881,
18070     red: 16711680,
18071     rosybrown: 12357519,
18072     royalblue: 4286945,
18073     saddlebrown: 9127187,
18074     salmon: 16416882,
18075     sandybrown: 16032864,
18076     seagreen: 3050327,
18077     seashell: 16774638,
18078     sienna: 10506797,
18079     silver: 12632256,
18080     skyblue: 8900331,
18081     slateblue: 6970061,
18082     slategray: 7372944,
18083     slategrey: 7372944,
18084     snow: 16775930,
18085     springgreen: 65407,
18086     steelblue: 4620980,
18087     tan: 13808780,
18088     teal: 32896,
18089     thistle: 14204888,
18090     tomato: 16737095,
18091     turquoise: 4251856,
18092     violet: 15631086,
18093     wheat: 16113331,
18094     white: 16777215,
18095     whitesmoke: 16119285,
18096     yellow: 16776960,
18097     yellowgreen: 10145074
18098   };
18099   define_default(Color, color, {
18100     copy(channels) {
18101       return Object.assign(new this.constructor(), this, channels);
18102     },
18103     displayable() {
18104       return this.rgb().displayable();
18105     },
18106     hex: color_formatHex,
18107     // Deprecated! Use color.formatHex.
18108     formatHex: color_formatHex,
18109     formatHex8: color_formatHex8,
18110     formatHsl: color_formatHsl,
18111     formatRgb: color_formatRgb,
18112     toString: color_formatRgb
18113   });
18114   function color_formatHex() {
18115     return this.rgb().formatHex();
18116   }
18117   function color_formatHex8() {
18118     return this.rgb().formatHex8();
18119   }
18120   function color_formatHsl() {
18121     return hslConvert(this).formatHsl();
18122   }
18123   function color_formatRgb() {
18124     return this.rgb().formatRgb();
18125   }
18126   function color(format2) {
18127     var m2, l2;
18128     format2 = (format2 + "").trim().toLowerCase();
18129     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;
18130   }
18131   function rgbn(n3) {
18132     return new Rgb(n3 >> 16 & 255, n3 >> 8 & 255, n3 & 255, 1);
18133   }
18134   function rgba(r2, g3, b2, a2) {
18135     if (a2 <= 0) r2 = g3 = b2 = NaN;
18136     return new Rgb(r2, g3, b2, a2);
18137   }
18138   function rgbConvert(o2) {
18139     if (!(o2 instanceof Color)) o2 = color(o2);
18140     if (!o2) return new Rgb();
18141     o2 = o2.rgb();
18142     return new Rgb(o2.r, o2.g, o2.b, o2.opacity);
18143   }
18144   function rgb(r2, g3, b2, opacity) {
18145     return arguments.length === 1 ? rgbConvert(r2) : new Rgb(r2, g3, b2, opacity == null ? 1 : opacity);
18146   }
18147   function Rgb(r2, g3, b2, opacity) {
18148     this.r = +r2;
18149     this.g = +g3;
18150     this.b = +b2;
18151     this.opacity = +opacity;
18152   }
18153   define_default(Rgb, rgb, extend(Color, {
18154     brighter(k2) {
18155       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
18156       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
18157     },
18158     darker(k2) {
18159       k2 = k2 == null ? darker : Math.pow(darker, k2);
18160       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
18161     },
18162     rgb() {
18163       return this;
18164     },
18165     clamp() {
18166       return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
18167     },
18168     displayable() {
18169       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);
18170     },
18171     hex: rgb_formatHex,
18172     // Deprecated! Use color.formatHex.
18173     formatHex: rgb_formatHex,
18174     formatHex8: rgb_formatHex8,
18175     formatRgb: rgb_formatRgb,
18176     toString: rgb_formatRgb
18177   }));
18178   function rgb_formatHex() {
18179     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b));
18180   }
18181   function rgb_formatHex8() {
18182     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b)).concat(hex((isNaN(this.opacity) ? 1 : this.opacity) * 255));
18183   }
18184   function rgb_formatRgb() {
18185     const a2 = clampa(this.opacity);
18186     return "".concat(a2 === 1 ? "rgb(" : "rgba(").concat(clampi(this.r), ", ").concat(clampi(this.g), ", ").concat(clampi(this.b)).concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
18187   }
18188   function clampa(opacity) {
18189     return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
18190   }
18191   function clampi(value) {
18192     return Math.max(0, Math.min(255, Math.round(value) || 0));
18193   }
18194   function hex(value) {
18195     value = clampi(value);
18196     return (value < 16 ? "0" : "") + value.toString(16);
18197   }
18198   function hsla(h2, s2, l2, a2) {
18199     if (a2 <= 0) h2 = s2 = l2 = NaN;
18200     else if (l2 <= 0 || l2 >= 1) h2 = s2 = NaN;
18201     else if (s2 <= 0) h2 = NaN;
18202     return new Hsl(h2, s2, l2, a2);
18203   }
18204   function hslConvert(o2) {
18205     if (o2 instanceof Hsl) return new Hsl(o2.h, o2.s, o2.l, o2.opacity);
18206     if (!(o2 instanceof Color)) o2 = color(o2);
18207     if (!o2) return new Hsl();
18208     if (o2 instanceof Hsl) return o2;
18209     o2 = o2.rgb();
18210     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;
18211     if (s2) {
18212       if (r2 === max3) h2 = (g3 - b2) / s2 + (g3 < b2) * 6;
18213       else if (g3 === max3) h2 = (b2 - r2) / s2 + 2;
18214       else h2 = (r2 - g3) / s2 + 4;
18215       s2 /= l2 < 0.5 ? max3 + min3 : 2 - max3 - min3;
18216       h2 *= 60;
18217     } else {
18218       s2 = l2 > 0 && l2 < 1 ? 0 : h2;
18219     }
18220     return new Hsl(h2, s2, l2, o2.opacity);
18221   }
18222   function hsl(h2, s2, l2, opacity) {
18223     return arguments.length === 1 ? hslConvert(h2) : new Hsl(h2, s2, l2, opacity == null ? 1 : opacity);
18224   }
18225   function Hsl(h2, s2, l2, opacity) {
18226     this.h = +h2;
18227     this.s = +s2;
18228     this.l = +l2;
18229     this.opacity = +opacity;
18230   }
18231   define_default(Hsl, hsl, extend(Color, {
18232     brighter(k2) {
18233       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
18234       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
18235     },
18236     darker(k2) {
18237       k2 = k2 == null ? darker : Math.pow(darker, k2);
18238       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
18239     },
18240     rgb() {
18241       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;
18242       return new Rgb(
18243         hsl2rgb(h2 >= 240 ? h2 - 240 : h2 + 120, m1, m2),
18244         hsl2rgb(h2, m1, m2),
18245         hsl2rgb(h2 < 120 ? h2 + 240 : h2 - 120, m1, m2),
18246         this.opacity
18247       );
18248     },
18249     clamp() {
18250       return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
18251     },
18252     displayable() {
18253       return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
18254     },
18255     formatHsl() {
18256       const a2 = clampa(this.opacity);
18257       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, ")"));
18258     }
18259   }));
18260   function clamph(value) {
18261     value = (value || 0) % 360;
18262     return value < 0 ? value + 360 : value;
18263   }
18264   function clampt(value) {
18265     return Math.max(0, Math.min(1, value || 0));
18266   }
18267   function hsl2rgb(h2, m1, m2) {
18268     return (h2 < 60 ? m1 + (m2 - m1) * h2 / 60 : h2 < 180 ? m2 : h2 < 240 ? m1 + (m2 - m1) * (240 - h2) / 60 : m1) * 255;
18269   }
18270
18271   // node_modules/d3-interpolate/src/basis.js
18272   function basis(t1, v0, v1, v2, v3) {
18273     var t2 = t1 * t1, t3 = t2 * t1;
18274     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;
18275   }
18276   function basis_default(values) {
18277     var n3 = values.length - 1;
18278     return function(t2) {
18279       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;
18280       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
18281     };
18282   }
18283
18284   // node_modules/d3-interpolate/src/basisClosed.js
18285   function basisClosed_default(values) {
18286     var n3 = values.length;
18287     return function(t2) {
18288       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];
18289       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
18290     };
18291   }
18292
18293   // node_modules/d3-interpolate/src/constant.js
18294   var constant_default3 = (x2) => () => x2;
18295
18296   // node_modules/d3-interpolate/src/color.js
18297   function linear(a2, d2) {
18298     return function(t2) {
18299       return a2 + t2 * d2;
18300     };
18301   }
18302   function exponential(a2, b2, y2) {
18303     return a2 = Math.pow(a2, y2), b2 = Math.pow(b2, y2) - a2, y2 = 1 / y2, function(t2) {
18304       return Math.pow(a2 + t2 * b2, y2);
18305     };
18306   }
18307   function gamma(y2) {
18308     return (y2 = +y2) === 1 ? nogamma : function(a2, b2) {
18309       return b2 - a2 ? exponential(a2, b2, y2) : constant_default3(isNaN(a2) ? b2 : a2);
18310     };
18311   }
18312   function nogamma(a2, b2) {
18313     var d2 = b2 - a2;
18314     return d2 ? linear(a2, d2) : constant_default3(isNaN(a2) ? b2 : a2);
18315   }
18316
18317   // node_modules/d3-interpolate/src/rgb.js
18318   var rgb_default = function rgbGamma(y2) {
18319     var color2 = gamma(y2);
18320     function rgb2(start2, end) {
18321       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);
18322       return function(t2) {
18323         start2.r = r2(t2);
18324         start2.g = g3(t2);
18325         start2.b = b2(t2);
18326         start2.opacity = opacity(t2);
18327         return start2 + "";
18328       };
18329     }
18330     rgb2.gamma = rgbGamma;
18331     return rgb2;
18332   }(1);
18333   function rgbSpline(spline) {
18334     return function(colors) {
18335       var n3 = colors.length, r2 = new Array(n3), g3 = new Array(n3), b2 = new Array(n3), i3, color2;
18336       for (i3 = 0; i3 < n3; ++i3) {
18337         color2 = rgb(colors[i3]);
18338         r2[i3] = color2.r || 0;
18339         g3[i3] = color2.g || 0;
18340         b2[i3] = color2.b || 0;
18341       }
18342       r2 = spline(r2);
18343       g3 = spline(g3);
18344       b2 = spline(b2);
18345       color2.opacity = 1;
18346       return function(t2) {
18347         color2.r = r2(t2);
18348         color2.g = g3(t2);
18349         color2.b = b2(t2);
18350         return color2 + "";
18351       };
18352     };
18353   }
18354   var rgbBasis = rgbSpline(basis_default);
18355   var rgbBasisClosed = rgbSpline(basisClosed_default);
18356
18357   // node_modules/d3-interpolate/src/numberArray.js
18358   function numberArray_default(a2, b2) {
18359     if (!b2) b2 = [];
18360     var n3 = a2 ? Math.min(b2.length, a2.length) : 0, c2 = b2.slice(), i3;
18361     return function(t2) {
18362       for (i3 = 0; i3 < n3; ++i3) c2[i3] = a2[i3] * (1 - t2) + b2[i3] * t2;
18363       return c2;
18364     };
18365   }
18366   function isNumberArray(x2) {
18367     return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
18368   }
18369
18370   // node_modules/d3-interpolate/src/array.js
18371   function genericArray(a2, b2) {
18372     var nb = b2 ? b2.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i3;
18373     for (i3 = 0; i3 < na; ++i3) x2[i3] = value_default(a2[i3], b2[i3]);
18374     for (; i3 < nb; ++i3) c2[i3] = b2[i3];
18375     return function(t2) {
18376       for (i3 = 0; i3 < na; ++i3) c2[i3] = x2[i3](t2);
18377       return c2;
18378     };
18379   }
18380
18381   // node_modules/d3-interpolate/src/date.js
18382   function date_default(a2, b2) {
18383     var d2 = /* @__PURE__ */ new Date();
18384     return a2 = +a2, b2 = +b2, function(t2) {
18385       return d2.setTime(a2 * (1 - t2) + b2 * t2), d2;
18386     };
18387   }
18388
18389   // node_modules/d3-interpolate/src/number.js
18390   function number_default(a2, b2) {
18391     return a2 = +a2, b2 = +b2, function(t2) {
18392       return a2 * (1 - t2) + b2 * t2;
18393     };
18394   }
18395
18396   // node_modules/d3-interpolate/src/object.js
18397   function object_default(a2, b2) {
18398     var i3 = {}, c2 = {}, k2;
18399     if (a2 === null || typeof a2 !== "object") a2 = {};
18400     if (b2 === null || typeof b2 !== "object") b2 = {};
18401     for (k2 in b2) {
18402       if (k2 in a2) {
18403         i3[k2] = value_default(a2[k2], b2[k2]);
18404       } else {
18405         c2[k2] = b2[k2];
18406       }
18407     }
18408     return function(t2) {
18409       for (k2 in i3) c2[k2] = i3[k2](t2);
18410       return c2;
18411     };
18412   }
18413
18414   // node_modules/d3-interpolate/src/string.js
18415   var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
18416   var reB = new RegExp(reA.source, "g");
18417   function zero2(b2) {
18418     return function() {
18419       return b2;
18420     };
18421   }
18422   function one(b2) {
18423     return function(t2) {
18424       return b2(t2) + "";
18425     };
18426   }
18427   function string_default(a2, b2) {
18428     var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i3 = -1, s2 = [], q2 = [];
18429     a2 = a2 + "", b2 = b2 + "";
18430     while ((am = reA.exec(a2)) && (bm = reB.exec(b2))) {
18431       if ((bs = bm.index) > bi) {
18432         bs = b2.slice(bi, bs);
18433         if (s2[i3]) s2[i3] += bs;
18434         else s2[++i3] = bs;
18435       }
18436       if ((am = am[0]) === (bm = bm[0])) {
18437         if (s2[i3]) s2[i3] += bm;
18438         else s2[++i3] = bm;
18439       } else {
18440         s2[++i3] = null;
18441         q2.push({ i: i3, x: number_default(am, bm) });
18442       }
18443       bi = reB.lastIndex;
18444     }
18445     if (bi < b2.length) {
18446       bs = b2.slice(bi);
18447       if (s2[i3]) s2[i3] += bs;
18448       else s2[++i3] = bs;
18449     }
18450     return s2.length < 2 ? q2[0] ? one(q2[0].x) : zero2(b2) : (b2 = q2.length, function(t2) {
18451       for (var i4 = 0, o2; i4 < b2; ++i4) s2[(o2 = q2[i4]).i] = o2.x(t2);
18452       return s2.join("");
18453     });
18454   }
18455
18456   // node_modules/d3-interpolate/src/value.js
18457   function value_default(a2, b2) {
18458     var t2 = typeof b2, c2;
18459     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);
18460   }
18461
18462   // node_modules/d3-interpolate/src/round.js
18463   function round_default(a2, b2) {
18464     return a2 = +a2, b2 = +b2, function(t2) {
18465       return Math.round(a2 * (1 - t2) + b2 * t2);
18466     };
18467   }
18468
18469   // node_modules/d3-interpolate/src/transform/decompose.js
18470   var degrees2 = 180 / Math.PI;
18471   var identity = {
18472     translateX: 0,
18473     translateY: 0,
18474     rotate: 0,
18475     skewX: 0,
18476     scaleX: 1,
18477     scaleY: 1
18478   };
18479   function decompose_default(a2, b2, c2, d2, e3, f2) {
18480     var scaleX, scaleY, skewX;
18481     if (scaleX = Math.sqrt(a2 * a2 + b2 * b2)) a2 /= scaleX, b2 /= scaleX;
18482     if (skewX = a2 * c2 + b2 * d2) c2 -= a2 * skewX, d2 -= b2 * skewX;
18483     if (scaleY = Math.sqrt(c2 * c2 + d2 * d2)) c2 /= scaleY, d2 /= scaleY, skewX /= scaleY;
18484     if (a2 * d2 < b2 * c2) a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX;
18485     return {
18486       translateX: e3,
18487       translateY: f2,
18488       rotate: Math.atan2(b2, a2) * degrees2,
18489       skewX: Math.atan(skewX) * degrees2,
18490       scaleX,
18491       scaleY
18492     };
18493   }
18494
18495   // node_modules/d3-interpolate/src/transform/parse.js
18496   var svgNode;
18497   function parseCss(value) {
18498     const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
18499     return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f);
18500   }
18501   function parseSvg(value) {
18502     if (value == null) return identity;
18503     if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
18504     svgNode.setAttribute("transform", value);
18505     if (!(value = svgNode.transform.baseVal.consolidate())) return identity;
18506     value = value.matrix;
18507     return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f);
18508   }
18509
18510   // node_modules/d3-interpolate/src/transform/index.js
18511   function interpolateTransform(parse, pxComma, pxParen, degParen) {
18512     function pop(s2) {
18513       return s2.length ? s2.pop() + " " : "";
18514     }
18515     function translate(xa, ya, xb, yb, s2, q2) {
18516       if (xa !== xb || ya !== yb) {
18517         var i3 = s2.push("translate(", null, pxComma, null, pxParen);
18518         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
18519       } else if (xb || yb) {
18520         s2.push("translate(" + xb + pxComma + yb + pxParen);
18521       }
18522     }
18523     function rotate(a2, b2, s2, q2) {
18524       if (a2 !== b2) {
18525         if (a2 - b2 > 180) b2 += 360;
18526         else if (b2 - a2 > 180) a2 += 360;
18527         q2.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: number_default(a2, b2) });
18528       } else if (b2) {
18529         s2.push(pop(s2) + "rotate(" + b2 + degParen);
18530       }
18531     }
18532     function skewX(a2, b2, s2, q2) {
18533       if (a2 !== b2) {
18534         q2.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: number_default(a2, b2) });
18535       } else if (b2) {
18536         s2.push(pop(s2) + "skewX(" + b2 + degParen);
18537       }
18538     }
18539     function scale(xa, ya, xb, yb, s2, q2) {
18540       if (xa !== xb || ya !== yb) {
18541         var i3 = s2.push(pop(s2) + "scale(", null, ",", null, ")");
18542         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
18543       } else if (xb !== 1 || yb !== 1) {
18544         s2.push(pop(s2) + "scale(" + xb + "," + yb + ")");
18545       }
18546     }
18547     return function(a2, b2) {
18548       var s2 = [], q2 = [];
18549       a2 = parse(a2), b2 = parse(b2);
18550       translate(a2.translateX, a2.translateY, b2.translateX, b2.translateY, s2, q2);
18551       rotate(a2.rotate, b2.rotate, s2, q2);
18552       skewX(a2.skewX, b2.skewX, s2, q2);
18553       scale(a2.scaleX, a2.scaleY, b2.scaleX, b2.scaleY, s2, q2);
18554       a2 = b2 = null;
18555       return function(t2) {
18556         var i3 = -1, n3 = q2.length, o2;
18557         while (++i3 < n3) s2[(o2 = q2[i3]).i] = o2.x(t2);
18558         return s2.join("");
18559       };
18560     };
18561   }
18562   var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
18563   var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
18564
18565   // node_modules/d3-interpolate/src/zoom.js
18566   var epsilon22 = 1e-12;
18567   function cosh(x2) {
18568     return ((x2 = Math.exp(x2)) + 1 / x2) / 2;
18569   }
18570   function sinh(x2) {
18571     return ((x2 = Math.exp(x2)) - 1 / x2) / 2;
18572   }
18573   function tanh(x2) {
18574     return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1);
18575   }
18576   var zoom_default = function zoomRho(rho, rho2, rho4) {
18577     function zoom(p02, p1) {
18578       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;
18579       if (d2 < epsilon22) {
18580         S2 = Math.log(w1 / w0) / rho;
18581         i3 = function(t2) {
18582           return [
18583             ux0 + t2 * dx,
18584             uy0 + t2 * dy,
18585             w0 * Math.exp(rho * t2 * S2)
18586           ];
18587         };
18588       } else {
18589         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);
18590         S2 = (r1 - r0) / rho;
18591         i3 = function(t2) {
18592           var s2 = t2 * S2, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0));
18593           return [
18594             ux0 + u2 * dx,
18595             uy0 + u2 * dy,
18596             w0 * coshr0 / cosh(rho * s2 + r0)
18597           ];
18598         };
18599       }
18600       i3.duration = S2 * 1e3 * rho / Math.SQRT2;
18601       return i3;
18602     }
18603     zoom.rho = function(_2) {
18604       var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22;
18605       return zoomRho(_1, _22, _4);
18606     };
18607     return zoom;
18608   }(Math.SQRT2, 2, 4);
18609
18610   // node_modules/d3-interpolate/src/quantize.js
18611   function quantize_default(interpolator, n3) {
18612     var samples = new Array(n3);
18613     for (var i3 = 0; i3 < n3; ++i3) samples[i3] = interpolator(i3 / (n3 - 1));
18614     return samples;
18615   }
18616
18617   // node_modules/d3-timer/src/timer.js
18618   var frame = 0;
18619   var timeout = 0;
18620   var interval = 0;
18621   var pokeDelay = 1e3;
18622   var taskHead;
18623   var taskTail;
18624   var clockLast = 0;
18625   var clockNow = 0;
18626   var clockSkew = 0;
18627   var clock = typeof performance === "object" && performance.now ? performance : Date;
18628   var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) {
18629     setTimeout(f2, 17);
18630   };
18631   function now() {
18632     return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
18633   }
18634   function clearNow() {
18635     clockNow = 0;
18636   }
18637   function Timer() {
18638     this._call = this._time = this._next = null;
18639   }
18640   Timer.prototype = timer.prototype = {
18641     constructor: Timer,
18642     restart: function(callback, delay, time) {
18643       if (typeof callback !== "function") throw new TypeError("callback is not a function");
18644       time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
18645       if (!this._next && taskTail !== this) {
18646         if (taskTail) taskTail._next = this;
18647         else taskHead = this;
18648         taskTail = this;
18649       }
18650       this._call = callback;
18651       this._time = time;
18652       sleep();
18653     },
18654     stop: function() {
18655       if (this._call) {
18656         this._call = null;
18657         this._time = Infinity;
18658         sleep();
18659       }
18660     }
18661   };
18662   function timer(callback, delay, time) {
18663     var t2 = new Timer();
18664     t2.restart(callback, delay, time);
18665     return t2;
18666   }
18667   function timerFlush() {
18668     now();
18669     ++frame;
18670     var t2 = taskHead, e3;
18671     while (t2) {
18672       if ((e3 = clockNow - t2._time) >= 0) t2._call.call(void 0, e3);
18673       t2 = t2._next;
18674     }
18675     --frame;
18676   }
18677   function wake() {
18678     clockNow = (clockLast = clock.now()) + clockSkew;
18679     frame = timeout = 0;
18680     try {
18681       timerFlush();
18682     } finally {
18683       frame = 0;
18684       nap();
18685       clockNow = 0;
18686     }
18687   }
18688   function poke() {
18689     var now3 = clock.now(), delay = now3 - clockLast;
18690     if (delay > pokeDelay) clockSkew -= delay, clockLast = now3;
18691   }
18692   function nap() {
18693     var t0, t1 = taskHead, t2, time = Infinity;
18694     while (t1) {
18695       if (t1._call) {
18696         if (time > t1._time) time = t1._time;
18697         t0 = t1, t1 = t1._next;
18698       } else {
18699         t2 = t1._next, t1._next = null;
18700         t1 = t0 ? t0._next = t2 : taskHead = t2;
18701       }
18702     }
18703     taskTail = t0;
18704     sleep(time);
18705   }
18706   function sleep(time) {
18707     if (frame) return;
18708     if (timeout) timeout = clearTimeout(timeout);
18709     var delay = time - clockNow;
18710     if (delay > 24) {
18711       if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
18712       if (interval) interval = clearInterval(interval);
18713     } else {
18714       if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
18715       frame = 1, setFrame(wake);
18716     }
18717   }
18718
18719   // node_modules/d3-timer/src/timeout.js
18720   function timeout_default(callback, delay, time) {
18721     var t2 = new Timer();
18722     delay = delay == null ? 0 : +delay;
18723     t2.restart((elapsed) => {
18724       t2.stop();
18725       callback(elapsed + delay);
18726     }, delay, time);
18727     return t2;
18728   }
18729
18730   // node_modules/d3-transition/src/transition/schedule.js
18731   var emptyOn = dispatch_default("start", "end", "cancel", "interrupt");
18732   var emptyTween = [];
18733   var CREATED = 0;
18734   var SCHEDULED = 1;
18735   var STARTING = 2;
18736   var STARTED = 3;
18737   var RUNNING = 4;
18738   var ENDING = 5;
18739   var ENDED = 6;
18740   function schedule_default(node, name, id2, index, group, timing) {
18741     var schedules = node.__transition;
18742     if (!schedules) node.__transition = {};
18743     else if (id2 in schedules) return;
18744     create(node, id2, {
18745       name,
18746       index,
18747       // For context during callback.
18748       group,
18749       // For context during callback.
18750       on: emptyOn,
18751       tween: emptyTween,
18752       time: timing.time,
18753       delay: timing.delay,
18754       duration: timing.duration,
18755       ease: timing.ease,
18756       timer: null,
18757       state: CREATED
18758     });
18759   }
18760   function init(node, id2) {
18761     var schedule = get2(node, id2);
18762     if (schedule.state > CREATED) throw new Error("too late; already scheduled");
18763     return schedule;
18764   }
18765   function set2(node, id2) {
18766     var schedule = get2(node, id2);
18767     if (schedule.state > STARTED) throw new Error("too late; already running");
18768     return schedule;
18769   }
18770   function get2(node, id2) {
18771     var schedule = node.__transition;
18772     if (!schedule || !(schedule = schedule[id2])) throw new Error("transition not found");
18773     return schedule;
18774   }
18775   function create(node, id2, self2) {
18776     var schedules = node.__transition, tween;
18777     schedules[id2] = self2;
18778     self2.timer = timer(schedule, 0, self2.time);
18779     function schedule(elapsed) {
18780       self2.state = SCHEDULED;
18781       self2.timer.restart(start2, self2.delay, self2.time);
18782       if (self2.delay <= elapsed) start2(elapsed - self2.delay);
18783     }
18784     function start2(elapsed) {
18785       var i3, j2, n3, o2;
18786       if (self2.state !== SCHEDULED) return stop();
18787       for (i3 in schedules) {
18788         o2 = schedules[i3];
18789         if (o2.name !== self2.name) continue;
18790         if (o2.state === STARTED) return timeout_default(start2);
18791         if (o2.state === RUNNING) {
18792           o2.state = ENDED;
18793           o2.timer.stop();
18794           o2.on.call("interrupt", node, node.__data__, o2.index, o2.group);
18795           delete schedules[i3];
18796         } else if (+i3 < id2) {
18797           o2.state = ENDED;
18798           o2.timer.stop();
18799           o2.on.call("cancel", node, node.__data__, o2.index, o2.group);
18800           delete schedules[i3];
18801         }
18802       }
18803       timeout_default(function() {
18804         if (self2.state === STARTED) {
18805           self2.state = RUNNING;
18806           self2.timer.restart(tick, self2.delay, self2.time);
18807           tick(elapsed);
18808         }
18809       });
18810       self2.state = STARTING;
18811       self2.on.call("start", node, node.__data__, self2.index, self2.group);
18812       if (self2.state !== STARTING) return;
18813       self2.state = STARTED;
18814       tween = new Array(n3 = self2.tween.length);
18815       for (i3 = 0, j2 = -1; i3 < n3; ++i3) {
18816         if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) {
18817           tween[++j2] = o2;
18818         }
18819       }
18820       tween.length = j2 + 1;
18821     }
18822     function tick(elapsed) {
18823       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;
18824       while (++i3 < n3) {
18825         tween[i3].call(node, t2);
18826       }
18827       if (self2.state === ENDING) {
18828         self2.on.call("end", node, node.__data__, self2.index, self2.group);
18829         stop();
18830       }
18831     }
18832     function stop() {
18833       self2.state = ENDED;
18834       self2.timer.stop();
18835       delete schedules[id2];
18836       for (var i3 in schedules) return;
18837       delete node.__transition;
18838     }
18839   }
18840
18841   // node_modules/d3-transition/src/interrupt.js
18842   function interrupt_default(node, name) {
18843     var schedules = node.__transition, schedule, active, empty2 = true, i3;
18844     if (!schedules) return;
18845     name = name == null ? null : name + "";
18846     for (i3 in schedules) {
18847       if ((schedule = schedules[i3]).name !== name) {
18848         empty2 = false;
18849         continue;
18850       }
18851       active = schedule.state > STARTING && schedule.state < ENDING;
18852       schedule.state = ENDED;
18853       schedule.timer.stop();
18854       schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
18855       delete schedules[i3];
18856     }
18857     if (empty2) delete node.__transition;
18858   }
18859
18860   // node_modules/d3-transition/src/selection/interrupt.js
18861   function interrupt_default2(name) {
18862     return this.each(function() {
18863       interrupt_default(this, name);
18864     });
18865   }
18866
18867   // node_modules/d3-transition/src/transition/tween.js
18868   function tweenRemove(id2, name) {
18869     var tween0, tween1;
18870     return function() {
18871       var schedule = set2(this, id2), tween = schedule.tween;
18872       if (tween !== tween0) {
18873         tween1 = tween0 = tween;
18874         for (var i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
18875           if (tween1[i3].name === name) {
18876             tween1 = tween1.slice();
18877             tween1.splice(i3, 1);
18878             break;
18879           }
18880         }
18881       }
18882       schedule.tween = tween1;
18883     };
18884   }
18885   function tweenFunction(id2, name, value) {
18886     var tween0, tween1;
18887     if (typeof value !== "function") throw new Error();
18888     return function() {
18889       var schedule = set2(this, id2), tween = schedule.tween;
18890       if (tween !== tween0) {
18891         tween1 = (tween0 = tween).slice();
18892         for (var t2 = { name, value }, i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
18893           if (tween1[i3].name === name) {
18894             tween1[i3] = t2;
18895             break;
18896           }
18897         }
18898         if (i3 === n3) tween1.push(t2);
18899       }
18900       schedule.tween = tween1;
18901     };
18902   }
18903   function tween_default(name, value) {
18904     var id2 = this._id;
18905     name += "";
18906     if (arguments.length < 2) {
18907       var tween = get2(this.node(), id2).tween;
18908       for (var i3 = 0, n3 = tween.length, t2; i3 < n3; ++i3) {
18909         if ((t2 = tween[i3]).name === name) {
18910           return t2.value;
18911         }
18912       }
18913       return null;
18914     }
18915     return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
18916   }
18917   function tweenValue(transition2, name, value) {
18918     var id2 = transition2._id;
18919     transition2.each(function() {
18920       var schedule = set2(this, id2);
18921       (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
18922     });
18923     return function(node) {
18924       return get2(node, id2).value[name];
18925     };
18926   }
18927
18928   // node_modules/d3-transition/src/transition/interpolate.js
18929   function interpolate_default(a2, b2) {
18930     var c2;
18931     return (typeof b2 === "number" ? number_default : b2 instanceof color ? rgb_default : (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default)(a2, b2);
18932   }
18933
18934   // node_modules/d3-transition/src/transition/attr.js
18935   function attrRemove2(name) {
18936     return function() {
18937       this.removeAttribute(name);
18938     };
18939   }
18940   function attrRemoveNS2(fullname) {
18941     return function() {
18942       this.removeAttributeNS(fullname.space, fullname.local);
18943     };
18944   }
18945   function attrConstant2(name, interpolate, value1) {
18946     var string00, string1 = value1 + "", interpolate0;
18947     return function() {
18948       var string0 = this.getAttribute(name);
18949       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
18950     };
18951   }
18952   function attrConstantNS2(fullname, interpolate, value1) {
18953     var string00, string1 = value1 + "", interpolate0;
18954     return function() {
18955       var string0 = this.getAttributeNS(fullname.space, fullname.local);
18956       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
18957     };
18958   }
18959   function attrFunction2(name, interpolate, value) {
18960     var string00, string10, interpolate0;
18961     return function() {
18962       var string0, value1 = value(this), string1;
18963       if (value1 == null) return void this.removeAttribute(name);
18964       string0 = this.getAttribute(name);
18965       string1 = value1 + "";
18966       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
18967     };
18968   }
18969   function attrFunctionNS2(fullname, interpolate, value) {
18970     var string00, string10, interpolate0;
18971     return function() {
18972       var string0, value1 = value(this), string1;
18973       if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
18974       string0 = this.getAttributeNS(fullname.space, fullname.local);
18975       string1 = value1 + "";
18976       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
18977     };
18978   }
18979   function attr_default2(name, value) {
18980     var fullname = namespace_default(name), i3 = fullname === "transform" ? interpolateTransformSvg : interpolate_default;
18981     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));
18982   }
18983
18984   // node_modules/d3-transition/src/transition/attrTween.js
18985   function attrInterpolate(name, i3) {
18986     return function(t2) {
18987       this.setAttribute(name, i3.call(this, t2));
18988     };
18989   }
18990   function attrInterpolateNS(fullname, i3) {
18991     return function(t2) {
18992       this.setAttributeNS(fullname.space, fullname.local, i3.call(this, t2));
18993     };
18994   }
18995   function attrTweenNS(fullname, value) {
18996     var t0, i0;
18997     function tween() {
18998       var i3 = value.apply(this, arguments);
18999       if (i3 !== i0) t0 = (i0 = i3) && attrInterpolateNS(fullname, i3);
19000       return t0;
19001     }
19002     tween._value = value;
19003     return tween;
19004   }
19005   function attrTween(name, value) {
19006     var t0, i0;
19007     function tween() {
19008       var i3 = value.apply(this, arguments);
19009       if (i3 !== i0) t0 = (i0 = i3) && attrInterpolate(name, i3);
19010       return t0;
19011     }
19012     tween._value = value;
19013     return tween;
19014   }
19015   function attrTween_default(name, value) {
19016     var key = "attr." + name;
19017     if (arguments.length < 2) return (key = this.tween(key)) && key._value;
19018     if (value == null) return this.tween(key, null);
19019     if (typeof value !== "function") throw new Error();
19020     var fullname = namespace_default(name);
19021     return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
19022   }
19023
19024   // node_modules/d3-transition/src/transition/delay.js
19025   function delayFunction(id2, value) {
19026     return function() {
19027       init(this, id2).delay = +value.apply(this, arguments);
19028     };
19029   }
19030   function delayConstant(id2, value) {
19031     return value = +value, function() {
19032       init(this, id2).delay = value;
19033     };
19034   }
19035   function delay_default(value) {
19036     var id2 = this._id;
19037     return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay;
19038   }
19039
19040   // node_modules/d3-transition/src/transition/duration.js
19041   function durationFunction(id2, value) {
19042     return function() {
19043       set2(this, id2).duration = +value.apply(this, arguments);
19044     };
19045   }
19046   function durationConstant(id2, value) {
19047     return value = +value, function() {
19048       set2(this, id2).duration = value;
19049     };
19050   }
19051   function duration_default(value) {
19052     var id2 = this._id;
19053     return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration;
19054   }
19055
19056   // node_modules/d3-transition/src/transition/ease.js
19057   function easeConstant(id2, value) {
19058     if (typeof value !== "function") throw new Error();
19059     return function() {
19060       set2(this, id2).ease = value;
19061     };
19062   }
19063   function ease_default(value) {
19064     var id2 = this._id;
19065     return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease;
19066   }
19067
19068   // node_modules/d3-transition/src/transition/easeVarying.js
19069   function easeVarying(id2, value) {
19070     return function() {
19071       var v2 = value.apply(this, arguments);
19072       if (typeof v2 !== "function") throw new Error();
19073       set2(this, id2).ease = v2;
19074     };
19075   }
19076   function easeVarying_default(value) {
19077     if (typeof value !== "function") throw new Error();
19078     return this.each(easeVarying(this._id, value));
19079   }
19080
19081   // node_modules/d3-transition/src/transition/filter.js
19082   function filter_default2(match) {
19083     if (typeof match !== "function") match = matcher_default(match);
19084     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19085       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
19086         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
19087           subgroup.push(node);
19088         }
19089       }
19090     }
19091     return new Transition(subgroups, this._parents, this._name, this._id);
19092   }
19093
19094   // node_modules/d3-transition/src/transition/merge.js
19095   function merge_default2(transition2) {
19096     if (transition2._id !== this._id) throw new Error();
19097     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) {
19098       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge3 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19099         if (node = group0[i3] || group1[i3]) {
19100           merge3[i3] = node;
19101         }
19102       }
19103     }
19104     for (; j2 < m0; ++j2) {
19105       merges[j2] = groups0[j2];
19106     }
19107     return new Transition(merges, this._parents, this._name, this._id);
19108   }
19109
19110   // node_modules/d3-transition/src/transition/on.js
19111   function start(name) {
19112     return (name + "").trim().split(/^|\s+/).every(function(t2) {
19113       var i3 = t2.indexOf(".");
19114       if (i3 >= 0) t2 = t2.slice(0, i3);
19115       return !t2 || t2 === "start";
19116     });
19117   }
19118   function onFunction(id2, name, listener) {
19119     var on0, on1, sit = start(name) ? init : set2;
19120     return function() {
19121       var schedule = sit(this, id2), on = schedule.on;
19122       if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
19123       schedule.on = on1;
19124     };
19125   }
19126   function on_default2(name, listener) {
19127     var id2 = this._id;
19128     return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
19129   }
19130
19131   // node_modules/d3-transition/src/transition/remove.js
19132   function removeFunction(id2) {
19133     return function() {
19134       var parent = this.parentNode;
19135       for (var i3 in this.__transition) if (+i3 !== id2) return;
19136       if (parent) parent.removeChild(this);
19137     };
19138   }
19139   function remove_default2() {
19140     return this.on("end.remove", removeFunction(this._id));
19141   }
19142
19143   // node_modules/d3-transition/src/transition/select.js
19144   function select_default3(select) {
19145     var name = this._name, id2 = this._id;
19146     if (typeof select !== "function") select = selector_default(select);
19147     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19148       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
19149         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
19150           if ("__data__" in node) subnode.__data__ = node.__data__;
19151           subgroup[i3] = subnode;
19152           schedule_default(subgroup[i3], name, id2, i3, subgroup, get2(node, id2));
19153         }
19154       }
19155     }
19156     return new Transition(subgroups, this._parents, name, id2);
19157   }
19158
19159   // node_modules/d3-transition/src/transition/selectAll.js
19160   function selectAll_default3(select) {
19161     var name = this._name, id2 = this._id;
19162     if (typeof select !== "function") select = selectorAll_default(select);
19163     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
19164       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19165         if (node = group[i3]) {
19166           for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) {
19167             if (child = children2[k2]) {
19168               schedule_default(child, name, id2, k2, children2, inherit2);
19169             }
19170           }
19171           subgroups.push(children2);
19172           parents.push(node);
19173         }
19174       }
19175     }
19176     return new Transition(subgroups, parents, name, id2);
19177   }
19178
19179   // node_modules/d3-transition/src/transition/selection.js
19180   var Selection2 = selection_default.prototype.constructor;
19181   function selection_default2() {
19182     return new Selection2(this._groups, this._parents);
19183   }
19184
19185   // node_modules/d3-transition/src/transition/style.js
19186   function styleNull(name, interpolate) {
19187     var string00, string10, interpolate0;
19188     return function() {
19189       var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
19190       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1);
19191     };
19192   }
19193   function styleRemove2(name) {
19194     return function() {
19195       this.style.removeProperty(name);
19196     };
19197   }
19198   function styleConstant2(name, interpolate, value1) {
19199     var string00, string1 = value1 + "", interpolate0;
19200     return function() {
19201       var string0 = styleValue(this, name);
19202       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
19203     };
19204   }
19205   function styleFunction2(name, interpolate, value) {
19206     var string00, string10, interpolate0;
19207     return function() {
19208       var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
19209       if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
19210       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
19211     };
19212   }
19213   function styleMaybeRemove(id2, name) {
19214     var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
19215     return function() {
19216       var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0;
19217       if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
19218       schedule.on = on1;
19219     };
19220   }
19221   function style_default2(name, value, priority) {
19222     var i3 = (name += "") === "transform" ? interpolateTransformCss : interpolate_default;
19223     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);
19224   }
19225
19226   // node_modules/d3-transition/src/transition/styleTween.js
19227   function styleInterpolate(name, i3, priority) {
19228     return function(t2) {
19229       this.style.setProperty(name, i3.call(this, t2), priority);
19230     };
19231   }
19232   function styleTween(name, value, priority) {
19233     var t2, i0;
19234     function tween() {
19235       var i3 = value.apply(this, arguments);
19236       if (i3 !== i0) t2 = (i0 = i3) && styleInterpolate(name, i3, priority);
19237       return t2;
19238     }
19239     tween._value = value;
19240     return tween;
19241   }
19242   function styleTween_default(name, value, priority) {
19243     var key = "style." + (name += "");
19244     if (arguments.length < 2) return (key = this.tween(key)) && key._value;
19245     if (value == null) return this.tween(key, null);
19246     if (typeof value !== "function") throw new Error();
19247     return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
19248   }
19249
19250   // node_modules/d3-transition/src/transition/text.js
19251   function textConstant2(value) {
19252     return function() {
19253       this.textContent = value;
19254     };
19255   }
19256   function textFunction2(value) {
19257     return function() {
19258       var value1 = value(this);
19259       this.textContent = value1 == null ? "" : value1;
19260     };
19261   }
19262   function text_default2(value) {
19263     return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + ""));
19264   }
19265
19266   // node_modules/d3-transition/src/transition/textTween.js
19267   function textInterpolate(i3) {
19268     return function(t2) {
19269       this.textContent = i3.call(this, t2);
19270     };
19271   }
19272   function textTween(value) {
19273     var t0, i0;
19274     function tween() {
19275       var i3 = value.apply(this, arguments);
19276       if (i3 !== i0) t0 = (i0 = i3) && textInterpolate(i3);
19277       return t0;
19278     }
19279     tween._value = value;
19280     return tween;
19281   }
19282   function textTween_default(value) {
19283     var key = "text";
19284     if (arguments.length < 1) return (key = this.tween(key)) && key._value;
19285     if (value == null) return this.tween(key, null);
19286     if (typeof value !== "function") throw new Error();
19287     return this.tween(key, textTween(value));
19288   }
19289
19290   // node_modules/d3-transition/src/transition/transition.js
19291   function transition_default() {
19292     var name = this._name, id0 = this._id, id1 = newId();
19293     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
19294       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19295         if (node = group[i3]) {
19296           var inherit2 = get2(node, id0);
19297           schedule_default(node, name, id1, i3, group, {
19298             time: inherit2.time + inherit2.delay + inherit2.duration,
19299             delay: 0,
19300             duration: inherit2.duration,
19301             ease: inherit2.ease
19302           });
19303         }
19304       }
19305     }
19306     return new Transition(groups, this._parents, name, id1);
19307   }
19308
19309   // node_modules/d3-transition/src/transition/end.js
19310   function end_default() {
19311     var on0, on1, that = this, id2 = that._id, size = that.size();
19312     return new Promise(function(resolve, reject) {
19313       var cancel = { value: reject }, end = { value: function() {
19314         if (--size === 0) resolve();
19315       } };
19316       that.each(function() {
19317         var schedule = set2(this, id2), on = schedule.on;
19318         if (on !== on0) {
19319           on1 = (on0 = on).copy();
19320           on1._.cancel.push(cancel);
19321           on1._.interrupt.push(cancel);
19322           on1._.end.push(end);
19323         }
19324         schedule.on = on1;
19325       });
19326       if (size === 0) resolve();
19327     });
19328   }
19329
19330   // node_modules/d3-transition/src/transition/index.js
19331   var id = 0;
19332   function Transition(groups, parents, name, id2) {
19333     this._groups = groups;
19334     this._parents = parents;
19335     this._name = name;
19336     this._id = id2;
19337   }
19338   function transition(name) {
19339     return selection_default().transition(name);
19340   }
19341   function newId() {
19342     return ++id;
19343   }
19344   var selection_prototype = selection_default.prototype;
19345   Transition.prototype = transition.prototype = {
19346     constructor: Transition,
19347     select: select_default3,
19348     selectAll: selectAll_default3,
19349     selectChild: selection_prototype.selectChild,
19350     selectChildren: selection_prototype.selectChildren,
19351     filter: filter_default2,
19352     merge: merge_default2,
19353     selection: selection_default2,
19354     transition: transition_default,
19355     call: selection_prototype.call,
19356     nodes: selection_prototype.nodes,
19357     node: selection_prototype.node,
19358     size: selection_prototype.size,
19359     empty: selection_prototype.empty,
19360     each: selection_prototype.each,
19361     on: on_default2,
19362     attr: attr_default2,
19363     attrTween: attrTween_default,
19364     style: style_default2,
19365     styleTween: styleTween_default,
19366     text: text_default2,
19367     textTween: textTween_default,
19368     remove: remove_default2,
19369     tween: tween_default,
19370     delay: delay_default,
19371     duration: duration_default,
19372     ease: ease_default,
19373     easeVarying: easeVarying_default,
19374     end: end_default,
19375     [Symbol.iterator]: selection_prototype[Symbol.iterator]
19376   };
19377
19378   // node_modules/d3-ease/src/linear.js
19379   var linear2 = (t2) => +t2;
19380
19381   // node_modules/d3-ease/src/cubic.js
19382   function cubicInOut(t2) {
19383     return ((t2 *= 2) <= 1 ? t2 * t2 * t2 : (t2 -= 2) * t2 * t2 + 2) / 2;
19384   }
19385
19386   // node_modules/d3-transition/src/selection/transition.js
19387   var defaultTiming = {
19388     time: null,
19389     // Set on use.
19390     delay: 0,
19391     duration: 250,
19392     ease: cubicInOut
19393   };
19394   function inherit(node, id2) {
19395     var timing;
19396     while (!(timing = node.__transition) || !(timing = timing[id2])) {
19397       if (!(node = node.parentNode)) {
19398         throw new Error("transition ".concat(id2, " not found"));
19399       }
19400     }
19401     return timing;
19402   }
19403   function transition_default2(name) {
19404     var id2, timing;
19405     if (name instanceof Transition) {
19406       id2 = name._id, name = name._name;
19407     } else {
19408       id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
19409     }
19410     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
19411       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19412         if (node = group[i3]) {
19413           schedule_default(node, name, id2, i3, group, timing || inherit(node, id2));
19414         }
19415       }
19416     }
19417     return new Transition(groups, this._parents, name, id2);
19418   }
19419
19420   // node_modules/d3-transition/src/selection/index.js
19421   selection_default.prototype.interrupt = interrupt_default2;
19422   selection_default.prototype.transition = transition_default2;
19423
19424   // node_modules/d3-zoom/src/constant.js
19425   var constant_default4 = (x2) => () => x2;
19426
19427   // node_modules/d3-zoom/src/event.js
19428   function ZoomEvent(type2, {
19429     sourceEvent,
19430     target,
19431     transform: transform2,
19432     dispatch: dispatch14
19433   }) {
19434     Object.defineProperties(this, {
19435       type: { value: type2, enumerable: true, configurable: true },
19436       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
19437       target: { value: target, enumerable: true, configurable: true },
19438       transform: { value: transform2, enumerable: true, configurable: true },
19439       _: { value: dispatch14 }
19440     });
19441   }
19442
19443   // node_modules/d3-zoom/src/transform.js
19444   function Transform(k2, x2, y2) {
19445     this.k = k2;
19446     this.x = x2;
19447     this.y = y2;
19448   }
19449   Transform.prototype = {
19450     constructor: Transform,
19451     scale: function(k2) {
19452       return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y);
19453     },
19454     translate: function(x2, y2) {
19455       return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2);
19456     },
19457     apply: function(point) {
19458       return [point[0] * this.k + this.x, point[1] * this.k + this.y];
19459     },
19460     applyX: function(x2) {
19461       return x2 * this.k + this.x;
19462     },
19463     applyY: function(y2) {
19464       return y2 * this.k + this.y;
19465     },
19466     invert: function(location) {
19467       return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
19468     },
19469     invertX: function(x2) {
19470       return (x2 - this.x) / this.k;
19471     },
19472     invertY: function(y2) {
19473       return (y2 - this.y) / this.k;
19474     },
19475     rescaleX: function(x2) {
19476       return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2));
19477     },
19478     rescaleY: function(y2) {
19479       return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2));
19480     },
19481     toString: function() {
19482       return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
19483     }
19484   };
19485   var identity2 = new Transform(1, 0, 0);
19486   transform.prototype = Transform.prototype;
19487   function transform(node) {
19488     while (!node.__zoom) if (!(node = node.parentNode)) return identity2;
19489     return node.__zoom;
19490   }
19491
19492   // node_modules/d3-zoom/src/noevent.js
19493   function nopropagation2(event) {
19494     event.stopImmediatePropagation();
19495   }
19496   function noevent_default2(event) {
19497     event.preventDefault();
19498     event.stopImmediatePropagation();
19499   }
19500
19501   // node_modules/d3-zoom/src/zoom.js
19502   function defaultFilter2(event) {
19503     return (!event.ctrlKey || event.type === "wheel") && !event.button;
19504   }
19505   function defaultExtent() {
19506     var e3 = this;
19507     if (e3 instanceof SVGElement) {
19508       e3 = e3.ownerSVGElement || e3;
19509       if (e3.hasAttribute("viewBox")) {
19510         e3 = e3.viewBox.baseVal;
19511         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
19512       }
19513       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
19514     }
19515     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
19516   }
19517   function defaultTransform() {
19518     return this.__zoom || identity2;
19519   }
19520   function defaultWheelDelta(event) {
19521     return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1);
19522   }
19523   function defaultTouchable2() {
19524     return navigator.maxTouchPoints || "ontouchstart" in this;
19525   }
19526   function defaultConstrain(transform2, extent, translateExtent) {
19527     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];
19528     return transform2.translate(
19529       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
19530       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
19531     );
19532   }
19533   function zoom_default2() {
19534     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;
19535     function zoom(selection2) {
19536       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)");
19537     }
19538     zoom.transform = function(collection, transform2, point, event) {
19539       var selection2 = collection.selection ? collection.selection() : collection;
19540       selection2.property("__zoom", defaultTransform);
19541       if (collection !== selection2) {
19542         schedule(collection, transform2, point, event);
19543       } else {
19544         selection2.interrupt().each(function() {
19545           gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end();
19546         });
19547       }
19548     };
19549     zoom.scaleBy = function(selection2, k2, p2, event) {
19550       zoom.scaleTo(selection2, function() {
19551         var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
19552         return k0 * k1;
19553       }, p2, event);
19554     };
19555     zoom.scaleTo = function(selection2, k2, p2, event) {
19556       zoom.transform(selection2, function() {
19557         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;
19558         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
19559       }, p2, event);
19560     };
19561     zoom.translateBy = function(selection2, x2, y2, event) {
19562       zoom.transform(selection2, function() {
19563         return constrain(this.__zoom.translate(
19564           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
19565           typeof y2 === "function" ? y2.apply(this, arguments) : y2
19566         ), extent.apply(this, arguments), translateExtent);
19567       }, null, event);
19568     };
19569     zoom.translateTo = function(selection2, x2, y2, p2, event) {
19570       zoom.transform(selection2, function() {
19571         var e3 = extent.apply(this, arguments), t2 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
19572         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
19573           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
19574           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
19575         ), e3, translateExtent);
19576       }, p2, event);
19577     };
19578     function scale(transform2, k2) {
19579       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
19580       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
19581     }
19582     function translate(transform2, p02, p1) {
19583       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
19584       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
19585     }
19586     function centroid(extent2) {
19587       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
19588     }
19589     function schedule(transition2, transform2, point, event) {
19590       transition2.on("start.zoom", function() {
19591         gesture(this, arguments).event(event).start();
19592       }).on("interrupt.zoom end.zoom", function() {
19593         gesture(this, arguments).event(event).end();
19594       }).tween("zoom", function() {
19595         var that = this, args = arguments, g3 = gesture(that, args).event(event), e3 = extent.apply(that, args), p2 = point == null ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, 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));
19596         return function(t2) {
19597           if (t2 === 1) t2 = b2;
19598           else {
19599             var l2 = i3(t2), k2 = w2 / l2[2];
19600             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
19601           }
19602           g3.zoom(null, t2);
19603         };
19604       });
19605     }
19606     function gesture(that, args, clean2) {
19607       return !clean2 && that.__zooming || new Gesture(that, args);
19608     }
19609     function Gesture(that, args) {
19610       this.that = that;
19611       this.args = args;
19612       this.active = 0;
19613       this.sourceEvent = null;
19614       this.extent = extent.apply(that, args);
19615       this.taps = 0;
19616     }
19617     Gesture.prototype = {
19618       event: function(event) {
19619         if (event) this.sourceEvent = event;
19620         return this;
19621       },
19622       start: function() {
19623         if (++this.active === 1) {
19624           this.that.__zooming = this;
19625           this.emit("start");
19626         }
19627         return this;
19628       },
19629       zoom: function(key, transform2) {
19630         if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]);
19631         if (this.touch0 && key !== "touch") this.touch0[1] = transform2.invert(this.touch0[0]);
19632         if (this.touch1 && key !== "touch") this.touch1[1] = transform2.invert(this.touch1[0]);
19633         this.that.__zoom = transform2;
19634         this.emit("zoom");
19635         return this;
19636       },
19637       end: function() {
19638         if (--this.active === 0) {
19639           delete this.that.__zooming;
19640           this.emit("end");
19641         }
19642         return this;
19643       },
19644       emit: function(type2) {
19645         var d2 = select_default2(this.that).datum();
19646         listeners.call(
19647           type2,
19648           this.that,
19649           new ZoomEvent(type2, {
19650             sourceEvent: this.sourceEvent,
19651             target: zoom,
19652             type: type2,
19653             transform: this.that.__zoom,
19654             dispatch: listeners
19655           }),
19656           d2
19657         );
19658       }
19659     };
19660     function wheeled(event, ...args) {
19661       if (!filter2.apply(this, arguments)) return;
19662       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);
19663       if (g3.wheel) {
19664         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
19665           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
19666         }
19667         clearTimeout(g3.wheel);
19668       } else if (t2.k === k2) return;
19669       else {
19670         g3.mouse = [p2, t2.invert(p2)];
19671         interrupt_default(this);
19672         g3.start();
19673       }
19674       noevent_default2(event);
19675       g3.wheel = setTimeout(wheelidled, wheelDelay);
19676       g3.zoom("mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
19677       function wheelidled() {
19678         g3.wheel = null;
19679         g3.end();
19680       }
19681     }
19682     function mousedowned(event, ...args) {
19683       if (touchending || !filter2.apply(this, arguments)) return;
19684       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;
19685       nodrag_default(event.view);
19686       nopropagation2(event);
19687       g3.mouse = [p2, this.__zoom.invert(p2)];
19688       interrupt_default(this);
19689       g3.start();
19690       function mousemoved(event2) {
19691         noevent_default2(event2);
19692         if (!g3.moved) {
19693           var dx = event2.clientX - x05, dy = event2.clientY - y05;
19694           g3.moved = dx * dx + dy * dy > clickDistance2;
19695         }
19696         g3.event(event2).zoom("mouse", constrain(translate(g3.that.__zoom, g3.mouse[0] = pointer_default(event2, currentTarget), g3.mouse[1]), g3.extent, translateExtent));
19697       }
19698       function mouseupped(event2) {
19699         v2.on("mousemove.zoom mouseup.zoom", null);
19700         yesdrag(event2.view, g3.moved);
19701         noevent_default2(event2);
19702         g3.event(event2).end();
19703       }
19704     }
19705     function dblclicked(event, ...args) {
19706       if (!filter2.apply(this, arguments)) return;
19707       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);
19708       noevent_default2(event);
19709       if (duration > 0) select_default2(this).transition().duration(duration).call(schedule, t1, p02, event);
19710       else select_default2(this).call(zoom.transform, t1, p02, event);
19711     }
19712     function touchstarted(event, ...args) {
19713       if (!filter2.apply(this, arguments)) return;
19714       var touches = event.touches, n3 = touches.length, g3 = gesture(this, args, event.changedTouches.length === n3).event(event), started, i3, t2, p2;
19715       nopropagation2(event);
19716       for (i3 = 0; i3 < n3; ++i3) {
19717         t2 = touches[i3], p2 = pointer_default(t2, this);
19718         p2 = [p2, this.__zoom.invert(p2), t2.identifier];
19719         if (!g3.touch0) g3.touch0 = p2, started = true, g3.taps = 1 + !!touchstarting;
19720         else if (!g3.touch1 && g3.touch0[2] !== p2[2]) g3.touch1 = p2, g3.taps = 0;
19721       }
19722       if (touchstarting) touchstarting = clearTimeout(touchstarting);
19723       if (started) {
19724         if (g3.taps < 2) touchfirst = p2[0], touchstarting = setTimeout(function() {
19725           touchstarting = null;
19726         }, touchDelay);
19727         interrupt_default(this);
19728         g3.start();
19729       }
19730     }
19731     function touchmoved(event, ...args) {
19732       if (!this.__zooming) return;
19733       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2, p2, l2;
19734       noevent_default2(event);
19735       for (i3 = 0; i3 < n3; ++i3) {
19736         t2 = touches[i3], p2 = pointer_default(t2, this);
19737         if (g3.touch0 && g3.touch0[2] === t2.identifier) g3.touch0[0] = p2;
19738         else if (g3.touch1 && g3.touch1[2] === t2.identifier) g3.touch1[0] = p2;
19739       }
19740       t2 = g3.that.__zoom;
19741       if (g3.touch1) {
19742         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;
19743         t2 = scale(t2, Math.sqrt(dp / dl));
19744         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
19745         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
19746       } else if (g3.touch0) p2 = g3.touch0[0], l2 = g3.touch0[1];
19747       else return;
19748       g3.zoom("touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
19749     }
19750     function touchended(event, ...args) {
19751       if (!this.__zooming) return;
19752       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2;
19753       nopropagation2(event);
19754       if (touchending) clearTimeout(touchending);
19755       touchending = setTimeout(function() {
19756         touchending = null;
19757       }, touchDelay);
19758       for (i3 = 0; i3 < n3; ++i3) {
19759         t2 = touches[i3];
19760         if (g3.touch0 && g3.touch0[2] === t2.identifier) delete g3.touch0;
19761         else if (g3.touch1 && g3.touch1[2] === t2.identifier) delete g3.touch1;
19762       }
19763       if (g3.touch1 && !g3.touch0) g3.touch0 = g3.touch1, delete g3.touch1;
19764       if (g3.touch0) g3.touch0[1] = this.__zoom.invert(g3.touch0[0]);
19765       else {
19766         g3.end();
19767         if (g3.taps === 2) {
19768           t2 = pointer_default(t2, this);
19769           if (Math.hypot(touchfirst[0] - t2[0], touchfirst[1] - t2[1]) < tapDistance) {
19770             var p2 = select_default2(this).on("dblclick.zoom");
19771             if (p2) p2.apply(this, arguments);
19772           }
19773         }
19774       }
19775     }
19776     zoom.wheelDelta = function(_2) {
19777       return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant_default4(+_2), zoom) : wheelDelta;
19778     };
19779     zoom.filter = function(_2) {
19780       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : filter2;
19781     };
19782     zoom.touchable = function(_2) {
19783       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : touchable;
19784     };
19785     zoom.extent = function(_2) {
19786       return arguments.length ? (extent = typeof _2 === "function" ? _2 : constant_default4([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
19787     };
19788     zoom.scaleExtent = function(_2) {
19789       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
19790     };
19791     zoom.translateExtent = function(_2) {
19792       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]]];
19793     };
19794     zoom.constrain = function(_2) {
19795       return arguments.length ? (constrain = _2, zoom) : constrain;
19796     };
19797     zoom.duration = function(_2) {
19798       return arguments.length ? (duration = +_2, zoom) : duration;
19799     };
19800     zoom.interpolate = function(_2) {
19801       return arguments.length ? (interpolate = _2, zoom) : interpolate;
19802     };
19803     zoom.on = function() {
19804       var value = listeners.on.apply(listeners, arguments);
19805       return value === listeners ? zoom : value;
19806     };
19807     zoom.clickDistance = function(_2) {
19808       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom) : Math.sqrt(clickDistance2);
19809     };
19810     zoom.tapDistance = function(_2) {
19811       return arguments.length ? (tapDistance = +_2, zoom) : tapDistance;
19812     };
19813     return zoom;
19814   }
19815
19816   // modules/geo/raw_mercator.js
19817   function geoRawMercator() {
19818     var project = mercatorRaw;
19819     var k2 = 512 / Math.PI;
19820     var x2 = 0;
19821     var y2 = 0;
19822     var clipExtent = [[0, 0], [0, 0]];
19823     function projection2(point) {
19824       point = project(point[0] * Math.PI / 180, point[1] * Math.PI / 180);
19825       return [point[0] * k2 + x2, y2 - point[1] * k2];
19826     }
19827     projection2.invert = function(point) {
19828       point = project.invert((point[0] - x2) / k2, (y2 - point[1]) / k2);
19829       return point && [point[0] * 180 / Math.PI, point[1] * 180 / Math.PI];
19830     };
19831     projection2.scale = function(_2) {
19832       if (!arguments.length) return k2;
19833       k2 = +_2;
19834       return projection2;
19835     };
19836     projection2.translate = function(_2) {
19837       if (!arguments.length) return [x2, y2];
19838       x2 = +_2[0];
19839       y2 = +_2[1];
19840       return projection2;
19841     };
19842     projection2.clipExtent = function(_2) {
19843       if (!arguments.length) return clipExtent;
19844       clipExtent = _2;
19845       return projection2;
19846     };
19847     projection2.transform = function(obj) {
19848       if (!arguments.length) return identity2.translate(x2, y2).scale(k2);
19849       x2 = +obj.x;
19850       y2 = +obj.y;
19851       k2 = +obj.k;
19852       return projection2;
19853     };
19854     projection2.stream = transform_default({
19855       point: function(x3, y3) {
19856         var vec = projection2([x3, y3]);
19857         this.stream.point(vec[0], vec[1]);
19858       }
19859     }).stream;
19860     return projection2;
19861   }
19862
19863   // modules/geo/ortho.js
19864   function geoOrthoNormalizedDotProduct(a2, b2, origin) {
19865     if (geoVecEqual(origin, a2) || geoVecEqual(origin, b2)) {
19866       return 1;
19867     }
19868     return geoVecNormalizedDot(a2, b2, origin);
19869   }
19870   function geoOrthoFilterDotProduct(dotp, epsilon3, lowerThreshold, upperThreshold, allowStraightAngles) {
19871     var val = Math.abs(dotp);
19872     if (val < epsilon3) {
19873       return 0;
19874     } else if (allowStraightAngles && Math.abs(val - 1) < epsilon3) {
19875       return 0;
19876     } else if (val < lowerThreshold || val > upperThreshold) {
19877       return dotp;
19878     } else {
19879       return null;
19880     }
19881   }
19882   function geoOrthoCalcScore(points, isClosed, epsilon3, threshold) {
19883     var score = 0;
19884     var first = isClosed ? 0 : 1;
19885     var last = isClosed ? points.length : points.length - 1;
19886     var coords = points.map(function(p2) {
19887       return p2.coord;
19888     });
19889     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
19890     var upperThreshold = Math.cos(threshold * Math.PI / 180);
19891     for (var i3 = first; i3 < last; i3++) {
19892       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19893       var origin = coords[i3];
19894       var b2 = coords[(i3 + 1) % coords.length];
19895       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold);
19896       if (dotp === null) continue;
19897       score = score + 2 * Math.min(Math.abs(dotp - 1), Math.min(Math.abs(dotp), Math.abs(dotp + 1)));
19898     }
19899     return score;
19900   }
19901   function geoOrthoMaxOffsetAngle(coords, isClosed, lessThan) {
19902     var max3 = -Infinity;
19903     var first = isClosed ? 0 : 1;
19904     var last = isClosed ? coords.length : coords.length - 1;
19905     for (var i3 = first; i3 < last; i3++) {
19906       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19907       var origin = coords[i3];
19908       var b2 = coords[(i3 + 1) % coords.length];
19909       var normalizedDotP = geoOrthoNormalizedDotProduct(a2, b2, origin);
19910       var angle2 = Math.acos(Math.abs(normalizedDotP)) * 180 / Math.PI;
19911       if (angle2 > 45) angle2 = 90 - angle2;
19912       if (angle2 >= lessThan) continue;
19913       if (angle2 > max3) max3 = angle2;
19914     }
19915     if (max3 === -Infinity) return null;
19916     return max3;
19917   }
19918   function geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles) {
19919     var score = null;
19920     var first = isClosed ? 0 : 1;
19921     var last = isClosed ? coords.length : coords.length - 1;
19922     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
19923     var upperThreshold = Math.cos(threshold * Math.PI / 180);
19924     for (var i3 = first; i3 < last; i3++) {
19925       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19926       var origin = coords[i3];
19927       var b2 = coords[(i3 + 1) % coords.length];
19928       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold, allowStraightAngles);
19929       if (dotp === null) continue;
19930       if (Math.abs(dotp) > 0) return 1;
19931       score = 0;
19932     }
19933     return score;
19934   }
19935
19936   // node_modules/lodash-es/_freeGlobal.js
19937   var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
19938   var freeGlobal_default = freeGlobal;
19939
19940   // node_modules/lodash-es/_root.js
19941   var freeSelf = typeof self == "object" && self && self.Object === Object && self;
19942   var root2 = freeGlobal_default || freeSelf || Function("return this")();
19943   var root_default = root2;
19944
19945   // node_modules/lodash-es/_Symbol.js
19946   var Symbol2 = root_default.Symbol;
19947   var Symbol_default = Symbol2;
19948
19949   // node_modules/lodash-es/_getRawTag.js
19950   var objectProto = Object.prototype;
19951   var hasOwnProperty = objectProto.hasOwnProperty;
19952   var nativeObjectToString = objectProto.toString;
19953   var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
19954   function getRawTag(value) {
19955     var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag];
19956     try {
19957       value[symToStringTag] = void 0;
19958       var unmasked = true;
19959     } catch (e3) {
19960     }
19961     var result = nativeObjectToString.call(value);
19962     if (unmasked) {
19963       if (isOwn) {
19964         value[symToStringTag] = tag2;
19965       } else {
19966         delete value[symToStringTag];
19967       }
19968     }
19969     return result;
19970   }
19971   var getRawTag_default = getRawTag;
19972
19973   // node_modules/lodash-es/_objectToString.js
19974   var objectProto2 = Object.prototype;
19975   var nativeObjectToString2 = objectProto2.toString;
19976   function objectToString(value) {
19977     return nativeObjectToString2.call(value);
19978   }
19979   var objectToString_default = objectToString;
19980
19981   // node_modules/lodash-es/_baseGetTag.js
19982   var nullTag = "[object Null]";
19983   var undefinedTag = "[object Undefined]";
19984   var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
19985   function baseGetTag(value) {
19986     if (value == null) {
19987       return value === void 0 ? undefinedTag : nullTag;
19988     }
19989     return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
19990   }
19991   var baseGetTag_default = baseGetTag;
19992
19993   // node_modules/lodash-es/isObjectLike.js
19994   function isObjectLike(value) {
19995     return value != null && typeof value == "object";
19996   }
19997   var isObjectLike_default = isObjectLike;
19998
19999   // node_modules/lodash-es/isSymbol.js
20000   var symbolTag = "[object Symbol]";
20001   function isSymbol(value) {
20002     return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
20003   }
20004   var isSymbol_default = isSymbol;
20005
20006   // node_modules/lodash-es/_arrayMap.js
20007   function arrayMap(array2, iteratee) {
20008     var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
20009     while (++index < length2) {
20010       result[index] = iteratee(array2[index], index, array2);
20011     }
20012     return result;
20013   }
20014   var arrayMap_default = arrayMap;
20015
20016   // node_modules/lodash-es/isArray.js
20017   var isArray = Array.isArray;
20018   var isArray_default = isArray;
20019
20020   // node_modules/lodash-es/_baseToString.js
20021   var INFINITY = 1 / 0;
20022   var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
20023   var symbolToString = symbolProto ? symbolProto.toString : void 0;
20024   function baseToString(value) {
20025     if (typeof value == "string") {
20026       return value;
20027     }
20028     if (isArray_default(value)) {
20029       return arrayMap_default(value, baseToString) + "";
20030     }
20031     if (isSymbol_default(value)) {
20032       return symbolToString ? symbolToString.call(value) : "";
20033     }
20034     var result = value + "";
20035     return result == "0" && 1 / value == -INFINITY ? "-0" : result;
20036   }
20037   var baseToString_default = baseToString;
20038
20039   // node_modules/lodash-es/_trimmedEndIndex.js
20040   var reWhitespace = /\s/;
20041   function trimmedEndIndex(string) {
20042     var index = string.length;
20043     while (index-- && reWhitespace.test(string.charAt(index))) {
20044     }
20045     return index;
20046   }
20047   var trimmedEndIndex_default = trimmedEndIndex;
20048
20049   // node_modules/lodash-es/_baseTrim.js
20050   var reTrimStart = /^\s+/;
20051   function baseTrim(string) {
20052     return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
20053   }
20054   var baseTrim_default = baseTrim;
20055
20056   // node_modules/lodash-es/isObject.js
20057   function isObject(value) {
20058     var type2 = typeof value;
20059     return value != null && (type2 == "object" || type2 == "function");
20060   }
20061   var isObject_default = isObject;
20062
20063   // node_modules/lodash-es/toNumber.js
20064   var NAN = 0 / 0;
20065   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
20066   var reIsBinary = /^0b[01]+$/i;
20067   var reIsOctal = /^0o[0-7]+$/i;
20068   var freeParseInt = parseInt;
20069   function toNumber(value) {
20070     if (typeof value == "number") {
20071       return value;
20072     }
20073     if (isSymbol_default(value)) {
20074       return NAN;
20075     }
20076     if (isObject_default(value)) {
20077       var other2 = typeof value.valueOf == "function" ? value.valueOf() : value;
20078       value = isObject_default(other2) ? other2 + "" : other2;
20079     }
20080     if (typeof value != "string") {
20081       return value === 0 ? value : +value;
20082     }
20083     value = baseTrim_default(value);
20084     var isBinary = reIsBinary.test(value);
20085     return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
20086   }
20087   var toNumber_default = toNumber;
20088
20089   // node_modules/lodash-es/identity.js
20090   function identity3(value) {
20091     return value;
20092   }
20093   var identity_default3 = identity3;
20094
20095   // node_modules/lodash-es/isFunction.js
20096   var asyncTag = "[object AsyncFunction]";
20097   var funcTag = "[object Function]";
20098   var genTag = "[object GeneratorFunction]";
20099   var proxyTag = "[object Proxy]";
20100   function isFunction(value) {
20101     if (!isObject_default(value)) {
20102       return false;
20103     }
20104     var tag2 = baseGetTag_default(value);
20105     return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag;
20106   }
20107   var isFunction_default = isFunction;
20108
20109   // node_modules/lodash-es/_coreJsData.js
20110   var coreJsData = root_default["__core-js_shared__"];
20111   var coreJsData_default = coreJsData;
20112
20113   // node_modules/lodash-es/_isMasked.js
20114   var maskSrcKey = function() {
20115     var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
20116     return uid ? "Symbol(src)_1." + uid : "";
20117   }();
20118   function isMasked(func) {
20119     return !!maskSrcKey && maskSrcKey in func;
20120   }
20121   var isMasked_default = isMasked;
20122
20123   // node_modules/lodash-es/_toSource.js
20124   var funcProto = Function.prototype;
20125   var funcToString = funcProto.toString;
20126   function toSource(func) {
20127     if (func != null) {
20128       try {
20129         return funcToString.call(func);
20130       } catch (e3) {
20131       }
20132       try {
20133         return func + "";
20134       } catch (e3) {
20135       }
20136     }
20137     return "";
20138   }
20139   var toSource_default = toSource;
20140
20141   // node_modules/lodash-es/_baseIsNative.js
20142   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
20143   var reIsHostCtor = /^\[object .+?Constructor\]$/;
20144   var funcProto2 = Function.prototype;
20145   var objectProto3 = Object.prototype;
20146   var funcToString2 = funcProto2.toString;
20147   var hasOwnProperty2 = objectProto3.hasOwnProperty;
20148   var reIsNative = RegExp(
20149     "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
20150   );
20151   function baseIsNative(value) {
20152     if (!isObject_default(value) || isMasked_default(value)) {
20153       return false;
20154     }
20155     var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
20156     return pattern.test(toSource_default(value));
20157   }
20158   var baseIsNative_default = baseIsNative;
20159
20160   // node_modules/lodash-es/_getValue.js
20161   function getValue(object, key) {
20162     return object == null ? void 0 : object[key];
20163   }
20164   var getValue_default = getValue;
20165
20166   // node_modules/lodash-es/_getNative.js
20167   function getNative(object, key) {
20168     var value = getValue_default(object, key);
20169     return baseIsNative_default(value) ? value : void 0;
20170   }
20171   var getNative_default = getNative;
20172
20173   // node_modules/lodash-es/_WeakMap.js
20174   var WeakMap = getNative_default(root_default, "WeakMap");
20175   var WeakMap_default = WeakMap;
20176
20177   // node_modules/lodash-es/_baseCreate.js
20178   var objectCreate = Object.create;
20179   var baseCreate = /* @__PURE__ */ function() {
20180     function object() {
20181     }
20182     return function(proto) {
20183       if (!isObject_default(proto)) {
20184         return {};
20185       }
20186       if (objectCreate) {
20187         return objectCreate(proto);
20188       }
20189       object.prototype = proto;
20190       var result = new object();
20191       object.prototype = void 0;
20192       return result;
20193     };
20194   }();
20195   var baseCreate_default = baseCreate;
20196
20197   // node_modules/lodash-es/_apply.js
20198   function apply(func, thisArg, args) {
20199     switch (args.length) {
20200       case 0:
20201         return func.call(thisArg);
20202       case 1:
20203         return func.call(thisArg, args[0]);
20204       case 2:
20205         return func.call(thisArg, args[0], args[1]);
20206       case 3:
20207         return func.call(thisArg, args[0], args[1], args[2]);
20208     }
20209     return func.apply(thisArg, args);
20210   }
20211   var apply_default = apply;
20212
20213   // node_modules/lodash-es/_copyArray.js
20214   function copyArray(source, array2) {
20215     var index = -1, length2 = source.length;
20216     array2 || (array2 = Array(length2));
20217     while (++index < length2) {
20218       array2[index] = source[index];
20219     }
20220     return array2;
20221   }
20222   var copyArray_default = copyArray;
20223
20224   // node_modules/lodash-es/_shortOut.js
20225   var HOT_COUNT = 800;
20226   var HOT_SPAN = 16;
20227   var nativeNow = Date.now;
20228   function shortOut(func) {
20229     var count = 0, lastCalled = 0;
20230     return function() {
20231       var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
20232       lastCalled = stamp;
20233       if (remaining > 0) {
20234         if (++count >= HOT_COUNT) {
20235           return arguments[0];
20236         }
20237       } else {
20238         count = 0;
20239       }
20240       return func.apply(void 0, arguments);
20241     };
20242   }
20243   var shortOut_default = shortOut;
20244
20245   // node_modules/lodash-es/constant.js
20246   function constant(value) {
20247     return function() {
20248       return value;
20249     };
20250   }
20251   var constant_default5 = constant;
20252
20253   // node_modules/lodash-es/_defineProperty.js
20254   var defineProperty = function() {
20255     try {
20256       var func = getNative_default(Object, "defineProperty");
20257       func({}, "", {});
20258       return func;
20259     } catch (e3) {
20260     }
20261   }();
20262   var defineProperty_default = defineProperty;
20263
20264   // node_modules/lodash-es/_baseSetToString.js
20265   var baseSetToString = !defineProperty_default ? identity_default3 : function(func, string) {
20266     return defineProperty_default(func, "toString", {
20267       "configurable": true,
20268       "enumerable": false,
20269       "value": constant_default5(string),
20270       "writable": true
20271     });
20272   };
20273   var baseSetToString_default = baseSetToString;
20274
20275   // node_modules/lodash-es/_setToString.js
20276   var setToString = shortOut_default(baseSetToString_default);
20277   var setToString_default = setToString;
20278
20279   // node_modules/lodash-es/_isIndex.js
20280   var MAX_SAFE_INTEGER = 9007199254740991;
20281   var reIsUint = /^(?:0|[1-9]\d*)$/;
20282   function isIndex(value, length2) {
20283     var type2 = typeof value;
20284     length2 = length2 == null ? MAX_SAFE_INTEGER : length2;
20285     return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
20286   }
20287   var isIndex_default = isIndex;
20288
20289   // node_modules/lodash-es/_baseAssignValue.js
20290   function baseAssignValue(object, key, value) {
20291     if (key == "__proto__" && defineProperty_default) {
20292       defineProperty_default(object, key, {
20293         "configurable": true,
20294         "enumerable": true,
20295         "value": value,
20296         "writable": true
20297       });
20298     } else {
20299       object[key] = value;
20300     }
20301   }
20302   var baseAssignValue_default = baseAssignValue;
20303
20304   // node_modules/lodash-es/eq.js
20305   function eq(value, other2) {
20306     return value === other2 || value !== value && other2 !== other2;
20307   }
20308   var eq_default = eq;
20309
20310   // node_modules/lodash-es/_assignValue.js
20311   var objectProto4 = Object.prototype;
20312   var hasOwnProperty3 = objectProto4.hasOwnProperty;
20313   function assignValue(object, key, value) {
20314     var objValue = object[key];
20315     if (!(hasOwnProperty3.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
20316       baseAssignValue_default(object, key, value);
20317     }
20318   }
20319   var assignValue_default = assignValue;
20320
20321   // node_modules/lodash-es/_copyObject.js
20322   function copyObject(source, props, object, customizer) {
20323     var isNew = !object;
20324     object || (object = {});
20325     var index = -1, length2 = props.length;
20326     while (++index < length2) {
20327       var key = props[index];
20328       var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
20329       if (newValue === void 0) {
20330         newValue = source[key];
20331       }
20332       if (isNew) {
20333         baseAssignValue_default(object, key, newValue);
20334       } else {
20335         assignValue_default(object, key, newValue);
20336       }
20337     }
20338     return object;
20339   }
20340   var copyObject_default = copyObject;
20341
20342   // node_modules/lodash-es/_overRest.js
20343   var nativeMax = Math.max;
20344   function overRest(func, start2, transform2) {
20345     start2 = nativeMax(start2 === void 0 ? func.length - 1 : start2, 0);
20346     return function() {
20347       var args = arguments, index = -1, length2 = nativeMax(args.length - start2, 0), array2 = Array(length2);
20348       while (++index < length2) {
20349         array2[index] = args[start2 + index];
20350       }
20351       index = -1;
20352       var otherArgs = Array(start2 + 1);
20353       while (++index < start2) {
20354         otherArgs[index] = args[index];
20355       }
20356       otherArgs[start2] = transform2(array2);
20357       return apply_default(func, this, otherArgs);
20358     };
20359   }
20360   var overRest_default = overRest;
20361
20362   // node_modules/lodash-es/_baseRest.js
20363   function baseRest(func, start2) {
20364     return setToString_default(overRest_default(func, start2, identity_default3), func + "");
20365   }
20366   var baseRest_default = baseRest;
20367
20368   // node_modules/lodash-es/isLength.js
20369   var MAX_SAFE_INTEGER2 = 9007199254740991;
20370   function isLength(value) {
20371     return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
20372   }
20373   var isLength_default = isLength;
20374
20375   // node_modules/lodash-es/isArrayLike.js
20376   function isArrayLike(value) {
20377     return value != null && isLength_default(value.length) && !isFunction_default(value);
20378   }
20379   var isArrayLike_default = isArrayLike;
20380
20381   // node_modules/lodash-es/_isIterateeCall.js
20382   function isIterateeCall(value, index, object) {
20383     if (!isObject_default(object)) {
20384       return false;
20385     }
20386     var type2 = typeof index;
20387     if (type2 == "number" ? isArrayLike_default(object) && isIndex_default(index, object.length) : type2 == "string" && index in object) {
20388       return eq_default(object[index], value);
20389     }
20390     return false;
20391   }
20392   var isIterateeCall_default = isIterateeCall;
20393
20394   // node_modules/lodash-es/_createAssigner.js
20395   function createAssigner(assigner) {
20396     return baseRest_default(function(object, sources) {
20397       var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : void 0, guard = length2 > 2 ? sources[2] : void 0;
20398       customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : void 0;
20399       if (guard && isIterateeCall_default(sources[0], sources[1], guard)) {
20400         customizer = length2 < 3 ? void 0 : customizer;
20401         length2 = 1;
20402       }
20403       object = Object(object);
20404       while (++index < length2) {
20405         var source = sources[index];
20406         if (source) {
20407           assigner(object, source, index, customizer);
20408         }
20409       }
20410       return object;
20411     });
20412   }
20413   var createAssigner_default = createAssigner;
20414
20415   // node_modules/lodash-es/_isPrototype.js
20416   var objectProto5 = Object.prototype;
20417   function isPrototype(value) {
20418     var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
20419     return value === proto;
20420   }
20421   var isPrototype_default = isPrototype;
20422
20423   // node_modules/lodash-es/_baseTimes.js
20424   function baseTimes(n3, iteratee) {
20425     var index = -1, result = Array(n3);
20426     while (++index < n3) {
20427       result[index] = iteratee(index);
20428     }
20429     return result;
20430   }
20431   var baseTimes_default = baseTimes;
20432
20433   // node_modules/lodash-es/_baseIsArguments.js
20434   var argsTag = "[object Arguments]";
20435   function baseIsArguments(value) {
20436     return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
20437   }
20438   var baseIsArguments_default = baseIsArguments;
20439
20440   // node_modules/lodash-es/isArguments.js
20441   var objectProto6 = Object.prototype;
20442   var hasOwnProperty4 = objectProto6.hasOwnProperty;
20443   var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
20444   var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
20445     return arguments;
20446   }()) ? baseIsArguments_default : function(value) {
20447     return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
20448   };
20449   var isArguments_default = isArguments;
20450
20451   // node_modules/lodash-es/stubFalse.js
20452   function stubFalse() {
20453     return false;
20454   }
20455   var stubFalse_default = stubFalse;
20456
20457   // node_modules/lodash-es/isBuffer.js
20458   var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
20459   var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
20460   var moduleExports = freeModule && freeModule.exports === freeExports;
20461   var Buffer2 = moduleExports ? root_default.Buffer : void 0;
20462   var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
20463   var isBuffer = nativeIsBuffer || stubFalse_default;
20464   var isBuffer_default = isBuffer;
20465
20466   // node_modules/lodash-es/_baseIsTypedArray.js
20467   var argsTag2 = "[object Arguments]";
20468   var arrayTag = "[object Array]";
20469   var boolTag = "[object Boolean]";
20470   var dateTag = "[object Date]";
20471   var errorTag = "[object Error]";
20472   var funcTag2 = "[object Function]";
20473   var mapTag = "[object Map]";
20474   var numberTag = "[object Number]";
20475   var objectTag = "[object Object]";
20476   var regexpTag = "[object RegExp]";
20477   var setTag = "[object Set]";
20478   var stringTag = "[object String]";
20479   var weakMapTag = "[object WeakMap]";
20480   var arrayBufferTag = "[object ArrayBuffer]";
20481   var dataViewTag = "[object DataView]";
20482   var float32Tag = "[object Float32Array]";
20483   var float64Tag = "[object Float64Array]";
20484   var int8Tag = "[object Int8Array]";
20485   var int16Tag = "[object Int16Array]";
20486   var int32Tag = "[object Int32Array]";
20487   var uint8Tag = "[object Uint8Array]";
20488   var uint8ClampedTag = "[object Uint8ClampedArray]";
20489   var uint16Tag = "[object Uint16Array]";
20490   var uint32Tag = "[object Uint32Array]";
20491   var typedArrayTags = {};
20492   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
20493   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;
20494   function baseIsTypedArray(value) {
20495     return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
20496   }
20497   var baseIsTypedArray_default = baseIsTypedArray;
20498
20499   // node_modules/lodash-es/_baseUnary.js
20500   function baseUnary(func) {
20501     return function(value) {
20502       return func(value);
20503     };
20504   }
20505   var baseUnary_default = baseUnary;
20506
20507   // node_modules/lodash-es/_nodeUtil.js
20508   var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
20509   var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
20510   var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
20511   var freeProcess = moduleExports2 && freeGlobal_default.process;
20512   var nodeUtil = function() {
20513     try {
20514       var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
20515       if (types) {
20516         return types;
20517       }
20518       return freeProcess && freeProcess.binding && freeProcess.binding("util");
20519     } catch (e3) {
20520     }
20521   }();
20522   var nodeUtil_default = nodeUtil;
20523
20524   // node_modules/lodash-es/isTypedArray.js
20525   var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
20526   var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
20527   var isTypedArray_default = isTypedArray;
20528
20529   // node_modules/lodash-es/_arrayLikeKeys.js
20530   var objectProto7 = Object.prototype;
20531   var hasOwnProperty5 = objectProto7.hasOwnProperty;
20532   function arrayLikeKeys(value, inherited) {
20533     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;
20534     for (var key in value) {
20535       if ((inherited || hasOwnProperty5.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
20536       (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
20537       isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
20538       isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
20539       isIndex_default(key, length2)))) {
20540         result.push(key);
20541       }
20542     }
20543     return result;
20544   }
20545   var arrayLikeKeys_default = arrayLikeKeys;
20546
20547   // node_modules/lodash-es/_overArg.js
20548   function overArg(func, transform2) {
20549     return function(arg) {
20550       return func(transform2(arg));
20551     };
20552   }
20553   var overArg_default = overArg;
20554
20555   // node_modules/lodash-es/_nativeKeys.js
20556   var nativeKeys = overArg_default(Object.keys, Object);
20557   var nativeKeys_default = nativeKeys;
20558
20559   // node_modules/lodash-es/_baseKeys.js
20560   var objectProto8 = Object.prototype;
20561   var hasOwnProperty6 = objectProto8.hasOwnProperty;
20562   function baseKeys(object) {
20563     if (!isPrototype_default(object)) {
20564       return nativeKeys_default(object);
20565     }
20566     var result = [];
20567     for (var key in Object(object)) {
20568       if (hasOwnProperty6.call(object, key) && key != "constructor") {
20569         result.push(key);
20570       }
20571     }
20572     return result;
20573   }
20574   var baseKeys_default = baseKeys;
20575
20576   // node_modules/lodash-es/keys.js
20577   function keys(object) {
20578     return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
20579   }
20580   var keys_default = keys;
20581
20582   // node_modules/lodash-es/_nativeKeysIn.js
20583   function nativeKeysIn(object) {
20584     var result = [];
20585     if (object != null) {
20586       for (var key in Object(object)) {
20587         result.push(key);
20588       }
20589     }
20590     return result;
20591   }
20592   var nativeKeysIn_default = nativeKeysIn;
20593
20594   // node_modules/lodash-es/_baseKeysIn.js
20595   var objectProto9 = Object.prototype;
20596   var hasOwnProperty7 = objectProto9.hasOwnProperty;
20597   function baseKeysIn(object) {
20598     if (!isObject_default(object)) {
20599       return nativeKeysIn_default(object);
20600     }
20601     var isProto = isPrototype_default(object), result = [];
20602     for (var key in object) {
20603       if (!(key == "constructor" && (isProto || !hasOwnProperty7.call(object, key)))) {
20604         result.push(key);
20605       }
20606     }
20607     return result;
20608   }
20609   var baseKeysIn_default = baseKeysIn;
20610
20611   // node_modules/lodash-es/keysIn.js
20612   function keysIn(object) {
20613     return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
20614   }
20615   var keysIn_default = keysIn;
20616
20617   // node_modules/lodash-es/_nativeCreate.js
20618   var nativeCreate = getNative_default(Object, "create");
20619   var nativeCreate_default = nativeCreate;
20620
20621   // node_modules/lodash-es/_hashClear.js
20622   function hashClear() {
20623     this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
20624     this.size = 0;
20625   }
20626   var hashClear_default = hashClear;
20627
20628   // node_modules/lodash-es/_hashDelete.js
20629   function hashDelete(key) {
20630     var result = this.has(key) && delete this.__data__[key];
20631     this.size -= result ? 1 : 0;
20632     return result;
20633   }
20634   var hashDelete_default = hashDelete;
20635
20636   // node_modules/lodash-es/_hashGet.js
20637   var HASH_UNDEFINED = "__lodash_hash_undefined__";
20638   var objectProto10 = Object.prototype;
20639   var hasOwnProperty8 = objectProto10.hasOwnProperty;
20640   function hashGet(key) {
20641     var data = this.__data__;
20642     if (nativeCreate_default) {
20643       var result = data[key];
20644       return result === HASH_UNDEFINED ? void 0 : result;
20645     }
20646     return hasOwnProperty8.call(data, key) ? data[key] : void 0;
20647   }
20648   var hashGet_default = hashGet;
20649
20650   // node_modules/lodash-es/_hashHas.js
20651   var objectProto11 = Object.prototype;
20652   var hasOwnProperty9 = objectProto11.hasOwnProperty;
20653   function hashHas(key) {
20654     var data = this.__data__;
20655     return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty9.call(data, key);
20656   }
20657   var hashHas_default = hashHas;
20658
20659   // node_modules/lodash-es/_hashSet.js
20660   var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
20661   function hashSet(key, value) {
20662     var data = this.__data__;
20663     this.size += this.has(key) ? 0 : 1;
20664     data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
20665     return this;
20666   }
20667   var hashSet_default = hashSet;
20668
20669   // node_modules/lodash-es/_Hash.js
20670   function Hash(entries) {
20671     var index = -1, length2 = entries == null ? 0 : entries.length;
20672     this.clear();
20673     while (++index < length2) {
20674       var entry = entries[index];
20675       this.set(entry[0], entry[1]);
20676     }
20677   }
20678   Hash.prototype.clear = hashClear_default;
20679   Hash.prototype["delete"] = hashDelete_default;
20680   Hash.prototype.get = hashGet_default;
20681   Hash.prototype.has = hashHas_default;
20682   Hash.prototype.set = hashSet_default;
20683   var Hash_default = Hash;
20684
20685   // node_modules/lodash-es/_listCacheClear.js
20686   function listCacheClear() {
20687     this.__data__ = [];
20688     this.size = 0;
20689   }
20690   var listCacheClear_default = listCacheClear;
20691
20692   // node_modules/lodash-es/_assocIndexOf.js
20693   function assocIndexOf(array2, key) {
20694     var length2 = array2.length;
20695     while (length2--) {
20696       if (eq_default(array2[length2][0], key)) {
20697         return length2;
20698       }
20699     }
20700     return -1;
20701   }
20702   var assocIndexOf_default = assocIndexOf;
20703
20704   // node_modules/lodash-es/_listCacheDelete.js
20705   var arrayProto = Array.prototype;
20706   var splice = arrayProto.splice;
20707   function listCacheDelete(key) {
20708     var data = this.__data__, index = assocIndexOf_default(data, key);
20709     if (index < 0) {
20710       return false;
20711     }
20712     var lastIndex = data.length - 1;
20713     if (index == lastIndex) {
20714       data.pop();
20715     } else {
20716       splice.call(data, index, 1);
20717     }
20718     --this.size;
20719     return true;
20720   }
20721   var listCacheDelete_default = listCacheDelete;
20722
20723   // node_modules/lodash-es/_listCacheGet.js
20724   function listCacheGet(key) {
20725     var data = this.__data__, index = assocIndexOf_default(data, key);
20726     return index < 0 ? void 0 : data[index][1];
20727   }
20728   var listCacheGet_default = listCacheGet;
20729
20730   // node_modules/lodash-es/_listCacheHas.js
20731   function listCacheHas(key) {
20732     return assocIndexOf_default(this.__data__, key) > -1;
20733   }
20734   var listCacheHas_default = listCacheHas;
20735
20736   // node_modules/lodash-es/_listCacheSet.js
20737   function listCacheSet(key, value) {
20738     var data = this.__data__, index = assocIndexOf_default(data, key);
20739     if (index < 0) {
20740       ++this.size;
20741       data.push([key, value]);
20742     } else {
20743       data[index][1] = value;
20744     }
20745     return this;
20746   }
20747   var listCacheSet_default = listCacheSet;
20748
20749   // node_modules/lodash-es/_ListCache.js
20750   function ListCache(entries) {
20751     var index = -1, length2 = entries == null ? 0 : entries.length;
20752     this.clear();
20753     while (++index < length2) {
20754       var entry = entries[index];
20755       this.set(entry[0], entry[1]);
20756     }
20757   }
20758   ListCache.prototype.clear = listCacheClear_default;
20759   ListCache.prototype["delete"] = listCacheDelete_default;
20760   ListCache.prototype.get = listCacheGet_default;
20761   ListCache.prototype.has = listCacheHas_default;
20762   ListCache.prototype.set = listCacheSet_default;
20763   var ListCache_default = ListCache;
20764
20765   // node_modules/lodash-es/_Map.js
20766   var Map2 = getNative_default(root_default, "Map");
20767   var Map_default = Map2;
20768
20769   // node_modules/lodash-es/_mapCacheClear.js
20770   function mapCacheClear() {
20771     this.size = 0;
20772     this.__data__ = {
20773       "hash": new Hash_default(),
20774       "map": new (Map_default || ListCache_default)(),
20775       "string": new Hash_default()
20776     };
20777   }
20778   var mapCacheClear_default = mapCacheClear;
20779
20780   // node_modules/lodash-es/_isKeyable.js
20781   function isKeyable(value) {
20782     var type2 = typeof value;
20783     return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
20784   }
20785   var isKeyable_default = isKeyable;
20786
20787   // node_modules/lodash-es/_getMapData.js
20788   function getMapData(map2, key) {
20789     var data = map2.__data__;
20790     return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
20791   }
20792   var getMapData_default = getMapData;
20793
20794   // node_modules/lodash-es/_mapCacheDelete.js
20795   function mapCacheDelete(key) {
20796     var result = getMapData_default(this, key)["delete"](key);
20797     this.size -= result ? 1 : 0;
20798     return result;
20799   }
20800   var mapCacheDelete_default = mapCacheDelete;
20801
20802   // node_modules/lodash-es/_mapCacheGet.js
20803   function mapCacheGet(key) {
20804     return getMapData_default(this, key).get(key);
20805   }
20806   var mapCacheGet_default = mapCacheGet;
20807
20808   // node_modules/lodash-es/_mapCacheHas.js
20809   function mapCacheHas(key) {
20810     return getMapData_default(this, key).has(key);
20811   }
20812   var mapCacheHas_default = mapCacheHas;
20813
20814   // node_modules/lodash-es/_mapCacheSet.js
20815   function mapCacheSet(key, value) {
20816     var data = getMapData_default(this, key), size = data.size;
20817     data.set(key, value);
20818     this.size += data.size == size ? 0 : 1;
20819     return this;
20820   }
20821   var mapCacheSet_default = mapCacheSet;
20822
20823   // node_modules/lodash-es/_MapCache.js
20824   function MapCache(entries) {
20825     var index = -1, length2 = entries == null ? 0 : entries.length;
20826     this.clear();
20827     while (++index < length2) {
20828       var entry = entries[index];
20829       this.set(entry[0], entry[1]);
20830     }
20831   }
20832   MapCache.prototype.clear = mapCacheClear_default;
20833   MapCache.prototype["delete"] = mapCacheDelete_default;
20834   MapCache.prototype.get = mapCacheGet_default;
20835   MapCache.prototype.has = mapCacheHas_default;
20836   MapCache.prototype.set = mapCacheSet_default;
20837   var MapCache_default = MapCache;
20838
20839   // node_modules/lodash-es/toString.js
20840   function toString(value) {
20841     return value == null ? "" : baseToString_default(value);
20842   }
20843   var toString_default = toString;
20844
20845   // node_modules/lodash-es/_arrayPush.js
20846   function arrayPush(array2, values) {
20847     var index = -1, length2 = values.length, offset = array2.length;
20848     while (++index < length2) {
20849       array2[offset + index] = values[index];
20850     }
20851     return array2;
20852   }
20853   var arrayPush_default = arrayPush;
20854
20855   // node_modules/lodash-es/_getPrototype.js
20856   var getPrototype = overArg_default(Object.getPrototypeOf, Object);
20857   var getPrototype_default = getPrototype;
20858
20859   // node_modules/lodash-es/isPlainObject.js
20860   var objectTag2 = "[object Object]";
20861   var funcProto3 = Function.prototype;
20862   var objectProto12 = Object.prototype;
20863   var funcToString3 = funcProto3.toString;
20864   var hasOwnProperty10 = objectProto12.hasOwnProperty;
20865   var objectCtorString = funcToString3.call(Object);
20866   function isPlainObject(value) {
20867     if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag2) {
20868       return false;
20869     }
20870     var proto = getPrototype_default(value);
20871     if (proto === null) {
20872       return true;
20873     }
20874     var Ctor = hasOwnProperty10.call(proto, "constructor") && proto.constructor;
20875     return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
20876   }
20877   var isPlainObject_default = isPlainObject;
20878
20879   // node_modules/lodash-es/_basePropertyOf.js
20880   function basePropertyOf(object) {
20881     return function(key) {
20882       return object == null ? void 0 : object[key];
20883     };
20884   }
20885   var basePropertyOf_default = basePropertyOf;
20886
20887   // node_modules/lodash-es/_stackClear.js
20888   function stackClear() {
20889     this.__data__ = new ListCache_default();
20890     this.size = 0;
20891   }
20892   var stackClear_default = stackClear;
20893
20894   // node_modules/lodash-es/_stackDelete.js
20895   function stackDelete(key) {
20896     var data = this.__data__, result = data["delete"](key);
20897     this.size = data.size;
20898     return result;
20899   }
20900   var stackDelete_default = stackDelete;
20901
20902   // node_modules/lodash-es/_stackGet.js
20903   function stackGet(key) {
20904     return this.__data__.get(key);
20905   }
20906   var stackGet_default = stackGet;
20907
20908   // node_modules/lodash-es/_stackHas.js
20909   function stackHas(key) {
20910     return this.__data__.has(key);
20911   }
20912   var stackHas_default = stackHas;
20913
20914   // node_modules/lodash-es/_stackSet.js
20915   var LARGE_ARRAY_SIZE = 200;
20916   function stackSet(key, value) {
20917     var data = this.__data__;
20918     if (data instanceof ListCache_default) {
20919       var pairs2 = data.__data__;
20920       if (!Map_default || pairs2.length < LARGE_ARRAY_SIZE - 1) {
20921         pairs2.push([key, value]);
20922         this.size = ++data.size;
20923         return this;
20924       }
20925       data = this.__data__ = new MapCache_default(pairs2);
20926     }
20927     data.set(key, value);
20928     this.size = data.size;
20929     return this;
20930   }
20931   var stackSet_default = stackSet;
20932
20933   // node_modules/lodash-es/_Stack.js
20934   function Stack(entries) {
20935     var data = this.__data__ = new ListCache_default(entries);
20936     this.size = data.size;
20937   }
20938   Stack.prototype.clear = stackClear_default;
20939   Stack.prototype["delete"] = stackDelete_default;
20940   Stack.prototype.get = stackGet_default;
20941   Stack.prototype.has = stackHas_default;
20942   Stack.prototype.set = stackSet_default;
20943   var Stack_default = Stack;
20944
20945   // node_modules/lodash-es/_cloneBuffer.js
20946   var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
20947   var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
20948   var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
20949   var Buffer3 = moduleExports3 ? root_default.Buffer : void 0;
20950   var allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : void 0;
20951   function cloneBuffer(buffer, isDeep) {
20952     if (isDeep) {
20953       return buffer.slice();
20954     }
20955     var length2 = buffer.length, result = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
20956     buffer.copy(result);
20957     return result;
20958   }
20959   var cloneBuffer_default = cloneBuffer;
20960
20961   // node_modules/lodash-es/_arrayFilter.js
20962   function arrayFilter(array2, predicate) {
20963     var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
20964     while (++index < length2) {
20965       var value = array2[index];
20966       if (predicate(value, index, array2)) {
20967         result[resIndex++] = value;
20968       }
20969     }
20970     return result;
20971   }
20972   var arrayFilter_default = arrayFilter;
20973
20974   // node_modules/lodash-es/stubArray.js
20975   function stubArray() {
20976     return [];
20977   }
20978   var stubArray_default = stubArray;
20979
20980   // node_modules/lodash-es/_getSymbols.js
20981   var objectProto13 = Object.prototype;
20982   var propertyIsEnumerable2 = objectProto13.propertyIsEnumerable;
20983   var nativeGetSymbols = Object.getOwnPropertySymbols;
20984   var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
20985     if (object == null) {
20986       return [];
20987     }
20988     object = Object(object);
20989     return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
20990       return propertyIsEnumerable2.call(object, symbol);
20991     });
20992   };
20993   var getSymbols_default = getSymbols;
20994
20995   // node_modules/lodash-es/_baseGetAllKeys.js
20996   function baseGetAllKeys(object, keysFunc, symbolsFunc) {
20997     var result = keysFunc(object);
20998     return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
20999   }
21000   var baseGetAllKeys_default = baseGetAllKeys;
21001
21002   // node_modules/lodash-es/_getAllKeys.js
21003   function getAllKeys(object) {
21004     return baseGetAllKeys_default(object, keys_default, getSymbols_default);
21005   }
21006   var getAllKeys_default = getAllKeys;
21007
21008   // node_modules/lodash-es/_DataView.js
21009   var DataView2 = getNative_default(root_default, "DataView");
21010   var DataView_default = DataView2;
21011
21012   // node_modules/lodash-es/_Promise.js
21013   var Promise2 = getNative_default(root_default, "Promise");
21014   var Promise_default = Promise2;
21015
21016   // node_modules/lodash-es/_Set.js
21017   var Set2 = getNative_default(root_default, "Set");
21018   var Set_default = Set2;
21019
21020   // node_modules/lodash-es/_getTag.js
21021   var mapTag2 = "[object Map]";
21022   var objectTag3 = "[object Object]";
21023   var promiseTag = "[object Promise]";
21024   var setTag2 = "[object Set]";
21025   var weakMapTag2 = "[object WeakMap]";
21026   var dataViewTag2 = "[object DataView]";
21027   var dataViewCtorString = toSource_default(DataView_default);
21028   var mapCtorString = toSource_default(Map_default);
21029   var promiseCtorString = toSource_default(Promise_default);
21030   var setCtorString = toSource_default(Set_default);
21031   var weakMapCtorString = toSource_default(WeakMap_default);
21032   var getTag = baseGetTag_default;
21033   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) {
21034     getTag = function(value) {
21035       var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
21036       if (ctorString) {
21037         switch (ctorString) {
21038           case dataViewCtorString:
21039             return dataViewTag2;
21040           case mapCtorString:
21041             return mapTag2;
21042           case promiseCtorString:
21043             return promiseTag;
21044           case setCtorString:
21045             return setTag2;
21046           case weakMapCtorString:
21047             return weakMapTag2;
21048         }
21049       }
21050       return result;
21051     };
21052   }
21053   var getTag_default = getTag;
21054
21055   // node_modules/lodash-es/_Uint8Array.js
21056   var Uint8Array2 = root_default.Uint8Array;
21057   var Uint8Array_default = Uint8Array2;
21058
21059   // node_modules/lodash-es/_cloneArrayBuffer.js
21060   function cloneArrayBuffer(arrayBuffer) {
21061     var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
21062     new Uint8Array_default(result).set(new Uint8Array_default(arrayBuffer));
21063     return result;
21064   }
21065   var cloneArrayBuffer_default = cloneArrayBuffer;
21066
21067   // node_modules/lodash-es/_cloneTypedArray.js
21068   function cloneTypedArray(typedArray, isDeep) {
21069     var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
21070     return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
21071   }
21072   var cloneTypedArray_default = cloneTypedArray;
21073
21074   // node_modules/lodash-es/_initCloneObject.js
21075   function initCloneObject(object) {
21076     return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
21077   }
21078   var initCloneObject_default = initCloneObject;
21079
21080   // node_modules/lodash-es/_setCacheAdd.js
21081   var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
21082   function setCacheAdd(value) {
21083     this.__data__.set(value, HASH_UNDEFINED3);
21084     return this;
21085   }
21086   var setCacheAdd_default = setCacheAdd;
21087
21088   // node_modules/lodash-es/_setCacheHas.js
21089   function setCacheHas(value) {
21090     return this.__data__.has(value);
21091   }
21092   var setCacheHas_default = setCacheHas;
21093
21094   // node_modules/lodash-es/_SetCache.js
21095   function SetCache(values) {
21096     var index = -1, length2 = values == null ? 0 : values.length;
21097     this.__data__ = new MapCache_default();
21098     while (++index < length2) {
21099       this.add(values[index]);
21100     }
21101   }
21102   SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
21103   SetCache.prototype.has = setCacheHas_default;
21104   var SetCache_default = SetCache;
21105
21106   // node_modules/lodash-es/_arraySome.js
21107   function arraySome(array2, predicate) {
21108     var index = -1, length2 = array2 == null ? 0 : array2.length;
21109     while (++index < length2) {
21110       if (predicate(array2[index], index, array2)) {
21111         return true;
21112       }
21113     }
21114     return false;
21115   }
21116   var arraySome_default = arraySome;
21117
21118   // node_modules/lodash-es/_cacheHas.js
21119   function cacheHas(cache, key) {
21120     return cache.has(key);
21121   }
21122   var cacheHas_default = cacheHas;
21123
21124   // node_modules/lodash-es/_equalArrays.js
21125   var COMPARE_PARTIAL_FLAG = 1;
21126   var COMPARE_UNORDERED_FLAG = 2;
21127   function equalArrays(array2, other2, bitmask, customizer, equalFunc, stack) {
21128     var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other2.length;
21129     if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
21130       return false;
21131     }
21132     var arrStacked = stack.get(array2);
21133     var othStacked = stack.get(other2);
21134     if (arrStacked && othStacked) {
21135       return arrStacked == other2 && othStacked == array2;
21136     }
21137     var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
21138     stack.set(array2, other2);
21139     stack.set(other2, array2);
21140     while (++index < arrLength) {
21141       var arrValue = array2[index], othValue = other2[index];
21142       if (customizer) {
21143         var compared = isPartial ? customizer(othValue, arrValue, index, other2, array2, stack) : customizer(arrValue, othValue, index, array2, other2, stack);
21144       }
21145       if (compared !== void 0) {
21146         if (compared) {
21147           continue;
21148         }
21149         result = false;
21150         break;
21151       }
21152       if (seen) {
21153         if (!arraySome_default(other2, function(othValue2, othIndex) {
21154           if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
21155             return seen.push(othIndex);
21156           }
21157         })) {
21158           result = false;
21159           break;
21160         }
21161       } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
21162         result = false;
21163         break;
21164       }
21165     }
21166     stack["delete"](array2);
21167     stack["delete"](other2);
21168     return result;
21169   }
21170   var equalArrays_default = equalArrays;
21171
21172   // node_modules/lodash-es/_mapToArray.js
21173   function mapToArray(map2) {
21174     var index = -1, result = Array(map2.size);
21175     map2.forEach(function(value, key) {
21176       result[++index] = [key, value];
21177     });
21178     return result;
21179   }
21180   var mapToArray_default = mapToArray;
21181
21182   // node_modules/lodash-es/_setToArray.js
21183   function setToArray(set4) {
21184     var index = -1, result = Array(set4.size);
21185     set4.forEach(function(value) {
21186       result[++index] = value;
21187     });
21188     return result;
21189   }
21190   var setToArray_default = setToArray;
21191
21192   // node_modules/lodash-es/_equalByTag.js
21193   var COMPARE_PARTIAL_FLAG2 = 1;
21194   var COMPARE_UNORDERED_FLAG2 = 2;
21195   var boolTag2 = "[object Boolean]";
21196   var dateTag2 = "[object Date]";
21197   var errorTag2 = "[object Error]";
21198   var mapTag3 = "[object Map]";
21199   var numberTag2 = "[object Number]";
21200   var regexpTag2 = "[object RegExp]";
21201   var setTag3 = "[object Set]";
21202   var stringTag2 = "[object String]";
21203   var symbolTag2 = "[object Symbol]";
21204   var arrayBufferTag2 = "[object ArrayBuffer]";
21205   var dataViewTag3 = "[object DataView]";
21206   var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
21207   var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
21208   function equalByTag(object, other2, tag2, bitmask, customizer, equalFunc, stack) {
21209     switch (tag2) {
21210       case dataViewTag3:
21211         if (object.byteLength != other2.byteLength || object.byteOffset != other2.byteOffset) {
21212           return false;
21213         }
21214         object = object.buffer;
21215         other2 = other2.buffer;
21216       case arrayBufferTag2:
21217         if (object.byteLength != other2.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other2))) {
21218           return false;
21219         }
21220         return true;
21221       case boolTag2:
21222       case dateTag2:
21223       case numberTag2:
21224         return eq_default(+object, +other2);
21225       case errorTag2:
21226         return object.name == other2.name && object.message == other2.message;
21227       case regexpTag2:
21228       case stringTag2:
21229         return object == other2 + "";
21230       case mapTag3:
21231         var convert = mapToArray_default;
21232       case setTag3:
21233         var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
21234         convert || (convert = setToArray_default);
21235         if (object.size != other2.size && !isPartial) {
21236           return false;
21237         }
21238         var stacked = stack.get(object);
21239         if (stacked) {
21240           return stacked == other2;
21241         }
21242         bitmask |= COMPARE_UNORDERED_FLAG2;
21243         stack.set(object, other2);
21244         var result = equalArrays_default(convert(object), convert(other2), bitmask, customizer, equalFunc, stack);
21245         stack["delete"](object);
21246         return result;
21247       case symbolTag2:
21248         if (symbolValueOf) {
21249           return symbolValueOf.call(object) == symbolValueOf.call(other2);
21250         }
21251     }
21252     return false;
21253   }
21254   var equalByTag_default = equalByTag;
21255
21256   // node_modules/lodash-es/_equalObjects.js
21257   var COMPARE_PARTIAL_FLAG3 = 1;
21258   var objectProto14 = Object.prototype;
21259   var hasOwnProperty11 = objectProto14.hasOwnProperty;
21260   function equalObjects(object, other2, bitmask, customizer, equalFunc, stack) {
21261     var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other2), othLength = othProps.length;
21262     if (objLength != othLength && !isPartial) {
21263       return false;
21264     }
21265     var index = objLength;
21266     while (index--) {
21267       var key = objProps[index];
21268       if (!(isPartial ? key in other2 : hasOwnProperty11.call(other2, key))) {
21269         return false;
21270       }
21271     }
21272     var objStacked = stack.get(object);
21273     var othStacked = stack.get(other2);
21274     if (objStacked && othStacked) {
21275       return objStacked == other2 && othStacked == object;
21276     }
21277     var result = true;
21278     stack.set(object, other2);
21279     stack.set(other2, object);
21280     var skipCtor = isPartial;
21281     while (++index < objLength) {
21282       key = objProps[index];
21283       var objValue = object[key], othValue = other2[key];
21284       if (customizer) {
21285         var compared = isPartial ? customizer(othValue, objValue, key, other2, object, stack) : customizer(objValue, othValue, key, object, other2, stack);
21286       }
21287       if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
21288         result = false;
21289         break;
21290       }
21291       skipCtor || (skipCtor = key == "constructor");
21292     }
21293     if (result && !skipCtor) {
21294       var objCtor = object.constructor, othCtor = other2.constructor;
21295       if (objCtor != othCtor && ("constructor" in object && "constructor" in other2) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
21296         result = false;
21297       }
21298     }
21299     stack["delete"](object);
21300     stack["delete"](other2);
21301     return result;
21302   }
21303   var equalObjects_default = equalObjects;
21304
21305   // node_modules/lodash-es/_baseIsEqualDeep.js
21306   var COMPARE_PARTIAL_FLAG4 = 1;
21307   var argsTag3 = "[object Arguments]";
21308   var arrayTag2 = "[object Array]";
21309   var objectTag4 = "[object Object]";
21310   var objectProto15 = Object.prototype;
21311   var hasOwnProperty12 = objectProto15.hasOwnProperty;
21312   function baseIsEqualDeep(object, other2, bitmask, customizer, equalFunc, stack) {
21313     var objIsArr = isArray_default(object), othIsArr = isArray_default(other2), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other2);
21314     objTag = objTag == argsTag3 ? objectTag4 : objTag;
21315     othTag = othTag == argsTag3 ? objectTag4 : othTag;
21316     var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
21317     if (isSameTag && isBuffer_default(object)) {
21318       if (!isBuffer_default(other2)) {
21319         return false;
21320       }
21321       objIsArr = true;
21322       objIsObj = false;
21323     }
21324     if (isSameTag && !objIsObj) {
21325       stack || (stack = new Stack_default());
21326       return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other2, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other2, objTag, bitmask, customizer, equalFunc, stack);
21327     }
21328     if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
21329       var objIsWrapped = objIsObj && hasOwnProperty12.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty12.call(other2, "__wrapped__");
21330       if (objIsWrapped || othIsWrapped) {
21331         var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other2.value() : other2;
21332         stack || (stack = new Stack_default());
21333         return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
21334       }
21335     }
21336     if (!isSameTag) {
21337       return false;
21338     }
21339     stack || (stack = new Stack_default());
21340     return equalObjects_default(object, other2, bitmask, customizer, equalFunc, stack);
21341   }
21342   var baseIsEqualDeep_default = baseIsEqualDeep;
21343
21344   // node_modules/lodash-es/_baseIsEqual.js
21345   function baseIsEqual(value, other2, bitmask, customizer, stack) {
21346     if (value === other2) {
21347       return true;
21348     }
21349     if (value == null || other2 == null || !isObjectLike_default(value) && !isObjectLike_default(other2)) {
21350       return value !== value && other2 !== other2;
21351     }
21352     return baseIsEqualDeep_default(value, other2, bitmask, customizer, baseIsEqual, stack);
21353   }
21354   var baseIsEqual_default = baseIsEqual;
21355
21356   // node_modules/lodash-es/_createBaseFor.js
21357   function createBaseFor(fromRight) {
21358     return function(object, iteratee, keysFunc) {
21359       var index = -1, iterable = Object(object), props = keysFunc(object), length2 = props.length;
21360       while (length2--) {
21361         var key = props[fromRight ? length2 : ++index];
21362         if (iteratee(iterable[key], key, iterable) === false) {
21363           break;
21364         }
21365       }
21366       return object;
21367     };
21368   }
21369   var createBaseFor_default = createBaseFor;
21370
21371   // node_modules/lodash-es/_baseFor.js
21372   var baseFor = createBaseFor_default();
21373   var baseFor_default = baseFor;
21374
21375   // node_modules/lodash-es/now.js
21376   var now2 = function() {
21377     return root_default.Date.now();
21378   };
21379   var now_default = now2;
21380
21381   // node_modules/lodash-es/debounce.js
21382   var FUNC_ERROR_TEXT = "Expected a function";
21383   var nativeMax2 = Math.max;
21384   var nativeMin = Math.min;
21385   function debounce(func, wait, options2) {
21386     var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
21387     if (typeof func != "function") {
21388       throw new TypeError(FUNC_ERROR_TEXT);
21389     }
21390     wait = toNumber_default(wait) || 0;
21391     if (isObject_default(options2)) {
21392       leading = !!options2.leading;
21393       maxing = "maxWait" in options2;
21394       maxWait = maxing ? nativeMax2(toNumber_default(options2.maxWait) || 0, wait) : maxWait;
21395       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
21396     }
21397     function invokeFunc(time) {
21398       var args = lastArgs, thisArg = lastThis;
21399       lastArgs = lastThis = void 0;
21400       lastInvokeTime = time;
21401       result = func.apply(thisArg, args);
21402       return result;
21403     }
21404     function leadingEdge(time) {
21405       lastInvokeTime = time;
21406       timerId = setTimeout(timerExpired, wait);
21407       return leading ? invokeFunc(time) : result;
21408     }
21409     function remainingWait(time) {
21410       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
21411       return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
21412     }
21413     function shouldInvoke(time) {
21414       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
21415       return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
21416     }
21417     function timerExpired() {
21418       var time = now_default();
21419       if (shouldInvoke(time)) {
21420         return trailingEdge(time);
21421       }
21422       timerId = setTimeout(timerExpired, remainingWait(time));
21423     }
21424     function trailingEdge(time) {
21425       timerId = void 0;
21426       if (trailing && lastArgs) {
21427         return invokeFunc(time);
21428       }
21429       lastArgs = lastThis = void 0;
21430       return result;
21431     }
21432     function cancel() {
21433       if (timerId !== void 0) {
21434         clearTimeout(timerId);
21435       }
21436       lastInvokeTime = 0;
21437       lastArgs = lastCallTime = lastThis = timerId = void 0;
21438     }
21439     function flush() {
21440       return timerId === void 0 ? result : trailingEdge(now_default());
21441     }
21442     function debounced() {
21443       var time = now_default(), isInvoking = shouldInvoke(time);
21444       lastArgs = arguments;
21445       lastThis = this;
21446       lastCallTime = time;
21447       if (isInvoking) {
21448         if (timerId === void 0) {
21449           return leadingEdge(lastCallTime);
21450         }
21451         if (maxing) {
21452           clearTimeout(timerId);
21453           timerId = setTimeout(timerExpired, wait);
21454           return invokeFunc(lastCallTime);
21455         }
21456       }
21457       if (timerId === void 0) {
21458         timerId = setTimeout(timerExpired, wait);
21459       }
21460       return result;
21461     }
21462     debounced.cancel = cancel;
21463     debounced.flush = flush;
21464     return debounced;
21465   }
21466   var debounce_default = debounce;
21467
21468   // node_modules/lodash-es/_assignMergeValue.js
21469   function assignMergeValue(object, key, value) {
21470     if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
21471       baseAssignValue_default(object, key, value);
21472     }
21473   }
21474   var assignMergeValue_default = assignMergeValue;
21475
21476   // node_modules/lodash-es/isArrayLikeObject.js
21477   function isArrayLikeObject(value) {
21478     return isObjectLike_default(value) && isArrayLike_default(value);
21479   }
21480   var isArrayLikeObject_default = isArrayLikeObject;
21481
21482   // node_modules/lodash-es/_safeGet.js
21483   function safeGet(object, key) {
21484     if (key === "constructor" && typeof object[key] === "function") {
21485       return;
21486     }
21487     if (key == "__proto__") {
21488       return;
21489     }
21490     return object[key];
21491   }
21492   var safeGet_default = safeGet;
21493
21494   // node_modules/lodash-es/toPlainObject.js
21495   function toPlainObject(value) {
21496     return copyObject_default(value, keysIn_default(value));
21497   }
21498   var toPlainObject_default = toPlainObject;
21499
21500   // node_modules/lodash-es/_baseMergeDeep.js
21501   function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
21502     var objValue = safeGet_default(object, key), srcValue = safeGet_default(source, key), stacked = stack.get(srcValue);
21503     if (stacked) {
21504       assignMergeValue_default(object, key, stacked);
21505       return;
21506     }
21507     var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
21508     var isCommon = newValue === void 0;
21509     if (isCommon) {
21510       var isArr = isArray_default(srcValue), isBuff = !isArr && isBuffer_default(srcValue), isTyped = !isArr && !isBuff && isTypedArray_default(srcValue);
21511       newValue = srcValue;
21512       if (isArr || isBuff || isTyped) {
21513         if (isArray_default(objValue)) {
21514           newValue = objValue;
21515         } else if (isArrayLikeObject_default(objValue)) {
21516           newValue = copyArray_default(objValue);
21517         } else if (isBuff) {
21518           isCommon = false;
21519           newValue = cloneBuffer_default(srcValue, true);
21520         } else if (isTyped) {
21521           isCommon = false;
21522           newValue = cloneTypedArray_default(srcValue, true);
21523         } else {
21524           newValue = [];
21525         }
21526       } else if (isPlainObject_default(srcValue) || isArguments_default(srcValue)) {
21527         newValue = objValue;
21528         if (isArguments_default(objValue)) {
21529           newValue = toPlainObject_default(objValue);
21530         } else if (!isObject_default(objValue) || isFunction_default(objValue)) {
21531           newValue = initCloneObject_default(srcValue);
21532         }
21533       } else {
21534         isCommon = false;
21535       }
21536     }
21537     if (isCommon) {
21538       stack.set(srcValue, newValue);
21539       mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
21540       stack["delete"](srcValue);
21541     }
21542     assignMergeValue_default(object, key, newValue);
21543   }
21544   var baseMergeDeep_default = baseMergeDeep;
21545
21546   // node_modules/lodash-es/_baseMerge.js
21547   function baseMerge(object, source, srcIndex, customizer, stack) {
21548     if (object === source) {
21549       return;
21550     }
21551     baseFor_default(source, function(srcValue, key) {
21552       stack || (stack = new Stack_default());
21553       if (isObject_default(srcValue)) {
21554         baseMergeDeep_default(object, source, key, srcIndex, baseMerge, customizer, stack);
21555       } else {
21556         var newValue = customizer ? customizer(safeGet_default(object, key), srcValue, key + "", object, source, stack) : void 0;
21557         if (newValue === void 0) {
21558           newValue = srcValue;
21559         }
21560         assignMergeValue_default(object, key, newValue);
21561       }
21562     }, keysIn_default);
21563   }
21564   var baseMerge_default = baseMerge;
21565
21566   // node_modules/lodash-es/_escapeHtmlChar.js
21567   var htmlEscapes = {
21568     "&": "&amp;",
21569     "<": "&lt;",
21570     ">": "&gt;",
21571     '"': "&quot;",
21572     "'": "&#39;"
21573   };
21574   var escapeHtmlChar = basePropertyOf_default(htmlEscapes);
21575   var escapeHtmlChar_default = escapeHtmlChar;
21576
21577   // node_modules/lodash-es/escape.js
21578   var reUnescapedHtml = /[&<>"']/g;
21579   var reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
21580   function escape2(string) {
21581     string = toString_default(string);
21582     return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar_default) : string;
21583   }
21584   var escape_default = escape2;
21585
21586   // node_modules/lodash-es/isEqual.js
21587   function isEqual(value, other2) {
21588     return baseIsEqual_default(value, other2);
21589   }
21590   var isEqual_default = isEqual;
21591
21592   // node_modules/lodash-es/isNumber.js
21593   var numberTag3 = "[object Number]";
21594   function isNumber(value) {
21595     return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag3;
21596   }
21597   var isNumber_default = isNumber;
21598
21599   // node_modules/lodash-es/merge.js
21600   var merge2 = createAssigner_default(function(object, source, srcIndex) {
21601     baseMerge_default(object, source, srcIndex);
21602   });
21603   var merge_default3 = merge2;
21604
21605   // node_modules/lodash-es/throttle.js
21606   var FUNC_ERROR_TEXT2 = "Expected a function";
21607   function throttle(func, wait, options2) {
21608     var leading = true, trailing = true;
21609     if (typeof func != "function") {
21610       throw new TypeError(FUNC_ERROR_TEXT2);
21611     }
21612     if (isObject_default(options2)) {
21613       leading = "leading" in options2 ? !!options2.leading : leading;
21614       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
21615     }
21616     return debounce_default(func, wait, {
21617       "leading": leading,
21618       "maxWait": wait,
21619       "trailing": trailing
21620     });
21621   }
21622   var throttle_default = throttle;
21623
21624   // node_modules/lodash-es/_unescapeHtmlChar.js
21625   var htmlUnescapes = {
21626     "&amp;": "&",
21627     "&lt;": "<",
21628     "&gt;": ">",
21629     "&quot;": '"',
21630     "&#39;": "'"
21631   };
21632   var unescapeHtmlChar = basePropertyOf_default(htmlUnescapes);
21633   var unescapeHtmlChar_default = unescapeHtmlChar;
21634
21635   // node_modules/lodash-es/unescape.js
21636   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
21637   var reHasEscapedHtml = RegExp(reEscapedHtml.source);
21638   function unescape(string) {
21639     string = toString_default(string);
21640     return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string;
21641   }
21642   var unescape_default = unescape;
21643
21644   // modules/osm/tags.js
21645   function osmIsInterestingTag(key) {
21646     return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
21647     key.indexOf("tiger:") !== 0;
21648   }
21649   var osmLifecyclePrefixes = {
21650     // nonexistent, might be built
21651     proposed: true,
21652     planned: true,
21653     // under maintenance or between groundbreaking and opening
21654     construction: true,
21655     // existent but not functional
21656     disused: true,
21657     // dilapidated to nonexistent
21658     abandoned: true,
21659     was: true,
21660     // nonexistent, still may appear in imagery
21661     dismantled: true,
21662     razed: true,
21663     demolished: true,
21664     destroyed: true,
21665     removed: true,
21666     obliterated: true,
21667     // existent occasionally, e.g. stormwater drainage basin
21668     intermittent: true
21669   };
21670   function osmRemoveLifecyclePrefix(key) {
21671     const keySegments = key.split(":");
21672     if (keySegments.length === 1) return key;
21673     if (keySegments[0] in osmLifecyclePrefixes) {
21674       return key.slice(keySegments[0].length + 1);
21675     }
21676     return key;
21677   }
21678   var osmAreaKeys = {};
21679   function osmSetAreaKeys(value) {
21680     osmAreaKeys = value;
21681   }
21682   var osmAreaKeysExceptions = {
21683     highway: {
21684       elevator: true,
21685       rest_area: true,
21686       services: true
21687     },
21688     public_transport: {
21689       platform: true
21690     },
21691     railway: {
21692       platform: true,
21693       roundhouse: true,
21694       station: true,
21695       traverser: true,
21696       turntable: true,
21697       wash: true,
21698       ventilation_shaft: true
21699     },
21700     waterway: {
21701       dam: true
21702     },
21703     amenity: {
21704       bicycle_parking: true
21705     }
21706   };
21707   function osmTagSuggestingArea(tags) {
21708     if (tags.area === "yes") return { area: "yes" };
21709     if (tags.area === "no") return null;
21710     var returnTags = {};
21711     for (var realKey in tags) {
21712       const key = osmRemoveLifecyclePrefix(realKey);
21713       if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
21714         returnTags[realKey] = tags[realKey];
21715         return returnTags;
21716       }
21717       if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
21718         returnTags[realKey] = tags[realKey];
21719         return returnTags;
21720       }
21721     }
21722     return null;
21723   }
21724   var osmLineTags = {};
21725   function osmSetLineTags(value) {
21726     osmLineTags = value;
21727   }
21728   var osmPointTags = {};
21729   function osmSetPointTags(value) {
21730     osmPointTags = value;
21731   }
21732   var osmVertexTags = {};
21733   function osmSetVertexTags(value) {
21734     osmVertexTags = value;
21735   }
21736   function osmNodeGeometriesForTags(nodeTags) {
21737     var geometries = {};
21738     for (var key in nodeTags) {
21739       if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
21740         geometries.point = true;
21741       }
21742       if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
21743         geometries.vertex = true;
21744       }
21745       if (geometries.point && geometries.vertex) break;
21746     }
21747     return geometries;
21748   }
21749   var osmOneWayForwardTags = {
21750     "aerialway": {
21751       "chair_lift": true,
21752       "drag_lift": true,
21753       "j-bar": true,
21754       "magic_carpet": true,
21755       "mixed_lift": true,
21756       "platter": true,
21757       "rope_tow": true,
21758       "t-bar": true,
21759       "zip_line": true
21760     },
21761     "conveying": {
21762       "forward": true
21763     },
21764     "highway": {
21765       "motorway": true
21766     },
21767     "junction": {
21768       "circular": true,
21769       "roundabout": true
21770     },
21771     "man_made": {
21772       "goods_conveyor": true,
21773       "piste:halfpipe": true
21774     },
21775     "oneway": {
21776       "yes": true
21777     },
21778     "piste:type": {
21779       "downhill": true,
21780       "sled": true,
21781       "yes": true
21782     },
21783     "seamark:type": {
21784       "two-way_route": true,
21785       "recommended_traffic_lane": true,
21786       "separation_lane": true,
21787       "separation_roundabout": true
21788     },
21789     "waterway": {
21790       "canal": true,
21791       "ditch": true,
21792       "drain": true,
21793       "fish_pass": true,
21794       "flowline": true,
21795       "pressurised": true,
21796       "river": true,
21797       "spillway": true,
21798       "stream": true,
21799       "tidal_channel": true
21800     }
21801   };
21802   var osmOneWayBackwardTags = {
21803     "conveying": {
21804       "backward": true
21805     },
21806     "oneway": {
21807       "-1": true
21808     }
21809   };
21810   var osmOneWayBiDirectionalTags = {
21811     "conveying": {
21812       "reversible": true
21813     },
21814     "oneway": {
21815       "alternating": true,
21816       "reversible": true
21817     }
21818   };
21819   var osmOneWayTags = merge_default3(
21820     osmOneWayForwardTags,
21821     osmOneWayBackwardTags,
21822     osmOneWayBiDirectionalTags
21823   );
21824   var osmPavedTags = {
21825     "surface": {
21826       "paved": true,
21827       "asphalt": true,
21828       "concrete": true,
21829       "chipseal": true,
21830       "concrete:lanes": true,
21831       "concrete:plates": true
21832     },
21833     "tracktype": {
21834       "grade1": true
21835     }
21836   };
21837   var osmSemipavedTags = {
21838     "surface": {
21839       "cobblestone": true,
21840       "cobblestone:flattened": true,
21841       "unhewn_cobblestone": true,
21842       "sett": true,
21843       "paving_stones": true,
21844       "metal": true,
21845       "wood": true
21846     }
21847   };
21848   var osmRightSideIsInsideTags = {
21849     "natural": {
21850       "cliff": true,
21851       "coastline": "coastline"
21852     },
21853     "barrier": {
21854       "retaining_wall": true,
21855       "kerb": true,
21856       "guard_rail": true,
21857       "city_wall": true
21858     },
21859     "man_made": {
21860       "embankment": true,
21861       "quay": true
21862     },
21863     "waterway": {
21864       "weir": true
21865     }
21866   };
21867   var osmRoutableHighwayTagValues = {
21868     motorway: true,
21869     trunk: true,
21870     primary: true,
21871     secondary: true,
21872     tertiary: true,
21873     residential: true,
21874     motorway_link: true,
21875     trunk_link: true,
21876     primary_link: true,
21877     secondary_link: true,
21878     tertiary_link: true,
21879     unclassified: true,
21880     road: true,
21881     service: true,
21882     track: true,
21883     living_street: true,
21884     bus_guideway: true,
21885     busway: true,
21886     path: true,
21887     footway: true,
21888     cycleway: true,
21889     bridleway: true,
21890     pedestrian: true,
21891     corridor: true,
21892     steps: true,
21893     ladder: true
21894   };
21895   var osmRoutableAerowayTags = {
21896     runway: true,
21897     taxiway: true
21898   };
21899   var osmPathHighwayTagValues = {
21900     path: true,
21901     footway: true,
21902     cycleway: true,
21903     bridleway: true,
21904     pedestrian: true,
21905     corridor: true,
21906     steps: true,
21907     ladder: true
21908   };
21909   var osmRailwayTrackTagValues = {
21910     rail: true,
21911     light_rail: true,
21912     tram: true,
21913     subway: true,
21914     monorail: true,
21915     funicular: true,
21916     miniature: true,
21917     narrow_gauge: true,
21918     disused: true,
21919     preserved: true
21920   };
21921   var osmFlowingWaterwayTagValues = {
21922     canal: true,
21923     ditch: true,
21924     drain: true,
21925     fish_pass: true,
21926     flowline: true,
21927     river: true,
21928     stream: true,
21929     tidal_channel: true
21930   };
21931   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/;
21932   function isColourValid(value) {
21933     if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
21934       return false;
21935     }
21936     if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
21937       return false;
21938     }
21939     return true;
21940   }
21941   var osmMutuallyExclusiveTagPairs = [
21942     ["noname", "name"],
21943     ["noref", "ref"],
21944     ["nohousenumber", "addr:housenumber"],
21945     ["noaddress", "addr:housenumber"],
21946     ["noaddress", "addr:housename"],
21947     ["noaddress", "addr:unit"],
21948     ["addr:nostreet", "addr:street"]
21949   ];
21950
21951   // modules/util/array.js
21952   function utilArrayIdentical(a2, b2) {
21953     if (a2 === b2) return true;
21954     var i3 = a2.length;
21955     if (i3 !== b2.length) return false;
21956     while (i3--) {
21957       if (a2[i3] !== b2[i3]) return false;
21958     }
21959     return true;
21960   }
21961   function utilArrayDifference(a2, b2) {
21962     var other2 = new Set(b2);
21963     return Array.from(new Set(a2)).filter(function(v2) {
21964       return !other2.has(v2);
21965     });
21966   }
21967   function utilArrayIntersection(a2, b2) {
21968     var other2 = new Set(b2);
21969     return Array.from(new Set(a2)).filter(function(v2) {
21970       return other2.has(v2);
21971     });
21972   }
21973   function utilArrayUnion(a2, b2) {
21974     var result = new Set(a2);
21975     b2.forEach(function(v2) {
21976       result.add(v2);
21977     });
21978     return Array.from(result);
21979   }
21980   function utilArrayUniq(a2) {
21981     return Array.from(new Set(a2));
21982   }
21983   function utilArrayChunk(a2, chunkSize) {
21984     if (!chunkSize || chunkSize < 0) return [a2.slice()];
21985     var result = new Array(Math.ceil(a2.length / chunkSize));
21986     return Array.from(result, function(item, i3) {
21987       return a2.slice(i3 * chunkSize, i3 * chunkSize + chunkSize);
21988     });
21989   }
21990   function utilArrayFlatten(a2) {
21991     return a2.reduce(function(acc, val) {
21992       return acc.concat(val);
21993     }, []);
21994   }
21995   function utilArrayGroupBy(a2, key) {
21996     return a2.reduce(function(acc, item) {
21997       var group = typeof key === "function" ? key(item) : item[key];
21998       (acc[group] = acc[group] || []).push(item);
21999       return acc;
22000     }, {});
22001   }
22002   function utilArrayUniqBy(a2, key) {
22003     var seen = /* @__PURE__ */ new Set();
22004     return a2.reduce(function(acc, item) {
22005       var val = typeof key === "function" ? key(item) : item[key];
22006       if (val && !seen.has(val)) {
22007         seen.add(val);
22008         acc.push(item);
22009       }
22010       return acc;
22011     }, []);
22012   }
22013
22014   // modules/util/util.js
22015   var import_diacritics = __toESM(require_diacritics());
22016
22017   // modules/util/svg_paths_rtl_fix.js
22018   var import_alif_toolkit = __toESM(require_lib());
22019   var rtlRegex = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u07BF\u08A0–\u08BF]/;
22020   function fixRTLTextForSvg(inputText) {
22021     var ret = "", rtlBuffer = [];
22022     var arabicRegex = /[\u0600-\u06FF]/g;
22023     var arabicDiacritics = /[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g;
22024     var arabicMath = /[\u0660-\u066C\u06F0-\u06F9]+/g;
22025     var thaanaVowel = /[\u07A6-\u07B0]/;
22026     var hebrewSign = /[\u0591-\u05bd\u05bf\u05c1-\u05c5\u05c7]/;
22027     if (arabicRegex.test(inputText)) {
22028       inputText = (0, import_alif_toolkit.WordShaper)(inputText);
22029     }
22030     for (var n3 = 0; n3 < inputText.length; n3++) {
22031       var c2 = inputText[n3];
22032       if (arabicMath.test(c2)) {
22033         ret += rtlBuffer.reverse().join("");
22034         rtlBuffer = [c2];
22035       } else {
22036         if (rtlBuffer.length && arabicMath.test(rtlBuffer[rtlBuffer.length - 1])) {
22037           ret += rtlBuffer.reverse().join("");
22038           rtlBuffer = [];
22039         }
22040         if ((thaanaVowel.test(c2) || hebrewSign.test(c2) || arabicDiacritics.test(c2)) && rtlBuffer.length) {
22041           rtlBuffer[rtlBuffer.length - 1] += c2;
22042         } else if (rtlRegex.test(c2) || c2.charCodeAt(0) >= 64336 && c2.charCodeAt(0) <= 65023 || c2.charCodeAt(0) >= 65136 && c2.charCodeAt(0) <= 65279) {
22043           rtlBuffer.push(c2);
22044         } else if (c2 === " " && rtlBuffer.length) {
22045           rtlBuffer = [rtlBuffer.reverse().join("") + " "];
22046         } else {
22047           ret += rtlBuffer.reverse().join("") + c2;
22048           rtlBuffer = [];
22049         }
22050       }
22051     }
22052     ret += rtlBuffer.reverse().join("");
22053     return ret;
22054   }
22055
22056   // modules/core/file_fetcher.js
22057   var import_vparse = __toESM(require_vparse());
22058
22059   // config/id.js
22060   var presetsCdnUrl = "https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/";
22061   var ociCdnUrl = "https://cdn.jsdelivr.net/npm/osm-community-index@{version}/";
22062   var wmfSitematrixCdnUrl = "https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/";
22063   var nsiCdnUrl = "https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/";
22064   var defaultOsmApiConnections = {
22065     live: {
22066       url: "https://www.openstreetmap.org",
22067       apiUrl: "https://api.openstreetmap.org",
22068       client_id: "0tmNTmd0Jo1dQp4AUmMBLtGiD9YpMuXzHefitcuVStc"
22069     },
22070     dev: {
22071       url: "https://api06.dev.openstreetmap.org",
22072       client_id: "Ee1wWJ6UlpERbF6BfTNOpwn0R8k_06mvMXdDUkeHMgw"
22073     }
22074   };
22075   var osmApiConnections = [];
22076   if (false) {
22077     osmApiConnections.push({
22078       url: null,
22079       apiUrl: null,
22080       client_id: null
22081     });
22082   } else if (false) {
22083     osmApiConnections.push(defaultOsmApiConnections[null]);
22084   } else {
22085     osmApiConnections.push(defaultOsmApiConnections.live);
22086     osmApiConnections.push(defaultOsmApiConnections.dev);
22087   }
22088   var taginfoApiUrl = "https://taginfo.openstreetmap.org/api/4/";
22089   var nominatimApiUrl = "https://nominatim.openstreetmap.org/";
22090   var showDonationMessage = true;
22091
22092   // package.json
22093   var package_default = {
22094     name: "iD",
22095     version: "2.32.0",
22096     description: "A friendly editor for OpenStreetMap",
22097     main: "dist/iD.min.js",
22098     repository: "github:openstreetmap/iD",
22099     homepage: "https://github.com/openstreetmap/iD",
22100     bugs: "https://github.com/openstreetmap/iD/issues",
22101     keywords: [
22102       "editor",
22103       "openstreetmap"
22104     ],
22105     license: "ISC",
22106     scripts: {
22107       all: "run-s clean build dist",
22108       build: "run-s build:css build:data build:js",
22109       "build:css": "node scripts/build_css.js",
22110       "build:data": "shx mkdir -p dist/data && node scripts/build_data.js",
22111       "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",
22112       "build:js": "node config/esbuild.config.mjs",
22113       "build:js:watch": "node config/esbuild.config.mjs --watch",
22114       clean: "shx rm -f dist/esbuild.json dist/*.js dist/*.map dist/*.css dist/img/*.svg",
22115       dist: "run-p dist:**",
22116       "dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/",
22117       "dist:pannellum": "shx mkdir -p dist/pannellum && shx cp -R node_modules/pannellum/build/* dist/pannellum/",
22118       "dist:min": "node config/esbuild.config.min.mjs",
22119       "dist:svg:iD": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "iD-%s" --symbol-sprite dist/img/iD-sprite.svg "svg/iD-sprite/**/*.svg"',
22120       "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',
22121       "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
22122       "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',
22123       "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",
22124       "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",
22125       "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',
22126       "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',
22127       imagery: "node scripts/update_imagery.js",
22128       lint: "eslint config scripts test/spec modules",
22129       "lint:fix": "eslint scripts test/spec modules --fix",
22130       start: "run-s start:watch",
22131       "start:single-build": "run-p build:js start:server",
22132       "start:watch": "run-p build:js:watch start:server",
22133       "start:server": "node scripts/server.js",
22134       test: "npm-run-all -s lint build test:spec",
22135       "test:spec": "vitest --no-isolate",
22136       translations: "node scripts/update_locales.js"
22137     },
22138     dependencies: {
22139       "@mapbox/geojson-area": "^0.2.2",
22140       "@mapbox/sexagesimal": "1.2.0",
22141       "@mapbox/vector-tile": "^2.0.3",
22142       "@rapideditor/country-coder": "~5.3.1",
22143       "@rapideditor/location-conflation": "~1.4.1",
22144       "@tmcw/togeojson": "^6.0.1",
22145       "@turf/bbox": "^7.2.0",
22146       "@turf/bbox-clip": "^7.2.0",
22147       "abortcontroller-polyfill": "^1.7.8",
22148       "aes-js": "^3.1.2",
22149       "alif-toolkit": "^1.3.0",
22150       "core-js-bundle": "^3.41.0",
22151       diacritics: "1.3.0",
22152       exifr: "^7.1.3",
22153       "fast-deep-equal": "~3.1.1",
22154       "fast-json-stable-stringify": "2.1.0",
22155       "lodash-es": "~4.17.15",
22156       marked: "~15.0.7",
22157       "node-diff3": "~3.1.0",
22158       "osm-auth": "~2.6.0",
22159       pannellum: "2.5.6",
22160       pbf: "^4.0.1",
22161       "polygon-clipping": "~0.15.7",
22162       rbush: "4.0.1",
22163       vitest: "^3.0.7",
22164       "whatwg-fetch": "^3.6.20",
22165       "which-polygon": "2.2.1"
22166     },
22167     devDependencies: {
22168       "@fortawesome/fontawesome-svg-core": "~6.7.2",
22169       "@fortawesome/free-brands-svg-icons": "~6.7.2",
22170       "@fortawesome/free-regular-svg-icons": "~6.7.2",
22171       "@fortawesome/free-solid-svg-icons": "~6.7.2",
22172       "@mapbox/maki": "^8.2.0",
22173       "@openstreetmap/id-tagging-schema": "^6.9.1",
22174       "@rapideditor/mapillary_sprite_source": "^1.8.0",
22175       "@rapideditor/temaki": "^5.9.0",
22176       "@transifex/api": "^7.1.3",
22177       "@types/chai": "^5.0.1",
22178       "@types/d3": "^7.4.3",
22179       "@types/happen": "^0.3.0",
22180       "@types/lodash-es": "^4.17.12",
22181       "@types/node": "^22.13.9",
22182       "@types/sinon": "^17.0.3",
22183       "@types/sinon-chai": "^4.0.0",
22184       autoprefixer: "^10.4.20",
22185       browserslist: "^4.24.4",
22186       "browserslist-to-esbuild": "^2.1.1",
22187       chai: "^5.2.0",
22188       chalk: "^4.1.2",
22189       "cldr-core": "^46.0.0",
22190       "cldr-localenames-full": "^46.1.0",
22191       "concat-files": "^0.1.1",
22192       d3: "~7.9.0",
22193       dotenv: "^16.4.7",
22194       "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
22195       esbuild: "^0.25.0",
22196       "esbuild-visualizer": "^0.7.0",
22197       eslint: "^9.21.0",
22198       "fetch-mock": "^11.1.1",
22199       gaze: "^1.1.3",
22200       glob: "^10.4.5",
22201       happen: "^0.3.2",
22202       "js-yaml": "^4.0.0",
22203       jsdom: "^26.0.0",
22204       "json-stringify-pretty-compact": "^3.0.0",
22205       "mapillary-js": "4.1.2",
22206       minimist: "^1.2.8",
22207       "name-suggestion-index": "~6.0",
22208       "netlify-cli": "^19.0.1",
22209       "npm-run-all": "^4.0.0",
22210       "osm-community-index": "~5.9.1",
22211       postcss: "^8.5.3",
22212       "postcss-prefix-selector": "^2.1.0",
22213       "serve-handler": "^6.1.6",
22214       shelljs: "^0.8.0",
22215       shx: "^0.3.0",
22216       sinon: "^11.1.2",
22217       "sinon-chai": "^4.0.0",
22218       smash: "0.0",
22219       "svg-sprite": "2.0.4",
22220       vparse: "~1.1.0"
22221     },
22222     engines: {
22223       node: ">=18"
22224     },
22225     browserslist: [
22226       "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions"
22227     ]
22228   };
22229
22230   // modules/core/file_fetcher.js
22231   var _mainFileFetcher = coreFileFetcher();
22232   function coreFileFetcher() {
22233     const ociVersion = package_default.dependencies["osm-community-index"] || package_default.devDependencies["osm-community-index"];
22234     const v2 = (0, import_vparse.default)(ociVersion);
22235     const ociVersionMinor = "".concat(v2.major, ".").concat(v2.minor);
22236     const presetsVersion = package_default.devDependencies["@openstreetmap/id-tagging-schema"];
22237     let _this = {};
22238     let _inflight4 = {};
22239     let _fileMap = {
22240       "address_formats": "data/address_formats.min.json",
22241       "imagery": "data/imagery.min.json",
22242       "intro_graph": "data/intro_graph.min.json",
22243       "keepRight": "data/keepRight.min.json",
22244       "languages": "data/languages.min.json",
22245       "locales": "locales/index.min.json",
22246       "phone_formats": "data/phone_formats.min.json",
22247       "qa_data": "data/qa_data.min.json",
22248       "shortcuts": "data/shortcuts.min.json",
22249       "territory_languages": "data/territory_languages.min.json",
22250       "oci_defaults": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/defaults.min.json",
22251       "oci_features": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/featureCollection.min.json",
22252       "oci_resources": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/resources.min.json",
22253       "presets_package": presetsCdnUrl.replace("{presets_version}", presetsVersion) + "package.json",
22254       "deprecated": presetsCdnUrl + "dist/deprecated.min.json",
22255       "discarded": presetsCdnUrl + "dist/discarded.min.json",
22256       "preset_categories": presetsCdnUrl + "dist/preset_categories.min.json",
22257       "preset_defaults": presetsCdnUrl + "dist/preset_defaults.min.json",
22258       "preset_fields": presetsCdnUrl + "dist/fields.min.json",
22259       "preset_presets": presetsCdnUrl + "dist/presets.min.json",
22260       "wmf_sitematrix": wmfSitematrixCdnUrl.replace("{version}", "0.2") + "data/wikipedia.min.json"
22261     };
22262     let _cachedData = {};
22263     _this.cache = () => _cachedData;
22264     _this.get = (which) => {
22265       if (_cachedData[which]) {
22266         return Promise.resolve(_cachedData[which]);
22267       }
22268       const file = _fileMap[which];
22269       const url = file && _this.asset(file);
22270       if (!url) {
22271         return Promise.reject('Unknown data file for "'.concat(which, '"'));
22272       }
22273       if (url.includes("{presets_version}")) {
22274         return _this.get("presets_package").then((result) => {
22275           const presetsVersion2 = result.version;
22276           return getUrl(url.replace("{presets_version}", presetsVersion2), which);
22277         });
22278       } else {
22279         return getUrl(url, which);
22280       }
22281     };
22282     function getUrl(url, which) {
22283       let prom = _inflight4[url];
22284       if (!prom) {
22285         _inflight4[url] = prom = (window.VITEST ? import("../".concat(url)) : fetch(url)).then((response) => {
22286           if (window.VITEST) return response.default;
22287           if (!response.ok || !response.json) {
22288             throw new Error(response.status + " " + response.statusText);
22289           }
22290           if (response.status === 204 || response.status === 205) return;
22291           return response.json();
22292         }).then((result) => {
22293           delete _inflight4[url];
22294           if (!result) {
22295             throw new Error('No data loaded for "'.concat(which, '"'));
22296           }
22297           _cachedData[which] = result;
22298           return result;
22299         }).catch((err) => {
22300           delete _inflight4[url];
22301           throw err;
22302         });
22303       }
22304       return prom;
22305     }
22306     _this.fileMap = function(val) {
22307       if (!arguments.length) return _fileMap;
22308       _fileMap = val;
22309       return _this;
22310     };
22311     let _assetPath = "";
22312     _this.assetPath = function(val) {
22313       if (!arguments.length) return _assetPath;
22314       _assetPath = val;
22315       return _this;
22316     };
22317     let _assetMap = {};
22318     _this.assetMap = function(val) {
22319       if (!arguments.length) return _assetMap;
22320       _assetMap = val;
22321       return _this;
22322     };
22323     _this.asset = (val) => {
22324       if (/^http(s)?:\/\//i.test(val)) return val;
22325       const filename = _assetPath + val;
22326       return _assetMap[filename] || filename;
22327     };
22328     return _this;
22329   }
22330
22331   // modules/util/detect.js
22332   var _detected;
22333   function utilDetect(refresh2) {
22334     if (_detected && !refresh2) return _detected;
22335     _detected = {};
22336     const ua = navigator.userAgent;
22337     let m2 = null;
22338     m2 = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i);
22339     if (m2 !== null) {
22340       _detected.browser = m2[1];
22341       _detected.version = m2[2];
22342     }
22343     if (!_detected.browser) {
22344       m2 = ua.match(/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i);
22345       if (m2 !== null) {
22346         _detected.browser = "msie";
22347         _detected.version = m2[1];
22348       }
22349     }
22350     if (!_detected.browser) {
22351       m2 = ua.match(/(opr)\/?\s*(\.?\d+(\.\d+)*)/i);
22352       if (m2 !== null) {
22353         _detected.browser = "Opera";
22354         _detected.version = m2[2];
22355       }
22356     }
22357     if (!_detected.browser) {
22358       m2 = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
22359       if (m2 !== null) {
22360         _detected.browser = m2[1];
22361         _detected.version = m2[2];
22362         m2 = ua.match(/version\/([\.\d]+)/i);
22363         if (m2 !== null) _detected.version = m2[1];
22364       }
22365     }
22366     if (!_detected.browser) {
22367       _detected.browser = navigator.appName;
22368       _detected.version = navigator.appVersion;
22369     }
22370     _detected.version = _detected.version.split(/\W/).slice(0, 2).join(".");
22371     _detected.opera = _detected.browser.toLowerCase() === "opera" && Number(_detected.version) < 15;
22372     if (_detected.browser.toLowerCase() === "msie") {
22373       _detected.ie = true;
22374       _detected.browser = "Internet Explorer";
22375       _detected.support = false;
22376     } else {
22377       _detected.ie = false;
22378       _detected.support = true;
22379     }
22380     _detected.filedrop = window.FileReader && "ondrop" in window;
22381     if (/Win/.test(ua)) {
22382       _detected.os = "win";
22383       _detected.platform = "Windows";
22384     } else if (/Mac/.test(ua)) {
22385       _detected.os = "mac";
22386       _detected.platform = "Macintosh";
22387     } else if (/X11/.test(ua) || /Linux/.test(ua)) {
22388       _detected.os = "linux";
22389       _detected.platform = "Linux";
22390     } else {
22391       _detected.os = "win";
22392       _detected.platform = "Unknown";
22393     }
22394     _detected.isMobileWebKit = (/\b(iPad|iPhone|iPod)\b/.test(ua) || // HACK: iPadOS 13+ requests desktop sites by default by using a Mac user agent,
22395     // so assume any "mac" with multitouch is actually iOS
22396     navigator.platform === "MacIntel" && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 1) && /WebKit/.test(ua) && !/Edge/.test(ua) && !window.MSStream;
22397     _detected.browserLocales = Array.from(new Set(
22398       // remove duplicates
22399       [navigator.language].concat(navigator.languages || []).concat([
22400         // old property for backwards compatibility
22401         navigator.userLanguage
22402       ]).filter(Boolean)
22403     ));
22404     const loc = window.top.location;
22405     let origin = loc.origin;
22406     if (!origin) {
22407       origin = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "");
22408     }
22409     _detected.host = origin + loc.pathname;
22410     return _detected;
22411   }
22412
22413   // modules/util/aes.js
22414   var import_aes_js = __toESM(require_aes_js());
22415   var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208];
22416   function utilAesEncrypt(text, key) {
22417     key = key || DEFAULT_128;
22418     const textBytes = import_aes_js.default.utils.utf8.toBytes(text);
22419     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
22420     const encryptedBytes = aesCtr.encrypt(textBytes);
22421     const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes);
22422     return encryptedHex;
22423   }
22424   function utilAesDecrypt(encryptedHex, key) {
22425     key = key || DEFAULT_128;
22426     const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex);
22427     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
22428     const decryptedBytes = aesCtr.decrypt(encryptedBytes);
22429     const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes);
22430     return text;
22431   }
22432
22433   // modules/util/clean_tags.js
22434   function utilCleanTags(tags) {
22435     var out = {};
22436     for (var k2 in tags) {
22437       if (!k2) continue;
22438       var v2 = tags[k2];
22439       if (v2 !== void 0) {
22440         out[k2] = cleanValue(k2, v2);
22441       }
22442     }
22443     return out;
22444     function cleanValue(k3, v3) {
22445       function keepSpaces(k4) {
22446         return /_hours|_times|:conditional$/.test(k4);
22447       }
22448       function skip(k4) {
22449         return /^(description|note|fixme|inscription)$/.test(k4);
22450       }
22451       if (skip(k3)) return v3;
22452       var cleaned = v3.split(";").map(function(s2) {
22453         return s2.trim();
22454       }).join(keepSpaces(k3) ? "; " : ";");
22455       if (k3.indexOf("website") !== -1 || k3.indexOf("email") !== -1 || cleaned.indexOf("http") === 0) {
22456         cleaned = cleaned.replace(/[\u200B-\u200F\uFEFF]/g, "");
22457       }
22458       return cleaned;
22459     }
22460   }
22461
22462   // modules/util/get_set_value.js
22463   function utilGetSetValue(selection2, value, shouldUpdate) {
22464     function setValue(value2, shouldUpdate2) {
22465       function valueNull() {
22466         delete this.value;
22467       }
22468       function valueConstant() {
22469         if (shouldUpdate2(this.value, value2)) {
22470           this.value = value2;
22471         }
22472       }
22473       function valueFunction() {
22474         var x2 = value2.apply(this, arguments);
22475         if (x2 === null || x2 === void 0) {
22476           delete this.value;
22477         } else if (shouldUpdate2(this.value, x2)) {
22478           this.value = x2;
22479         }
22480       }
22481       return value2 === null || value2 === void 0 ? valueNull : typeof value2 === "function" ? valueFunction : valueConstant;
22482     }
22483     if (arguments.length === 1) {
22484       return selection2.property("value");
22485     }
22486     if (shouldUpdate === void 0) {
22487       shouldUpdate = (a2, b2) => a2 !== b2;
22488     }
22489     return selection2.each(setValue(value, shouldUpdate));
22490   }
22491
22492   // modules/util/keybinding.js
22493   function utilKeybinding(namespace) {
22494     var _keybindings = {};
22495     function testBindings(d3_event, isCapturing) {
22496       var didMatch = false;
22497       var bindings = Object.keys(_keybindings).map(function(id2) {
22498         return _keybindings[id2];
22499       });
22500       var i3, binding;
22501       for (i3 = 0; i3 < bindings.length; i3++) {
22502         binding = bindings[i3];
22503         if (!binding.event.modifiers.shiftKey) continue;
22504         if (!!binding.capture !== isCapturing) continue;
22505         if (matches(d3_event, binding, true)) {
22506           binding.callback(d3_event);
22507           didMatch = true;
22508           break;
22509         }
22510       }
22511       if (didMatch) return;
22512       for (i3 = 0; i3 < bindings.length; i3++) {
22513         binding = bindings[i3];
22514         if (binding.event.modifiers.shiftKey) continue;
22515         if (!!binding.capture !== isCapturing) continue;
22516         if (matches(d3_event, binding, false)) {
22517           binding.callback(d3_event);
22518           break;
22519         }
22520       }
22521       function matches(d3_event2, binding2, testShift) {
22522         var event = d3_event2;
22523         var isMatch = false;
22524         var tryKeyCode = true;
22525         if (event.key !== void 0) {
22526           tryKeyCode = event.key.charCodeAt(0) > 127;
22527           isMatch = true;
22528           if (binding2.event.key === void 0) {
22529             isMatch = false;
22530           } else if (Array.isArray(binding2.event.key)) {
22531             if (binding2.event.key.map(function(s2) {
22532               return s2.toLowerCase();
22533             }).indexOf(event.key.toLowerCase()) === -1) {
22534               isMatch = false;
22535             }
22536           } else {
22537             if (event.key.toLowerCase() !== binding2.event.key.toLowerCase()) {
22538               isMatch = false;
22539             }
22540           }
22541         }
22542         if (!isMatch && (tryKeyCode || binding2.event.modifiers.altKey)) {
22543           isMatch = event.keyCode === binding2.event.keyCode;
22544         }
22545         if (!isMatch) return false;
22546         if (!(event.ctrlKey && event.altKey)) {
22547           if (event.ctrlKey !== binding2.event.modifiers.ctrlKey) return false;
22548           if (event.altKey !== binding2.event.modifiers.altKey) return false;
22549         }
22550         if (event.metaKey !== binding2.event.modifiers.metaKey) return false;
22551         if (testShift && event.shiftKey !== binding2.event.modifiers.shiftKey) return false;
22552         return true;
22553       }
22554     }
22555     function capture(d3_event) {
22556       testBindings(d3_event, true);
22557     }
22558     function bubble(d3_event) {
22559       var tagName = select_default2(d3_event.target).node().tagName;
22560       if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
22561         return;
22562       }
22563       testBindings(d3_event, false);
22564     }
22565     function keybinding(selection2) {
22566       selection2 = selection2 || select_default2(document);
22567       selection2.on("keydown.capture." + namespace, capture, true);
22568       selection2.on("keydown.bubble." + namespace, bubble, false);
22569       return keybinding;
22570     }
22571     keybinding.unbind = function(selection2) {
22572       _keybindings = [];
22573       selection2 = selection2 || select_default2(document);
22574       selection2.on("keydown.capture." + namespace, null);
22575       selection2.on("keydown.bubble." + namespace, null);
22576       return keybinding;
22577     };
22578     keybinding.clear = function() {
22579       _keybindings = {};
22580       return keybinding;
22581     };
22582     keybinding.off = function(codes, capture2) {
22583       var arr = utilArrayUniq([].concat(codes));
22584       for (var i3 = 0; i3 < arr.length; i3++) {
22585         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
22586         delete _keybindings[id2];
22587       }
22588       return keybinding;
22589     };
22590     keybinding.on = function(codes, callback, capture2) {
22591       if (typeof callback !== "function") {
22592         return keybinding.off(codes, capture2);
22593       }
22594       var arr = utilArrayUniq([].concat(codes));
22595       for (var i3 = 0; i3 < arr.length; i3++) {
22596         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
22597         var binding = {
22598           id: id2,
22599           capture: capture2,
22600           callback,
22601           event: {
22602             key: void 0,
22603             // preferred
22604             keyCode: 0,
22605             // fallback
22606             modifiers: {
22607               shiftKey: false,
22608               ctrlKey: false,
22609               altKey: false,
22610               metaKey: false
22611             }
22612           }
22613         };
22614         if (_keybindings[id2]) {
22615           console.warn('warning: duplicate keybinding for "' + id2 + '"');
22616         }
22617         _keybindings[id2] = binding;
22618         var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g);
22619         for (var j2 = 0; j2 < matches.length; j2++) {
22620           if (matches[j2] === "++") matches[j2] = "+";
22621           if (matches[j2] in utilKeybinding.modifierCodes) {
22622             var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]];
22623             binding.event.modifiers[prop] = true;
22624           } else {
22625             binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2];
22626             if (matches[j2] in utilKeybinding.keyCodes) {
22627               binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]];
22628             }
22629           }
22630         }
22631       }
22632       return keybinding;
22633     };
22634     return keybinding;
22635   }
22636   utilKeybinding.modifierCodes = {
22637     // Shift key, ⇧
22638     "\u21E7": 16,
22639     shift: 16,
22640     // CTRL key, on Mac: ⌃
22641     "\u2303": 17,
22642     ctrl: 17,
22643     // ALT key, on Mac: ⌥ (Alt)
22644     "\u2325": 18,
22645     alt: 18,
22646     option: 18,
22647     // META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
22648     "\u2318": 91,
22649     meta: 91,
22650     cmd: 91,
22651     "super": 91,
22652     win: 91
22653   };
22654   utilKeybinding.modifierProperties = {
22655     16: "shiftKey",
22656     17: "ctrlKey",
22657     18: "altKey",
22658     91: "metaKey"
22659   };
22660   utilKeybinding.plusKeys = ["plus", "ffplus", "=", "ffequals", "\u2260", "\xB1"];
22661   utilKeybinding.minusKeys = ["_", "-", "ffminus", "dash", "\u2013", "\u2014"];
22662   utilKeybinding.keys = {
22663     // Backspace key, on Mac: ⌫ (Backspace)
22664     "\u232B": "Backspace",
22665     backspace: "Backspace",
22666     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
22667     "\u21E5": "Tab",
22668     "\u21C6": "Tab",
22669     tab: "Tab",
22670     // Return key, ↩
22671     "\u21A9": "Enter",
22672     "\u21B5": "Enter",
22673     "\u23CE": "Enter",
22674     "return": "Enter",
22675     enter: "Enter",
22676     "\u2305": "Enter",
22677     // Pause/Break key
22678     "pause": "Pause",
22679     "pause-break": "Pause",
22680     // Caps Lock key, ⇪
22681     "\u21EA": "CapsLock",
22682     caps: "CapsLock",
22683     "caps-lock": "CapsLock",
22684     // Escape key, on Mac: ⎋, on Windows: Esc
22685     "\u238B": ["Escape", "Esc"],
22686     escape: ["Escape", "Esc"],
22687     esc: ["Escape", "Esc"],
22688     // Space key
22689     space: [" ", "Spacebar"],
22690     // Page-Up key, or pgup, on Mac: ↖
22691     "\u2196": "PageUp",
22692     pgup: "PageUp",
22693     "page-up": "PageUp",
22694     // Page-Down key, or pgdown, on Mac: ↘
22695     "\u2198": "PageDown",
22696     pgdown: "PageDown",
22697     "page-down": "PageDown",
22698     // END key, on Mac: ⇟
22699     "\u21DF": "End",
22700     end: "End",
22701     // HOME key, on Mac: ⇞
22702     "\u21DE": "Home",
22703     home: "Home",
22704     // Insert key, or ins
22705     ins: "Insert",
22706     insert: "Insert",
22707     // Delete key, on Mac: ⌦ (Delete)
22708     "\u2326": ["Delete", "Del"],
22709     del: ["Delete", "Del"],
22710     "delete": ["Delete", "Del"],
22711     // Left Arrow Key, or ←
22712     "\u2190": ["ArrowLeft", "Left"],
22713     left: ["ArrowLeft", "Left"],
22714     "arrow-left": ["ArrowLeft", "Left"],
22715     // Up Arrow Key, or ↑
22716     "\u2191": ["ArrowUp", "Up"],
22717     up: ["ArrowUp", "Up"],
22718     "arrow-up": ["ArrowUp", "Up"],
22719     // Right Arrow Key, or →
22720     "\u2192": ["ArrowRight", "Right"],
22721     right: ["ArrowRight", "Right"],
22722     "arrow-right": ["ArrowRight", "Right"],
22723     // Up Arrow Key, or ↓
22724     "\u2193": ["ArrowDown", "Down"],
22725     down: ["ArrowDown", "Down"],
22726     "arrow-down": ["ArrowDown", "Down"],
22727     // odities, stuff for backward compatibility (browsers and code):
22728     // Num-Multiply, or *
22729     "*": ["*", "Multiply"],
22730     star: ["*", "Multiply"],
22731     asterisk: ["*", "Multiply"],
22732     multiply: ["*", "Multiply"],
22733     // Num-Plus or +
22734     "+": ["+", "Add"],
22735     "plus": ["+", "Add"],
22736     // Num-Subtract, or -
22737     "-": ["-", "Subtract"],
22738     subtract: ["-", "Subtract"],
22739     "dash": ["-", "Subtract"],
22740     // Semicolon
22741     semicolon: ";",
22742     // = or equals
22743     equals: "=",
22744     // Comma, or ,
22745     comma: ",",
22746     // Period, or ., or full-stop
22747     period: ".",
22748     "full-stop": ".",
22749     // Slash, or /, or forward-slash
22750     slash: "/",
22751     "forward-slash": "/",
22752     // Tick, or `, or back-quote
22753     tick: "`",
22754     "back-quote": "`",
22755     // Open bracket, or [
22756     "open-bracket": "[",
22757     // Back slash, or \
22758     "back-slash": "\\",
22759     // Close bracket, or ]
22760     "close-bracket": "]",
22761     // Apostrophe, or Quote, or '
22762     quote: "'",
22763     apostrophe: "'",
22764     // NUMPAD 0-9
22765     "num-0": "0",
22766     "num-1": "1",
22767     "num-2": "2",
22768     "num-3": "3",
22769     "num-4": "4",
22770     "num-5": "5",
22771     "num-6": "6",
22772     "num-7": "7",
22773     "num-8": "8",
22774     "num-9": "9",
22775     // F1-F25
22776     f1: "F1",
22777     f2: "F2",
22778     f3: "F3",
22779     f4: "F4",
22780     f5: "F5",
22781     f6: "F6",
22782     f7: "F7",
22783     f8: "F8",
22784     f9: "F9",
22785     f10: "F10",
22786     f11: "F11",
22787     f12: "F12",
22788     f13: "F13",
22789     f14: "F14",
22790     f15: "F15",
22791     f16: "F16",
22792     f17: "F17",
22793     f18: "F18",
22794     f19: "F19",
22795     f20: "F20",
22796     f21: "F21",
22797     f22: "F22",
22798     f23: "F23",
22799     f24: "F24",
22800     f25: "F25"
22801   };
22802   utilKeybinding.keyCodes = {
22803     // Backspace key, on Mac: ⌫ (Backspace)
22804     "\u232B": 8,
22805     backspace: 8,
22806     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
22807     "\u21E5": 9,
22808     "\u21C6": 9,
22809     tab: 9,
22810     // Return key, ↩
22811     "\u21A9": 13,
22812     "\u21B5": 13,
22813     "\u23CE": 13,
22814     "return": 13,
22815     enter: 13,
22816     "\u2305": 13,
22817     // Pause/Break key
22818     "pause": 19,
22819     "pause-break": 19,
22820     // Caps Lock key, ⇪
22821     "\u21EA": 20,
22822     caps: 20,
22823     "caps-lock": 20,
22824     // Escape key, on Mac: ⎋, on Windows: Esc
22825     "\u238B": 27,
22826     escape: 27,
22827     esc: 27,
22828     // Space key
22829     space: 32,
22830     // Page-Up key, or pgup, on Mac: ↖
22831     "\u2196": 33,
22832     pgup: 33,
22833     "page-up": 33,
22834     // Page-Down key, or pgdown, on Mac: ↘
22835     "\u2198": 34,
22836     pgdown: 34,
22837     "page-down": 34,
22838     // END key, on Mac: ⇟
22839     "\u21DF": 35,
22840     end: 35,
22841     // HOME key, on Mac: ⇞
22842     "\u21DE": 36,
22843     home: 36,
22844     // Insert key, or ins
22845     ins: 45,
22846     insert: 45,
22847     // Delete key, on Mac: ⌦ (Delete)
22848     "\u2326": 46,
22849     del: 46,
22850     "delete": 46,
22851     // Left Arrow Key, or ←
22852     "\u2190": 37,
22853     left: 37,
22854     "arrow-left": 37,
22855     // Up Arrow Key, or ↑
22856     "\u2191": 38,
22857     up: 38,
22858     "arrow-up": 38,
22859     // Right Arrow Key, or →
22860     "\u2192": 39,
22861     right: 39,
22862     "arrow-right": 39,
22863     // Up Arrow Key, or ↓
22864     "\u2193": 40,
22865     down: 40,
22866     "arrow-down": 40,
22867     // odities, printing characters that come out wrong:
22868     // Firefox Equals
22869     "ffequals": 61,
22870     // Num-Multiply, or *
22871     "*": 106,
22872     star: 106,
22873     asterisk: 106,
22874     multiply: 106,
22875     // Num-Plus or +
22876     "+": 107,
22877     "plus": 107,
22878     // Num-Subtract, or -
22879     "-": 109,
22880     subtract: 109,
22881     // Vertical Bar / Pipe
22882     "|": 124,
22883     // Firefox Plus
22884     "ffplus": 171,
22885     // Firefox Minus
22886     "ffminus": 173,
22887     // Semicolon
22888     ";": 186,
22889     semicolon: 186,
22890     // = or equals
22891     "=": 187,
22892     "equals": 187,
22893     // Comma, or ,
22894     ",": 188,
22895     comma: 188,
22896     // Dash / Underscore key
22897     "dash": 189,
22898     // Period, or ., or full-stop
22899     ".": 190,
22900     period: 190,
22901     "full-stop": 190,
22902     // Slash, or /, or forward-slash
22903     "/": 191,
22904     slash: 191,
22905     "forward-slash": 191,
22906     // Tick, or `, or back-quote
22907     "`": 192,
22908     tick: 192,
22909     "back-quote": 192,
22910     // Open bracket, or [
22911     "[": 219,
22912     "open-bracket": 219,
22913     // Back slash, or \
22914     "\\": 220,
22915     "back-slash": 220,
22916     // Close bracket, or ]
22917     "]": 221,
22918     "close-bracket": 221,
22919     // Apostrophe, or Quote, or '
22920     "'": 222,
22921     quote: 222,
22922     apostrophe: 222
22923   };
22924   var i = 95;
22925   var n = 0;
22926   while (++i < 106) {
22927     utilKeybinding.keyCodes["num-" + n] = i;
22928     ++n;
22929   }
22930   i = 47;
22931   n = 0;
22932   while (++i < 58) {
22933     utilKeybinding.keyCodes[n] = i;
22934     ++n;
22935   }
22936   i = 111;
22937   n = 1;
22938   while (++i < 136) {
22939     utilKeybinding.keyCodes["f" + n] = i;
22940     ++n;
22941   }
22942   i = 64;
22943   while (++i < 91) {
22944     utilKeybinding.keyCodes[String.fromCharCode(i).toLowerCase()] = i;
22945   }
22946
22947   // modules/util/object.js
22948   function utilObjectOmit(obj, omitKeys) {
22949     return Object.keys(obj).reduce(function(result, key) {
22950       if (omitKeys.indexOf(key) === -1) {
22951         result[key] = obj[key];
22952       }
22953       return result;
22954     }, {});
22955   }
22956   function utilCheckTagDictionary(tags, tagDictionary) {
22957     for (const key in tags) {
22958       const value = tags[key];
22959       if (tagDictionary[key] && value in tagDictionary[key]) {
22960         return tagDictionary[key][value];
22961       }
22962     }
22963     return void 0;
22964   }
22965
22966   // modules/util/rebind.js
22967   function utilRebind(target, source, ...args) {
22968     for (const method of args) {
22969       target[method] = d3_rebind(target, source, source[method]);
22970     }
22971     return target;
22972   }
22973   function d3_rebind(target, source, method) {
22974     return function() {
22975       var value = method.apply(source, arguments);
22976       return value === source ? target : value;
22977     };
22978   }
22979
22980   // modules/util/session_mutex.js
22981   function utilSessionMutex(name) {
22982     var mutex = {};
22983     var intervalID;
22984     function renew() {
22985       if (typeof window === "undefined") return;
22986       var expires = /* @__PURE__ */ new Date();
22987       expires.setSeconds(expires.getSeconds() + 5);
22988       document.cookie = name + "=1; expires=" + expires.toUTCString() + "; sameSite=strict";
22989     }
22990     mutex.lock = function() {
22991       if (intervalID) return true;
22992       var cookie = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1");
22993       if (cookie) return false;
22994       renew();
22995       intervalID = window.setInterval(renew, 4e3);
22996       return true;
22997     };
22998     mutex.unlock = function() {
22999       if (!intervalID) return;
23000       document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; sameSite=strict";
23001       clearInterval(intervalID);
23002       intervalID = null;
23003     };
23004     mutex.locked = function() {
23005       return !!intervalID;
23006     };
23007     return mutex;
23008   }
23009
23010   // modules/util/tiler.js
23011   function utilTiler() {
23012     var _size = [256, 256];
23013     var _scale = 256;
23014     var _tileSize = 256;
23015     var _zoomExtent = [0, 20];
23016     var _translate = [_size[0] / 2, _size[1] / 2];
23017     var _margin = 0;
23018     var _skipNullIsland = false;
23019     function clamp3(num, min3, max3) {
23020       return Math.max(min3, Math.min(num, max3));
23021     }
23022     function nearNullIsland(tile) {
23023       var x2 = tile[0];
23024       var y2 = tile[1];
23025       var z2 = tile[2];
23026       if (z2 >= 7) {
23027         var center = Math.pow(2, z2 - 1);
23028         var width = Math.pow(2, z2 - 6);
23029         var min3 = center - width / 2;
23030         var max3 = center + width / 2 - 1;
23031         return x2 >= min3 && x2 <= max3 && y2 >= min3 && y2 <= max3;
23032       }
23033       return false;
23034     }
23035     function tiler8() {
23036       var z2 = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
23037       var z0 = clamp3(Math.round(z2), _zoomExtent[0], _zoomExtent[1]);
23038       var tileMin = 0;
23039       var tileMax = Math.pow(2, z0) - 1;
23040       var log2ts = Math.log(_tileSize) * Math.LOG2E;
23041       var k2 = Math.pow(2, z2 - z0 + log2ts);
23042       var origin = [
23043         (_translate[0] - _scale / 2) / k2,
23044         (_translate[1] - _scale / 2) / k2
23045       ];
23046       var cols = range(
23047         clamp3(Math.floor(-origin[0]) - _margin, tileMin, tileMax + 1),
23048         clamp3(Math.ceil(_size[0] / k2 - origin[0]) + _margin, tileMin, tileMax + 1)
23049       );
23050       var rows = range(
23051         clamp3(Math.floor(-origin[1]) - _margin, tileMin, tileMax + 1),
23052         clamp3(Math.ceil(_size[1] / k2 - origin[1]) + _margin, tileMin, tileMax + 1)
23053       );
23054       var tiles = [];
23055       for (var i3 = 0; i3 < rows.length; i3++) {
23056         var y2 = rows[i3];
23057         for (var j2 = 0; j2 < cols.length; j2++) {
23058           var x2 = cols[j2];
23059           if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) {
23060             tiles.unshift([x2, y2, z0]);
23061           } else {
23062             tiles.push([x2, y2, z0]);
23063           }
23064         }
23065       }
23066       tiles.translate = origin;
23067       tiles.scale = k2;
23068       return tiles;
23069     }
23070     tiler8.getTiles = function(projection2) {
23071       var origin = [
23072         projection2.scale() * Math.PI - projection2.translate()[0],
23073         projection2.scale() * Math.PI - projection2.translate()[1]
23074       ];
23075       this.size(projection2.clipExtent()[1]).scale(projection2.scale() * 2 * Math.PI).translate(projection2.translate());
23076       var tiles = tiler8();
23077       var ts = tiles.scale;
23078       return tiles.map(function(tile) {
23079         if (_skipNullIsland && nearNullIsland(tile)) {
23080           return false;
23081         }
23082         var x2 = tile[0] * ts - origin[0];
23083         var y2 = tile[1] * ts - origin[1];
23084         return {
23085           id: tile.toString(),
23086           xyz: tile,
23087           extent: geoExtent(
23088             projection2.invert([x2, y2 + ts]),
23089             projection2.invert([x2 + ts, y2])
23090           )
23091         };
23092       }).filter(Boolean);
23093     };
23094     tiler8.getGeoJSON = function(projection2) {
23095       var features = tiler8.getTiles(projection2).map(function(tile) {
23096         return {
23097           type: "Feature",
23098           properties: {
23099             id: tile.id,
23100             name: tile.id
23101           },
23102           geometry: {
23103             type: "Polygon",
23104             coordinates: [tile.extent.polygon()]
23105           }
23106         };
23107       });
23108       return {
23109         type: "FeatureCollection",
23110         features
23111       };
23112     };
23113     tiler8.tileSize = function(val) {
23114       if (!arguments.length) return _tileSize;
23115       _tileSize = val;
23116       return tiler8;
23117     };
23118     tiler8.zoomExtent = function(val) {
23119       if (!arguments.length) return _zoomExtent;
23120       _zoomExtent = val;
23121       return tiler8;
23122     };
23123     tiler8.size = function(val) {
23124       if (!arguments.length) return _size;
23125       _size = val;
23126       return tiler8;
23127     };
23128     tiler8.scale = function(val) {
23129       if (!arguments.length) return _scale;
23130       _scale = val;
23131       return tiler8;
23132     };
23133     tiler8.translate = function(val) {
23134       if (!arguments.length) return _translate;
23135       _translate = val;
23136       return tiler8;
23137     };
23138     tiler8.margin = function(val) {
23139       if (!arguments.length) return _margin;
23140       _margin = +val;
23141       return tiler8;
23142     };
23143     tiler8.skipNullIsland = function(val) {
23144       if (!arguments.length) return _skipNullIsland;
23145       _skipNullIsland = val;
23146       return tiler8;
23147     };
23148     return tiler8;
23149   }
23150
23151   // modules/util/trigger_event.js
23152   function utilTriggerEvent(target, type2, eventProperties) {
23153     target.each(function() {
23154       var evt = document.createEvent("HTMLEvents");
23155       evt.initEvent(type2, true, true);
23156       for (var prop in eventProperties) {
23157         evt[prop] = eventProperties[prop];
23158       }
23159       this.dispatchEvent(evt);
23160     });
23161   }
23162
23163   // modules/util/units.js
23164   var OSM_PRECISION = 7;
23165   function displayLength(m2, isImperial) {
23166     var d2 = m2 * (isImperial ? 3.28084 : 1);
23167     var unit2;
23168     if (isImperial) {
23169       if (d2 >= 5280) {
23170         d2 /= 5280;
23171         unit2 = "miles";
23172       } else {
23173         unit2 = "feet";
23174       }
23175     } else {
23176       if (d2 >= 1e3) {
23177         d2 /= 1e3;
23178         unit2 = "kilometers";
23179       } else {
23180         unit2 = "meters";
23181       }
23182     }
23183     return _t("units." + unit2, {
23184       quantity: d2.toLocaleString(_mainLocalizer.localeCode(), {
23185         maximumSignificantDigits: 4
23186       })
23187     });
23188   }
23189   function displayArea(m2, isImperial) {
23190     var locale2 = _mainLocalizer.localeCode();
23191     var d2 = m2 * (isImperial ? 10.7639111056 : 1);
23192     var d1, d22, area;
23193     var unit1 = "";
23194     var unit2 = "";
23195     if (isImperial) {
23196       if (d2 >= 6969600) {
23197         d1 = d2 / 27878400;
23198         unit1 = "square_miles";
23199       } else {
23200         d1 = d2;
23201         unit1 = "square_feet";
23202       }
23203       if (d2 > 4356 && d2 < 4356e4) {
23204         d22 = d2 / 43560;
23205         unit2 = "acres";
23206       }
23207     } else {
23208       if (d2 >= 25e4) {
23209         d1 = d2 / 1e6;
23210         unit1 = "square_kilometers";
23211       } else {
23212         d1 = d2;
23213         unit1 = "square_meters";
23214       }
23215       if (d2 > 1e3 && d2 < 1e7) {
23216         d22 = d2 / 1e4;
23217         unit2 = "hectares";
23218       }
23219     }
23220     area = _t("units." + unit1, {
23221       quantity: d1.toLocaleString(locale2, {
23222         maximumSignificantDigits: 4
23223       })
23224     });
23225     if (d22) {
23226       return _t("units.area_pair", {
23227         area1: area,
23228         area2: _t("units." + unit2, {
23229           quantity: d22.toLocaleString(locale2, {
23230             maximumSignificantDigits: 2
23231           })
23232         })
23233       });
23234     } else {
23235       return area;
23236     }
23237   }
23238   function wrap(x2, min3, max3) {
23239     var d2 = max3 - min3;
23240     return ((x2 - min3) % d2 + d2) % d2 + min3;
23241   }
23242   function clamp(x2, min3, max3) {
23243     return Math.max(min3, Math.min(x2, max3));
23244   }
23245   function roundToDecimal(target, decimalPlace) {
23246     target = Number(target);
23247     decimalPlace = Number(decimalPlace);
23248     const factor = Math.pow(10, decimalPlace);
23249     return Math.round(target * factor) / factor;
23250   }
23251   function displayCoordinate(deg, pos, neg) {
23252     var displayCoordinate2;
23253     var locale2 = _mainLocalizer.localeCode();
23254     var degreesFloor = Math.floor(Math.abs(deg));
23255     var min3 = (Math.abs(deg) - degreesFloor) * 60;
23256     var minFloor = Math.floor(min3);
23257     var sec = (min3 - minFloor) * 60;
23258     var fix = roundToDecimal(sec, 8);
23259     var secRounded = roundToDecimal(fix, 0);
23260     if (secRounded === 60) {
23261       secRounded = 0;
23262       minFloor += 1;
23263       if (minFloor === 60) {
23264         minFloor = 0;
23265         degreesFloor += 1;
23266       }
23267     }
23268     displayCoordinate2 = _t("units.arcdegrees", {
23269       quantity: degreesFloor.toLocaleString(locale2)
23270     }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", {
23271       quantity: minFloor.toLocaleString(locale2)
23272     }) : "") + (secRounded !== 0 ? _t("units.arcseconds", {
23273       quantity: secRounded.toLocaleString(locale2)
23274     }) : "");
23275     if (deg === 0) {
23276       return displayCoordinate2;
23277     } else {
23278       return _t("units.coordinate", {
23279         coordinate: displayCoordinate2,
23280         direction: _t("units." + (deg > 0 ? pos : neg))
23281       });
23282     }
23283   }
23284   function dmsCoordinatePair(coord2) {
23285     return _t("units.coordinate_pair", {
23286       latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"),
23287       longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west")
23288     });
23289   }
23290   function decimalCoordinatePair(coord2) {
23291     return _t("units.coordinate_pair", {
23292       latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION),
23293       longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION)
23294     });
23295   }
23296   function dmsMatcher(q2) {
23297     const matchers = [
23298       // D M SS , D M SS  ex: 35 11 10.1 , 136 49 53.8
23299       {
23300         condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/,
23301         parser: function(q3) {
23302           const match = this.condition.exec(q3);
23303           const lat = +match[2] + +match[3] / 60 + +match[4] / 3600;
23304           const lng = +match[6] + +match[7] / 60 + +match[8] / 3600;
23305           const isNegLat = match[1] === "-" ? -lat : lat;
23306           const isNegLng = match[5] === "-" ? -lng : lng;
23307           const d2 = [isNegLat, isNegLng];
23308           return d2;
23309         }
23310       },
23311       // D MM , D MM ex: 35 11.1683 , 136 49.8966
23312       {
23313         condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/,
23314         parser: function(q3) {
23315           const match = this.condition.exec(q3);
23316           const lat = +match[2] + +match[3] / 60;
23317           const lng = +match[5] + +match[6] / 60;
23318           const isNegLat = match[1] === "-" ? -lat : lat;
23319           const isNegLng = match[4] === "-" ? -lng : lng;
23320           const d2 = [isNegLat, isNegLng];
23321           return d2;
23322         }
23323       }
23324     ];
23325     for (const matcher of matchers) {
23326       if (matcher.condition.test(q2)) {
23327         return matcher.parser(q2);
23328       }
23329     }
23330     return null;
23331   }
23332
23333   // modules/core/localizer.js
23334   var _mainLocalizer = coreLocalizer();
23335   var _t = _mainLocalizer.t;
23336   function coreLocalizer() {
23337     let localizer = {};
23338     let _dataLanguages = {};
23339     let _dataLocales = {};
23340     let _localeStrings = {};
23341     let _localeCode = "en-US";
23342     let _localeCodes = ["en-US", "en"];
23343     let _languageCode = "en";
23344     let _textDirection = "ltr";
23345     let _usesMetric = false;
23346     let _languageNames = {};
23347     let _scriptNames = {};
23348     localizer.localeCode = () => _localeCode;
23349     localizer.localeCodes = () => _localeCodes;
23350     localizer.languageCode = () => _languageCode;
23351     localizer.textDirection = () => _textDirection;
23352     localizer.usesMetric = () => _usesMetric;
23353     localizer.languageNames = () => _languageNames;
23354     localizer.scriptNames = () => _scriptNames;
23355     let _preferredLocaleCodes = [];
23356     localizer.preferredLocaleCodes = function(codes) {
23357       if (!arguments.length) return _preferredLocaleCodes;
23358       if (typeof codes === "string") {
23359         _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean);
23360       } else {
23361         _preferredLocaleCodes = codes;
23362       }
23363       return localizer;
23364     };
23365     var _loadPromise;
23366     localizer.ensureLoaded = () => {
23367       if (_loadPromise) return _loadPromise;
23368       let filesToFetch = [
23369         "languages",
23370         // load the list of languages
23371         "locales"
23372         // load the list of supported locales
23373       ];
23374       const localeDirs = {
23375         general: "locales",
23376         tagging: presetsCdnUrl + "dist/translations"
23377       };
23378       let fileMap = _mainFileFetcher.fileMap();
23379       for (let scopeId in localeDirs) {
23380         const key = "locales_index_".concat(scopeId);
23381         if (!fileMap[key]) {
23382           fileMap[key] = localeDirs[scopeId] + "/index.min.json";
23383         }
23384         filesToFetch.push(key);
23385       }
23386       return _loadPromise = Promise.all(filesToFetch.map((key) => _mainFileFetcher.get(key))).then((results) => {
23387         _dataLanguages = results[0];
23388         _dataLocales = results[1];
23389         let indexes = results.slice(2);
23390         let requestedLocales = (_preferredLocaleCodes || []).concat(utilDetect().browserLocales).concat(["en"]);
23391         _localeCodes = localesToUseFrom(requestedLocales);
23392         _localeCode = _localeCodes[0];
23393         let loadStringsPromises = [];
23394         indexes.forEach((index, i3) => {
23395           const fullCoverageIndex = _localeCodes.findIndex(function(locale2) {
23396             return index[locale2] && index[locale2].pct === 1;
23397           });
23398           _localeCodes.slice(0, fullCoverageIndex + 1).forEach(function(code) {
23399             let scopeId = Object.keys(localeDirs)[i3];
23400             let directory = Object.values(localeDirs)[i3];
23401             if (index[code]) loadStringsPromises.push(localizer.loadLocale(code, scopeId, directory));
23402           });
23403         });
23404         return Promise.all(loadStringsPromises);
23405       }).then(() => {
23406         updateForCurrentLocale();
23407       }).catch((err) => console.error(err));
23408     };
23409     function localesToUseFrom(requestedLocales) {
23410       let supportedLocales = _dataLocales;
23411       let toUse = [];
23412       for (let i3 in requestedLocales) {
23413         let locale2 = requestedLocales[i3];
23414         if (supportedLocales[locale2]) toUse.push(locale2);
23415         if (locale2.includes("-")) {
23416           let langPart = locale2.split("-")[0];
23417           if (supportedLocales[langPart]) toUse.push(langPart);
23418         }
23419       }
23420       return utilArrayUniq(toUse);
23421     }
23422     function updateForCurrentLocale() {
23423       if (!_localeCode) return;
23424       _languageCode = _localeCode.split("-")[0];
23425       const currentData = _dataLocales[_localeCode] || _dataLocales[_languageCode];
23426       const hash2 = utilStringQs(window.location.hash);
23427       if (hash2.rtl === "true") {
23428         _textDirection = "rtl";
23429       } else if (hash2.rtl === "false") {
23430         _textDirection = "ltr";
23431       } else {
23432         _textDirection = currentData && currentData.rtl ? "rtl" : "ltr";
23433       }
23434       let locale2 = _localeCode;
23435       if (locale2.toLowerCase() === "en-us") locale2 = "en";
23436       _languageNames = _localeStrings.general[locale2].languageNames || _localeStrings.general[_languageCode].languageNames;
23437       _scriptNames = _localeStrings.general[locale2].scriptNames || _localeStrings.general[_languageCode].scriptNames;
23438       _usesMetric = _localeCode.slice(-3).toLowerCase() !== "-us";
23439     }
23440     localizer.loadLocale = (locale2, scopeId, directory) => {
23441       if (locale2.toLowerCase() === "en-us") locale2 = "en";
23442       if (_localeStrings[scopeId] && _localeStrings[scopeId][locale2]) {
23443         return Promise.resolve(locale2);
23444       }
23445       let fileMap = _mainFileFetcher.fileMap();
23446       const key = "locale_".concat(scopeId, "_").concat(locale2);
23447       if (!fileMap[key]) {
23448         fileMap[key] = "".concat(directory, "/").concat(locale2, ".min.json");
23449       }
23450       return _mainFileFetcher.get(key).then((d2) => {
23451         if (!_localeStrings[scopeId]) _localeStrings[scopeId] = {};
23452         _localeStrings[scopeId][locale2] = d2[locale2];
23453         return locale2;
23454       });
23455     };
23456     localizer.pluralRule = function(number3) {
23457       return pluralRule(number3, _localeCode);
23458     };
23459     function pluralRule(number3, localeCode) {
23460       const rules = "Intl" in window && Intl.PluralRules && new Intl.PluralRules(localeCode);
23461       if (rules) {
23462         return rules.select(number3);
23463       }
23464       if (number3 === 1) return "one";
23465       return "other";
23466     }
23467     localizer.tInfo = function(origStringId, replacements, locale2) {
23468       let stringId = origStringId.trim();
23469       let scopeId = "general";
23470       if (stringId[0] === "_") {
23471         let split = stringId.split(".");
23472         scopeId = split[0].slice(1);
23473         stringId = split.slice(1).join(".");
23474       }
23475       locale2 = locale2 || _localeCode;
23476       let path = stringId.split(".").map((s2) => s2.replace(/<TX_DOT>/g, ".")).reverse();
23477       let stringsKey = locale2;
23478       if (stringsKey.toLowerCase() === "en-us") stringsKey = "en";
23479       let result = _localeStrings && _localeStrings[scopeId] && _localeStrings[scopeId][stringsKey];
23480       while (result !== void 0 && path.length) {
23481         result = result[path.pop()];
23482       }
23483       if (result !== void 0) {
23484         if (replacements) {
23485           if (typeof result === "object" && Object.keys(result).length) {
23486             const number3 = Object.values(replacements).find(function(value) {
23487               return typeof value === "number";
23488             });
23489             if (number3 !== void 0) {
23490               const rule = pluralRule(number3, locale2);
23491               if (result[rule]) {
23492                 result = result[rule];
23493               } else {
23494                 result = Object.values(result)[0];
23495               }
23496             }
23497           }
23498           if (typeof result === "string") {
23499             for (let key in replacements) {
23500               let value = replacements[key];
23501               if (typeof value === "number") {
23502                 if (value.toLocaleString) {
23503                   value = value.toLocaleString(locale2, {
23504                     style: "decimal",
23505                     useGrouping: true,
23506                     minimumFractionDigits: 0
23507                   });
23508                 } else {
23509                   value = value.toString();
23510                 }
23511               }
23512               const token = "{".concat(key, "}");
23513               const regex = new RegExp(token, "g");
23514               result = result.replace(regex, value);
23515             }
23516           }
23517         }
23518         if (typeof result === "string") {
23519           return {
23520             text: result,
23521             locale: locale2
23522           };
23523         }
23524       }
23525       let index = _localeCodes.indexOf(locale2);
23526       if (index >= 0 && index < _localeCodes.length - 1) {
23527         let fallback = _localeCodes[index + 1];
23528         return localizer.tInfo(origStringId, replacements, fallback);
23529       }
23530       if (replacements && "default" in replacements) {
23531         return {
23532           text: replacements.default,
23533           locale: null
23534         };
23535       }
23536       const missing = "Missing ".concat(locale2, " translation: ").concat(origStringId);
23537       if (typeof console !== "undefined") console.error(missing);
23538       return {
23539         text: missing,
23540         locale: "en"
23541       };
23542     };
23543     localizer.hasTextForStringId = function(stringId) {
23544       return !!localizer.tInfo(stringId, { default: "nothing found" }).locale;
23545     };
23546     localizer.t = function(stringId, replacements, locale2) {
23547       return localizer.tInfo(stringId, replacements, locale2).text;
23548     };
23549     localizer.t.html = function(stringId, replacements, locale2) {
23550       replacements = Object.assign({}, replacements);
23551       for (var k2 in replacements) {
23552         if (typeof replacements[k2] === "string") {
23553           replacements[k2] = escape_default(replacements[k2]);
23554         }
23555         if (typeof replacements[k2] === "object" && typeof replacements[k2].html === "string") {
23556           replacements[k2] = replacements[k2].html;
23557         }
23558       }
23559       const info = localizer.tInfo(stringId, replacements, locale2);
23560       if (info.text) {
23561         return '<span class="localized-text" lang="'.concat(info.locale || "und", '">').concat(info.text, "</span>");
23562       } else {
23563         return "";
23564       }
23565     };
23566     localizer.t.append = function(stringId, replacements, locale2) {
23567       const ret = function(selection2) {
23568         const info = localizer.tInfo(stringId, replacements, locale2);
23569         return selection2.append("span").attr("class", "localized-text").attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
23570       };
23571       ret.stringId = stringId;
23572       return ret;
23573     };
23574     localizer.t.addOrUpdate = function(stringId, replacements, locale2) {
23575       const ret = function(selection2) {
23576         const info = localizer.tInfo(stringId, replacements, locale2);
23577         const span = selection2.selectAll("span.localized-text").data([info]);
23578         const enter = span.enter().append("span").classed("localized-text", true);
23579         span.merge(enter).attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
23580       };
23581       ret.stringId = stringId;
23582       return ret;
23583     };
23584     localizer.languageName = (code, options2) => {
23585       if (_languageNames && _languageNames[code]) {
23586         return _languageNames[code];
23587       }
23588       if (options2 && options2.localOnly) return null;
23589       const langInfo = _dataLanguages[code];
23590       if (langInfo) {
23591         if (langInfo.nativeName) {
23592           return localizer.t("translate.language_and_code", { language: langInfo.nativeName, code });
23593         } else if (langInfo.base && langInfo.script) {
23594           const base = langInfo.base;
23595           if (_languageNames && _languageNames[base]) {
23596             const scriptCode = langInfo.script;
23597             const script = _scriptNames && _scriptNames[scriptCode] || scriptCode;
23598             return localizer.t("translate.language_and_code", { language: _languageNames[base], code: script });
23599           } else if (_dataLanguages[base] && _dataLanguages[base].nativeName) {
23600             return localizer.t("translate.language_and_code", { language: _dataLanguages[base].nativeName, code });
23601           }
23602         }
23603       }
23604       return code;
23605     };
23606     localizer.floatFormatter = (locale2) => {
23607       if (!("Intl" in window && "NumberFormat" in Intl && "formatToParts" in Intl.NumberFormat.prototype)) {
23608         return (number3, fractionDigits) => {
23609           return fractionDigits === void 0 ? number3.toString() : number3.toFixed(fractionDigits);
23610         };
23611       } else {
23612         return (number3, fractionDigits) => number3.toLocaleString(locale2, {
23613           minimumFractionDigits: fractionDigits,
23614           maximumFractionDigits: fractionDigits === void 0 ? 20 : fractionDigits
23615         });
23616       }
23617     };
23618     localizer.floatParser = (locale2) => {
23619       const polyfill = (string) => +string.trim();
23620       if (!("Intl" in window && "NumberFormat" in Intl)) return polyfill;
23621       const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
23622       if (!("formatToParts" in format2)) return polyfill;
23623       const parts = format2.formatToParts(-12345.6);
23624       const numerals = Array.from({ length: 10 }).map((_2, i3) => format2.format(i3));
23625       const index = new Map(numerals.map((d2, i3) => [d2, i3]));
23626       const literalPart = parts.find((d2) => d2.type === "literal");
23627       const literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
23628       const groupPart = parts.find((d2) => d2.type === "group");
23629       const group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
23630       const decimalPart = parts.find((d2) => d2.type === "decimal");
23631       const decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
23632       const numeral = new RegExp("[".concat(numerals.join(""), "]"), "g");
23633       const getIndex = (d2) => index.get(d2);
23634       return (string) => {
23635         string = string.trim();
23636         if (literal) string = string.replace(literal, "");
23637         if (group) string = string.replace(group, "");
23638         if (decimal) string = string.replace(decimal, ".");
23639         string = string.replace(numeral, getIndex);
23640         return string ? +string : NaN;
23641       };
23642     };
23643     localizer.decimalPlaceCounter = (locale2) => {
23644       var literal, group, decimal;
23645       if ("Intl" in window && "NumberFormat" in Intl) {
23646         const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
23647         if ("formatToParts" in format2) {
23648           const parts = format2.formatToParts(-12345.6);
23649           const literalPart = parts.find((d2) => d2.type === "literal");
23650           literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
23651           const groupPart = parts.find((d2) => d2.type === "group");
23652           group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
23653           const decimalPart = parts.find((d2) => d2.type === "decimal");
23654           decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
23655         }
23656       }
23657       return (string) => {
23658         string = string.trim();
23659         if (literal) string = string.replace(literal, "");
23660         if (group) string = string.replace(group, "");
23661         const parts = string.split(decimal || ".");
23662         return parts && parts[1] && parts[1].length || 0;
23663       };
23664     };
23665     return localizer;
23666   }
23667
23668   // modules/util/util.js
23669   function utilTagText(entity) {
23670     var obj = entity && entity.tags || {};
23671     return Object.keys(obj).map(function(k2) {
23672       return k2 + "=" + obj[k2];
23673     }).join(", ");
23674   }
23675   function utilTotalExtent(array2, graph) {
23676     var extent = geoExtent();
23677     var val, entity;
23678     for (var i3 = 0; i3 < array2.length; i3++) {
23679       val = array2[i3];
23680       entity = typeof val === "string" ? graph.hasEntity(val) : val;
23681       if (entity) {
23682         extent._extend(entity.extent(graph));
23683       }
23684     }
23685     return extent;
23686   }
23687   function utilTagDiff(oldTags, newTags) {
23688     var tagDiff = [];
23689     var keys2 = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
23690     keys2.forEach(function(k2) {
23691       var oldVal = oldTags[k2];
23692       var newVal = newTags[k2];
23693       if ((oldVal || oldVal === "") && (newVal === void 0 || newVal !== oldVal)) {
23694         tagDiff.push({
23695           type: "-",
23696           key: k2,
23697           oldVal,
23698           newVal,
23699           display: "- " + k2 + "=" + oldVal
23700         });
23701       }
23702       if ((newVal || newVal === "") && (oldVal === void 0 || newVal !== oldVal)) {
23703         tagDiff.push({
23704           type: "+",
23705           key: k2,
23706           oldVal,
23707           newVal,
23708           display: "+ " + k2 + "=" + newVal
23709         });
23710       }
23711     });
23712     return tagDiff;
23713   }
23714   function utilEntitySelector(ids) {
23715     return ids.length ? "." + ids.join(",.") : "nothing";
23716   }
23717   function utilEntityOrMemberSelector(ids, graph) {
23718     var seen = new Set(ids);
23719     ids.forEach(collectShallowDescendants);
23720     return utilEntitySelector(Array.from(seen));
23721     function collectShallowDescendants(id2) {
23722       var entity = graph.hasEntity(id2);
23723       if (!entity || entity.type !== "relation") return;
23724       entity.members.map(function(member) {
23725         return member.id;
23726       }).forEach(function(id3) {
23727         seen.add(id3);
23728       });
23729     }
23730   }
23731   function utilEntityOrDeepMemberSelector(ids, graph) {
23732     return utilEntitySelector(utilEntityAndDeepMemberIDs(ids, graph));
23733   }
23734   function utilEntityAndDeepMemberIDs(ids, graph) {
23735     var seen = /* @__PURE__ */ new Set();
23736     ids.forEach(collectDeepDescendants);
23737     return Array.from(seen);
23738     function collectDeepDescendants(id2) {
23739       if (seen.has(id2)) return;
23740       seen.add(id2);
23741       var entity = graph.hasEntity(id2);
23742       if (!entity || entity.type !== "relation") return;
23743       entity.members.map(function(member) {
23744         return member.id;
23745       }).forEach(collectDeepDescendants);
23746     }
23747   }
23748   function utilDeepMemberSelector(ids, graph, skipMultipolgonMembers) {
23749     var idsSet = new Set(ids);
23750     var seen = /* @__PURE__ */ new Set();
23751     var returners = /* @__PURE__ */ new Set();
23752     ids.forEach(collectDeepDescendants);
23753     return utilEntitySelector(Array.from(returners));
23754     function collectDeepDescendants(id2) {
23755       if (seen.has(id2)) return;
23756       seen.add(id2);
23757       if (!idsSet.has(id2)) {
23758         returners.add(id2);
23759       }
23760       var entity = graph.hasEntity(id2);
23761       if (!entity || entity.type !== "relation") return;
23762       if (skipMultipolgonMembers && entity.isMultipolygon()) return;
23763       entity.members.map(function(member) {
23764         return member.id;
23765       }).forEach(collectDeepDescendants);
23766     }
23767   }
23768   function utilHighlightEntities(ids, highlighted, context) {
23769     context.surface().selectAll(utilEntityOrDeepMemberSelector(ids, context.graph())).classed("highlighted", highlighted);
23770   }
23771   function utilGetAllNodes(ids, graph) {
23772     var seen = /* @__PURE__ */ new Set();
23773     var nodes = /* @__PURE__ */ new Set();
23774     ids.forEach(collectNodes);
23775     return Array.from(nodes);
23776     function collectNodes(id2) {
23777       if (seen.has(id2)) return;
23778       seen.add(id2);
23779       var entity = graph.hasEntity(id2);
23780       if (!entity) return;
23781       if (entity.type === "node") {
23782         nodes.add(entity);
23783       } else if (entity.type === "way") {
23784         entity.nodes.forEach(collectNodes);
23785       } else {
23786         entity.members.map(function(member) {
23787           return member.id;
23788         }).forEach(collectNodes);
23789       }
23790     }
23791   }
23792   function utilDisplayName(entity, hideNetwork) {
23793     var localizedNameKey = "name:" + _mainLocalizer.languageCode().toLowerCase();
23794     var name = entity.tags[localizedNameKey] || entity.tags.name || "";
23795     var tags = {
23796       direction: entity.tags.direction,
23797       from: entity.tags.from,
23798       name,
23799       network: hideNetwork ? void 0 : entity.tags.cycle_network || entity.tags.network,
23800       ref: entity.tags.ref,
23801       to: entity.tags.to,
23802       via: entity.tags.via
23803     };
23804     if (entity.tags.route && entity.tags.name && entity.tags.name.match(/[→⇒↔⇔]|[-=]>/)) {
23805       return entity.tags.name;
23806     }
23807     if (!entity.tags.route && name) {
23808       return name;
23809     }
23810     var keyComponents = [];
23811     if (tags.network) {
23812       keyComponents.push("network");
23813     }
23814     if (tags.ref) {
23815       keyComponents.push("ref");
23816     }
23817     if (tags.name) {
23818       keyComponents.push("name");
23819     }
23820     if (entity.tags.route) {
23821       if (tags.direction) {
23822         keyComponents.push("direction");
23823       } else if (tags.from && tags.to) {
23824         keyComponents.push("from");
23825         keyComponents.push("to");
23826         if (tags.via) {
23827           keyComponents.push("via");
23828         }
23829       }
23830     }
23831     if (keyComponents.length) {
23832       name = _t("inspector.display_name." + keyComponents.join("_"), tags);
23833     }
23834     return name;
23835   }
23836   function utilDisplayNameForPath(entity) {
23837     var name = utilDisplayName(entity);
23838     var isFirefox = utilDetect().browser.toLowerCase().indexOf("firefox") > -1;
23839     var isNewChromium = Number(utilDetect().version.split(".")[0]) >= 96;
23840     if (!isFirefox && !isNewChromium && name && rtlRegex.test(name)) {
23841       name = fixRTLTextForSvg(name);
23842     }
23843     return name;
23844   }
23845   function utilDisplayType(id2) {
23846     return {
23847       n: _t("inspector.node"),
23848       w: _t("inspector.way"),
23849       r: _t("inspector.relation")
23850     }[id2.charAt(0)];
23851   }
23852   function utilEntityRoot(entityType) {
23853     return {
23854       node: "n",
23855       way: "w",
23856       relation: "r"
23857     }[entityType];
23858   }
23859   function utilCombinedTags(entityIDs, graph) {
23860     var tags = {};
23861     var tagCounts = {};
23862     var allKeys = /* @__PURE__ */ new Set();
23863     var entities = entityIDs.map(function(entityID) {
23864       return graph.hasEntity(entityID);
23865     }).filter(Boolean);
23866     entities.forEach(function(entity) {
23867       var keys2 = Object.keys(entity.tags).filter(Boolean);
23868       keys2.forEach(function(key2) {
23869         allKeys.add(key2);
23870       });
23871     });
23872     entities.forEach(function(entity) {
23873       allKeys.forEach(function(key2) {
23874         var value = entity.tags[key2];
23875         if (!tags.hasOwnProperty(key2)) {
23876           tags[key2] = value;
23877         } else {
23878           if (!Array.isArray(tags[key2])) {
23879             if (tags[key2] !== value) {
23880               tags[key2] = [tags[key2], value];
23881             }
23882           } else {
23883             if (tags[key2].indexOf(value) === -1) {
23884               tags[key2].push(value);
23885             }
23886           }
23887         }
23888         var tagHash = key2 + "=" + value;
23889         if (!tagCounts[tagHash]) tagCounts[tagHash] = 0;
23890         tagCounts[tagHash] += 1;
23891       });
23892     });
23893     for (var key in tags) {
23894       if (!Array.isArray(tags[key])) continue;
23895       tags[key] = tags[key].sort(function(val12, val2) {
23896         var key2 = key2;
23897         var count2 = tagCounts[key2 + "=" + val2];
23898         var count1 = tagCounts[key2 + "=" + val12];
23899         if (count2 !== count1) {
23900           return count2 - count1;
23901         }
23902         if (val2 && val12) {
23903           return val12.localeCompare(val2);
23904         }
23905         return val12 ? 1 : -1;
23906       });
23907     }
23908     return tags;
23909   }
23910   function utilStringQs(str) {
23911     str = str.replace(/^[#?]{0,2}/, "");
23912     return Object.fromEntries(new URLSearchParams(str));
23913   }
23914   function utilQsString(obj, softEncode) {
23915     let str = new URLSearchParams(obj).toString();
23916     if (softEncode) {
23917       str = str.replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent);
23918     }
23919     return str;
23920   }
23921   function utilPrefixDOMProperty(property) {
23922     var prefixes2 = ["webkit", "ms", "moz", "o"];
23923     var i3 = -1;
23924     var n3 = prefixes2.length;
23925     var s2 = document.body;
23926     if (property in s2) return property;
23927     property = property.slice(0, 1).toUpperCase() + property.slice(1);
23928     while (++i3 < n3) {
23929       if (prefixes2[i3] + property in s2) {
23930         return prefixes2[i3] + property;
23931       }
23932     }
23933     return false;
23934   }
23935   function utilPrefixCSSProperty(property) {
23936     var prefixes2 = ["webkit", "ms", "Moz", "O"];
23937     var i3 = -1;
23938     var n3 = prefixes2.length;
23939     var s2 = document.body.style;
23940     if (property.toLowerCase() in s2) {
23941       return property.toLowerCase();
23942     }
23943     while (++i3 < n3) {
23944       if (prefixes2[i3] + property in s2) {
23945         return "-" + prefixes2[i3].toLowerCase() + property.replace(/([A-Z])/g, "-$1").toLowerCase();
23946       }
23947     }
23948     return false;
23949   }
23950   var transformProperty;
23951   function utilSetTransform(el, x2, y2, scale) {
23952     var prop = transformProperty = transformProperty || utilPrefixCSSProperty("Transform");
23953     var translate = utilDetect().opera ? "translate(" + x2 + "px," + y2 + "px)" : "translate3d(" + x2 + "px," + y2 + "px,0)";
23954     return el.style(prop, translate + (scale ? " scale(" + scale + ")" : ""));
23955   }
23956   function utilEditDistance(a2, b2) {
23957     a2 = (0, import_diacritics.remove)(a2.toLowerCase());
23958     b2 = (0, import_diacritics.remove)(b2.toLowerCase());
23959     if (a2.length === 0) return b2.length;
23960     if (b2.length === 0) return a2.length;
23961     var matrix = [];
23962     var i3, j2;
23963     for (i3 = 0; i3 <= b2.length; i3++) {
23964       matrix[i3] = [i3];
23965     }
23966     for (j2 = 0; j2 <= a2.length; j2++) {
23967       matrix[0][j2] = j2;
23968     }
23969     for (i3 = 1; i3 <= b2.length; i3++) {
23970       for (j2 = 1; j2 <= a2.length; j2++) {
23971         if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) {
23972           matrix[i3][j2] = matrix[i3 - 1][j2 - 1];
23973         } else {
23974           matrix[i3][j2] = Math.min(
23975             matrix[i3 - 1][j2 - 1] + 1,
23976             // substitution
23977             Math.min(
23978               matrix[i3][j2 - 1] + 1,
23979               // insertion
23980               matrix[i3 - 1][j2] + 1
23981             )
23982           );
23983         }
23984       }
23985     }
23986     return matrix[b2.length][a2.length];
23987   }
23988   function utilFastMouse(container) {
23989     var rect = container.getBoundingClientRect();
23990     var rectLeft = rect.left;
23991     var rectTop = rect.top;
23992     var clientLeft = +container.clientLeft;
23993     var clientTop = +container.clientTop;
23994     return function(e3) {
23995       return [
23996         e3.clientX - rectLeft - clientLeft,
23997         e3.clientY - rectTop - clientTop
23998       ];
23999     };
24000   }
24001   function utilAsyncMap(inputs, func, callback) {
24002     var remaining = inputs.length;
24003     var results = [];
24004     var errors = [];
24005     inputs.forEach(function(d2, i3) {
24006       func(d2, function done(err, data) {
24007         errors[i3] = err;
24008         results[i3] = data;
24009         remaining--;
24010         if (!remaining) callback(errors, results);
24011       });
24012     });
24013   }
24014   function utilWrap(index, length2) {
24015     if (index < 0) {
24016       index += Math.ceil(-index / length2) * length2;
24017     }
24018     return index % length2;
24019   }
24020   function utilFunctor(value) {
24021     if (typeof value === "function") return value;
24022     return function() {
24023       return value;
24024     };
24025   }
24026   function utilNoAuto(selection2) {
24027     var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea";
24028     return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("data-1p-ignore", "true").attr("data-bwignore", "true").attr("data-form-type", "other").attr("data-lpignore", "true").attr("spellcheck", isText ? "true" : "false");
24029   }
24030   function utilHashcode(str) {
24031     var hash2 = 0;
24032     if (str.length === 0) {
24033       return hash2;
24034     }
24035     for (var i3 = 0; i3 < str.length; i3++) {
24036       var char = str.charCodeAt(i3);
24037       hash2 = (hash2 << 5) - hash2 + char;
24038       hash2 = hash2 & hash2;
24039     }
24040     return hash2;
24041   }
24042   function utilSafeClassName(str) {
24043     return str.toLowerCase().replace(/[^a-z0-9]+/g, "_");
24044   }
24045   function utilUniqueDomId(val) {
24046     return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString();
24047   }
24048   function utilUnicodeCharsCount(str) {
24049     return Array.from(str).length;
24050   }
24051   function utilUnicodeCharsTruncated(str, limit) {
24052     return Array.from(str).slice(0, limit).join("");
24053   }
24054   function toNumericID(id2) {
24055     var match = id2.match(/^[cnwr](-?\d+)$/);
24056     if (match) {
24057       return parseInt(match[1], 10);
24058     }
24059     return NaN;
24060   }
24061   function compareNumericIDs(left, right) {
24062     if (isNaN(left) && isNaN(right)) return -1;
24063     if (isNaN(left)) return 1;
24064     if (isNaN(right)) return -1;
24065     if (Math.sign(left) !== Math.sign(right)) return -Math.sign(left);
24066     if (Math.sign(left) < 0) return Math.sign(right - left);
24067     return Math.sign(left - right);
24068   }
24069   function utilCompareIDs(left, right) {
24070     return compareNumericIDs(toNumericID(left), toNumericID(right));
24071   }
24072   function utilOldestID(ids) {
24073     if (ids.length === 0) {
24074       return void 0;
24075     }
24076     var oldestIDIndex = 0;
24077     var oldestID = toNumericID(ids[0]);
24078     for (var i3 = 1; i3 < ids.length; i3++) {
24079       var num = toNumericID(ids[i3]);
24080       if (compareNumericIDs(oldestID, num) === 1) {
24081         oldestIDIndex = i3;
24082         oldestID = num;
24083       }
24084     }
24085     return ids[oldestIDIndex];
24086   }
24087   function utilCleanOsmString(val, maxChars) {
24088     if (val === void 0 || val === null) {
24089       val = "";
24090     } else {
24091       val = val.toString();
24092     }
24093     val = val.trim();
24094     if (val.normalize) val = val.normalize("NFC");
24095     return utilUnicodeCharsTruncated(val, maxChars);
24096   }
24097
24098   // modules/osm/entity.js
24099   function osmEntity(attrs) {
24100     if (this instanceof osmEntity) return;
24101     if (attrs && attrs.type) {
24102       return osmEntity[attrs.type].apply(this, arguments);
24103     } else if (attrs && attrs.id) {
24104       return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
24105     }
24106     return new osmEntity().initialize(arguments);
24107   }
24108   osmEntity.id = function(type2) {
24109     return osmEntity.id.fromOSM(type2, osmEntity.id.next[type2]--);
24110   };
24111   osmEntity.id.next = {
24112     changeset: -1,
24113     node: -1,
24114     way: -1,
24115     relation: -1
24116   };
24117   osmEntity.id.fromOSM = function(type2, id2) {
24118     return type2[0] + id2;
24119   };
24120   osmEntity.id.toOSM = function(id2) {
24121     var match = id2.match(/^[cnwr](-?\d+)$/);
24122     if (match) {
24123       return match[1];
24124     }
24125     return "";
24126   };
24127   osmEntity.id.type = function(id2) {
24128     return { "c": "changeset", "n": "node", "w": "way", "r": "relation" }[id2[0]];
24129   };
24130   osmEntity.key = function(entity) {
24131     return entity.id + "v" + (entity.v || 0);
24132   };
24133   var _deprecatedTagValuesByKey;
24134   osmEntity.deprecatedTagValuesByKey = function(dataDeprecated) {
24135     if (!_deprecatedTagValuesByKey) {
24136       _deprecatedTagValuesByKey = {};
24137       dataDeprecated.forEach(function(d2) {
24138         var oldKeys = Object.keys(d2.old);
24139         if (oldKeys.length === 1) {
24140           var oldKey = oldKeys[0];
24141           var oldValue = d2.old[oldKey];
24142           if (oldValue !== "*") {
24143             if (!_deprecatedTagValuesByKey[oldKey]) {
24144               _deprecatedTagValuesByKey[oldKey] = [oldValue];
24145             } else {
24146               _deprecatedTagValuesByKey[oldKey].push(oldValue);
24147             }
24148           }
24149         }
24150       });
24151     }
24152     return _deprecatedTagValuesByKey;
24153   };
24154   osmEntity.prototype = {
24155     /** @type {Tags} */
24156     tags: {},
24157     initialize: function(sources) {
24158       for (var i3 = 0; i3 < sources.length; ++i3) {
24159         var source = sources[i3];
24160         for (var prop in source) {
24161           if (Object.prototype.hasOwnProperty.call(source, prop)) {
24162             if (source[prop] === void 0) {
24163               delete this[prop];
24164             } else {
24165               this[prop] = source[prop];
24166             }
24167           }
24168         }
24169       }
24170       if (!this.id && this.type) {
24171         this.id = osmEntity.id(this.type);
24172       }
24173       if (!this.hasOwnProperty("visible")) {
24174         this.visible = true;
24175       }
24176       if (debug) {
24177         Object.freeze(this);
24178         Object.freeze(this.tags);
24179         if (this.loc) Object.freeze(this.loc);
24180         if (this.nodes) Object.freeze(this.nodes);
24181         if (this.members) Object.freeze(this.members);
24182       }
24183       return this;
24184     },
24185     copy: function(resolver, copies) {
24186       if (copies[this.id]) return copies[this.id];
24187       var copy2 = osmEntity(this, { id: void 0, user: void 0, version: void 0 });
24188       copies[this.id] = copy2;
24189       return copy2;
24190     },
24191     osmId: function() {
24192       return osmEntity.id.toOSM(this.id);
24193     },
24194     isNew: function() {
24195       var osmId = osmEntity.id.toOSM(this.id);
24196       return osmId.length === 0 || osmId[0] === "-";
24197     },
24198     update: function(attrs) {
24199       return osmEntity(this, attrs, { v: 1 + (this.v || 0) });
24200     },
24201     mergeTags: function(tags) {
24202       var merged = Object.assign({}, this.tags);
24203       var changed = false;
24204       for (var k2 in tags) {
24205         var t1 = merged[k2];
24206         var t2 = tags[k2];
24207         if (!t1) {
24208           changed = true;
24209           merged[k2] = t2;
24210         } else if (t1 !== t2) {
24211           changed = true;
24212           merged[k2] = utilUnicodeCharsTruncated(
24213             utilArrayUnion(t1.split(/;\s*/), t2.split(/;\s*/)).join(";"),
24214             255
24215             // avoid exceeding character limit; see also context.maxCharsForTagValue()
24216           );
24217         }
24218       }
24219       return changed ? this.update({ tags: merged }) : this;
24220     },
24221     intersects: function(extent, resolver) {
24222       return this.extent(resolver).intersects(extent);
24223     },
24224     hasNonGeometryTags: function() {
24225       return Object.keys(this.tags).some(function(k2) {
24226         return k2 !== "area";
24227       });
24228     },
24229     hasParentRelations: function(resolver) {
24230       return resolver.parentRelations(this).length > 0;
24231     },
24232     hasInterestingTags: function() {
24233       return Object.keys(this.tags).some(osmIsInterestingTag);
24234     },
24235     isDegenerate: function() {
24236       return true;
24237     },
24238     deprecatedTags: function(dataDeprecated) {
24239       var tags = this.tags;
24240       if (Object.keys(tags).length === 0) return [];
24241       var deprecated = [];
24242       dataDeprecated.forEach(function(d2) {
24243         var oldKeys = Object.keys(d2.old);
24244         if (d2.replace) {
24245           var hasExistingValues = Object.keys(d2.replace).some(function(replaceKey) {
24246             if (!tags[replaceKey] || d2.old[replaceKey]) return false;
24247             var replaceValue = d2.replace[replaceKey];
24248             if (replaceValue === "*") return false;
24249             if (replaceValue === tags[replaceKey]) return false;
24250             return true;
24251           });
24252           if (hasExistingValues) return;
24253         }
24254         var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
24255           if (!tags[oldKey]) return false;
24256           if (d2.old[oldKey] === "*") return true;
24257           if (d2.old[oldKey] === tags[oldKey]) return true;
24258           var vals = tags[oldKey].split(";").filter(Boolean);
24259           if (vals.length === 0) {
24260             return false;
24261           } else if (vals.length > 1) {
24262             return vals.indexOf(d2.old[oldKey]) !== -1;
24263           } else {
24264             if (tags[oldKey] === d2.old[oldKey]) {
24265               if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) {
24266                 var replaceKeys = Object.keys(d2.replace);
24267                 return !replaceKeys.every(function(replaceKey) {
24268                   return tags[replaceKey] === d2.replace[replaceKey];
24269                 });
24270               } else {
24271                 return true;
24272               }
24273             }
24274           }
24275           return false;
24276         });
24277         if (matchesDeprecatedTags) {
24278           deprecated.push(d2);
24279         }
24280       });
24281       return deprecated;
24282     }
24283   };
24284
24285   // modules/osm/lanes.js
24286   function osmLanes(entity) {
24287     if (entity.type !== "way") return null;
24288     if (!entity.tags.highway) return null;
24289     var tags = entity.tags;
24290     var isOneWay = entity.isOneWay();
24291     var laneCount = getLaneCount(tags, isOneWay);
24292     var maxspeed = parseMaxspeed(tags);
24293     var laneDirections = parseLaneDirections(tags, isOneWay, laneCount);
24294     var forward = laneDirections.forward;
24295     var backward = laneDirections.backward;
24296     var bothways = laneDirections.bothways;
24297     var turnLanes = {};
24298     turnLanes.unspecified = parseTurnLanes(tags["turn:lanes"]);
24299     turnLanes.forward = parseTurnLanes(tags["turn:lanes:forward"]);
24300     turnLanes.backward = parseTurnLanes(tags["turn:lanes:backward"]);
24301     var maxspeedLanes = {};
24302     maxspeedLanes.unspecified = parseMaxspeedLanes(tags["maxspeed:lanes"], maxspeed);
24303     maxspeedLanes.forward = parseMaxspeedLanes(tags["maxspeed:lanes:forward"], maxspeed);
24304     maxspeedLanes.backward = parseMaxspeedLanes(tags["maxspeed:lanes:backward"], maxspeed);
24305     var psvLanes = {};
24306     psvLanes.unspecified = parseMiscLanes(tags["psv:lanes"]);
24307     psvLanes.forward = parseMiscLanes(tags["psv:lanes:forward"]);
24308     psvLanes.backward = parseMiscLanes(tags["psv:lanes:backward"]);
24309     var busLanes = {};
24310     busLanes.unspecified = parseMiscLanes(tags["bus:lanes"]);
24311     busLanes.forward = parseMiscLanes(tags["bus:lanes:forward"]);
24312     busLanes.backward = parseMiscLanes(tags["bus:lanes:backward"]);
24313     var taxiLanes = {};
24314     taxiLanes.unspecified = parseMiscLanes(tags["taxi:lanes"]);
24315     taxiLanes.forward = parseMiscLanes(tags["taxi:lanes:forward"]);
24316     taxiLanes.backward = parseMiscLanes(tags["taxi:lanes:backward"]);
24317     var hovLanes = {};
24318     hovLanes.unspecified = parseMiscLanes(tags["hov:lanes"]);
24319     hovLanes.forward = parseMiscLanes(tags["hov:lanes:forward"]);
24320     hovLanes.backward = parseMiscLanes(tags["hov:lanes:backward"]);
24321     var hgvLanes = {};
24322     hgvLanes.unspecified = parseMiscLanes(tags["hgv:lanes"]);
24323     hgvLanes.forward = parseMiscLanes(tags["hgv:lanes:forward"]);
24324     hgvLanes.backward = parseMiscLanes(tags["hgv:lanes:backward"]);
24325     var bicyclewayLanes = {};
24326     bicyclewayLanes.unspecified = parseBicycleWay(tags["bicycleway:lanes"]);
24327     bicyclewayLanes.forward = parseBicycleWay(tags["bicycleway:lanes:forward"]);
24328     bicyclewayLanes.backward = parseBicycleWay(tags["bicycleway:lanes:backward"]);
24329     var lanesObj = {
24330       forward: [],
24331       backward: [],
24332       unspecified: []
24333     };
24334     mapToLanesObj(lanesObj, turnLanes, "turnLane");
24335     mapToLanesObj(lanesObj, maxspeedLanes, "maxspeed");
24336     mapToLanesObj(lanesObj, psvLanes, "psv");
24337     mapToLanesObj(lanesObj, busLanes, "bus");
24338     mapToLanesObj(lanesObj, taxiLanes, "taxi");
24339     mapToLanesObj(lanesObj, hovLanes, "hov");
24340     mapToLanesObj(lanesObj, hgvLanes, "hgv");
24341     mapToLanesObj(lanesObj, bicyclewayLanes, "bicycleway");
24342     return {
24343       metadata: {
24344         count: laneCount,
24345         oneway: isOneWay,
24346         forward,
24347         backward,
24348         bothways,
24349         turnLanes,
24350         maxspeed,
24351         maxspeedLanes,
24352         psvLanes,
24353         busLanes,
24354         taxiLanes,
24355         hovLanes,
24356         hgvLanes,
24357         bicyclewayLanes
24358       },
24359       lanes: lanesObj
24360     };
24361   }
24362   function getLaneCount(tags, isOneWay) {
24363     var count;
24364     if (tags.lanes) {
24365       count = parseInt(tags.lanes, 10);
24366       if (count > 0) {
24367         return count;
24368       }
24369     }
24370     switch (tags.highway) {
24371       case "trunk":
24372       case "motorway":
24373         count = isOneWay ? 2 : 4;
24374         break;
24375       default:
24376         count = isOneWay ? 1 : 2;
24377         break;
24378     }
24379     return count;
24380   }
24381   function parseMaxspeed(tags) {
24382     var maxspeed = tags.maxspeed;
24383     if (!maxspeed) return;
24384     var maxspeedRegex = /^([0-9][\.0-9]+?)(?:[ ]?(?:km\/h|kmh|kph|mph|knots))?$/;
24385     if (!maxspeedRegex.test(maxspeed)) return;
24386     return parseInt(maxspeed, 10);
24387   }
24388   function parseLaneDirections(tags, isOneWay, laneCount) {
24389     var forward = parseInt(tags["lanes:forward"], 10);
24390     var backward = parseInt(tags["lanes:backward"], 10);
24391     var bothways = parseInt(tags["lanes:both_ways"], 10) > 0 ? 1 : 0;
24392     if (parseInt(tags.oneway, 10) === -1) {
24393       forward = 0;
24394       bothways = 0;
24395       backward = laneCount;
24396     } else if (isOneWay) {
24397       forward = laneCount;
24398       bothways = 0;
24399       backward = 0;
24400     } else if (isNaN(forward) && isNaN(backward)) {
24401       backward = Math.floor((laneCount - bothways) / 2);
24402       forward = laneCount - bothways - backward;
24403     } else if (isNaN(forward)) {
24404       if (backward > laneCount - bothways) {
24405         backward = laneCount - bothways;
24406       }
24407       forward = laneCount - bothways - backward;
24408     } else if (isNaN(backward)) {
24409       if (forward > laneCount - bothways) {
24410         forward = laneCount - bothways;
24411       }
24412       backward = laneCount - bothways - forward;
24413     }
24414     return {
24415       forward,
24416       backward,
24417       bothways
24418     };
24419   }
24420   function parseTurnLanes(tag2) {
24421     if (!tag2) return;
24422     var validValues = [
24423       "left",
24424       "slight_left",
24425       "sharp_left",
24426       "through",
24427       "right",
24428       "slight_right",
24429       "sharp_right",
24430       "reverse",
24431       "merge_to_left",
24432       "merge_to_right",
24433       "none"
24434     ];
24435     return tag2.split("|").map(function(s2) {
24436       if (s2 === "") s2 = "none";
24437       return s2.split(";").map(function(d2) {
24438         return validValues.indexOf(d2) === -1 ? "unknown" : d2;
24439       });
24440     });
24441   }
24442   function parseMaxspeedLanes(tag2, maxspeed) {
24443     if (!tag2) return;
24444     return tag2.split("|").map(function(s2) {
24445       if (s2 === "none") return s2;
24446       var m2 = parseInt(s2, 10);
24447       if (s2 === "" || m2 === maxspeed) return null;
24448       return isNaN(m2) ? "unknown" : m2;
24449     });
24450   }
24451   function parseMiscLanes(tag2) {
24452     if (!tag2) return;
24453     var validValues = [
24454       "yes",
24455       "no",
24456       "designated"
24457     ];
24458     return tag2.split("|").map(function(s2) {
24459       if (s2 === "") s2 = "no";
24460       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
24461     });
24462   }
24463   function parseBicycleWay(tag2) {
24464     if (!tag2) return;
24465     var validValues = [
24466       "yes",
24467       "no",
24468       "designated",
24469       "lane"
24470     ];
24471     return tag2.split("|").map(function(s2) {
24472       if (s2 === "") s2 = "no";
24473       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
24474     });
24475   }
24476   function mapToLanesObj(lanesObj, data, key) {
24477     if (data.forward) {
24478       data.forward.forEach(function(l2, i3) {
24479         if (!lanesObj.forward[i3]) lanesObj.forward[i3] = {};
24480         lanesObj.forward[i3][key] = l2;
24481       });
24482     }
24483     if (data.backward) {
24484       data.backward.forEach(function(l2, i3) {
24485         if (!lanesObj.backward[i3]) lanesObj.backward[i3] = {};
24486         lanesObj.backward[i3][key] = l2;
24487       });
24488     }
24489     if (data.unspecified) {
24490       data.unspecified.forEach(function(l2, i3) {
24491         if (!lanesObj.unspecified[i3]) lanesObj.unspecified[i3] = {};
24492         lanesObj.unspecified[i3][key] = l2;
24493       });
24494     }
24495   }
24496
24497   // modules/osm/way.js
24498   function osmWay() {
24499     if (!(this instanceof osmWay)) {
24500       return new osmWay().initialize(arguments);
24501     } else if (arguments.length) {
24502       this.initialize(arguments);
24503     }
24504   }
24505   osmEntity.way = osmWay;
24506   osmWay.prototype = Object.create(osmEntity.prototype);
24507   var prototype = {
24508     type: "way",
24509     nodes: [],
24510     copy: function(resolver, copies) {
24511       if (copies[this.id]) return copies[this.id];
24512       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
24513       var nodes = this.nodes.map(function(id2) {
24514         return resolver.entity(id2).copy(resolver, copies).id;
24515       });
24516       copy2 = copy2.update({ nodes });
24517       copies[this.id] = copy2;
24518       return copy2;
24519     },
24520     extent: function(resolver) {
24521       return resolver.transient(this, "extent", function() {
24522         var extent = geoExtent();
24523         for (var i3 = 0; i3 < this.nodes.length; i3++) {
24524           var node = resolver.hasEntity(this.nodes[i3]);
24525           if (node) {
24526             extent._extend(node.extent());
24527           }
24528         }
24529         return extent;
24530       });
24531     },
24532     first: function() {
24533       return this.nodes[0];
24534     },
24535     last: function() {
24536       return this.nodes[this.nodes.length - 1];
24537     },
24538     contains: function(node) {
24539       return this.nodes.indexOf(node) >= 0;
24540     },
24541     affix: function(node) {
24542       if (this.nodes[0] === node) return "prefix";
24543       if (this.nodes[this.nodes.length - 1] === node) return "suffix";
24544     },
24545     layer: function() {
24546       if (isFinite(this.tags.layer)) {
24547         return Math.max(-10, Math.min(+this.tags.layer, 10));
24548       }
24549       if (this.tags.covered === "yes") return -1;
24550       if (this.tags.location === "overground") return 1;
24551       if (this.tags.location === "underground") return -1;
24552       if (this.tags.location === "underwater") return -10;
24553       if (this.tags.power === "line") return 10;
24554       if (this.tags.power === "minor_line") return 10;
24555       if (this.tags.aerialway) return 10;
24556       if (this.tags.bridge) return 1;
24557       if (this.tags.cutting) return -1;
24558       if (this.tags.tunnel) return -1;
24559       if (this.tags.waterway) return -1;
24560       if (this.tags.man_made === "pipeline") return -10;
24561       if (this.tags.boundary) return -10;
24562       return 0;
24563     },
24564     // the approximate width of the line based on its tags except its `width` tag
24565     impliedLineWidthMeters: function() {
24566       var averageWidths = {
24567         highway: {
24568           // width is for single lane
24569           motorway: 5,
24570           motorway_link: 5,
24571           trunk: 4.5,
24572           trunk_link: 4.5,
24573           primary: 4,
24574           secondary: 4,
24575           tertiary: 4,
24576           primary_link: 4,
24577           secondary_link: 4,
24578           tertiary_link: 4,
24579           unclassified: 4,
24580           road: 4,
24581           living_street: 4,
24582           bus_guideway: 4,
24583           busway: 4,
24584           pedestrian: 4,
24585           residential: 3.5,
24586           service: 3.5,
24587           track: 3,
24588           cycleway: 2.5,
24589           bridleway: 2,
24590           corridor: 2,
24591           steps: 2,
24592           path: 1.5,
24593           footway: 1.5,
24594           ladder: 0.5
24595         },
24596         railway: {
24597           // width includes ties and rail bed, not just track gauge
24598           rail: 2.5,
24599           light_rail: 2.5,
24600           tram: 2.5,
24601           subway: 2.5,
24602           monorail: 2.5,
24603           funicular: 2.5,
24604           disused: 2.5,
24605           preserved: 2.5,
24606           miniature: 1.5,
24607           narrow_gauge: 1.5
24608         },
24609         waterway: {
24610           river: 50,
24611           canal: 25,
24612           stream: 5,
24613           tidal_channel: 5,
24614           fish_pass: 2.5,
24615           drain: 2.5,
24616           ditch: 1.5
24617         }
24618       };
24619       for (var key in averageWidths) {
24620         if (this.tags[key] && averageWidths[key][this.tags[key]]) {
24621           var width = averageWidths[key][this.tags[key]];
24622           if (key === "highway") {
24623             var laneCount = this.tags.lanes && parseInt(this.tags.lanes, 10);
24624             if (!laneCount) laneCount = this.isOneWay() ? 1 : 2;
24625             return width * laneCount;
24626           }
24627           return width;
24628         }
24629       }
24630       return null;
24631     },
24632     /** @returns {boolean} for example, if `oneway=yes` */
24633     isOneWayForwards() {
24634       if (this.tags.oneway === "no") return false;
24635       return !!utilCheckTagDictionary(this.tags, osmOneWayForwardTags);
24636     },
24637     /** @returns {boolean} for example, if `oneway=-1` */
24638     isOneWayBackwards() {
24639       if (this.tags.oneway === "no") return false;
24640       return !!utilCheckTagDictionary(this.tags, osmOneWayBackwardTags);
24641     },
24642     /** @returns {boolean} for example, if `oneway=alternating` */
24643     isBiDirectional() {
24644       if (this.tags.oneway === "no") return false;
24645       return !!utilCheckTagDictionary(this.tags, osmOneWayBiDirectionalTags);
24646     },
24647     /** @returns {boolean} */
24648     isOneWay() {
24649       if (this.tags.oneway === "no") return false;
24650       return !!utilCheckTagDictionary(this.tags, osmOneWayTags);
24651     },
24652     // Some identifier for tag that implies that this way is "sided",
24653     // i.e. the right side is the 'inside' (e.g. the right side of a
24654     // natural=cliff is lower).
24655     sidednessIdentifier: function() {
24656       for (const realKey in this.tags) {
24657         const value = this.tags[realKey];
24658         const key = osmRemoveLifecyclePrefix(realKey);
24659         if (key in osmRightSideIsInsideTags && value in osmRightSideIsInsideTags[key]) {
24660           if (osmRightSideIsInsideTags[key][value] === true) {
24661             return key;
24662           } else {
24663             return osmRightSideIsInsideTags[key][value];
24664           }
24665         }
24666       }
24667       return null;
24668     },
24669     isSided: function() {
24670       if (this.tags.two_sided === "yes") {
24671         return false;
24672       }
24673       return this.sidednessIdentifier() !== null;
24674     },
24675     lanes: function() {
24676       return osmLanes(this);
24677     },
24678     isClosed: function() {
24679       return this.nodes.length > 1 && this.first() === this.last();
24680     },
24681     isConvex: function(resolver) {
24682       if (!this.isClosed() || this.isDegenerate()) return null;
24683       var nodes = utilArrayUniq(resolver.childNodes(this));
24684       var coords = nodes.map(function(n3) {
24685         return n3.loc;
24686       });
24687       var curr = 0;
24688       var prev = 0;
24689       for (var i3 = 0; i3 < coords.length; i3++) {
24690         var o2 = coords[(i3 + 1) % coords.length];
24691         var a2 = coords[i3];
24692         var b2 = coords[(i3 + 2) % coords.length];
24693         var res = geoVecCross(a2, b2, o2);
24694         curr = res > 0 ? 1 : res < 0 ? -1 : 0;
24695         if (curr === 0) {
24696           continue;
24697         } else if (prev && curr !== prev) {
24698           return false;
24699         }
24700         prev = curr;
24701       }
24702       return true;
24703     },
24704     // returns an object with the tag that implies this is an area, if any
24705     tagSuggestingArea: function() {
24706       return osmTagSuggestingArea(this.tags);
24707     },
24708     isArea: function() {
24709       if (this.tags.area === "yes") return true;
24710       if (!this.isClosed() || this.tags.area === "no") return false;
24711       return this.tagSuggestingArea() !== null;
24712     },
24713     isDegenerate: function() {
24714       return new Set(this.nodes).size < (this.isClosed() ? 3 : 2);
24715     },
24716     areAdjacent: function(n1, n22) {
24717       for (var i3 = 0; i3 < this.nodes.length; i3++) {
24718         if (this.nodes[i3] === n1) {
24719           if (this.nodes[i3 - 1] === n22) return true;
24720           if (this.nodes[i3 + 1] === n22) return true;
24721         }
24722       }
24723       return false;
24724     },
24725     geometry: function(graph) {
24726       return graph.transient(this, "geometry", function() {
24727         return this.isArea() ? "area" : "line";
24728       });
24729     },
24730     // returns an array of objects representing the segments between the nodes in this way
24731     segments: function(graph) {
24732       function segmentExtent(graph2) {
24733         var n1 = graph2.hasEntity(this.nodes[0]);
24734         var n22 = graph2.hasEntity(this.nodes[1]);
24735         return n1 && n22 && geoExtent([
24736           [
24737             Math.min(n1.loc[0], n22.loc[0]),
24738             Math.min(n1.loc[1], n22.loc[1])
24739           ],
24740           [
24741             Math.max(n1.loc[0], n22.loc[0]),
24742             Math.max(n1.loc[1], n22.loc[1])
24743           ]
24744         ]);
24745       }
24746       return graph.transient(this, "segments", function() {
24747         var segments = [];
24748         for (var i3 = 0; i3 < this.nodes.length - 1; i3++) {
24749           segments.push({
24750             id: this.id + "-" + i3,
24751             wayId: this.id,
24752             index: i3,
24753             nodes: [this.nodes[i3], this.nodes[i3 + 1]],
24754             extent: segmentExtent
24755           });
24756         }
24757         return segments;
24758       });
24759     },
24760     // If this way is not closed, append the beginning node to the end of the nodelist to close it.
24761     close: function() {
24762       if (this.isClosed() || !this.nodes.length) return this;
24763       var nodes = this.nodes.slice();
24764       nodes = nodes.filter(noRepeatNodes);
24765       nodes.push(nodes[0]);
24766       return this.update({ nodes });
24767     },
24768     // If this way is closed, remove any connector nodes from the end of the nodelist to unclose it.
24769     unclose: function() {
24770       if (!this.isClosed()) return this;
24771       var nodes = this.nodes.slice();
24772       var connector = this.first();
24773       var i3 = nodes.length - 1;
24774       while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24775         nodes.splice(i3, 1);
24776         i3 = nodes.length - 1;
24777       }
24778       nodes = nodes.filter(noRepeatNodes);
24779       return this.update({ nodes });
24780     },
24781     // Adds a node (id) in front of the node which is currently at position index.
24782     // If index is undefined, the node will be added to the end of the way for linear ways,
24783     //   or just before the final connecting node for circular ways.
24784     // Consecutive duplicates are eliminated including existing ones.
24785     // Circularity is always preserved when adding a node.
24786     addNode: function(id2, index) {
24787       var nodes = this.nodes.slice();
24788       var isClosed = this.isClosed();
24789       var max3 = isClosed ? nodes.length - 1 : nodes.length;
24790       if (index === void 0) {
24791         index = max3;
24792       }
24793       if (index < 0 || index > max3) {
24794         throw new RangeError("index " + index + " out of range 0.." + max3);
24795       }
24796       if (isClosed) {
24797         var connector = this.first();
24798         var i3 = 1;
24799         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
24800           nodes.splice(i3, 1);
24801           if (index > i3) index--;
24802         }
24803         i3 = nodes.length - 1;
24804         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24805           nodes.splice(i3, 1);
24806           if (index > i3) index--;
24807           i3 = nodes.length - 1;
24808         }
24809       }
24810       nodes.splice(index, 0, id2);
24811       nodes = nodes.filter(noRepeatNodes);
24812       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24813         nodes.push(nodes[0]);
24814       }
24815       return this.update({ nodes });
24816     },
24817     // Replaces the node which is currently at position index with the given node (id).
24818     // Consecutive duplicates are eliminated including existing ones.
24819     // Circularity is preserved when updating a node.
24820     updateNode: function(id2, index) {
24821       var nodes = this.nodes.slice();
24822       var isClosed = this.isClosed();
24823       var max3 = nodes.length - 1;
24824       if (index === void 0 || index < 0 || index > max3) {
24825         throw new RangeError("index " + index + " out of range 0.." + max3);
24826       }
24827       if (isClosed) {
24828         var connector = this.first();
24829         var i3 = 1;
24830         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
24831           nodes.splice(i3, 1);
24832           if (index > i3) index--;
24833         }
24834         i3 = nodes.length - 1;
24835         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24836           nodes.splice(i3, 1);
24837           if (index === i3) index = 0;
24838           i3 = nodes.length - 1;
24839         }
24840       }
24841       nodes.splice(index, 1, id2);
24842       nodes = nodes.filter(noRepeatNodes);
24843       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24844         nodes.push(nodes[0]);
24845       }
24846       return this.update({ nodes });
24847     },
24848     // Replaces each occurrence of node id needle with replacement.
24849     // Consecutive duplicates are eliminated including existing ones.
24850     // Circularity is preserved.
24851     replaceNode: function(needleID, replacementID) {
24852       var nodes = this.nodes.slice();
24853       var isClosed = this.isClosed();
24854       for (var i3 = 0; i3 < nodes.length; i3++) {
24855         if (nodes[i3] === needleID) {
24856           nodes[i3] = replacementID;
24857         }
24858       }
24859       nodes = nodes.filter(noRepeatNodes);
24860       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24861         nodes.push(nodes[0]);
24862       }
24863       return this.update({ nodes });
24864     },
24865     // Removes each occurrence of node id.
24866     // Consecutive duplicates are eliminated including existing ones.
24867     // Circularity is preserved.
24868     removeNode: function(id2) {
24869       var nodes = this.nodes.slice();
24870       var isClosed = this.isClosed();
24871       nodes = nodes.filter(function(node) {
24872         return node !== id2;
24873       }).filter(noRepeatNodes);
24874       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24875         nodes.push(nodes[0]);
24876       }
24877       return this.update({ nodes });
24878     },
24879     asJXON: function(changeset_id) {
24880       var r2 = {
24881         way: {
24882           "@id": this.osmId(),
24883           "@version": this.version || 0,
24884           nd: this.nodes.map(function(id2) {
24885             return { keyAttributes: { ref: osmEntity.id.toOSM(id2) } };
24886           }, this),
24887           tag: Object.keys(this.tags).map(function(k2) {
24888             return { keyAttributes: { k: k2, v: this.tags[k2] } };
24889           }, this)
24890         }
24891       };
24892       if (changeset_id) {
24893         r2.way["@changeset"] = changeset_id;
24894       }
24895       return r2;
24896     },
24897     asGeoJSON: function(resolver) {
24898       return resolver.transient(this, "GeoJSON", function() {
24899         var coordinates = resolver.childNodes(this).map(function(n3) {
24900           return n3.loc;
24901         });
24902         if (this.isArea() && this.isClosed()) {
24903           return {
24904             type: "Polygon",
24905             coordinates: [coordinates]
24906           };
24907         } else {
24908           return {
24909             type: "LineString",
24910             coordinates
24911           };
24912         }
24913       });
24914     },
24915     area: function(resolver) {
24916       return resolver.transient(this, "area", function() {
24917         var nodes = resolver.childNodes(this);
24918         var json = {
24919           type: "Polygon",
24920           coordinates: [nodes.map(function(n3) {
24921             return n3.loc;
24922           })]
24923         };
24924         if (!this.isClosed() && nodes.length) {
24925           json.coordinates[0].push(nodes[0].loc);
24926         }
24927         var area = area_default(json);
24928         if (area > 2 * Math.PI) {
24929           json.coordinates[0] = json.coordinates[0].reverse();
24930           area = area_default(json);
24931         }
24932         return isNaN(area) ? 0 : area;
24933       });
24934     }
24935   };
24936   Object.assign(osmWay.prototype, prototype);
24937   function noRepeatNodes(node, i3, arr) {
24938     return i3 === 0 || node !== arr[i3 - 1];
24939   }
24940
24941   // modules/osm/multipolygon.js
24942   function osmJoinWays(toJoin, graph) {
24943     function resolve(member) {
24944       return graph.childNodes(graph.entity(member.id));
24945     }
24946     function reverse(item2) {
24947       var action = actionReverse(item2.id, { reverseOneway: true });
24948       sequences.actions.push(action);
24949       return item2 instanceof osmWay ? action(graph).entity(item2.id) : item2;
24950     }
24951     toJoin = toJoin.filter(function(member) {
24952       return member.type === "way" && graph.hasEntity(member.id);
24953     });
24954     var i3;
24955     var joinAsMembers = true;
24956     for (i3 = 0; i3 < toJoin.length; i3++) {
24957       if (toJoin[i3] instanceof osmWay) {
24958         joinAsMembers = false;
24959         break;
24960       }
24961     }
24962     var sequences = [];
24963     sequences.actions = [];
24964     while (toJoin.length) {
24965       var item = toJoin.shift();
24966       var currWays = [item];
24967       var currNodes = resolve(item).slice();
24968       while (toJoin.length) {
24969         var start2 = currNodes[0];
24970         var end = currNodes[currNodes.length - 1];
24971         var fn = null;
24972         var nodes = null;
24973         for (i3 = 0; i3 < toJoin.length; i3++) {
24974           item = toJoin[i3];
24975           nodes = resolve(item);
24976           if (joinAsMembers && currWays.length === 1 && nodes[0] !== end && nodes[nodes.length - 1] !== end && (nodes[nodes.length - 1] === start2 || nodes[0] === start2)) {
24977             currWays[0] = reverse(currWays[0]);
24978             currNodes.reverse();
24979             start2 = currNodes[0];
24980             end = currNodes[currNodes.length - 1];
24981           }
24982           if (nodes[0] === end) {
24983             fn = currNodes.push;
24984             nodes = nodes.slice(1);
24985             break;
24986           } else if (nodes[nodes.length - 1] === end) {
24987             fn = currNodes.push;
24988             nodes = nodes.slice(0, -1).reverse();
24989             item = reverse(item);
24990             break;
24991           } else if (nodes[nodes.length - 1] === start2) {
24992             fn = currNodes.unshift;
24993             nodes = nodes.slice(0, -1);
24994             break;
24995           } else if (nodes[0] === start2) {
24996             fn = currNodes.unshift;
24997             nodes = nodes.slice(1).reverse();
24998             item = reverse(item);
24999             break;
25000           } else {
25001             fn = nodes = null;
25002           }
25003         }
25004         if (!nodes) {
25005           break;
25006         }
25007         fn.apply(currWays, [item]);
25008         fn.apply(currNodes, nodes);
25009         toJoin.splice(i3, 1);
25010       }
25011       currWays.nodes = currNodes;
25012       sequences.push(currWays);
25013     }
25014     return sequences;
25015   }
25016
25017   // modules/actions/add_member.js
25018   function actionAddMember(relationId, member, memberIndex) {
25019     return function action(graph) {
25020       var relation = graph.entity(relationId);
25021       var isPTv2 = /stop|platform/.test(member.role);
25022       if (member.type === "way" && !isPTv2) {
25023         graph = addWayMember(relation, graph);
25024       } else {
25025         if (isPTv2 && isNaN(memberIndex)) {
25026           memberIndex = 0;
25027         }
25028         graph = graph.replace(relation.addMember(member, memberIndex));
25029       }
25030       return graph;
25031     };
25032     function addWayMember(relation, graph) {
25033       var groups, item, i3, j2, k2;
25034       var PTv2members = [];
25035       var members = [];
25036       for (i3 = 0; i3 < relation.members.length; i3++) {
25037         var m2 = relation.members[i3];
25038         if (/stop|platform/.test(m2.role)) {
25039           PTv2members.push(m2);
25040         } else {
25041           members.push(m2);
25042         }
25043       }
25044       relation = relation.update({ members });
25045       groups = utilArrayGroupBy(relation.members, "type");
25046       groups.way = groups.way || [];
25047       groups.way.push(member);
25048       members = withIndex(groups.way);
25049       var joined = osmJoinWays(members, graph);
25050       for (i3 = 0; i3 < joined.length; i3++) {
25051         var segment = joined[i3];
25052         var nodes = segment.nodes.slice();
25053         var startIndex = segment[0].index;
25054         for (j2 = 0; j2 < members.length; j2++) {
25055           if (members[j2].index === startIndex) {
25056             break;
25057           }
25058         }
25059         for (k2 = 0; k2 < segment.length; k2++) {
25060           item = segment[k2];
25061           var way = graph.entity(item.id);
25062           if (k2 > 0) {
25063             if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) {
25064               moveMember(members, item.index, j2 + k2);
25065             }
25066           }
25067           nodes.splice(0, way.nodes.length - 1);
25068         }
25069       }
25070       var wayMembers = [];
25071       for (i3 = 0; i3 < members.length; i3++) {
25072         item = members[i3];
25073         if (item.index === -1) continue;
25074         wayMembers.push(utilObjectOmit(item, ["index"]));
25075       }
25076       var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []);
25077       return graph.replace(relation.update({ members: newMembers }));
25078       function moveMember(arr, findIndex, toIndex) {
25079         var i4;
25080         for (i4 = 0; i4 < arr.length; i4++) {
25081           if (arr[i4].index === findIndex) {
25082             break;
25083           }
25084         }
25085         var item2 = Object.assign({}, arr[i4]);
25086         arr[i4].index = -1;
25087         delete item2.index;
25088         arr.splice(toIndex, 0, item2);
25089       }
25090       function withIndex(arr) {
25091         var result = new Array(arr.length);
25092         for (var i4 = 0; i4 < arr.length; i4++) {
25093           result[i4] = Object.assign({}, arr[i4]);
25094           result[i4].index = i4;
25095         }
25096         return result;
25097       }
25098     }
25099   }
25100
25101   // modules/actions/add_midpoint.js
25102   function actionAddMidpoint(midpoint, node) {
25103     return function(graph) {
25104       graph = graph.replace(node.move(midpoint.loc));
25105       var parents = utilArrayIntersection(
25106         graph.parentWays(graph.entity(midpoint.edge[0])),
25107         graph.parentWays(graph.entity(midpoint.edge[1]))
25108       );
25109       parents.forEach(function(way) {
25110         for (var i3 = 0; i3 < way.nodes.length - 1; i3++) {
25111           if (geoEdgeEqual([way.nodes[i3], way.nodes[i3 + 1]], midpoint.edge)) {
25112             graph = graph.replace(graph.entity(way.id).addNode(node.id, i3 + 1));
25113             return;
25114           }
25115         }
25116       });
25117       return graph;
25118     };
25119   }
25120
25121   // modules/actions/add_vertex.js
25122   function actionAddVertex(wayId, nodeId, index) {
25123     return function(graph) {
25124       return graph.replace(graph.entity(wayId).addNode(nodeId, index));
25125     };
25126   }
25127
25128   // modules/actions/change_member.js
25129   function actionChangeMember(relationId, member, memberIndex) {
25130     return function(graph) {
25131       return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
25132     };
25133   }
25134
25135   // modules/actions/change_preset.js
25136   function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
25137     return function action(graph) {
25138       var entity = graph.entity(entityID);
25139       var geometry = entity.geometry(graph);
25140       var tags = entity.tags;
25141       const loc = entity.extent(graph).center();
25142       var preserveKeys;
25143       if (newPreset) {
25144         preserveKeys = [];
25145         if (newPreset.addTags) {
25146           preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
25147         }
25148         if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) {
25149           newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key));
25150         }
25151       }
25152       if (oldPreset) tags = oldPreset.unsetTags(tags, geometry, preserveKeys, false, loc);
25153       if (newPreset) tags = newPreset.setTags(tags, geometry, skipFieldDefaults, loc);
25154       return graph.replace(entity.update({ tags }));
25155     };
25156   }
25157
25158   // modules/actions/change_tags.js
25159   function actionChangeTags(entityId, tags) {
25160     return function(graph) {
25161       var entity = graph.entity(entityId);
25162       return graph.replace(entity.update({ tags }));
25163     };
25164   }
25165
25166   // modules/osm/node.js
25167   var cardinal = {
25168     north: 0,
25169     n: 0,
25170     northnortheast: 22,
25171     nne: 22,
25172     northeast: 45,
25173     ne: 45,
25174     eastnortheast: 67,
25175     ene: 67,
25176     east: 90,
25177     e: 90,
25178     eastsoutheast: 112,
25179     ese: 112,
25180     southeast: 135,
25181     se: 135,
25182     southsoutheast: 157,
25183     sse: 157,
25184     south: 180,
25185     s: 180,
25186     southsouthwest: 202,
25187     ssw: 202,
25188     southwest: 225,
25189     sw: 225,
25190     westsouthwest: 247,
25191     wsw: 247,
25192     west: 270,
25193     w: 270,
25194     westnorthwest: 292,
25195     wnw: 292,
25196     northwest: 315,
25197     nw: 315,
25198     northnorthwest: 337,
25199     nnw: 337
25200   };
25201   function osmNode() {
25202     if (!(this instanceof osmNode)) {
25203       return new osmNode().initialize(arguments);
25204     } else if (arguments.length) {
25205       this.initialize(arguments);
25206     }
25207   }
25208   osmEntity.node = osmNode;
25209   osmNode.prototype = Object.create(osmEntity.prototype);
25210   var prototype2 = {
25211     type: "node",
25212     loc: [9999, 9999],
25213     extent: function() {
25214       return new geoExtent(this.loc);
25215     },
25216     geometry: function(graph) {
25217       return graph.transient(this, "geometry", function() {
25218         return graph.isPoi(this) ? "point" : "vertex";
25219       });
25220     },
25221     move: function(loc) {
25222       return this.update({ loc });
25223     },
25224     isDegenerate: function() {
25225       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);
25226     },
25227     // Inspect tags and geometry to determine which direction(s) this node/vertex points
25228     directions: function(resolver, projection2) {
25229       var val;
25230       var i3;
25231       if (this.isHighwayIntersection(resolver) && (this.tags.stop || "").toLowerCase() === "all") {
25232         val = "all";
25233       } else {
25234         val = (this.tags.direction || "").toLowerCase();
25235         var re3 = /:direction$/i;
25236         var keys2 = Object.keys(this.tags);
25237         for (i3 = 0; i3 < keys2.length; i3++) {
25238           if (re3.test(keys2[i3])) {
25239             val = this.tags[keys2[i3]].toLowerCase();
25240             break;
25241           }
25242         }
25243       }
25244       if (val === "") return [];
25245       var values = val.split(";");
25246       var results = [];
25247       values.forEach(function(v2) {
25248         if (cardinal[v2] !== void 0) {
25249           v2 = cardinal[v2];
25250         }
25251         if (v2 !== "" && !isNaN(+v2)) {
25252           results.push(+v2);
25253           return;
25254         }
25255         var lookBackward = this.tags["traffic_sign:backward"] || v2 === "backward" || v2 === "both" || v2 === "all";
25256         var lookForward = this.tags["traffic_sign:forward"] || v2 === "forward" || v2 === "both" || v2 === "all";
25257         if (!lookForward && !lookBackward) return;
25258         var nodeIds = {};
25259         resolver.parentWays(this).filter((p2) => this.tags.highway || this.tags.traffic_sign || this.tags.traffic_calming || this.tags.barrier || this.tags.cycleway ? p2.tags.highway : true).filter((p2) => this.tags.railway ? p2.tags.railway : true).filter((p2) => this.tags.waterway ? p2.tags.waterway : true).forEach(function(parent) {
25260           var nodes = parent.nodes;
25261           for (i3 = 0; i3 < nodes.length; i3++) {
25262             if (nodes[i3] === this.id) {
25263               if (lookForward && i3 > 0) {
25264                 nodeIds[nodes[i3 - 1]] = true;
25265               }
25266               if (lookBackward && i3 < nodes.length - 1) {
25267                 nodeIds[nodes[i3 + 1]] = true;
25268               }
25269             }
25270           }
25271         }, this);
25272         Object.keys(nodeIds).forEach(function(nodeId) {
25273           results.push(
25274             geoAngle(this, resolver.entity(nodeId), projection2) * (180 / Math.PI) + 90
25275           );
25276         }, this);
25277       }, this);
25278       return utilArrayUniq(results);
25279     },
25280     isCrossing: function() {
25281       return this.tags.highway === "crossing" || this.tags.railway && this.tags.railway.indexOf("crossing") !== -1;
25282     },
25283     isEndpoint: function(resolver) {
25284       return resolver.transient(this, "isEndpoint", function() {
25285         var id2 = this.id;
25286         return resolver.parentWays(this).filter(function(parent) {
25287           return !parent.isClosed() && !!parent.affix(id2);
25288         }).length > 0;
25289       });
25290     },
25291     isConnected: function(resolver) {
25292       return resolver.transient(this, "isConnected", function() {
25293         var parents = resolver.parentWays(this);
25294         if (parents.length > 1) {
25295           for (var i3 in parents) {
25296             if (parents[i3].geometry(resolver) === "line" && parents[i3].hasInterestingTags()) return true;
25297           }
25298         } else if (parents.length === 1) {
25299           var way = parents[0];
25300           var nodes = way.nodes.slice();
25301           if (way.isClosed()) {
25302             nodes.pop();
25303           }
25304           return nodes.indexOf(this.id) !== nodes.lastIndexOf(this.id);
25305         }
25306         return false;
25307       });
25308     },
25309     parentIntersectionWays: function(resolver) {
25310       return resolver.transient(this, "parentIntersectionWays", function() {
25311         return resolver.parentWays(this).filter(function(parent) {
25312           return (parent.tags.highway || parent.tags.waterway || parent.tags.railway || parent.tags.aeroway) && parent.geometry(resolver) === "line";
25313         });
25314       });
25315     },
25316     isIntersection: function(resolver) {
25317       return this.parentIntersectionWays(resolver).length > 1;
25318     },
25319     isHighwayIntersection: function(resolver) {
25320       return resolver.transient(this, "isHighwayIntersection", function() {
25321         return resolver.parentWays(this).filter(function(parent) {
25322           return parent.tags.highway && parent.geometry(resolver) === "line";
25323         }).length > 1;
25324       });
25325     },
25326     isOnAddressLine: function(resolver) {
25327       return resolver.transient(this, "isOnAddressLine", function() {
25328         return resolver.parentWays(this).filter(function(parent) {
25329           return parent.tags.hasOwnProperty("addr:interpolation") && parent.geometry(resolver) === "line";
25330         }).length > 0;
25331       });
25332     },
25333     asJXON: function(changeset_id) {
25334       var r2 = {
25335         node: {
25336           "@id": this.osmId(),
25337           "@lon": this.loc[0],
25338           "@lat": this.loc[1],
25339           "@version": this.version || 0,
25340           tag: Object.keys(this.tags).map(function(k2) {
25341             return { keyAttributes: { k: k2, v: this.tags[k2] } };
25342           }, this)
25343         }
25344       };
25345       if (changeset_id) r2.node["@changeset"] = changeset_id;
25346       return r2;
25347     },
25348     asGeoJSON: function() {
25349       return {
25350         type: "Point",
25351         coordinates: this.loc
25352       };
25353     }
25354   };
25355   Object.assign(osmNode.prototype, prototype2);
25356
25357   // modules/actions/circularize.js
25358   function actionCircularize(wayId, projection2, maxAngle) {
25359     maxAngle = (maxAngle || 20) * Math.PI / 180;
25360     var action = function(graph, t2) {
25361       if (t2 === null || !isFinite(t2)) t2 = 1;
25362       t2 = Math.min(Math.max(+t2, 0), 1);
25363       var way = graph.entity(wayId);
25364       var origNodes = {};
25365       graph.childNodes(way).forEach(function(node2) {
25366         if (!origNodes[node2.id]) origNodes[node2.id] = node2;
25367       });
25368       if (!way.isConvex(graph)) {
25369         graph = action.makeConvex(graph);
25370       }
25371       var nodes = utilArrayUniq(graph.childNodes(way));
25372       var keyNodes = nodes.filter(function(n3) {
25373         return graph.parentWays(n3).length !== 1;
25374       });
25375       var points = nodes.map(function(n3) {
25376         return projection2(n3.loc);
25377       });
25378       var keyPoints = keyNodes.map(function(n3) {
25379         return projection2(n3.loc);
25380       });
25381       var centroid = points.length === 2 ? geoVecInterp(points[0], points[1], 0.5) : centroid_default2(points);
25382       var radius = median(points, function(p2) {
25383         return geoVecLength(centroid, p2);
25384       });
25385       var sign2 = area_default3(points) > 0 ? 1 : -1;
25386       var ids, i3, j2, k2;
25387       if (!keyNodes.length) {
25388         keyNodes = [nodes[0]];
25389         keyPoints = [points[0]];
25390       }
25391       if (keyNodes.length === 1) {
25392         var index = nodes.indexOf(keyNodes[0]);
25393         var oppositeIndex = Math.floor((index + nodes.length / 2) % nodes.length);
25394         keyNodes.push(nodes[oppositeIndex]);
25395         keyPoints.push(points[oppositeIndex]);
25396       }
25397       for (i3 = 0; i3 < keyPoints.length; i3++) {
25398         var nextKeyNodeIndex = (i3 + 1) % keyNodes.length;
25399         var startNode = keyNodes[i3];
25400         var endNode = keyNodes[nextKeyNodeIndex];
25401         var startNodeIndex = nodes.indexOf(startNode);
25402         var endNodeIndex = nodes.indexOf(endNode);
25403         var numberNewPoints = -1;
25404         var indexRange = endNodeIndex - startNodeIndex;
25405         var nearNodes = {};
25406         var inBetweenNodes = [];
25407         var startAngle, endAngle, totalAngle, eachAngle;
25408         var angle2, loc, node, origNode;
25409         if (indexRange < 0) {
25410           indexRange += nodes.length;
25411         }
25412         var distance = geoVecLength(centroid, keyPoints[i3]) || 1e-4;
25413         keyPoints[i3] = [
25414           centroid[0] + (keyPoints[i3][0] - centroid[0]) / distance * radius,
25415           centroid[1] + (keyPoints[i3][1] - centroid[1]) / distance * radius
25416         ];
25417         loc = projection2.invert(keyPoints[i3]);
25418         node = keyNodes[i3];
25419         origNode = origNodes[node.id];
25420         node = node.move(geoVecInterp(origNode.loc, loc, t2));
25421         graph = graph.replace(node);
25422         startAngle = Math.atan2(keyPoints[i3][1] - centroid[1], keyPoints[i3][0] - centroid[0]);
25423         endAngle = Math.atan2(keyPoints[nextKeyNodeIndex][1] - centroid[1], keyPoints[nextKeyNodeIndex][0] - centroid[0]);
25424         totalAngle = endAngle - startAngle;
25425         if (totalAngle * sign2 > 0) {
25426           totalAngle = -sign2 * (2 * Math.PI - Math.abs(totalAngle));
25427         }
25428         do {
25429           numberNewPoints++;
25430           eachAngle = totalAngle / (indexRange + numberNewPoints);
25431         } while (Math.abs(eachAngle) > maxAngle);
25432         for (j2 = 1; j2 < indexRange; j2++) {
25433           angle2 = startAngle + j2 * eachAngle;
25434           loc = projection2.invert([
25435             centroid[0] + Math.cos(angle2) * radius,
25436             centroid[1] + Math.sin(angle2) * radius
25437           ]);
25438           node = nodes[(j2 + startNodeIndex) % nodes.length];
25439           origNode = origNodes[node.id];
25440           nearNodes[node.id] = angle2;
25441           node = node.move(geoVecInterp(origNode.loc, loc, t2));
25442           graph = graph.replace(node);
25443         }
25444         for (j2 = 0; j2 < numberNewPoints; j2++) {
25445           angle2 = startAngle + (indexRange + j2) * eachAngle;
25446           loc = projection2.invert([
25447             centroid[0] + Math.cos(angle2) * radius,
25448             centroid[1] + Math.sin(angle2) * radius
25449           ]);
25450           var min3 = Infinity;
25451           for (var nodeId in nearNodes) {
25452             var nearAngle = nearNodes[nodeId];
25453             var dist = Math.abs(nearAngle - angle2);
25454             if (dist < min3) {
25455               min3 = dist;
25456               origNode = origNodes[nodeId];
25457             }
25458           }
25459           node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) });
25460           graph = graph.replace(node);
25461           nodes.splice(endNodeIndex + j2, 0, node);
25462           inBetweenNodes.push(node.id);
25463         }
25464         if (indexRange === 1 && inBetweenNodes.length) {
25465           var startIndex1 = way.nodes.lastIndexOf(startNode.id);
25466           var endIndex1 = way.nodes.lastIndexOf(endNode.id);
25467           var wayDirection1 = endIndex1 - startIndex1;
25468           if (wayDirection1 < -1) {
25469             wayDirection1 = 1;
25470           }
25471           var parentWays = graph.parentWays(keyNodes[i3]);
25472           for (j2 = 0; j2 < parentWays.length; j2++) {
25473             var sharedWay = parentWays[j2];
25474             if (sharedWay === way) continue;
25475             if (sharedWay.areAdjacent(startNode.id, endNode.id)) {
25476               var startIndex2 = sharedWay.nodes.lastIndexOf(startNode.id);
25477               var endIndex2 = sharedWay.nodes.lastIndexOf(endNode.id);
25478               var wayDirection2 = endIndex2 - startIndex2;
25479               var insertAt = endIndex2;
25480               if (wayDirection2 < -1) {
25481                 wayDirection2 = 1;
25482               }
25483               if (wayDirection1 !== wayDirection2) {
25484                 inBetweenNodes.reverse();
25485                 insertAt = startIndex2;
25486               }
25487               for (k2 = 0; k2 < inBetweenNodes.length; k2++) {
25488                 sharedWay = sharedWay.addNode(inBetweenNodes[k2], insertAt + k2);
25489               }
25490               graph = graph.replace(sharedWay);
25491             }
25492           }
25493         }
25494       }
25495       ids = nodes.map(function(n3) {
25496         return n3.id;
25497       });
25498       ids.push(ids[0]);
25499       way = way.update({ nodes: ids });
25500       graph = graph.replace(way);
25501       return graph;
25502     };
25503     action.makeConvex = function(graph) {
25504       var way = graph.entity(wayId);
25505       var nodes = utilArrayUniq(graph.childNodes(way));
25506       var points = nodes.map(function(n3) {
25507         return projection2(n3.loc);
25508       });
25509       var sign2 = area_default3(points) > 0 ? 1 : -1;
25510       var hull = hull_default(points);
25511       var i3, j2;
25512       if (sign2 === -1) {
25513         nodes.reverse();
25514         points.reverse();
25515       }
25516       for (i3 = 0; i3 < hull.length - 1; i3++) {
25517         var startIndex = points.indexOf(hull[i3]);
25518         var endIndex = points.indexOf(hull[i3 + 1]);
25519         var indexRange = endIndex - startIndex;
25520         if (indexRange < 0) {
25521           indexRange += nodes.length;
25522         }
25523         for (j2 = 1; j2 < indexRange; j2++) {
25524           var point = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange);
25525           var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point));
25526           graph = graph.replace(node);
25527         }
25528       }
25529       return graph;
25530     };
25531     action.disabled = function(graph) {
25532       if (!graph.entity(wayId).isClosed()) {
25533         return "not_closed";
25534       }
25535       var way = graph.entity(wayId);
25536       var nodes = utilArrayUniq(graph.childNodes(way));
25537       var points = nodes.map(function(n3) {
25538         return projection2(n3.loc);
25539       });
25540       var hull = hull_default(points);
25541       var epsilonAngle = Math.PI / 180;
25542       if (hull.length !== points.length || hull.length < 3) {
25543         return false;
25544       }
25545       var centroid = centroid_default2(points);
25546       var radius = geoVecLengthSquare(centroid, points[0]);
25547       var i3, actualPoint;
25548       for (i3 = 0; i3 < hull.length; i3++) {
25549         actualPoint = hull[i3];
25550         var actualDist = geoVecLengthSquare(actualPoint, centroid);
25551         var diff = Math.abs(actualDist - radius);
25552         if (diff > 0.05 * radius) {
25553           return false;
25554         }
25555       }
25556       for (i3 = 0; i3 < hull.length; i3++) {
25557         actualPoint = hull[i3];
25558         var nextPoint = hull[(i3 + 1) % hull.length];
25559         var startAngle = Math.atan2(actualPoint[1] - centroid[1], actualPoint[0] - centroid[0]);
25560         var endAngle = Math.atan2(nextPoint[1] - centroid[1], nextPoint[0] - centroid[0]);
25561         var angle2 = endAngle - startAngle;
25562         if (angle2 < 0) {
25563           angle2 = -angle2;
25564         }
25565         if (angle2 > Math.PI) {
25566           angle2 = 2 * Math.PI - angle2;
25567         }
25568         if (angle2 > maxAngle + epsilonAngle) {
25569           return false;
25570         }
25571       }
25572       return "already_circular";
25573     };
25574     action.transitionable = true;
25575     return action;
25576   }
25577
25578   // modules/actions/delete_way.js
25579   function actionDeleteWay(wayID) {
25580     function canDeleteNode(node, graph) {
25581       if (graph.parentWays(node).length || graph.parentRelations(node).length) return false;
25582       var geometries = osmNodeGeometriesForTags(node.tags);
25583       if (geometries.point) return false;
25584       if (geometries.vertex) return true;
25585       return !node.hasInterestingTags();
25586     }
25587     var action = function(graph) {
25588       var way = graph.entity(wayID);
25589       graph.parentRelations(way).forEach(function(parent) {
25590         parent = parent.removeMembersWithID(wayID);
25591         graph = graph.replace(parent);
25592         if (parent.isDegenerate()) {
25593           graph = actionDeleteRelation(parent.id)(graph);
25594         }
25595       });
25596       new Set(way.nodes).forEach(function(nodeID) {
25597         graph = graph.replace(way.removeNode(nodeID));
25598         var node = graph.entity(nodeID);
25599         if (canDeleteNode(node, graph)) {
25600           graph = graph.remove(node);
25601         }
25602       });
25603       return graph.remove(way);
25604     };
25605     return action;
25606   }
25607
25608   // modules/actions/delete_multiple.js
25609   function actionDeleteMultiple(ids) {
25610     var actions = {
25611       way: actionDeleteWay,
25612       node: actionDeleteNode,
25613       relation: actionDeleteRelation
25614     };
25615     var action = function(graph) {
25616       ids.forEach(function(id2) {
25617         if (graph.hasEntity(id2)) {
25618           graph = actions[graph.entity(id2).type](id2)(graph);
25619         }
25620       });
25621       return graph;
25622     };
25623     return action;
25624   }
25625
25626   // modules/actions/delete_relation.js
25627   function actionDeleteRelation(relationID, allowUntaggedMembers) {
25628     function canDeleteEntity(entity, graph) {
25629       return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && (!entity.hasInterestingTags() && !allowUntaggedMembers);
25630     }
25631     var action = function(graph) {
25632       var relation = graph.entity(relationID);
25633       graph.parentRelations(relation).forEach(function(parent) {
25634         parent = parent.removeMembersWithID(relationID);
25635         graph = graph.replace(parent);
25636         if (parent.isDegenerate()) {
25637           graph = actionDeleteRelation(parent.id)(graph);
25638         }
25639       });
25640       var memberIDs = utilArrayUniq(relation.members.map(function(m2) {
25641         return m2.id;
25642       }));
25643       memberIDs.forEach(function(memberID) {
25644         graph = graph.replace(relation.removeMembersWithID(memberID));
25645         var entity = graph.entity(memberID);
25646         if (canDeleteEntity(entity, graph)) {
25647           graph = actionDeleteMultiple([memberID])(graph);
25648         }
25649       });
25650       return graph.remove(relation);
25651     };
25652     return action;
25653   }
25654
25655   // modules/actions/delete_node.js
25656   function actionDeleteNode(nodeId) {
25657     var action = function(graph) {
25658       var node = graph.entity(nodeId);
25659       graph.parentWays(node).forEach(function(parent) {
25660         parent = parent.removeNode(nodeId);
25661         graph = graph.replace(parent);
25662         if (parent.isDegenerate()) {
25663           graph = actionDeleteWay(parent.id)(graph);
25664         }
25665       });
25666       graph.parentRelations(node).forEach(function(parent) {
25667         parent = parent.removeMembersWithID(nodeId);
25668         graph = graph.replace(parent);
25669         if (parent.isDegenerate()) {
25670           graph = actionDeleteRelation(parent.id)(graph);
25671         }
25672       });
25673       return graph.remove(node);
25674     };
25675     return action;
25676   }
25677
25678   // modules/actions/connect.js
25679   function actionConnect(nodeIDs) {
25680     var action = function(graph) {
25681       var survivor;
25682       var node;
25683       var parents;
25684       var i3, j2;
25685       nodeIDs.reverse();
25686       var interestingIDs = [];
25687       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25688         node = graph.entity(nodeIDs[i3]);
25689         if (node.hasInterestingTags()) {
25690           if (!node.isNew()) {
25691             interestingIDs.push(node.id);
25692           }
25693         }
25694       }
25695       survivor = graph.entity(utilOldestID(interestingIDs.length > 0 ? interestingIDs : nodeIDs));
25696       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25697         node = graph.entity(nodeIDs[i3]);
25698         if (node.id === survivor.id) continue;
25699         parents = graph.parentWays(node);
25700         for (j2 = 0; j2 < parents.length; j2++) {
25701           graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id));
25702         }
25703         parents = graph.parentRelations(node);
25704         for (j2 = 0; j2 < parents.length; j2++) {
25705           graph = graph.replace(parents[j2].replaceMember(node, survivor));
25706         }
25707         survivor = survivor.mergeTags(node.tags);
25708         graph = actionDeleteNode(node.id)(graph);
25709       }
25710       graph = graph.replace(survivor);
25711       parents = graph.parentWays(survivor);
25712       for (i3 = 0; i3 < parents.length; i3++) {
25713         if (parents[i3].isDegenerate()) {
25714           graph = actionDeleteWay(parents[i3].id)(graph);
25715         }
25716       }
25717       return graph;
25718     };
25719     action.disabled = function(graph) {
25720       var seen = {};
25721       var restrictionIDs = [];
25722       var survivor;
25723       var node, way;
25724       var relations, relation, role;
25725       var i3, j2, k2;
25726       survivor = graph.entity(utilOldestID(nodeIDs));
25727       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25728         node = graph.entity(nodeIDs[i3]);
25729         relations = graph.parentRelations(node);
25730         for (j2 = 0; j2 < relations.length; j2++) {
25731           relation = relations[j2];
25732           role = relation.memberById(node.id).role || "";
25733           if (relation.hasFromViaTo()) {
25734             restrictionIDs.push(relation.id);
25735           }
25736           if (seen[relation.id] !== void 0 && seen[relation.id] !== role) {
25737             return "relation";
25738           } else {
25739             seen[relation.id] = role;
25740           }
25741         }
25742       }
25743       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25744         node = graph.entity(nodeIDs[i3]);
25745         var parents = graph.parentWays(node);
25746         for (j2 = 0; j2 < parents.length; j2++) {
25747           var parent = parents[j2];
25748           relations = graph.parentRelations(parent);
25749           for (k2 = 0; k2 < relations.length; k2++) {
25750             relation = relations[k2];
25751             if (relation.hasFromViaTo()) {
25752               restrictionIDs.push(relation.id);
25753             }
25754           }
25755         }
25756       }
25757       restrictionIDs = utilArrayUniq(restrictionIDs);
25758       for (i3 = 0; i3 < restrictionIDs.length; i3++) {
25759         relation = graph.entity(restrictionIDs[i3]);
25760         if (!relation.isComplete(graph)) continue;
25761         var memberWays = relation.members.filter(function(m2) {
25762           return m2.type === "way";
25763         }).map(function(m2) {
25764           return graph.entity(m2.id);
25765         });
25766         memberWays = utilArrayUniq(memberWays);
25767         var f2 = relation.memberByRole("from");
25768         var t2 = relation.memberByRole("to");
25769         var isUturn = f2.id === t2.id;
25770         var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] };
25771         for (j2 = 0; j2 < relation.members.length; j2++) {
25772           collectNodes(relation.members[j2], nodes);
25773         }
25774         nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates));
25775         nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates));
25776         var filter2 = keyNodeFilter(nodes.keyfrom, nodes.keyto);
25777         nodes.from = nodes.from.filter(filter2);
25778         nodes.via = nodes.via.filter(filter2);
25779         nodes.to = nodes.to.filter(filter2);
25780         var connectFrom = false;
25781         var connectVia = false;
25782         var connectTo = false;
25783         var connectKeyFrom = false;
25784         var connectKeyTo = false;
25785         for (j2 = 0; j2 < nodeIDs.length; j2++) {
25786           var n3 = nodeIDs[j2];
25787           if (nodes.from.indexOf(n3) !== -1) {
25788             connectFrom = true;
25789           }
25790           if (nodes.via.indexOf(n3) !== -1) {
25791             connectVia = true;
25792           }
25793           if (nodes.to.indexOf(n3) !== -1) {
25794             connectTo = true;
25795           }
25796           if (nodes.keyfrom.indexOf(n3) !== -1) {
25797             connectKeyFrom = true;
25798           }
25799           if (nodes.keyto.indexOf(n3) !== -1) {
25800             connectKeyTo = true;
25801           }
25802         }
25803         if (connectFrom && connectTo && !isUturn) {
25804           return "restriction";
25805         }
25806         if (connectFrom && connectVia) {
25807           return "restriction";
25808         }
25809         if (connectTo && connectVia) {
25810           return "restriction";
25811         }
25812         if (connectKeyFrom || connectKeyTo) {
25813           if (nodeIDs.length !== 2) {
25814             return "restriction";
25815           }
25816           var n0 = null;
25817           var n1 = null;
25818           for (j2 = 0; j2 < memberWays.length; j2++) {
25819             way = memberWays[j2];
25820             if (way.contains(nodeIDs[0])) {
25821               n0 = nodeIDs[0];
25822             }
25823             if (way.contains(nodeIDs[1])) {
25824               n1 = nodeIDs[1];
25825             }
25826           }
25827           if (n0 && n1) {
25828             var ok = false;
25829             for (j2 = 0; j2 < memberWays.length; j2++) {
25830               way = memberWays[j2];
25831               if (way.areAdjacent(n0, n1)) {
25832                 ok = true;
25833                 break;
25834               }
25835             }
25836             if (!ok) {
25837               return "restriction";
25838             }
25839           }
25840         }
25841         for (j2 = 0; j2 < memberWays.length; j2++) {
25842           way = memberWays[j2].update({});
25843           for (k2 = 0; k2 < nodeIDs.length; k2++) {
25844             if (nodeIDs[k2] === survivor.id) continue;
25845             if (way.areAdjacent(nodeIDs[k2], survivor.id)) {
25846               way = way.removeNode(nodeIDs[k2]);
25847             } else {
25848               way = way.replaceNode(nodeIDs[k2], survivor.id);
25849             }
25850           }
25851           if (way.isDegenerate()) {
25852             return "restriction";
25853           }
25854         }
25855       }
25856       return false;
25857       function hasDuplicates(n4, i4, arr) {
25858         return arr.indexOf(n4) !== arr.lastIndexOf(n4);
25859       }
25860       function keyNodeFilter(froms, tos) {
25861         return function(n4) {
25862           return froms.indexOf(n4) === -1 && tos.indexOf(n4) === -1;
25863         };
25864       }
25865       function collectNodes(member, collection) {
25866         var entity = graph.hasEntity(member.id);
25867         if (!entity) return;
25868         var role2 = member.role || "";
25869         if (!collection[role2]) {
25870           collection[role2] = [];
25871         }
25872         if (member.type === "node") {
25873           collection[role2].push(member.id);
25874           if (role2 === "via") {
25875             collection.keyfrom.push(member.id);
25876             collection.keyto.push(member.id);
25877           }
25878         } else if (member.type === "way") {
25879           collection[role2].push.apply(collection[role2], entity.nodes);
25880           if (role2 === "from" || role2 === "via") {
25881             collection.keyfrom.push(entity.first());
25882             collection.keyfrom.push(entity.last());
25883           }
25884           if (role2 === "to" || role2 === "via") {
25885             collection.keyto.push(entity.first());
25886             collection.keyto.push(entity.last());
25887           }
25888         }
25889       }
25890     };
25891     return action;
25892   }
25893
25894   // modules/actions/copy_entities.js
25895   function actionCopyEntities(ids, fromGraph) {
25896     var _copies = {};
25897     var action = function(graph) {
25898       ids.forEach(function(id3) {
25899         fromGraph.entity(id3).copy(fromGraph, _copies);
25900       });
25901       for (var id2 in _copies) {
25902         graph = graph.replace(_copies[id2]);
25903       }
25904       return graph;
25905     };
25906     action.copies = function() {
25907       return _copies;
25908     };
25909     return action;
25910   }
25911
25912   // modules/actions/delete_member.js
25913   function actionDeleteMember(relationId, memberIndex) {
25914     return function(graph) {
25915       var relation = graph.entity(relationId).removeMember(memberIndex);
25916       graph = graph.replace(relation);
25917       if (relation.isDegenerate()) {
25918         graph = actionDeleteRelation(relation.id)(graph);
25919       }
25920       return graph;
25921     };
25922   }
25923
25924   // modules/actions/discard_tags.js
25925   function actionDiscardTags(difference2, discardTags) {
25926     discardTags = discardTags || {};
25927     return (graph) => {
25928       difference2.modified().forEach(checkTags);
25929       difference2.created().forEach(checkTags);
25930       return graph;
25931       function checkTags(entity) {
25932         const keys2 = Object.keys(entity.tags);
25933         let didDiscard = false;
25934         let tags = {};
25935         for (let i3 = 0; i3 < keys2.length; i3++) {
25936           const k2 = keys2[i3];
25937           if (discardTags[k2] || !entity.tags[k2]) {
25938             didDiscard = true;
25939           } else {
25940             tags[k2] = entity.tags[k2];
25941           }
25942         }
25943         if (didDiscard) {
25944           graph = graph.replace(entity.update({ tags }));
25945         }
25946       }
25947     };
25948   }
25949
25950   // modules/actions/disconnect.js
25951   function actionDisconnect(nodeId, newNodeId) {
25952     var wayIds;
25953     var disconnectableRelationTypes = {
25954       "associatedStreet": true,
25955       "enforcement": true,
25956       "site": true
25957     };
25958     var action = function(graph) {
25959       var node = graph.entity(nodeId);
25960       var connections = action.connections(graph);
25961       connections.forEach(function(connection) {
25962         var way = graph.entity(connection.wayID);
25963         var newNode = osmNode({ id: newNodeId, loc: node.loc, tags: node.tags });
25964         graph = graph.replace(newNode);
25965         if (connection.index === 0 && way.isArea()) {
25966           graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
25967         } else if (way.isClosed() && connection.index === way.nodes.length - 1) {
25968           graph = graph.replace(way.unclose().addNode(newNode.id));
25969         } else {
25970           graph = graph.replace(way.updateNode(newNode.id, connection.index));
25971         }
25972       });
25973       return graph;
25974     };
25975     action.connections = function(graph) {
25976       var candidates = [];
25977       var keeping = false;
25978       var parentWays = graph.parentWays(graph.entity(nodeId));
25979       var way, waynode;
25980       for (var i3 = 0; i3 < parentWays.length; i3++) {
25981         way = parentWays[i3];
25982         if (wayIds && wayIds.indexOf(way.id) === -1) {
25983           keeping = true;
25984           continue;
25985         }
25986         if (way.isArea() && way.nodes[0] === nodeId) {
25987           candidates.push({ wayID: way.id, index: 0 });
25988         } else {
25989           for (var j2 = 0; j2 < way.nodes.length; j2++) {
25990             waynode = way.nodes[j2];
25991             if (waynode === nodeId) {
25992               if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) {
25993                 continue;
25994               }
25995               candidates.push({ wayID: way.id, index: j2 });
25996             }
25997           }
25998         }
25999       }
26000       return keeping ? candidates : candidates.slice(1);
26001     };
26002     action.disabled = function(graph) {
26003       var connections = action.connections(graph);
26004       if (connections.length === 0) return "not_connected";
26005       var parentWays = graph.parentWays(graph.entity(nodeId));
26006       var seenRelationIds = {};
26007       var sharedRelation;
26008       parentWays.forEach(function(way) {
26009         var relations = graph.parentRelations(way);
26010         relations.filter((relation) => !disconnectableRelationTypes[relation.tags.type]).forEach(function(relation) {
26011           if (relation.id in seenRelationIds) {
26012             if (wayIds) {
26013               if (wayIds.indexOf(way.id) !== -1 || wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
26014                 sharedRelation = relation;
26015               }
26016             } else {
26017               sharedRelation = relation;
26018             }
26019           } else {
26020             seenRelationIds[relation.id] = way.id;
26021           }
26022         });
26023       });
26024       if (sharedRelation) return "relation";
26025     };
26026     action.limitWays = function(val) {
26027       if (!arguments.length) return wayIds;
26028       wayIds = val;
26029       return action;
26030     };
26031     return action;
26032   }
26033
26034   // modules/actions/extract.js
26035   function actionExtract(entityID, projection2) {
26036     var extractedNodeID;
26037     var action = function(graph, shiftKeyPressed) {
26038       var entity = graph.entity(entityID);
26039       if (entity.type === "node") {
26040         return extractFromNode(entity, graph, shiftKeyPressed);
26041       }
26042       return extractFromWayOrRelation(entity, graph);
26043     };
26044     function extractFromNode(node, graph, shiftKeyPressed) {
26045       extractedNodeID = node.id;
26046       var replacement = osmNode({ loc: node.loc });
26047       graph = graph.replace(replacement);
26048       graph = graph.parentWays(node).reduce(function(accGraph, parentWay) {
26049         return accGraph.replace(parentWay.replaceNode(entityID, replacement.id));
26050       }, graph);
26051       if (!shiftKeyPressed) return graph;
26052       return graph.parentRelations(node).reduce(function(accGraph, parentRel) {
26053         return accGraph.replace(parentRel.replaceMember(node, replacement));
26054       }, graph);
26055     }
26056     function extractFromWayOrRelation(entity, graph) {
26057       var fromGeometry = entity.geometry(graph);
26058       var keysToCopyAndRetain = ["source", "wheelchair"];
26059       var keysToRetain = ["area"];
26060       var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"];
26061       var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph));
26062       extractedLoc = extractedLoc && projection2.invert(extractedLoc);
26063       if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
26064         extractedLoc = entity.extent(graph).center();
26065       }
26066       var indoorAreaValues = {
26067         area: true,
26068         corridor: true,
26069         elevator: true,
26070         level: true,
26071         room: true
26072       };
26073       var isBuilding = entity.tags.building && entity.tags.building !== "no" || entity.tags["building:part"] && entity.tags["building:part"] !== "no";
26074       var isIndoorArea = fromGeometry === "area" && entity.tags.indoor && indoorAreaValues[entity.tags.indoor];
26075       var entityTags = Object.assign({}, entity.tags);
26076       var pointTags = {};
26077       for (var key in entityTags) {
26078         if (entity.type === "relation" && key === "type") {
26079           continue;
26080         }
26081         if (keysToRetain.indexOf(key) !== -1) {
26082           continue;
26083         }
26084         if (isBuilding) {
26085           if (buildingKeysToRetain.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/)) continue;
26086         }
26087         if (isIndoorArea && key === "indoor") {
26088           continue;
26089         }
26090         pointTags[key] = entityTags[key];
26091         if (keysToCopyAndRetain.indexOf(key) !== -1 || key.match(/^addr:.{1,}/)) {
26092           continue;
26093         } else if (isIndoorArea && key === "level") {
26094           continue;
26095         }
26096         delete entityTags[key];
26097       }
26098       if (!isBuilding && !isIndoorArea && fromGeometry === "area") {
26099         entityTags.area = "yes";
26100       }
26101       var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
26102       graph = graph.replace(replacement);
26103       extractedNodeID = replacement.id;
26104       return graph.replace(entity.update({ tags: entityTags }));
26105     }
26106     action.getExtractedNodeID = function() {
26107       return extractedNodeID;
26108     };
26109     return action;
26110   }
26111
26112   // modules/actions/join.js
26113   function actionJoin(ids) {
26114     function groupEntitiesByGeometry(graph) {
26115       var entities = ids.map(function(id2) {
26116         return graph.entity(id2);
26117       });
26118       return Object.assign(
26119         { line: [] },
26120         utilArrayGroupBy(entities, function(entity) {
26121           return entity.geometry(graph);
26122         })
26123       );
26124     }
26125     var action = function(graph) {
26126       var ways = ids.map(graph.entity, graph);
26127       var survivorID = utilOldestID(ways.map((way) => way.id));
26128       ways.sort(function(a2, b2) {
26129         var aSided = a2.isSided();
26130         var bSided = b2.isSided();
26131         return aSided && !bSided ? -1 : bSided && !aSided ? 1 : 0;
26132       });
26133       var sequences = osmJoinWays(ways, graph);
26134       var joined = sequences[0];
26135       graph = sequences.actions.reduce(function(g3, action2) {
26136         return action2(g3);
26137       }, graph);
26138       var survivor = graph.entity(survivorID);
26139       survivor = survivor.update({ nodes: joined.nodes.map(function(n3) {
26140         return n3.id;
26141       }) });
26142       graph = graph.replace(survivor);
26143       joined.forEach(function(way) {
26144         if (way.id === survivorID) return;
26145         graph.parentRelations(way).forEach(function(parent) {
26146           graph = graph.replace(parent.replaceMember(way, survivor));
26147         });
26148         survivor = survivor.mergeTags(way.tags);
26149         graph = graph.replace(survivor);
26150         graph = actionDeleteWay(way.id)(graph);
26151       });
26152       function checkForSimpleMultipolygon() {
26153         if (!survivor.isClosed()) return;
26154         var multipolygons = graph.parentMultipolygons(survivor).filter(function(multipolygon2) {
26155           return multipolygon2.members.length === 1;
26156         });
26157         if (multipolygons.length !== 1) return;
26158         var multipolygon = multipolygons[0];
26159         for (var key in survivor.tags) {
26160           if (multipolygon.tags[key] && // don't collapse if tags cannot be cleanly merged
26161           multipolygon.tags[key] !== survivor.tags[key]) return;
26162         }
26163         survivor = survivor.mergeTags(multipolygon.tags);
26164         graph = graph.replace(survivor);
26165         graph = actionDeleteRelation(
26166           multipolygon.id,
26167           true
26168           /* allow untagged members */
26169         )(graph);
26170         var tags = Object.assign({}, survivor.tags);
26171         if (survivor.geometry(graph) !== "area") {
26172           tags.area = "yes";
26173         }
26174         delete tags.type;
26175         survivor = survivor.update({ tags });
26176         graph = graph.replace(survivor);
26177       }
26178       checkForSimpleMultipolygon();
26179       return graph;
26180     };
26181     action.resultingWayNodesLength = function(graph) {
26182       return ids.reduce(function(count, id2) {
26183         return count + graph.entity(id2).nodes.length;
26184       }, 0) - ids.length - 1;
26185     };
26186     action.disabled = function(graph) {
26187       var geometries = groupEntitiesByGeometry(graph);
26188       if (ids.length < 2 || ids.length !== geometries.line.length) {
26189         return "not_eligible";
26190       }
26191       var joined = osmJoinWays(ids.map(graph.entity, graph), graph);
26192       if (joined.length > 1) {
26193         return "not_adjacent";
26194       }
26195       var i3;
26196       var sortedParentRelations = function(id2) {
26197         return graph.parentRelations(graph.entity(id2)).filter((rel) => !rel.isRestriction() && !rel.isConnectivity()).sort((a2, b2) => a2.id.localeCompare(b2.id));
26198       };
26199       var relsA = sortedParentRelations(ids[0]);
26200       for (i3 = 1; i3 < ids.length; i3++) {
26201         var relsB = sortedParentRelations(ids[i3]);
26202         if (!utilArrayIdentical(relsA, relsB)) {
26203           return "conflicting_relations";
26204         }
26205       }
26206       for (i3 = 0; i3 < ids.length - 1; i3++) {
26207         for (var j2 = i3 + 1; j2 < ids.length; j2++) {
26208           var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) {
26209             return e3.loc;
26210           });
26211           var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) {
26212             return e3.loc;
26213           });
26214           var intersections = geoPathIntersections(path1, path2);
26215           var common = utilArrayIntersection(
26216             joined[0].nodes.map(function(n3) {
26217               return n3.loc.toString();
26218             }),
26219             intersections.map(function(n3) {
26220               return n3.toString();
26221             })
26222           );
26223           if (common.length !== intersections.length) {
26224             return "paths_intersect";
26225           }
26226         }
26227       }
26228       var nodeIds = joined[0].nodes.map(function(n3) {
26229         return n3.id;
26230       }).slice(1, -1);
26231       var relation;
26232       var tags = {};
26233       var conflicting = false;
26234       joined[0].forEach(function(way) {
26235         var parents = graph.parentRelations(way);
26236         parents.forEach(function(parent) {
26237           if ((parent.isRestriction() || parent.isConnectivity()) && parent.members.some(function(m2) {
26238             return nodeIds.indexOf(m2.id) >= 0;
26239           })) {
26240             relation = parent;
26241           }
26242         });
26243         for (var k2 in way.tags) {
26244           if (!(k2 in tags)) {
26245             tags[k2] = way.tags[k2];
26246           } else if (tags[k2] && osmIsInterestingTag(k2) && tags[k2] !== way.tags[k2]) {
26247             conflicting = true;
26248           }
26249         }
26250       });
26251       if (relation) {
26252         return relation.isRestriction() ? "restriction" : "connectivity";
26253       }
26254       if (conflicting) {
26255         return "conflicting_tags";
26256       }
26257     };
26258     return action;
26259   }
26260
26261   // modules/actions/merge.js
26262   function actionMerge(ids) {
26263     function groupEntitiesByGeometry(graph) {
26264       var entities = ids.map(function(id2) {
26265         return graph.entity(id2);
26266       });
26267       return Object.assign(
26268         { point: [], area: [], line: [], relation: [] },
26269         utilArrayGroupBy(entities, function(entity) {
26270           return entity.geometry(graph);
26271         })
26272       );
26273     }
26274     var action = function(graph) {
26275       var geometries = groupEntitiesByGeometry(graph);
26276       var target = geometries.area[0] || geometries.line[0];
26277       var points = geometries.point;
26278       points.forEach(function(point) {
26279         target = target.mergeTags(point.tags);
26280         graph = graph.replace(target);
26281         graph.parentRelations(point).forEach(function(parent) {
26282           graph = graph.replace(parent.replaceMember(point, target));
26283         });
26284         var nodes = utilArrayUniq(graph.childNodes(target));
26285         var removeNode = point;
26286         if (!point.isNew()) {
26287           var inserted = false;
26288           var canBeReplaced = function(node2) {
26289             return !(graph.parentWays(node2).length > 1 || graph.parentRelations(node2).length);
26290           };
26291           var replaceNode = function(node2) {
26292             graph = graph.replace(point.update({ tags: node2.tags, loc: node2.loc }));
26293             target = target.replaceNode(node2.id, point.id);
26294             graph = graph.replace(target);
26295             removeNode = node2;
26296             inserted = true;
26297           };
26298           var i3;
26299           var node;
26300           for (i3 = 0; i3 < nodes.length; i3++) {
26301             node = nodes[i3];
26302             if (canBeReplaced(node) && node.isNew()) {
26303               replaceNode(node);
26304               break;
26305             }
26306           }
26307           if (!inserted && point.hasInterestingTags()) {
26308             for (i3 = 0; i3 < nodes.length; i3++) {
26309               node = nodes[i3];
26310               if (canBeReplaced(node) && !node.hasInterestingTags()) {
26311                 replaceNode(node);
26312                 break;
26313               }
26314             }
26315             if (!inserted) {
26316               for (i3 = 0; i3 < nodes.length; i3++) {
26317                 node = nodes[i3];
26318                 if (canBeReplaced(node) && utilCompareIDs(point.id, node.id) < 0) {
26319                   replaceNode(node);
26320                   break;
26321                 }
26322               }
26323             }
26324           }
26325         }
26326         graph = graph.remove(removeNode);
26327       });
26328       if (target.tags.area === "yes") {
26329         var tags = Object.assign({}, target.tags);
26330         delete tags.area;
26331         if (osmTagSuggestingArea(tags)) {
26332           target = target.update({ tags });
26333           graph = graph.replace(target);
26334         }
26335       }
26336       return graph;
26337     };
26338     action.disabled = function(graph) {
26339       var geometries = groupEntitiesByGeometry(graph);
26340       if (geometries.point.length === 0 || geometries.area.length + geometries.line.length !== 1 || geometries.relation.length !== 0) {
26341         return "not_eligible";
26342       }
26343     };
26344     return action;
26345   }
26346
26347   // modules/actions/merge_nodes.js
26348   function actionMergeNodes(nodeIDs, loc) {
26349     function chooseLoc(graph) {
26350       if (!nodeIDs.length) return null;
26351       var sum = [0, 0];
26352       var interestingCount = 0;
26353       var interestingLoc;
26354       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
26355         var node = graph.entity(nodeIDs[i3]);
26356         if (node.hasInterestingTags()) {
26357           interestingLoc = ++interestingCount === 1 ? node.loc : null;
26358         }
26359         sum = geoVecAdd(sum, node.loc);
26360       }
26361       return interestingLoc || geoVecScale(sum, 1 / nodeIDs.length);
26362     }
26363     var action = function(graph) {
26364       if (nodeIDs.length < 2) return graph;
26365       var toLoc = loc;
26366       if (!toLoc) {
26367         toLoc = chooseLoc(graph);
26368       }
26369       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
26370         var node = graph.entity(nodeIDs[i3]);
26371         if (node.loc !== toLoc) {
26372           graph = graph.replace(node.move(toLoc));
26373         }
26374       }
26375       return actionConnect(nodeIDs)(graph);
26376     };
26377     action.disabled = function(graph) {
26378       if (nodeIDs.length < 2) return "not_eligible";
26379       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
26380         var entity = graph.entity(nodeIDs[i3]);
26381         if (entity.type !== "node") return "not_eligible";
26382       }
26383       return actionConnect(nodeIDs).disabled(graph);
26384     };
26385     return action;
26386   }
26387
26388   // modules/osm/changeset.js
26389   function osmChangeset() {
26390     if (!(this instanceof osmChangeset)) {
26391       return new osmChangeset().initialize(arguments);
26392     } else if (arguments.length) {
26393       this.initialize(arguments);
26394     }
26395   }
26396   osmEntity.changeset = osmChangeset;
26397   osmChangeset.prototype = Object.create(osmEntity.prototype);
26398   Object.assign(osmChangeset.prototype, {
26399     type: "changeset",
26400     extent: function() {
26401       return new geoExtent();
26402     },
26403     geometry: function() {
26404       return "changeset";
26405     },
26406     asJXON: function() {
26407       return {
26408         osm: {
26409           changeset: {
26410             tag: Object.keys(this.tags).map(function(k2) {
26411               return { "@k": k2, "@v": this.tags[k2] };
26412             }, this),
26413             "@version": 0.6,
26414             "@generator": "iD"
26415           }
26416         }
26417       };
26418     },
26419     // Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
26420     // XML. Returns a string.
26421     osmChangeJXON: function(changes) {
26422       var changeset_id = this.id;
26423       function nest(x2, order) {
26424         var groups = {};
26425         for (var i3 = 0; i3 < x2.length; i3++) {
26426           var tagName = Object.keys(x2[i3])[0];
26427           if (!groups[tagName]) groups[tagName] = [];
26428           groups[tagName].push(x2[i3][tagName]);
26429         }
26430         var ordered = {};
26431         order.forEach(function(o2) {
26432           if (groups[o2]) ordered[o2] = groups[o2];
26433         });
26434         return ordered;
26435       }
26436       function sort(changes2) {
26437         function resolve(item) {
26438           return relations.find(function(relation2) {
26439             return item.keyAttributes.type === "relation" && item.keyAttributes.ref === relation2["@id"];
26440           });
26441         }
26442         function isNew(item) {
26443           return !sorted[item["@id"]] && !processing.find(function(proc) {
26444             return proc["@id"] === item["@id"];
26445           });
26446         }
26447         var processing = [];
26448         var sorted = {};
26449         var relations = changes2.relation;
26450         if (!relations) return changes2;
26451         for (var i3 = 0; i3 < relations.length; i3++) {
26452           var relation = relations[i3];
26453           if (!sorted[relation["@id"]]) {
26454             processing.push(relation);
26455           }
26456           while (processing.length > 0) {
26457             var next = processing[0], deps = next.member.map(resolve).filter(Boolean).filter(isNew);
26458             if (deps.length === 0) {
26459               sorted[next["@id"]] = next;
26460               processing.shift();
26461             } else {
26462               processing = deps.concat(processing);
26463             }
26464           }
26465         }
26466         changes2.relation = Object.values(sorted);
26467         return changes2;
26468       }
26469       function rep(entity) {
26470         return entity.asJXON(changeset_id);
26471       }
26472       return {
26473         osmChange: {
26474           "@version": 0.6,
26475           "@generator": "iD",
26476           "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])),
26477           "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]),
26478           "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true })
26479         }
26480       };
26481     },
26482     asGeoJSON: function() {
26483       return {};
26484     }
26485   });
26486
26487   // modules/osm/note.js
26488   function osmNote() {
26489     if (!(this instanceof osmNote)) {
26490       return new osmNote().initialize(arguments);
26491     } else if (arguments.length) {
26492       this.initialize(arguments);
26493     }
26494   }
26495   osmNote.id = function() {
26496     return osmNote.id.next--;
26497   };
26498   osmNote.id.next = -1;
26499   Object.assign(osmNote.prototype, {
26500     type: "note",
26501     initialize: function(sources) {
26502       for (var i3 = 0; i3 < sources.length; ++i3) {
26503         var source = sources[i3];
26504         for (var prop in source) {
26505           if (Object.prototype.hasOwnProperty.call(source, prop)) {
26506             if (source[prop] === void 0) {
26507               delete this[prop];
26508             } else {
26509               this[prop] = source[prop];
26510             }
26511           }
26512         }
26513       }
26514       if (!this.id) {
26515         this.id = osmNote.id().toString();
26516       }
26517       return this;
26518     },
26519     extent: function() {
26520       return new geoExtent(this.loc);
26521     },
26522     update: function(attrs) {
26523       return osmNote(this, attrs);
26524     },
26525     isNew: function() {
26526       return this.id < 0;
26527     },
26528     move: function(loc) {
26529       return this.update({ loc });
26530     }
26531   });
26532
26533   // modules/osm/relation.js
26534   function osmRelation() {
26535     if (!(this instanceof osmRelation)) {
26536       return new osmRelation().initialize(arguments);
26537     } else if (arguments.length) {
26538       this.initialize(arguments);
26539     }
26540   }
26541   osmEntity.relation = osmRelation;
26542   osmRelation.prototype = Object.create(osmEntity.prototype);
26543   osmRelation.creationOrder = function(a2, b2) {
26544     var aId = parseInt(osmEntity.id.toOSM(a2.id), 10);
26545     var bId = parseInt(osmEntity.id.toOSM(b2.id), 10);
26546     if (aId < 0 || bId < 0) return aId - bId;
26547     return bId - aId;
26548   };
26549   var prototype3 = {
26550     type: "relation",
26551     members: [],
26552     copy: function(resolver, copies) {
26553       if (copies[this.id]) return copies[this.id];
26554       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
26555       var members = this.members.map(function(member) {
26556         return Object.assign({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
26557       });
26558       copy2 = copy2.update({ members });
26559       copies[this.id] = copy2;
26560       return copy2;
26561     },
26562     extent: function(resolver, memo) {
26563       return resolver.transient(this, "extent", function() {
26564         if (memo && memo[this.id]) return geoExtent();
26565         memo = memo || {};
26566         memo[this.id] = true;
26567         var extent = geoExtent();
26568         for (var i3 = 0; i3 < this.members.length; i3++) {
26569           var member = resolver.hasEntity(this.members[i3].id);
26570           if (member) {
26571             extent._extend(member.extent(resolver, memo));
26572           }
26573         }
26574         return extent;
26575       });
26576     },
26577     geometry: function(graph) {
26578       return graph.transient(this, "geometry", function() {
26579         return this.isMultipolygon() ? "area" : "relation";
26580       });
26581     },
26582     isDegenerate: function() {
26583       return this.members.length === 0;
26584     },
26585     // Return an array of members, each extended with an 'index' property whose value
26586     // is the member index.
26587     indexedMembers: function() {
26588       var result = new Array(this.members.length);
26589       for (var i3 = 0; i3 < this.members.length; i3++) {
26590         result[i3] = Object.assign({}, this.members[i3], { index: i3 });
26591       }
26592       return result;
26593     },
26594     // Return the first member with the given role. A copy of the member object
26595     // is returned, extended with an 'index' property whose value is the member index.
26596     memberByRole: function(role) {
26597       for (var i3 = 0; i3 < this.members.length; i3++) {
26598         if (this.members[i3].role === role) {
26599           return Object.assign({}, this.members[i3], { index: i3 });
26600         }
26601       }
26602     },
26603     // Same as memberByRole, but returns all members with the given role
26604     membersByRole: function(role) {
26605       var result = [];
26606       for (var i3 = 0; i3 < this.members.length; i3++) {
26607         if (this.members[i3].role === role) {
26608           result.push(Object.assign({}, this.members[i3], { index: i3 }));
26609         }
26610       }
26611       return result;
26612     },
26613     // Return the first member with the given id. A copy of the member object
26614     // is returned, extended with an 'index' property whose value is the member index.
26615     memberById: function(id2) {
26616       for (var i3 = 0; i3 < this.members.length; i3++) {
26617         if (this.members[i3].id === id2) {
26618           return Object.assign({}, this.members[i3], { index: i3 });
26619         }
26620       }
26621     },
26622     // Return the first member with the given id and role. A copy of the member object
26623     // is returned, extended with an 'index' property whose value is the member index.
26624     memberByIdAndRole: function(id2, role) {
26625       for (var i3 = 0; i3 < this.members.length; i3++) {
26626         if (this.members[i3].id === id2 && this.members[i3].role === role) {
26627           return Object.assign({}, this.members[i3], { index: i3 });
26628         }
26629       }
26630     },
26631     addMember: function(member, index) {
26632       var members = this.members.slice();
26633       members.splice(index === void 0 ? members.length : index, 0, member);
26634       return this.update({ members });
26635     },
26636     updateMember: function(member, index) {
26637       var members = this.members.slice();
26638       members.splice(index, 1, Object.assign({}, members[index], member));
26639       return this.update({ members });
26640     },
26641     removeMember: function(index) {
26642       var members = this.members.slice();
26643       members.splice(index, 1);
26644       return this.update({ members });
26645     },
26646     removeMembersWithID: function(id2) {
26647       var members = this.members.filter(function(m2) {
26648         return m2.id !== id2;
26649       });
26650       return this.update({ members });
26651     },
26652     moveMember: function(fromIndex, toIndex) {
26653       var members = this.members.slice();
26654       members.splice(toIndex, 0, members.splice(fromIndex, 1)[0]);
26655       return this.update({ members });
26656     },
26657     // Wherever a member appears with id `needle.id`, replace it with a member
26658     // with id `replacement.id`, type `replacement.type`, and the original role,
26659     // By default, adding a duplicate member (by id and role) is prevented.
26660     // Return an updated relation.
26661     replaceMember: function(needle, replacement, keepDuplicates) {
26662       if (!this.memberById(needle.id)) return this;
26663       var members = [];
26664       for (var i3 = 0; i3 < this.members.length; i3++) {
26665         var member = this.members[i3];
26666         if (member.id !== needle.id) {
26667           members.push(member);
26668         } else if (keepDuplicates || !this.memberByIdAndRole(replacement.id, member.role)) {
26669           members.push({ id: replacement.id, type: replacement.type, role: member.role });
26670         }
26671       }
26672       return this.update({ members });
26673     },
26674     asJXON: function(changeset_id) {
26675       var r2 = {
26676         relation: {
26677           "@id": this.osmId(),
26678           "@version": this.version || 0,
26679           member: this.members.map(function(member) {
26680             return {
26681               keyAttributes: {
26682                 type: member.type,
26683                 role: member.role,
26684                 ref: osmEntity.id.toOSM(member.id)
26685               }
26686             };
26687           }, this),
26688           tag: Object.keys(this.tags).map(function(k2) {
26689             return { keyAttributes: { k: k2, v: this.tags[k2] } };
26690           }, this)
26691         }
26692       };
26693       if (changeset_id) {
26694         r2.relation["@changeset"] = changeset_id;
26695       }
26696       return r2;
26697     },
26698     asGeoJSON: function(resolver) {
26699       return resolver.transient(this, "GeoJSON", function() {
26700         if (this.isMultipolygon()) {
26701           return {
26702             type: "MultiPolygon",
26703             coordinates: this.multipolygon(resolver)
26704           };
26705         } else {
26706           return {
26707             type: "FeatureCollection",
26708             properties: this.tags,
26709             features: this.members.map(function(member) {
26710               return Object.assign({ role: member.role }, resolver.entity(member.id).asGeoJSON(resolver));
26711             })
26712           };
26713         }
26714       });
26715     },
26716     area: function(resolver) {
26717       return resolver.transient(this, "area", function() {
26718         return area_default(this.asGeoJSON(resolver));
26719       });
26720     },
26721     isMultipolygon: function() {
26722       return this.tags.type === "multipolygon";
26723     },
26724     isComplete: function(resolver) {
26725       for (var i3 = 0; i3 < this.members.length; i3++) {
26726         if (!resolver.hasEntity(this.members[i3].id)) {
26727           return false;
26728         }
26729       }
26730       return true;
26731     },
26732     hasFromViaTo: function() {
26733       return this.members.some(function(m2) {
26734         return m2.role === "from";
26735       }) && this.members.some(
26736         (m2) => m2.role === "via" || m2.role === "intersection" && this.tags.type === "destination_sign"
26737       ) && this.members.some(function(m2) {
26738         return m2.role === "to";
26739       });
26740     },
26741     isRestriction: function() {
26742       return !!(this.tags.type && this.tags.type.match(/^restriction:?/));
26743     },
26744     isValidRestriction: function() {
26745       if (!this.isRestriction()) return false;
26746       var froms = this.members.filter(function(m2) {
26747         return m2.role === "from";
26748       });
26749       var vias = this.members.filter(function(m2) {
26750         return m2.role === "via";
26751       });
26752       var tos = this.members.filter(function(m2) {
26753         return m2.role === "to";
26754       });
26755       if (froms.length !== 1 && this.tags.restriction !== "no_entry") return false;
26756       if (froms.some(function(m2) {
26757         return m2.type !== "way";
26758       })) return false;
26759       if (tos.length !== 1 && this.tags.restriction !== "no_exit") return false;
26760       if (tos.some(function(m2) {
26761         return m2.type !== "way";
26762       })) return false;
26763       if (vias.length === 0) return false;
26764       if (vias.length > 1 && vias.some(function(m2) {
26765         return m2.type !== "way";
26766       })) return false;
26767       return true;
26768     },
26769     isConnectivity: function() {
26770       return !!(this.tags.type && this.tags.type.match(/^connectivity:?/));
26771     },
26772     // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm],
26773     // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings.
26774     //
26775     // This corresponds to the structure needed for rendering a multipolygon path using a
26776     // `evenodd` fill rule, as well as the structure of a GeoJSON MultiPolygon geometry.
26777     //
26778     // In the case of invalid geometries, this function will still return a result which
26779     // includes the nodes of all way members, but some Nds may be unclosed and some inner
26780     // rings not matched with the intended outer ring.
26781     //
26782     multipolygon: function(resolver) {
26783       var outers = this.members.filter(function(m2) {
26784         return "outer" === (m2.role || "outer");
26785       });
26786       var inners = this.members.filter(function(m2) {
26787         return "inner" === m2.role;
26788       });
26789       outers = osmJoinWays(outers, resolver);
26790       inners = osmJoinWays(inners, resolver);
26791       var sequenceToLineString = function(sequence) {
26792         if (sequence.nodes.length > 2 && sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
26793           sequence.nodes.push(sequence.nodes[0]);
26794         }
26795         return sequence.nodes.map(function(node) {
26796           return node.loc;
26797         });
26798       };
26799       outers = outers.map(sequenceToLineString);
26800       inners = inners.map(sequenceToLineString);
26801       var result = outers.map(function(o3) {
26802         return [area_default({ type: "Polygon", coordinates: [o3] }) > 2 * Math.PI ? o3.reverse() : o3];
26803       });
26804       function findOuter(inner2) {
26805         var o3, outer;
26806         for (o3 = 0; o3 < outers.length; o3++) {
26807           outer = outers[o3];
26808           if (geoPolygonContainsPolygon(outer, inner2)) {
26809             return o3;
26810           }
26811         }
26812         for (o3 = 0; o3 < outers.length; o3++) {
26813           outer = outers[o3];
26814           if (geoPolygonIntersectsPolygon(outer, inner2, false)) {
26815             return o3;
26816           }
26817         }
26818       }
26819       for (var i3 = 0; i3 < inners.length; i3++) {
26820         var inner = inners[i3];
26821         if (area_default({ type: "Polygon", coordinates: [inner] }) < 2 * Math.PI) {
26822           inner = inner.reverse();
26823         }
26824         var o2 = findOuter(inners[i3]);
26825         if (o2 !== void 0) {
26826           result[o2].push(inners[i3]);
26827         } else {
26828           result.push([inners[i3]]);
26829         }
26830       }
26831       return result;
26832     }
26833   };
26834   Object.assign(osmRelation.prototype, prototype3);
26835
26836   // modules/osm/qa_item.js
26837   var QAItem = class _QAItem {
26838     constructor(loc, service, itemType, id2, props) {
26839       this.loc = loc;
26840       this.service = service.title;
26841       this.itemType = itemType;
26842       this.id = id2 ? id2 : "".concat(_QAItem.id());
26843       this.update(props);
26844       if (service && typeof service.getIcon === "function") {
26845         this.icon = service.getIcon(itemType);
26846       }
26847     }
26848     update(props) {
26849       const { loc, service, itemType, id: id2 } = this;
26850       Object.keys(props).forEach((prop) => this[prop] = props[prop]);
26851       this.loc = loc;
26852       this.service = service;
26853       this.itemType = itemType;
26854       this.id = id2;
26855       return this;
26856     }
26857     // Generic handling for newly created QAItems
26858     static id() {
26859       return this.nextId--;
26860     }
26861   };
26862   QAItem.nextId = -1;
26863
26864   // modules/actions/split.js
26865   function actionSplit(nodeIds, newWayIds) {
26866     if (typeof nodeIds === "string") nodeIds = [nodeIds];
26867     var _wayIDs;
26868     var _keepHistoryOn = "longest";
26869     const circularJunctions = ["roundabout", "circular"];
26870     var _createdWayIDs = [];
26871     function dist(graph, nA, nB) {
26872       var locA = graph.entity(nA).loc;
26873       var locB = graph.entity(nB).loc;
26874       var epsilon3 = 1e-6;
26875       return locA && locB ? geoSphericalDistance(locA, locB) : epsilon3;
26876     }
26877     function splitArea(nodes, idxA, graph) {
26878       var lengths = new Array(nodes.length);
26879       var length2;
26880       var i3;
26881       var best = 0;
26882       var idxB;
26883       function wrap2(index) {
26884         return utilWrap(index, nodes.length);
26885       }
26886       length2 = 0;
26887       for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) {
26888         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]);
26889         lengths[i3] = length2;
26890       }
26891       length2 = 0;
26892       for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) {
26893         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]);
26894         if (length2 < lengths[i3]) {
26895           lengths[i3] = length2;
26896         }
26897       }
26898       for (i3 = 0; i3 < nodes.length; i3++) {
26899         var cost = lengths[i3] / dist(graph, nodes[idxA], nodes[i3]);
26900         if (cost > best) {
26901           idxB = i3;
26902           best = cost;
26903         }
26904       }
26905       return idxB;
26906     }
26907     function totalLengthBetweenNodes(graph, nodes) {
26908       var totalLength = 0;
26909       for (var i3 = 0; i3 < nodes.length - 1; i3++) {
26910         totalLength += dist(graph, nodes[i3], nodes[i3 + 1]);
26911       }
26912       return totalLength;
26913     }
26914     function split(graph, nodeId, wayA, newWayId, otherNodeIds) {
26915       var wayB = osmWay({ id: newWayId, tags: wayA.tags });
26916       var nodesA;
26917       var nodesB;
26918       var isArea = wayA.isArea();
26919       if (wayA.isClosed()) {
26920         var nodes = wayA.nodes.slice(0, -1);
26921         var idxA = nodes.indexOf(nodeId);
26922         var idxB = otherNodeIds.length > 0 ? nodes.indexOf(otherNodeIds[0]) : splitArea(nodes, idxA, graph);
26923         if (idxB < idxA) {
26924           nodesA = nodes.slice(idxA).concat(nodes.slice(0, idxB + 1));
26925           nodesB = nodes.slice(idxB, idxA + 1);
26926         } else {
26927           nodesA = nodes.slice(idxA, idxB + 1);
26928           nodesB = nodes.slice(idxB).concat(nodes.slice(0, idxA + 1));
26929         }
26930       } else {
26931         var idx = wayA.nodes.indexOf(nodeId, 1);
26932         nodesA = wayA.nodes.slice(0, idx + 1);
26933         nodesB = wayA.nodes.slice(idx);
26934       }
26935       var lengthA = totalLengthBetweenNodes(graph, nodesA);
26936       var lengthB = totalLengthBetweenNodes(graph, nodesB);
26937       if (_keepHistoryOn === "longest" && lengthB > lengthA) {
26938         wayA = wayA.update({ nodes: nodesB });
26939         wayB = wayB.update({ nodes: nodesA });
26940         var temp = lengthA;
26941         lengthA = lengthB;
26942         lengthB = temp;
26943       } else {
26944         wayA = wayA.update({ nodes: nodesA });
26945         wayB = wayB.update({ nodes: nodesB });
26946       }
26947       if (wayA.tags.step_count) {
26948         var stepCount = Number(wayA.tags.step_count);
26949         if (stepCount && // ensure a number
26950         isFinite(stepCount) && // ensure positive
26951         stepCount > 0 && // ensure integer
26952         Math.round(stepCount) === stepCount) {
26953           var tagsA = Object.assign({}, wayA.tags);
26954           var tagsB = Object.assign({}, wayB.tags);
26955           var ratioA = lengthA / (lengthA + lengthB);
26956           var countA = Math.round(stepCount * ratioA);
26957           tagsA.step_count = countA.toString();
26958           tagsB.step_count = (stepCount - countA).toString();
26959           wayA = wayA.update({ tags: tagsA });
26960           wayB = wayB.update({ tags: tagsB });
26961         }
26962       }
26963       graph = graph.replace(wayA);
26964       graph = graph.replace(wayB);
26965       graph.parentRelations(wayA).forEach(function(relation) {
26966         if (relation.hasFromViaTo()) {
26967           var f2 = relation.memberByRole("from");
26968           var v2 = [
26969             ...relation.membersByRole("via"),
26970             ...relation.membersByRole("intersection")
26971           ];
26972           var t2 = relation.memberByRole("to");
26973           var i3;
26974           if (f2.id === wayA.id || t2.id === wayA.id) {
26975             var keepB = false;
26976             if (v2.length === 1 && v2[0].type === "node") {
26977               keepB = wayB.contains(v2[0].id);
26978             } else {
26979               for (i3 = 0; i3 < v2.length; i3++) {
26980                 if (v2[i3].type === "way") {
26981                   var wayVia = graph.hasEntity(v2[i3].id);
26982                   if (wayVia && utilArrayIntersection(wayB.nodes, wayVia.nodes).length) {
26983                     keepB = true;
26984                     break;
26985                   }
26986                 }
26987               }
26988             }
26989             if (keepB) {
26990               relation = relation.replaceMember(wayA, wayB);
26991               graph = graph.replace(relation);
26992             }
26993           } else {
26994             for (i3 = 0; i3 < v2.length; i3++) {
26995               if (v2[i3].type === "way" && v2[i3].id === wayA.id) {
26996                 graph = splitWayMember(graph, relation.id, wayA, wayB);
26997               }
26998             }
26999           }
27000         } else {
27001           graph = splitWayMember(graph, relation.id, wayA, wayB);
27002         }
27003       });
27004       if (isArea) {
27005         var multipolygon = osmRelation({
27006           tags: Object.assign({}, wayA.tags, { type: "multipolygon" }),
27007           members: [
27008             { id: wayA.id, role: "outer", type: "way" },
27009             { id: wayB.id, role: "outer", type: "way" }
27010           ]
27011         });
27012         graph = graph.replace(multipolygon);
27013         graph = graph.replace(wayA.update({ tags: {} }));
27014         graph = graph.replace(wayB.update({ tags: {} }));
27015       }
27016       _createdWayIDs.push(wayB.id);
27017       return graph;
27018     }
27019     function splitWayMember(graph, relationId, wayA, wayB) {
27020       function connects(way1, way2) {
27021         if (way1.nodes.length < 2 || way2.nodes.length < 2) return false;
27022         if (circularJunctions.includes(way1.tags.junction) && way1.isClosed()) {
27023           return way1.nodes.some((nodeId) => nodeId === way2.nodes[0] || nodeId === way2.nodes[way2.nodes.length - 1]);
27024         } else if (circularJunctions.includes(way2.tags.junction) && way2.isClosed()) {
27025           return way2.nodes.some((nodeId) => nodeId === way1.nodes[0] || nodeId === way1.nodes[way1.nodes.length - 1]);
27026         }
27027         if (way1.nodes[0] === way2.nodes[0]) return true;
27028         if (way1.nodes[0] === way2.nodes[way2.nodes.length - 1]) return true;
27029         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[way2.nodes.length - 1]) return true;
27030         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[0]) return true;
27031         return false;
27032       }
27033       let relation = graph.entity(relationId);
27034       const insertMembers = [];
27035       const members = relation.members;
27036       for (let i3 = 0; i3 < members.length; i3++) {
27037         const member = members[i3];
27038         if (member.id === wayA.id) {
27039           let wayAconnectsPrev = false;
27040           let wayAconnectsNext = false;
27041           let wayBconnectsPrev = false;
27042           let wayBconnectsNext = false;
27043           if (i3 > 0 && graph.hasEntity(members[i3 - 1].id)) {
27044             const prevEntity = graph.entity(members[i3 - 1].id);
27045             if (prevEntity.type === "way") {
27046               wayAconnectsPrev = connects(prevEntity, wayA);
27047               wayBconnectsPrev = connects(prevEntity, wayB);
27048             }
27049           }
27050           if (i3 < members.length - 1 && graph.hasEntity(members[i3 + 1].id)) {
27051             const nextEntity = graph.entity(members[i3 + 1].id);
27052             if (nextEntity.type === "way") {
27053               wayAconnectsNext = connects(nextEntity, wayA);
27054               wayBconnectsNext = connects(nextEntity, wayB);
27055             }
27056           }
27057           if (wayAconnectsPrev && !wayAconnectsNext || !wayBconnectsPrev && wayBconnectsNext && !(!wayAconnectsPrev && wayAconnectsNext)) {
27058             insertMembers.push({ at: i3 + 1, role: member.role });
27059             continue;
27060           }
27061           if (!wayAconnectsPrev && wayAconnectsNext || wayBconnectsPrev && !wayBconnectsNext && !(wayAconnectsPrev && !wayAconnectsNext)) {
27062             insertMembers.push({ at: i3, role: member.role });
27063             continue;
27064           }
27065           if (wayAconnectsPrev && wayBconnectsPrev && wayAconnectsNext && wayBconnectsNext) {
27066             if (i3 > 2 && graph.hasEntity(members[i3 - 2].id)) {
27067               const prev2Entity = graph.entity(members[i3 - 2].id);
27068               if (connects(prev2Entity, wayA) && !connects(prev2Entity, wayB)) {
27069                 insertMembers.push({ at: i3, role: member.role });
27070                 continue;
27071               }
27072               if (connects(prev2Entity, wayB) && !connects(prev2Entity, wayA)) {
27073                 insertMembers.push({ at: i3 + 1, role: member.role });
27074                 continue;
27075               }
27076             }
27077             if (i3 < members.length - 2 && graph.hasEntity(members[i3 + 2].id)) {
27078               const next2Entity = graph.entity(members[i3 + 2].id);
27079               if (connects(next2Entity, wayA) && !connects(next2Entity, wayB)) {
27080                 insertMembers.push({ at: i3 + 1, role: member.role });
27081                 continue;
27082               }
27083               if (connects(next2Entity, wayB) && !connects(next2Entity, wayA)) {
27084                 insertMembers.push({ at: i3, role: member.role });
27085                 continue;
27086               }
27087             }
27088           }
27089           if (wayA.nodes[wayA.nodes.length - 1] === wayB.nodes[0]) {
27090             insertMembers.push({ at: i3 + 1, role: member.role });
27091           } else {
27092             insertMembers.push({ at: i3, role: member.role });
27093           }
27094         }
27095       }
27096       insertMembers.reverse().forEach((item) => {
27097         graph = graph.replace(relation.addMember({
27098           id: wayB.id,
27099           type: "way",
27100           role: item.role
27101         }, item.at));
27102         relation = graph.entity(relation.id);
27103       });
27104       return graph;
27105     }
27106     var action = function(graph) {
27107       _createdWayIDs = [];
27108       var newWayIndex = 0;
27109       for (var i3 = 0; i3 < nodeIds.length; i3++) {
27110         var nodeId = nodeIds[i3];
27111         var candidates = action.waysForNode(nodeId, graph);
27112         for (var j2 = 0; j2 < candidates.length; j2++) {
27113           graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex], nodeIds.slice(j2 + 1));
27114           newWayIndex += 1;
27115         }
27116       }
27117       return graph;
27118     };
27119     action.getCreatedWayIDs = function() {
27120       return _createdWayIDs;
27121     };
27122     action.waysForNode = function(nodeId, graph) {
27123       var node = graph.entity(nodeId);
27124       var splittableParents = graph.parentWays(node).filter(isSplittable);
27125       if (!_wayIDs) {
27126         var hasLine = splittableParents.some(function(parent) {
27127           return parent.geometry(graph) === "line";
27128         });
27129         if (hasLine) {
27130           return splittableParents.filter(function(parent) {
27131             return parent.geometry(graph) === "line";
27132           });
27133         }
27134       }
27135       return splittableParents;
27136       function isSplittable(parent) {
27137         if (_wayIDs && _wayIDs.indexOf(parent.id) === -1) return false;
27138         if (parent.isClosed()) return true;
27139         for (var i3 = 1; i3 < parent.nodes.length - 1; i3++) {
27140           if (parent.nodes[i3] === nodeId) return true;
27141         }
27142         return false;
27143       }
27144     };
27145     action.ways = function(graph) {
27146       return utilArrayUniq([].concat.apply([], nodeIds.map(function(nodeId) {
27147         return action.waysForNode(nodeId, graph);
27148       })));
27149     };
27150     action.disabled = function(graph) {
27151       for (const nodeId of nodeIds) {
27152         const candidates = action.waysForNode(nodeId, graph);
27153         if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) {
27154           return "not_eligible";
27155         }
27156         for (const way of candidates) {
27157           const parentRelations = graph.parentRelations(way);
27158           for (const parentRelation of parentRelations) {
27159             if (parentRelation.hasFromViaTo()) {
27160               const vias = [
27161                 ...parentRelation.membersByRole("via"),
27162                 ...parentRelation.membersByRole("intersection")
27163               ];
27164               if (!vias.every((via) => graph.hasEntity(via.id))) {
27165                 return "parent_incomplete";
27166               }
27167             } else {
27168               for (let i3 = 0; i3 < parentRelation.members.length; i3++) {
27169                 if (parentRelation.members[i3].id === way.id) {
27170                   const memberBeforePresent = i3 > 0 && graph.hasEntity(parentRelation.members[i3 - 1].id);
27171                   const memberAfterPresent = i3 < parentRelation.members.length - 1 && graph.hasEntity(parentRelation.members[i3 + 1].id);
27172                   if (!memberBeforePresent && !memberAfterPresent && parentRelation.members.length > 1) {
27173                     return "parent_incomplete";
27174                   }
27175                 }
27176               }
27177             }
27178             const relTypesExceptions = ["junction", "enforcement"];
27179             if (circularJunctions.includes(way.tags.junction) && way.isClosed() && !relTypesExceptions.includes(parentRelation.tags.type)) {
27180               return "simple_roundabout";
27181             }
27182           }
27183         }
27184       }
27185     };
27186     action.limitWays = function(val) {
27187       if (!arguments.length) return _wayIDs;
27188       _wayIDs = val;
27189       return action;
27190     };
27191     action.keepHistoryOn = function(val) {
27192       if (!arguments.length) return _keepHistoryOn;
27193       _keepHistoryOn = val;
27194       return action;
27195     };
27196     return action;
27197   }
27198
27199   // modules/core/graph.js
27200   function coreGraph(other2, mutable) {
27201     if (!(this instanceof coreGraph)) return new coreGraph(other2, mutable);
27202     if (other2 instanceof coreGraph) {
27203       var base = other2.base();
27204       this.entities = Object.assign(Object.create(base.entities), other2.entities);
27205       this._parentWays = Object.assign(Object.create(base.parentWays), other2._parentWays);
27206       this._parentRels = Object.assign(Object.create(base.parentRels), other2._parentRels);
27207     } else {
27208       this.entities = /* @__PURE__ */ Object.create({});
27209       this._parentWays = /* @__PURE__ */ Object.create({});
27210       this._parentRels = /* @__PURE__ */ Object.create({});
27211       this.rebase(other2 || [], [this]);
27212     }
27213     this.transients = {};
27214     this._childNodes = {};
27215     this.frozen = !mutable;
27216   }
27217   coreGraph.prototype = {
27218     hasEntity: function(id2) {
27219       return this.entities[id2];
27220     },
27221     entity: function(id2) {
27222       var entity = this.entities[id2];
27223       if (!entity) {
27224         entity = this.entities.__proto__[id2];
27225       }
27226       if (!entity) {
27227         throw new Error("entity " + id2 + " not found");
27228       }
27229       return entity;
27230     },
27231     geometry: function(id2) {
27232       return this.entity(id2).geometry(this);
27233     },
27234     transient: function(entity, key, fn) {
27235       var id2 = entity.id;
27236       var transients = this.transients[id2] || (this.transients[id2] = {});
27237       if (transients[key] !== void 0) {
27238         return transients[key];
27239       }
27240       transients[key] = fn.call(entity);
27241       return transients[key];
27242     },
27243     parentWays: function(entity) {
27244       var parents = this._parentWays[entity.id];
27245       var result = [];
27246       if (parents) {
27247         parents.forEach(function(id2) {
27248           result.push(this.entity(id2));
27249         }, this);
27250       }
27251       return result;
27252     },
27253     isPoi: function(entity) {
27254       var parents = this._parentWays[entity.id];
27255       return !parents || parents.size === 0;
27256     },
27257     isShared: function(entity) {
27258       var parents = this._parentWays[entity.id];
27259       return parents && parents.size > 1;
27260     },
27261     parentRelations: function(entity) {
27262       var parents = this._parentRels[entity.id];
27263       var result = [];
27264       if (parents) {
27265         parents.forEach(function(id2) {
27266           result.push(this.entity(id2));
27267         }, this);
27268       }
27269       return result;
27270     },
27271     parentMultipolygons: function(entity) {
27272       return this.parentRelations(entity).filter(function(relation) {
27273         return relation.isMultipolygon();
27274       });
27275     },
27276     childNodes: function(entity) {
27277       if (this._childNodes[entity.id]) return this._childNodes[entity.id];
27278       if (!entity.nodes) return [];
27279       var nodes = [];
27280       for (var i3 = 0; i3 < entity.nodes.length; i3++) {
27281         nodes[i3] = this.entity(entity.nodes[i3]);
27282       }
27283       if (debug) Object.freeze(nodes);
27284       this._childNodes[entity.id] = nodes;
27285       return this._childNodes[entity.id];
27286     },
27287     base: function() {
27288       return {
27289         "entities": Object.getPrototypeOf(this.entities),
27290         "parentWays": Object.getPrototypeOf(this._parentWays),
27291         "parentRels": Object.getPrototypeOf(this._parentRels)
27292       };
27293     },
27294     // Unlike other graph methods, rebase mutates in place. This is because it
27295     // is used only during the history operation that merges newly downloaded
27296     // data into each state. To external consumers, it should appear as if the
27297     // graph always contained the newly downloaded data.
27298     rebase: function(entities, stack, force) {
27299       var base = this.base();
27300       var i3, j2, k2, id2;
27301       for (i3 = 0; i3 < entities.length; i3++) {
27302         var entity = entities[i3];
27303         if (!entity.visible || !force && base.entities[entity.id]) continue;
27304         base.entities[entity.id] = entity;
27305         this._updateCalculated(void 0, entity, base.parentWays, base.parentRels);
27306         if (entity.type === "way") {
27307           for (j2 = 0; j2 < entity.nodes.length; j2++) {
27308             id2 = entity.nodes[j2];
27309             for (k2 = 1; k2 < stack.length; k2++) {
27310               var ents = stack[k2].entities;
27311               if (ents.hasOwnProperty(id2) && ents[id2] === void 0) {
27312                 delete ents[id2];
27313               }
27314             }
27315           }
27316         }
27317       }
27318       for (i3 = 0; i3 < stack.length; i3++) {
27319         stack[i3]._updateRebased();
27320       }
27321     },
27322     _updateRebased: function() {
27323       var base = this.base();
27324       Object.keys(this._parentWays).forEach(function(child) {
27325         if (base.parentWays[child]) {
27326           base.parentWays[child].forEach(function(id2) {
27327             if (!this.entities.hasOwnProperty(id2)) {
27328               this._parentWays[child].add(id2);
27329             }
27330           }, this);
27331         }
27332       }, this);
27333       Object.keys(this._parentRels).forEach(function(child) {
27334         if (base.parentRels[child]) {
27335           base.parentRels[child].forEach(function(id2) {
27336             if (!this.entities.hasOwnProperty(id2)) {
27337               this._parentRels[child].add(id2);
27338             }
27339           }, this);
27340         }
27341       }, this);
27342       this.transients = {};
27343     },
27344     // Updates calculated properties (parentWays, parentRels) for the specified change
27345     _updateCalculated: function(oldentity, entity, parentWays, parentRels) {
27346       parentWays = parentWays || this._parentWays;
27347       parentRels = parentRels || this._parentRels;
27348       var type2 = entity && entity.type || oldentity && oldentity.type;
27349       var removed, added, i3;
27350       if (type2 === "way") {
27351         if (oldentity && entity) {
27352           removed = utilArrayDifference(oldentity.nodes, entity.nodes);
27353           added = utilArrayDifference(entity.nodes, oldentity.nodes);
27354         } else if (oldentity) {
27355           removed = oldentity.nodes;
27356           added = [];
27357         } else if (entity) {
27358           removed = [];
27359           added = entity.nodes;
27360         }
27361         for (i3 = 0; i3 < removed.length; i3++) {
27362           parentWays[removed[i3]] = new Set(parentWays[removed[i3]]);
27363           parentWays[removed[i3]].delete(oldentity.id);
27364         }
27365         for (i3 = 0; i3 < added.length; i3++) {
27366           parentWays[added[i3]] = new Set(parentWays[added[i3]]);
27367           parentWays[added[i3]].add(entity.id);
27368         }
27369       } else if (type2 === "relation") {
27370         var oldentityMemberIDs = oldentity ? oldentity.members.map(function(m2) {
27371           return m2.id;
27372         }) : [];
27373         var entityMemberIDs = entity ? entity.members.map(function(m2) {
27374           return m2.id;
27375         }) : [];
27376         if (oldentity && entity) {
27377           removed = utilArrayDifference(oldentityMemberIDs, entityMemberIDs);
27378           added = utilArrayDifference(entityMemberIDs, oldentityMemberIDs);
27379         } else if (oldentity) {
27380           removed = oldentityMemberIDs;
27381           added = [];
27382         } else if (entity) {
27383           removed = [];
27384           added = entityMemberIDs;
27385         }
27386         for (i3 = 0; i3 < removed.length; i3++) {
27387           parentRels[removed[i3]] = new Set(parentRels[removed[i3]]);
27388           parentRels[removed[i3]].delete(oldentity.id);
27389         }
27390         for (i3 = 0; i3 < added.length; i3++) {
27391           parentRels[added[i3]] = new Set(parentRels[added[i3]]);
27392           parentRels[added[i3]].add(entity.id);
27393         }
27394       }
27395     },
27396     replace: function(entity) {
27397       if (this.entities[entity.id] === entity) return this;
27398       return this.update(function() {
27399         this._updateCalculated(this.entities[entity.id], entity);
27400         this.entities[entity.id] = entity;
27401       });
27402     },
27403     remove: function(entity) {
27404       return this.update(function() {
27405         this._updateCalculated(entity, void 0);
27406         this.entities[entity.id] = void 0;
27407       });
27408     },
27409     revert: function(id2) {
27410       var baseEntity = this.base().entities[id2];
27411       var headEntity = this.entities[id2];
27412       if (headEntity === baseEntity) return this;
27413       return this.update(function() {
27414         this._updateCalculated(headEntity, baseEntity);
27415         delete this.entities[id2];
27416       });
27417     },
27418     update: function() {
27419       var graph = this.frozen ? coreGraph(this, true) : this;
27420       for (var i3 = 0; i3 < arguments.length; i3++) {
27421         arguments[i3].call(graph, graph);
27422       }
27423       if (this.frozen) graph.frozen = true;
27424       return graph;
27425     },
27426     // Obliterates any existing entities
27427     load: function(entities) {
27428       var base = this.base();
27429       this.entities = Object.create(base.entities);
27430       for (var i3 in entities) {
27431         this.entities[i3] = entities[i3];
27432         this._updateCalculated(base.entities[i3], this.entities[i3]);
27433       }
27434       return this;
27435     }
27436   };
27437
27438   // modules/osm/intersection.js
27439   function osmTurn(turn) {
27440     if (!(this instanceof osmTurn)) {
27441       return new osmTurn(turn);
27442     }
27443     Object.assign(this, turn);
27444   }
27445   function osmIntersection(graph, startVertexId, maxDistance) {
27446     maxDistance = maxDistance || 30;
27447     var vgraph = coreGraph();
27448     var i3, j2, k2;
27449     function memberOfRestriction(entity) {
27450       return graph.parentRelations(entity).some(function(r2) {
27451         return r2.isRestriction();
27452       });
27453     }
27454     function isRoad(way2) {
27455       if (way2.isArea() || way2.isDegenerate()) return false;
27456       var roads = {
27457         "motorway": true,
27458         "motorway_link": true,
27459         "trunk": true,
27460         "trunk_link": true,
27461         "primary": true,
27462         "primary_link": true,
27463         "secondary": true,
27464         "secondary_link": true,
27465         "tertiary": true,
27466         "tertiary_link": true,
27467         "residential": true,
27468         "unclassified": true,
27469         "living_street": true,
27470         "service": true,
27471         "busway": true,
27472         "road": true,
27473         "track": true
27474       };
27475       return roads[way2.tags.highway];
27476     }
27477     var startNode = graph.entity(startVertexId);
27478     var checkVertices = [startNode];
27479     var checkWays;
27480     var vertices = [];
27481     var vertexIds = [];
27482     var vertex;
27483     var ways = [];
27484     var wayIds = [];
27485     var way;
27486     var nodes = [];
27487     var node;
27488     var parents = [];
27489     var parent;
27490     var actions = [];
27491     while (checkVertices.length) {
27492       vertex = checkVertices.pop();
27493       checkWays = graph.parentWays(vertex);
27494       var hasWays = false;
27495       for (i3 = 0; i3 < checkWays.length; i3++) {
27496         way = checkWays[i3];
27497         if (!isRoad(way) && !memberOfRestriction(way)) continue;
27498         ways.push(way);
27499         hasWays = true;
27500         nodes = utilArrayUniq(graph.childNodes(way));
27501         for (j2 = 0; j2 < nodes.length; j2++) {
27502           node = nodes[j2];
27503           if (node === vertex) continue;
27504           if (vertices.indexOf(node) !== -1) continue;
27505           if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance) continue;
27506           var hasParents = false;
27507           parents = graph.parentWays(node);
27508           for (k2 = 0; k2 < parents.length; k2++) {
27509             parent = parents[k2];
27510             if (parent === way) continue;
27511             if (ways.indexOf(parent) !== -1) continue;
27512             if (!isRoad(parent)) continue;
27513             hasParents = true;
27514             break;
27515           }
27516           if (hasParents) {
27517             checkVertices.push(node);
27518           }
27519         }
27520       }
27521       if (hasWays) {
27522         vertices.push(vertex);
27523       }
27524     }
27525     vertices = utilArrayUniq(vertices);
27526     ways = utilArrayUniq(ways);
27527     ways.forEach(function(way2) {
27528       graph.childNodes(way2).forEach(function(node2) {
27529         vgraph = vgraph.replace(node2);
27530       });
27531       vgraph = vgraph.replace(way2);
27532       graph.parentRelations(way2).forEach(function(relation) {
27533         if (relation.isRestriction()) {
27534           if (relation.isValidRestriction(graph)) {
27535             vgraph = vgraph.replace(relation);
27536           } else if (relation.isComplete(graph)) {
27537             actions.push(actionDeleteRelation(relation.id));
27538           }
27539         }
27540       });
27541     });
27542     ways.forEach(function(w2) {
27543       var way2 = vgraph.entity(w2.id);
27544       if (way2.tags.oneway === "-1") {
27545         var action = actionReverse(way2.id, { reverseOneway: true });
27546         actions.push(action);
27547         vgraph = action(vgraph);
27548       }
27549     });
27550     var origCount = osmEntity.id.next.way;
27551     vertices.forEach(function(v2) {
27552       var splitAll = actionSplit([v2.id]).keepHistoryOn("first");
27553       if (!splitAll.disabled(vgraph)) {
27554         splitAll.ways(vgraph).forEach(function(way2) {
27555           var splitOne = actionSplit([v2.id]).limitWays([way2.id]).keepHistoryOn("first");
27556           actions.push(splitOne);
27557           vgraph = splitOne(vgraph);
27558         });
27559       }
27560     });
27561     osmEntity.id.next.way = origCount;
27562     vertexIds = vertices.map(function(v2) {
27563       return v2.id;
27564     });
27565     vertices = [];
27566     ways = [];
27567     vertexIds.forEach(function(id2) {
27568       var vertex2 = vgraph.entity(id2);
27569       var parents2 = vgraph.parentWays(vertex2);
27570       vertices.push(vertex2);
27571       ways = ways.concat(parents2);
27572     });
27573     vertices = utilArrayUniq(vertices);
27574     ways = utilArrayUniq(ways);
27575     vertexIds = vertices.map(function(v2) {
27576       return v2.id;
27577     });
27578     wayIds = ways.map(function(w2) {
27579       return w2.id;
27580     });
27581     function withMetadata(way2, vertexIds2) {
27582       var __oneWay = way2.isOneWay() && !way2.isBiDirectional();
27583       var __first = vertexIds2.indexOf(way2.first()) !== -1;
27584       var __last = vertexIds2.indexOf(way2.last()) !== -1;
27585       var __via = __first && __last;
27586       var __from = __first && !__oneWay || __last;
27587       var __to = __first || __last && !__oneWay;
27588       return way2.update({
27589         __first,
27590         __last,
27591         __from,
27592         __via,
27593         __to,
27594         __oneWay
27595       });
27596     }
27597     ways = [];
27598     wayIds.forEach(function(id2) {
27599       var way2 = withMetadata(vgraph.entity(id2), vertexIds);
27600       vgraph = vgraph.replace(way2);
27601       ways.push(way2);
27602     });
27603     var keepGoing;
27604     var removeWayIds = [];
27605     var removeVertexIds = [];
27606     do {
27607       keepGoing = false;
27608       checkVertices = vertexIds.slice();
27609       for (i3 = 0; i3 < checkVertices.length; i3++) {
27610         var vertexId = checkVertices[i3];
27611         vertex = vgraph.hasEntity(vertexId);
27612         if (!vertex) {
27613           if (vertexIds.indexOf(vertexId) !== -1) {
27614             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27615           }
27616           removeVertexIds.push(vertexId);
27617           continue;
27618         }
27619         parents = vgraph.parentWays(vertex);
27620         if (parents.length < 3) {
27621           if (vertexIds.indexOf(vertexId) !== -1) {
27622             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27623           }
27624         }
27625         if (parents.length === 2) {
27626           var a2 = parents[0];
27627           var b2 = parents[1];
27628           var aIsLeaf = a2 && !a2.__via;
27629           var bIsLeaf = b2 && !b2.__via;
27630           var leaf, survivor;
27631           if (aIsLeaf && !bIsLeaf) {
27632             leaf = a2;
27633             survivor = b2;
27634           } else if (!aIsLeaf && bIsLeaf) {
27635             leaf = b2;
27636             survivor = a2;
27637           }
27638           if (leaf && survivor) {
27639             survivor = withMetadata(survivor, vertexIds);
27640             vgraph = vgraph.replace(survivor).remove(leaf);
27641             removeWayIds.push(leaf.id);
27642             keepGoing = true;
27643           }
27644         }
27645         parents = vgraph.parentWays(vertex);
27646         if (parents.length < 2) {
27647           if (vertexIds.indexOf(vertexId) !== -1) {
27648             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27649           }
27650           removeVertexIds.push(vertexId);
27651           keepGoing = true;
27652         }
27653         if (parents.length < 1) {
27654           vgraph = vgraph.remove(vertex);
27655         }
27656       }
27657     } while (keepGoing);
27658     vertices = vertices.filter(function(vertex2) {
27659       return removeVertexIds.indexOf(vertex2.id) === -1;
27660     }).map(function(vertex2) {
27661       return vgraph.entity(vertex2.id);
27662     });
27663     ways = ways.filter(function(way2) {
27664       return removeWayIds.indexOf(way2.id) === -1;
27665     }).map(function(way2) {
27666       return vgraph.entity(way2.id);
27667     });
27668     var intersection2 = {
27669       graph: vgraph,
27670       actions,
27671       vertices,
27672       ways
27673     };
27674     intersection2.turns = function(fromWayId, maxViaWay) {
27675       if (!fromWayId) return [];
27676       if (!maxViaWay) maxViaWay = 0;
27677       var vgraph2 = intersection2.graph;
27678       var keyVertexIds = intersection2.vertices.map(function(v2) {
27679         return v2.id;
27680       });
27681       var start2 = vgraph2.entity(fromWayId);
27682       if (!start2 || !(start2.__from || start2.__via)) return [];
27683       var maxPathLength = maxViaWay * 2 + 3;
27684       var turns = [];
27685       step(start2);
27686       return turns;
27687       function step(entity, currPath, currRestrictions, matchedRestriction) {
27688         currPath = (currPath || []).slice();
27689         if (currPath.length >= maxPathLength) return;
27690         currPath.push(entity.id);
27691         currRestrictions = (currRestrictions || []).slice();
27692         if (entity.type === "node") {
27693           stepNode(entity, currPath, currRestrictions);
27694         } else {
27695           stepWay(entity, currPath, currRestrictions, matchedRestriction);
27696         }
27697       }
27698       function stepNode(entity, currPath, currRestrictions) {
27699         var i4, j3;
27700         var parents2 = vgraph2.parentWays(entity);
27701         var nextWays = [];
27702         for (i4 = 0; i4 < parents2.length; i4++) {
27703           var way2 = parents2[i4];
27704           if (way2.__oneWay && way2.nodes[0] !== entity.id) continue;
27705           if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3) continue;
27706           var restrict = null;
27707           for (j3 = 0; j3 < currRestrictions.length; j3++) {
27708             var restriction = currRestrictions[j3];
27709             var f2 = restriction.memberByRole("from");
27710             var v2 = restriction.membersByRole("via");
27711             var t2 = restriction.memberByRole("to");
27712             var isNo = /^no_/.test(restriction.tags.restriction);
27713             var isOnly = /^only_/.test(restriction.tags.restriction);
27714             if (!(isNo || isOnly)) {
27715               continue;
27716             }
27717             var matchesFrom = f2.id === fromWayId;
27718             var matchesViaTo = false;
27719             var isAlongOnlyPath = false;
27720             if (t2.id === way2.id) {
27721               if (v2.length === 1 && v2[0].type === "node") {
27722                 matchesViaTo = v2[0].id === entity.id && (matchesFrom && currPath.length === 2 || !matchesFrom && currPath.length > 2);
27723               } else {
27724                 var pathVias = [];
27725                 for (k2 = 2; k2 < currPath.length; k2 += 2) {
27726                   pathVias.push(currPath[k2]);
27727                 }
27728                 var restrictionVias = [];
27729                 for (k2 = 0; k2 < v2.length; k2++) {
27730                   if (v2[k2].type === "way") {
27731                     restrictionVias.push(v2[k2].id);
27732                   }
27733                 }
27734                 var diff = utilArrayDifference(pathVias, restrictionVias);
27735                 matchesViaTo = !diff.length;
27736               }
27737             } else if (isOnly) {
27738               for (k2 = 0; k2 < v2.length; k2++) {
27739                 if (v2[k2].type === "way" && v2[k2].id === way2.id) {
27740                   isAlongOnlyPath = true;
27741                   break;
27742                 }
27743               }
27744             }
27745             if (matchesViaTo) {
27746               if (isOnly) {
27747                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true };
27748               } else {
27749                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true };
27750               }
27751             } else {
27752               if (isAlongOnlyPath) {
27753                 restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false };
27754               } else if (isOnly) {
27755                 restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true };
27756               }
27757             }
27758             if (restrict && restrict.direct) break;
27759           }
27760           nextWays.push({ way: way2, restrict });
27761         }
27762         nextWays.forEach(function(nextWay) {
27763           step(nextWay.way, currPath, currRestrictions, nextWay.restrict);
27764         });
27765       }
27766       function stepWay(entity, currPath, currRestrictions, matchedRestriction) {
27767         var i4;
27768         if (currPath.length >= 3) {
27769           var turnPath = currPath.slice();
27770           if (matchedRestriction && matchedRestriction.direct === false) {
27771             for (i4 = 0; i4 < turnPath.length; i4++) {
27772               if (turnPath[i4] === matchedRestriction.from) {
27773                 turnPath = turnPath.slice(i4);
27774                 break;
27775               }
27776             }
27777           }
27778           var turn = pathToTurn(turnPath);
27779           if (turn) {
27780             if (matchedRestriction) {
27781               turn.restrictionID = matchedRestriction.id;
27782               turn.no = matchedRestriction.no;
27783               turn.only = matchedRestriction.only;
27784               turn.direct = matchedRestriction.direct;
27785             }
27786             turns.push(osmTurn(turn));
27787           }
27788           if (currPath[0] === currPath[2]) return;
27789         }
27790         if (matchedRestriction && matchedRestriction.end) return;
27791         var n1 = vgraph2.entity(entity.first());
27792         var n22 = vgraph2.entity(entity.last());
27793         var dist = geoSphericalDistance(n1.loc, n22.loc);
27794         var nextNodes = [];
27795         if (currPath.length > 1) {
27796           if (dist > maxDistance) return;
27797           if (!entity.__via) return;
27798         }
27799         if (!entity.__oneWay && // bidirectional..
27800         keyVertexIds.indexOf(n1.id) !== -1 && // key vertex..
27801         currPath.indexOf(n1.id) === -1) {
27802           nextNodes.push(n1);
27803         }
27804         if (keyVertexIds.indexOf(n22.id) !== -1 && // key vertex..
27805         currPath.indexOf(n22.id) === -1) {
27806           nextNodes.push(n22);
27807         }
27808         nextNodes.forEach(function(nextNode) {
27809           var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) {
27810             if (!r2.isRestriction()) return false;
27811             var f2 = r2.memberByRole("from");
27812             if (!f2 || f2.id !== entity.id) return false;
27813             var isOnly = /^only_/.test(r2.tags.restriction);
27814             if (!isOnly) return true;
27815             var isOnlyVia = false;
27816             var v2 = r2.membersByRole("via");
27817             if (v2.length === 1 && v2[0].type === "node") {
27818               isOnlyVia = v2[0].id === nextNode.id;
27819             } else {
27820               for (var i5 = 0; i5 < v2.length; i5++) {
27821                 if (v2[i5].type !== "way") continue;
27822                 var viaWay = vgraph2.entity(v2[i5].id);
27823                 if (viaWay.first() === nextNode.id || viaWay.last() === nextNode.id) {
27824                   isOnlyVia = true;
27825                   break;
27826                 }
27827               }
27828             }
27829             return isOnlyVia;
27830           });
27831           step(nextNode, currPath, currRestrictions.concat(fromRestrictions), false);
27832         });
27833       }
27834       function pathToTurn(path) {
27835         if (path.length < 3) return;
27836         var fromWayId2, fromNodeId, fromVertexId;
27837         var toWayId, toNodeId, toVertexId;
27838         var viaWayIds, viaNodeId, isUturn;
27839         fromWayId2 = path[0];
27840         toWayId = path[path.length - 1];
27841         if (path.length === 3 && fromWayId2 === toWayId) {
27842           var way2 = vgraph2.entity(fromWayId2);
27843           if (way2.__oneWay) return null;
27844           isUturn = true;
27845           viaNodeId = fromVertexId = toVertexId = path[1];
27846           fromNodeId = toNodeId = adjacentNode(fromWayId2, viaNodeId);
27847         } else {
27848           isUturn = false;
27849           fromVertexId = path[1];
27850           fromNodeId = adjacentNode(fromWayId2, fromVertexId);
27851           toVertexId = path[path.length - 2];
27852           toNodeId = adjacentNode(toWayId, toVertexId);
27853           if (path.length === 3) {
27854             viaNodeId = path[1];
27855           } else {
27856             viaWayIds = path.filter(function(entityId) {
27857               return entityId[0] === "w";
27858             });
27859             viaWayIds = viaWayIds.slice(1, viaWayIds.length - 1);
27860           }
27861         }
27862         return {
27863           key: path.join("_"),
27864           path,
27865           from: { node: fromNodeId, way: fromWayId2, vertex: fromVertexId },
27866           via: { node: viaNodeId, ways: viaWayIds },
27867           to: { node: toNodeId, way: toWayId, vertex: toVertexId },
27868           u: isUturn
27869         };
27870         function adjacentNode(wayId, affixId) {
27871           var nodes2 = vgraph2.entity(wayId).nodes;
27872           return affixId === nodes2[0] ? nodes2[1] : nodes2[nodes2.length - 2];
27873         }
27874       }
27875     };
27876     return intersection2;
27877   }
27878   function osmInferRestriction(graph, turn, projection2) {
27879     var fromWay = graph.entity(turn.from.way);
27880     var fromNode = graph.entity(turn.from.node);
27881     var fromVertex = graph.entity(turn.from.vertex);
27882     var toWay = graph.entity(turn.to.way);
27883     var toNode = graph.entity(turn.to.node);
27884     var toVertex = graph.entity(turn.to.vertex);
27885     var fromOneWay = fromWay.tags.oneway === "yes";
27886     var toOneWay = toWay.tags.oneway === "yes";
27887     var angle2 = (geoAngle(fromVertex, fromNode, projection2) - geoAngle(toVertex, toNode, projection2)) * 180 / Math.PI;
27888     while (angle2 < 0) {
27889       angle2 += 360;
27890     }
27891     if (fromNode === toNode) {
27892       return "no_u_turn";
27893     }
27894     if ((angle2 < 23 || angle2 > 336) && fromOneWay && toOneWay) {
27895       return "no_u_turn";
27896     }
27897     if ((angle2 < 40 || angle2 > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
27898       return "no_u_turn";
27899     }
27900     if (angle2 < 158) {
27901       return "no_right_turn";
27902     }
27903     if (angle2 > 202) {
27904       return "no_left_turn";
27905     }
27906     return "no_straight_on";
27907   }
27908
27909   // modules/actions/merge_polygon.js
27910   function actionMergePolygon(ids, newRelationId) {
27911     function groupEntities(graph) {
27912       var entities = ids.map(function(id2) {
27913         return graph.entity(id2);
27914       });
27915       var geometryGroups = utilArrayGroupBy(entities, function(entity) {
27916         if (entity.type === "way" && entity.isClosed()) {
27917           return "closedWay";
27918         } else if (entity.type === "relation" && entity.isMultipolygon()) {
27919           return "multipolygon";
27920         } else {
27921           return "other";
27922         }
27923       });
27924       return Object.assign(
27925         { closedWay: [], multipolygon: [], other: [] },
27926         geometryGroups
27927       );
27928     }
27929     var action = function(graph) {
27930       var entities = groupEntities(graph);
27931       var polygons = entities.multipolygon.reduce(function(polygons2, m2) {
27932         return polygons2.concat(osmJoinWays(m2.members, graph));
27933       }, []).concat(entities.closedWay.map(function(d2) {
27934         var member = [{ id: d2.id }];
27935         member.nodes = graph.childNodes(d2);
27936         return member;
27937       }));
27938       var contained = polygons.map(function(w2, i3) {
27939         return polygons.map(function(d2, n3) {
27940           if (i3 === n3) return null;
27941           return geoPolygonContainsPolygon(
27942             d2.nodes.map(function(n4) {
27943               return n4.loc;
27944             }),
27945             w2.nodes.map(function(n4) {
27946               return n4.loc;
27947             })
27948           );
27949         });
27950       });
27951       var members = [];
27952       var outer = true;
27953       while (polygons.length) {
27954         extractUncontained(polygons);
27955         polygons = polygons.filter(isContained);
27956         contained = contained.filter(isContained).map(filterContained);
27957       }
27958       function isContained(d2, i3) {
27959         return contained[i3].some(function(val) {
27960           return val;
27961         });
27962       }
27963       function filterContained(d2) {
27964         return d2.filter(isContained);
27965       }
27966       function extractUncontained(polygons2) {
27967         polygons2.forEach(function(d2, i3) {
27968           if (!isContained(d2, i3)) {
27969             d2.forEach(function(member) {
27970               members.push({
27971                 type: "way",
27972                 id: member.id,
27973                 role: outer ? "outer" : "inner"
27974               });
27975             });
27976           }
27977         });
27978         outer = !outer;
27979       }
27980       var relation;
27981       if (entities.multipolygon.length > 0) {
27982         var oldestID = utilOldestID(entities.multipolygon.map((entity) => entity.id));
27983         relation = entities.multipolygon.find((entity) => entity.id === oldestID);
27984       } else {
27985         relation = osmRelation({ id: newRelationId, tags: { type: "multipolygon" } });
27986       }
27987       entities.multipolygon.forEach(function(m2) {
27988         if (m2.id !== relation.id) {
27989           relation = relation.mergeTags(m2.tags);
27990           graph = graph.remove(m2);
27991         }
27992       });
27993       entities.closedWay.forEach(function(way) {
27994         function isThisOuter(m2) {
27995           return m2.id === way.id && m2.role !== "inner";
27996         }
27997         if (members.some(isThisOuter)) {
27998           relation = relation.mergeTags(way.tags);
27999           graph = graph.replace(way.update({ tags: {} }));
28000         }
28001       });
28002       return graph.replace(relation.update({
28003         members,
28004         tags: utilObjectOmit(relation.tags, ["area"])
28005       }));
28006     };
28007     action.disabled = function(graph) {
28008       var entities = groupEntities(graph);
28009       if (entities.other.length > 0 || entities.closedWay.length + entities.multipolygon.length < 2) {
28010         return "not_eligible";
28011       }
28012       if (!entities.multipolygon.every(function(r2) {
28013         return r2.isComplete(graph);
28014       })) {
28015         return "incomplete_relation";
28016       }
28017       if (!entities.multipolygon.length) {
28018         var sharedMultipolygons = [];
28019         entities.closedWay.forEach(function(way, i3) {
28020           if (i3 === 0) {
28021             sharedMultipolygons = graph.parentMultipolygons(way);
28022           } else {
28023             sharedMultipolygons = utilArrayIntersection(sharedMultipolygons, graph.parentMultipolygons(way));
28024           }
28025         });
28026         sharedMultipolygons = sharedMultipolygons.filter(function(relation) {
28027           return relation.members.length === entities.closedWay.length;
28028         });
28029         if (sharedMultipolygons.length) {
28030           return "not_eligible";
28031         }
28032       } else if (entities.closedWay.some(function(way) {
28033         return utilArrayIntersection(graph.parentMultipolygons(way), entities.multipolygon).length;
28034       })) {
28035         return "not_eligible";
28036       }
28037     };
28038     return action;
28039   }
28040
28041   // modules/actions/merge_remote_changes.js
28042   var import_fast_deep_equal = __toESM(require_fast_deep_equal());
28043
28044   // node_modules/node-diff3/index.mjs
28045   function LCS(buffer1, buffer2) {
28046     let equivalenceClasses = {};
28047     for (let j2 = 0; j2 < buffer2.length; j2++) {
28048       const item = buffer2[j2];
28049       if (equivalenceClasses[item]) {
28050         equivalenceClasses[item].push(j2);
28051       } else {
28052         equivalenceClasses[item] = [j2];
28053       }
28054     }
28055     const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null };
28056     let candidates = [NULLRESULT];
28057     for (let i3 = 0; i3 < buffer1.length; i3++) {
28058       const item = buffer1[i3];
28059       const buffer2indices = equivalenceClasses[item] || [];
28060       let r2 = 0;
28061       let c2 = candidates[0];
28062       for (let jx = 0; jx < buffer2indices.length; jx++) {
28063         const j2 = buffer2indices[jx];
28064         let s2;
28065         for (s2 = r2; s2 < candidates.length; s2++) {
28066           if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) {
28067             break;
28068           }
28069         }
28070         if (s2 < candidates.length) {
28071           const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] };
28072           if (r2 === candidates.length) {
28073             candidates.push(c2);
28074           } else {
28075             candidates[r2] = c2;
28076           }
28077           r2 = s2 + 1;
28078           c2 = newCandidate;
28079           if (r2 === candidates.length) {
28080             break;
28081           }
28082         }
28083       }
28084       candidates[r2] = c2;
28085     }
28086     return candidates[candidates.length - 1];
28087   }
28088   function diffIndices(buffer1, buffer2) {
28089     const lcs = LCS(buffer1, buffer2);
28090     let result = [];
28091     let tail1 = buffer1.length;
28092     let tail2 = buffer2.length;
28093     for (let candidate = lcs; candidate !== null; candidate = candidate.chain) {
28094       const mismatchLength1 = tail1 - candidate.buffer1index - 1;
28095       const mismatchLength2 = tail2 - candidate.buffer2index - 1;
28096       tail1 = candidate.buffer1index;
28097       tail2 = candidate.buffer2index;
28098       if (mismatchLength1 || mismatchLength2) {
28099         result.push({
28100           buffer1: [tail1 + 1, mismatchLength1],
28101           buffer1Content: buffer1.slice(tail1 + 1, tail1 + 1 + mismatchLength1),
28102           buffer2: [tail2 + 1, mismatchLength2],
28103           buffer2Content: buffer2.slice(tail2 + 1, tail2 + 1 + mismatchLength2)
28104         });
28105       }
28106     }
28107     result.reverse();
28108     return result;
28109   }
28110   function diff3MergeRegions(a2, o2, b2) {
28111     let hunks = [];
28112     function addHunk(h2, ab) {
28113       hunks.push({
28114         ab,
28115         oStart: h2.buffer1[0],
28116         oLength: h2.buffer1[1],
28117         // length of o to remove
28118         abStart: h2.buffer2[0],
28119         abLength: h2.buffer2[1]
28120         // length of a/b to insert
28121         // abContent: (ab === 'a' ? a : b).slice(h.buffer2[0], h.buffer2[0] + h.buffer2[1])
28122       });
28123     }
28124     diffIndices(o2, a2).forEach((item) => addHunk(item, "a"));
28125     diffIndices(o2, b2).forEach((item) => addHunk(item, "b"));
28126     hunks.sort((x2, y2) => x2.oStart - y2.oStart);
28127     let results = [];
28128     let currOffset = 0;
28129     function advanceTo(endOffset) {
28130       if (endOffset > currOffset) {
28131         results.push({
28132           stable: true,
28133           buffer: "o",
28134           bufferStart: currOffset,
28135           bufferLength: endOffset - currOffset,
28136           bufferContent: o2.slice(currOffset, endOffset)
28137         });
28138         currOffset = endOffset;
28139       }
28140     }
28141     while (hunks.length) {
28142       let hunk = hunks.shift();
28143       let regionStart = hunk.oStart;
28144       let regionEnd = hunk.oStart + hunk.oLength;
28145       let regionHunks = [hunk];
28146       advanceTo(regionStart);
28147       while (hunks.length) {
28148         const nextHunk = hunks[0];
28149         const nextHunkStart = nextHunk.oStart;
28150         if (nextHunkStart > regionEnd) break;
28151         regionEnd = Math.max(regionEnd, nextHunkStart + nextHunk.oLength);
28152         regionHunks.push(hunks.shift());
28153       }
28154       if (regionHunks.length === 1) {
28155         if (hunk.abLength > 0) {
28156           const buffer = hunk.ab === "a" ? a2 : b2;
28157           results.push({
28158             stable: true,
28159             buffer: hunk.ab,
28160             bufferStart: hunk.abStart,
28161             bufferLength: hunk.abLength,
28162             bufferContent: buffer.slice(hunk.abStart, hunk.abStart + hunk.abLength)
28163           });
28164         }
28165       } else {
28166         let bounds = {
28167           a: [a2.length, -1, o2.length, -1],
28168           b: [b2.length, -1, o2.length, -1]
28169         };
28170         while (regionHunks.length) {
28171           hunk = regionHunks.shift();
28172           const oStart = hunk.oStart;
28173           const oEnd = oStart + hunk.oLength;
28174           const abStart = hunk.abStart;
28175           const abEnd = abStart + hunk.abLength;
28176           let b3 = bounds[hunk.ab];
28177           b3[0] = Math.min(abStart, b3[0]);
28178           b3[1] = Math.max(abEnd, b3[1]);
28179           b3[2] = Math.min(oStart, b3[2]);
28180           b3[3] = Math.max(oEnd, b3[3]);
28181         }
28182         const aStart = bounds.a[0] + (regionStart - bounds.a[2]);
28183         const aEnd = bounds.a[1] + (regionEnd - bounds.a[3]);
28184         const bStart = bounds.b[0] + (regionStart - bounds.b[2]);
28185         const bEnd = bounds.b[1] + (regionEnd - bounds.b[3]);
28186         let result = {
28187           stable: false,
28188           aStart,
28189           aLength: aEnd - aStart,
28190           aContent: a2.slice(aStart, aEnd),
28191           oStart: regionStart,
28192           oLength: regionEnd - regionStart,
28193           oContent: o2.slice(regionStart, regionEnd),
28194           bStart,
28195           bLength: bEnd - bStart,
28196           bContent: b2.slice(bStart, bEnd)
28197         };
28198         results.push(result);
28199       }
28200       currOffset = regionEnd;
28201     }
28202     advanceTo(o2.length);
28203     return results;
28204   }
28205   function diff3Merge(a2, o2, b2, options2) {
28206     let defaults = {
28207       excludeFalseConflicts: true,
28208       stringSeparator: /\s+/
28209     };
28210     options2 = Object.assign(defaults, options2);
28211     if (typeof a2 === "string") a2 = a2.split(options2.stringSeparator);
28212     if (typeof o2 === "string") o2 = o2.split(options2.stringSeparator);
28213     if (typeof b2 === "string") b2 = b2.split(options2.stringSeparator);
28214     let results = [];
28215     const regions = diff3MergeRegions(a2, o2, b2);
28216     let okBuffer = [];
28217     function flushOk() {
28218       if (okBuffer.length) {
28219         results.push({ ok: okBuffer });
28220       }
28221       okBuffer = [];
28222     }
28223     function isFalseConflict(a3, b3) {
28224       if (a3.length !== b3.length) return false;
28225       for (let i3 = 0; i3 < a3.length; i3++) {
28226         if (a3[i3] !== b3[i3]) return false;
28227       }
28228       return true;
28229     }
28230     regions.forEach((region) => {
28231       if (region.stable) {
28232         okBuffer.push(...region.bufferContent);
28233       } else {
28234         if (options2.excludeFalseConflicts && isFalseConflict(region.aContent, region.bContent)) {
28235           okBuffer.push(...region.aContent);
28236         } else {
28237           flushOk();
28238           results.push({
28239             conflict: {
28240               a: region.aContent,
28241               aIndex: region.aStart,
28242               o: region.oContent,
28243               oIndex: region.oStart,
28244               b: region.bContent,
28245               bIndex: region.bStart
28246             }
28247           });
28248         }
28249       }
28250     });
28251     flushOk();
28252     return results;
28253   }
28254
28255   // modules/actions/merge_remote_changes.js
28256   var import_lodash = __toESM(require_lodash());
28257   function actionMergeRemoteChanges(id2, localGraph, remoteGraph, discardTags, formatUser) {
28258     discardTags = discardTags || {};
28259     var _option = "safe";
28260     var _conflicts = [];
28261     function user(d2) {
28262       return typeof formatUser === "function" ? formatUser(d2) : (0, import_lodash.escape)(d2);
28263     }
28264     function mergeLocation(remote, target) {
28265       function pointEqual(a2, b2) {
28266         var epsilon3 = 1e-6;
28267         return Math.abs(a2[0] - b2[0]) < epsilon3 && Math.abs(a2[1] - b2[1]) < epsilon3;
28268       }
28269       if (_option === "force_local" || pointEqual(target.loc, remote.loc)) {
28270         return target;
28271       }
28272       if (_option === "force_remote") {
28273         return target.update({ loc: remote.loc });
28274       }
28275       _conflicts.push(_t.html("merge_remote_changes.conflict.location", { user: { html: user(remote.user) } }));
28276       return target;
28277     }
28278     function mergeNodes(base, remote, target) {
28279       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.nodes, remote.nodes)) {
28280         return target;
28281       }
28282       if (_option === "force_remote") {
28283         return target.update({ nodes: remote.nodes });
28284       }
28285       var ccount = _conflicts.length;
28286       var o2 = base.nodes || [];
28287       var a2 = target.nodes || [];
28288       var b2 = remote.nodes || [];
28289       var nodes = [];
28290       var hunks = diff3Merge(a2, o2, b2, { excludeFalseConflicts: true });
28291       for (var i3 = 0; i3 < hunks.length; i3++) {
28292         var hunk = hunks[i3];
28293         if (hunk.ok) {
28294           nodes.push.apply(nodes, hunk.ok);
28295         } else {
28296           var c2 = hunk.conflict;
28297           if ((0, import_fast_deep_equal.default)(c2.o, c2.a)) {
28298             nodes.push.apply(nodes, c2.b);
28299           } else if ((0, import_fast_deep_equal.default)(c2.o, c2.b)) {
28300             nodes.push.apply(nodes, c2.a);
28301           } else {
28302             _conflicts.push(_t.html("merge_remote_changes.conflict.nodelist", { user: { html: user(remote.user) } }));
28303             break;
28304           }
28305         }
28306       }
28307       return _conflicts.length === ccount ? target.update({ nodes }) : target;
28308     }
28309     function mergeChildren(targetWay, children2, updates, graph) {
28310       function isUsed(node2, targetWay2) {
28311         var hasInterestingParent = graph.parentWays(node2).some(function(way) {
28312           return way.id !== targetWay2.id;
28313         });
28314         return node2.hasInterestingTags() || hasInterestingParent || graph.parentRelations(node2).length > 0;
28315       }
28316       var ccount = _conflicts.length;
28317       for (var i3 = 0; i3 < children2.length; i3++) {
28318         var id3 = children2[i3];
28319         var node = graph.hasEntity(id3);
28320         if (targetWay.nodes.indexOf(id3) === -1) {
28321           if (node && !isUsed(node, targetWay)) {
28322             updates.removeIds.push(id3);
28323           }
28324           continue;
28325         }
28326         var local = localGraph.hasEntity(id3);
28327         var remote = remoteGraph.hasEntity(id3);
28328         var target;
28329         if (_option === "force_remote" && remote && remote.visible) {
28330           updates.replacements.push(remote);
28331         } else if (_option === "force_local" && local) {
28332           target = osmEntity(local);
28333           if (remote) {
28334             target = target.update({ version: remote.version });
28335           }
28336           updates.replacements.push(target);
28337         } else if (_option === "safe" && local && remote && local.version !== remote.version) {
28338           target = osmEntity(local, { version: remote.version });
28339           if (remote.visible) {
28340             target = mergeLocation(remote, target);
28341           } else {
28342             _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
28343           }
28344           if (_conflicts.length !== ccount) break;
28345           updates.replacements.push(target);
28346         }
28347       }
28348       return targetWay;
28349     }
28350     function updateChildren(updates, graph) {
28351       for (var i3 = 0; i3 < updates.replacements.length; i3++) {
28352         graph = graph.replace(updates.replacements[i3]);
28353       }
28354       if (updates.removeIds.length) {
28355         graph = actionDeleteMultiple(updates.removeIds)(graph);
28356       }
28357       return graph;
28358     }
28359     function mergeMembers(remote, target) {
28360       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.members, remote.members)) {
28361         return target;
28362       }
28363       if (_option === "force_remote") {
28364         return target.update({ members: remote.members });
28365       }
28366       _conflicts.push(_t.html("merge_remote_changes.conflict.memberlist", { user: { html: user(remote.user) } }));
28367       return target;
28368     }
28369     function mergeTags(base, remote, target) {
28370       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.tags, remote.tags)) {
28371         return target;
28372       }
28373       if (_option === "force_remote") {
28374         return target.update({ tags: remote.tags });
28375       }
28376       var ccount = _conflicts.length;
28377       var o2 = base.tags || {};
28378       var a2 = target.tags || {};
28379       var b2 = remote.tags || {};
28380       var keys2 = utilArrayUnion(utilArrayUnion(Object.keys(o2), Object.keys(a2)), Object.keys(b2)).filter(function(k3) {
28381         return !discardTags[k3];
28382       });
28383       var tags = Object.assign({}, a2);
28384       var changed = false;
28385       for (var i3 = 0; i3 < keys2.length; i3++) {
28386         var k2 = keys2[i3];
28387         if (o2[k2] !== b2[k2] && a2[k2] !== b2[k2]) {
28388           if (o2[k2] !== a2[k2]) {
28389             _conflicts.push(_t.html(
28390               "merge_remote_changes.conflict.tags",
28391               { tag: k2, local: a2[k2], remote: b2[k2], user: { html: user(remote.user) } }
28392             ));
28393           } else {
28394             if (b2.hasOwnProperty(k2)) {
28395               tags[k2] = b2[k2];
28396             } else {
28397               delete tags[k2];
28398             }
28399             changed = true;
28400           }
28401         }
28402       }
28403       return changed && _conflicts.length === ccount ? target.update({ tags }) : target;
28404     }
28405     var action = function(graph) {
28406       var updates = { replacements: [], removeIds: [] };
28407       var base = graph.base().entities[id2];
28408       var local = localGraph.entity(id2);
28409       var remote = remoteGraph.entity(id2);
28410       var target = osmEntity(local, { version: remote.version });
28411       if (!remote.visible) {
28412         if (_option === "force_remote") {
28413           return actionDeleteMultiple([id2])(graph);
28414         } else if (_option === "force_local") {
28415           if (target.type === "way") {
28416             target = mergeChildren(target, utilArrayUniq(local.nodes), updates, graph);
28417             graph = updateChildren(updates, graph);
28418           }
28419           return graph.replace(target);
28420         } else {
28421           _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
28422           return graph;
28423         }
28424       }
28425       if (target.type === "node") {
28426         target = mergeLocation(remote, target);
28427       } else if (target.type === "way") {
28428         graph.rebase(remoteGraph.childNodes(remote), [graph], false);
28429         target = mergeNodes(base, remote, target);
28430         target = mergeChildren(target, utilArrayUnion(local.nodes, remote.nodes), updates, graph);
28431       } else if (target.type === "relation") {
28432         target = mergeMembers(remote, target);
28433       }
28434       target = mergeTags(base, remote, target);
28435       if (!_conflicts.length) {
28436         graph = updateChildren(updates, graph).replace(target);
28437       }
28438       return graph;
28439     };
28440     action.withOption = function(opt) {
28441       _option = opt;
28442       return action;
28443     };
28444     action.conflicts = function() {
28445       return _conflicts;
28446     };
28447     return action;
28448   }
28449
28450   // modules/actions/move.js
28451   function actionMove(moveIDs, tryDelta, projection2, cache) {
28452     var _delta = tryDelta;
28453     function setupCache(graph) {
28454       function canMove(nodeID) {
28455         if (moveIDs.indexOf(nodeID) !== -1) return true;
28456         var parents = graph.parentWays(graph.entity(nodeID));
28457         if (parents.length < 3) return true;
28458         var parentsMoving = parents.every(function(way) {
28459           return cache.moving[way.id];
28460         });
28461         if (!parentsMoving) delete cache.moving[nodeID];
28462         return parentsMoving;
28463       }
28464       function cacheEntities(ids) {
28465         for (var i3 = 0; i3 < ids.length; i3++) {
28466           var id2 = ids[i3];
28467           if (cache.moving[id2]) continue;
28468           cache.moving[id2] = true;
28469           var entity = graph.hasEntity(id2);
28470           if (!entity) continue;
28471           if (entity.type === "node") {
28472             cache.nodes.push(id2);
28473             cache.startLoc[id2] = entity.loc;
28474           } else if (entity.type === "way") {
28475             cache.ways.push(id2);
28476             cacheEntities(entity.nodes);
28477           } else {
28478             cacheEntities(entity.members.map(function(member) {
28479               return member.id;
28480             }));
28481           }
28482         }
28483       }
28484       function cacheIntersections(ids) {
28485         function isEndpoint(way2, id3) {
28486           return !way2.isClosed() && !!way2.affix(id3);
28487         }
28488         for (var i3 = 0; i3 < ids.length; i3++) {
28489           var id2 = ids[i3];
28490           var childNodes = graph.childNodes(graph.entity(id2));
28491           for (var j2 = 0; j2 < childNodes.length; j2++) {
28492             var node = childNodes[j2];
28493             var parents = graph.parentWays(node);
28494             if (parents.length !== 2) continue;
28495             var moved = graph.entity(id2);
28496             var unmoved = null;
28497             for (var k2 = 0; k2 < parents.length; k2++) {
28498               var way = parents[k2];
28499               if (!cache.moving[way.id]) {
28500                 unmoved = way;
28501                 break;
28502               }
28503             }
28504             if (!unmoved) continue;
28505             if (utilArrayIntersection(moved.nodes, unmoved.nodes).length > 2) continue;
28506             if (moved.isArea() || unmoved.isArea()) continue;
28507             cache.intersections.push({
28508               nodeId: node.id,
28509               movedId: moved.id,
28510               unmovedId: unmoved.id,
28511               movedIsEP: isEndpoint(moved, node.id),
28512               unmovedIsEP: isEndpoint(unmoved, node.id)
28513             });
28514           }
28515         }
28516       }
28517       if (!cache) {
28518         cache = {};
28519       }
28520       if (!cache.ok) {
28521         cache.moving = {};
28522         cache.intersections = [];
28523         cache.replacedVertex = {};
28524         cache.startLoc = {};
28525         cache.nodes = [];
28526         cache.ways = [];
28527         cacheEntities(moveIDs);
28528         cacheIntersections(cache.ways);
28529         cache.nodes = cache.nodes.filter(canMove);
28530         cache.ok = true;
28531       }
28532     }
28533     function replaceMovedVertex(nodeId, wayId, graph, delta) {
28534       var way = graph.entity(wayId);
28535       var moved = graph.entity(nodeId);
28536       var movedIndex = way.nodes.indexOf(nodeId);
28537       var len, prevIndex, nextIndex;
28538       if (way.isClosed()) {
28539         len = way.nodes.length - 1;
28540         prevIndex = (movedIndex + len - 1) % len;
28541         nextIndex = (movedIndex + len + 1) % len;
28542       } else {
28543         len = way.nodes.length;
28544         prevIndex = movedIndex - 1;
28545         nextIndex = movedIndex + 1;
28546       }
28547       var prev = graph.hasEntity(way.nodes[prevIndex]);
28548       var next = graph.hasEntity(way.nodes[nextIndex]);
28549       if (!prev || !next) return graph;
28550       var key = wayId + "_" + nodeId;
28551       var orig = cache.replacedVertex[key];
28552       if (!orig) {
28553         orig = osmNode();
28554         cache.replacedVertex[key] = orig;
28555         cache.startLoc[orig.id] = cache.startLoc[nodeId];
28556       }
28557       var start2, end;
28558       if (delta) {
28559         start2 = projection2(cache.startLoc[nodeId]);
28560         end = projection2.invert(geoVecAdd(start2, delta));
28561       } else {
28562         end = cache.startLoc[nodeId];
28563       }
28564       orig = orig.move(end);
28565       var angle2 = Math.abs(geoAngle(orig, prev, projection2) - geoAngle(orig, next, projection2)) * 180 / Math.PI;
28566       if (angle2 > 175 && angle2 < 185) return graph;
28567       var p1 = [prev.loc, orig.loc, moved.loc, next.loc].map(projection2);
28568       var p2 = [prev.loc, moved.loc, orig.loc, next.loc].map(projection2);
28569       var d1 = geoPathLength(p1);
28570       var d2 = geoPathLength(p2);
28571       var insertAt = d1 <= d2 ? movedIndex : nextIndex;
28572       if (way.isClosed() && insertAt === 0) insertAt = len;
28573       way = way.addNode(orig.id, insertAt);
28574       return graph.replace(orig).replace(way);
28575     }
28576     function removeDuplicateVertices(wayId, graph) {
28577       var way = graph.entity(wayId);
28578       var epsilon3 = 1e-6;
28579       var prev, curr;
28580       function isInteresting(node, graph2) {
28581         return graph2.parentWays(node).length > 1 || graph2.parentRelations(node).length || node.hasInterestingTags();
28582       }
28583       for (var i3 = 0; i3 < way.nodes.length; i3++) {
28584         curr = graph.entity(way.nodes[i3]);
28585         if (prev && curr && geoVecEqual(prev.loc, curr.loc, epsilon3)) {
28586           if (!isInteresting(prev, graph)) {
28587             way = way.removeNode(prev.id);
28588             graph = graph.replace(way).remove(prev);
28589           } else if (!isInteresting(curr, graph)) {
28590             way = way.removeNode(curr.id);
28591             graph = graph.replace(way).remove(curr);
28592           }
28593         }
28594         prev = curr;
28595       }
28596       return graph;
28597     }
28598     function unZorroIntersection(intersection2, graph) {
28599       var vertex = graph.entity(intersection2.nodeId);
28600       var way1 = graph.entity(intersection2.movedId);
28601       var way2 = graph.entity(intersection2.unmovedId);
28602       var isEP1 = intersection2.movedIsEP;
28603       var isEP2 = intersection2.unmovedIsEP;
28604       if (isEP1 && isEP2) return graph;
28605       var nodes1 = graph.childNodes(way1).filter(function(n3) {
28606         return n3 !== vertex;
28607       });
28608       var nodes2 = graph.childNodes(way2).filter(function(n3) {
28609         return n3 !== vertex;
28610       });
28611       if (way1.isClosed() && way1.first() === vertex.id) nodes1.push(nodes1[0]);
28612       if (way2.isClosed() && way2.first() === vertex.id) nodes2.push(nodes2[0]);
28613       var edge1 = !isEP1 && geoChooseEdge(nodes1, projection2(vertex.loc), projection2);
28614       var edge2 = !isEP2 && geoChooseEdge(nodes2, projection2(vertex.loc), projection2);
28615       var loc;
28616       if (!isEP1 && !isEP2) {
28617         var epsilon3 = 1e-6, maxIter = 10;
28618         for (var i3 = 0; i3 < maxIter; i3++) {
28619           loc = geoVecInterp(edge1.loc, edge2.loc, 0.5);
28620           edge1 = geoChooseEdge(nodes1, projection2(loc), projection2);
28621           edge2 = geoChooseEdge(nodes2, projection2(loc), projection2);
28622           if (Math.abs(edge1.distance - edge2.distance) < epsilon3) break;
28623         }
28624       } else if (!isEP1) {
28625         loc = edge1.loc;
28626       } else {
28627         loc = edge2.loc;
28628       }
28629       graph = graph.replace(vertex.move(loc));
28630       if (!isEP1 && edge1.index !== way1.nodes.indexOf(vertex.id)) {
28631         way1 = way1.removeNode(vertex.id).addNode(vertex.id, edge1.index);
28632         graph = graph.replace(way1);
28633       }
28634       if (!isEP2 && edge2.index !== way2.nodes.indexOf(vertex.id)) {
28635         way2 = way2.removeNode(vertex.id).addNode(vertex.id, edge2.index);
28636         graph = graph.replace(way2);
28637       }
28638       return graph;
28639     }
28640     function cleanupIntersections(graph) {
28641       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
28642         var obj = cache.intersections[i3];
28643         graph = replaceMovedVertex(obj.nodeId, obj.movedId, graph, _delta);
28644         graph = replaceMovedVertex(obj.nodeId, obj.unmovedId, graph, null);
28645         graph = unZorroIntersection(obj, graph);
28646         graph = removeDuplicateVertices(obj.movedId, graph);
28647         graph = removeDuplicateVertices(obj.unmovedId, graph);
28648       }
28649       return graph;
28650     }
28651     function limitDelta(graph) {
28652       function moveNode(loc) {
28653         return geoVecAdd(projection2(loc), _delta);
28654       }
28655       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
28656         var obj = cache.intersections[i3];
28657         if (obj.movedIsEP && obj.unmovedIsEP) continue;
28658         if (!obj.movedIsEP) continue;
28659         var node = graph.entity(obj.nodeId);
28660         var start2 = projection2(node.loc);
28661         var end = geoVecAdd(start2, _delta);
28662         var movedNodes = graph.childNodes(graph.entity(obj.movedId));
28663         var movedPath = movedNodes.map(function(n3) {
28664           return moveNode(n3.loc);
28665         });
28666         var unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId));
28667         var unmovedPath = unmovedNodes.map(function(n3) {
28668           return projection2(n3.loc);
28669         });
28670         var hits = geoPathIntersections(movedPath, unmovedPath);
28671         for (var j2 = 0; i3 < hits.length; i3++) {
28672           if (geoVecEqual(hits[j2], end)) continue;
28673           var edge = geoChooseEdge(unmovedNodes, end, projection2);
28674           _delta = geoVecSubtract(projection2(edge.loc), start2);
28675         }
28676       }
28677     }
28678     var action = function(graph) {
28679       if (_delta[0] === 0 && _delta[1] === 0) return graph;
28680       setupCache(graph);
28681       if (cache.intersections.length) {
28682         limitDelta(graph);
28683       }
28684       for (var i3 = 0; i3 < cache.nodes.length; i3++) {
28685         var node = graph.entity(cache.nodes[i3]);
28686         var start2 = projection2(node.loc);
28687         var end = geoVecAdd(start2, _delta);
28688         graph = graph.replace(node.move(projection2.invert(end)));
28689       }
28690       if (cache.intersections.length) {
28691         graph = cleanupIntersections(graph);
28692       }
28693       return graph;
28694     };
28695     action.delta = function() {
28696       return _delta;
28697     };
28698     return action;
28699   }
28700
28701   // modules/actions/move_member.js
28702   function actionMoveMember(relationId, fromIndex, toIndex) {
28703     return function(graph) {
28704       return graph.replace(graph.entity(relationId).moveMember(fromIndex, toIndex));
28705     };
28706   }
28707
28708   // modules/actions/move_node.js
28709   function actionMoveNode(nodeID, toLoc) {
28710     var action = function(graph, t2) {
28711       if (t2 === null || !isFinite(t2)) t2 = 1;
28712       t2 = Math.min(Math.max(+t2, 0), 1);
28713       var node = graph.entity(nodeID);
28714       return graph.replace(
28715         node.move(geoVecInterp(node.loc, toLoc, t2))
28716       );
28717     };
28718     action.transitionable = true;
28719     return action;
28720   }
28721
28722   // modules/actions/noop.js
28723   function actionNoop() {
28724     return function(graph) {
28725       return graph;
28726     };
28727   }
28728
28729   // modules/actions/orthogonalize.js
28730   function actionOrthogonalize(wayID, projection2, vertexID, degThresh, ep) {
28731     var epsilon3 = ep || 1e-4;
28732     var threshold = degThresh || 13;
28733     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
28734     var upperThreshold = Math.cos(threshold * Math.PI / 180);
28735     var action = function(graph, t2) {
28736       if (t2 === null || !isFinite(t2)) t2 = 1;
28737       t2 = Math.min(Math.max(+t2, 0), 1);
28738       var way = graph.entity(wayID);
28739       way = way.removeNode("");
28740       if (way.tags.nonsquare) {
28741         var tags = Object.assign({}, way.tags);
28742         delete tags.nonsquare;
28743         way = way.update({ tags });
28744       }
28745       graph = graph.replace(way);
28746       var isClosed = way.isClosed();
28747       var nodes = graph.childNodes(way).slice();
28748       if (isClosed) nodes.pop();
28749       if (vertexID !== void 0) {
28750         nodes = nodeSubset(nodes, vertexID, isClosed);
28751         if (nodes.length !== 3) return graph;
28752       }
28753       var nodeCount = {};
28754       var points = [];
28755       var corner = { i: 0, dotp: 1 };
28756       var node, point, loc, score, motions, i3, j2;
28757       for (i3 = 0; i3 < nodes.length; i3++) {
28758         node = nodes[i3];
28759         nodeCount[node.id] = (nodeCount[node.id] || 0) + 1;
28760         points.push({ id: node.id, coord: projection2(node.loc) });
28761       }
28762       if (points.length === 3) {
28763         for (i3 = 0; i3 < 1e3; i3++) {
28764           motions = points.map(calcMotion);
28765           points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]);
28766           score = corner.dotp;
28767           if (score < epsilon3) {
28768             break;
28769           }
28770         }
28771         node = graph.entity(nodes[corner.i].id);
28772         loc = projection2.invert(points[corner.i].coord);
28773         graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28774       } else {
28775         var straights = [];
28776         var simplified = [];
28777         for (i3 = 0; i3 < points.length; i3++) {
28778           point = points[i3];
28779           var dotp = 0;
28780           if (isClosed || i3 > 0 && i3 < points.length - 1) {
28781             var a2 = points[(i3 - 1 + points.length) % points.length];
28782             var b2 = points[(i3 + 1) % points.length];
28783             dotp = Math.abs(geoOrthoNormalizedDotProduct(a2.coord, b2.coord, point.coord));
28784           }
28785           if (dotp > upperThreshold) {
28786             straights.push(point);
28787           } else {
28788             simplified.push(point);
28789           }
28790         }
28791         var bestPoints = clonePoints(simplified);
28792         var originalPoints = clonePoints(simplified);
28793         score = Infinity;
28794         for (i3 = 0; i3 < 1e3; i3++) {
28795           motions = simplified.map(calcMotion);
28796           for (j2 = 0; j2 < motions.length; j2++) {
28797             simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]);
28798           }
28799           var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold);
28800           if (newScore < score) {
28801             bestPoints = clonePoints(simplified);
28802             score = newScore;
28803           }
28804           if (score < epsilon3) {
28805             break;
28806           }
28807         }
28808         var bestCoords = bestPoints.map(function(p2) {
28809           return p2.coord;
28810         });
28811         if (isClosed) bestCoords.push(bestCoords[0]);
28812         for (i3 = 0; i3 < bestPoints.length; i3++) {
28813           point = bestPoints[i3];
28814           if (!geoVecEqual(originalPoints[i3].coord, point.coord)) {
28815             node = graph.entity(point.id);
28816             loc = projection2.invert(point.coord);
28817             graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28818           }
28819         }
28820         for (i3 = 0; i3 < straights.length; i3++) {
28821           point = straights[i3];
28822           if (nodeCount[point.id] > 1) continue;
28823           node = graph.entity(point.id);
28824           if (t2 === 1 && graph.parentWays(node).length === 1 && graph.parentRelations(node).length === 0 && !node.hasInterestingTags()) {
28825             graph = actionDeleteNode(node.id)(graph);
28826           } else {
28827             var choice = geoVecProject(point.coord, bestCoords);
28828             if (choice) {
28829               loc = projection2.invert(choice.target);
28830               graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28831             }
28832           }
28833         }
28834       }
28835       return graph;
28836       function clonePoints(array2) {
28837         return array2.map(function(p2) {
28838           return { id: p2.id, coord: [p2.coord[0], p2.coord[1]] };
28839         });
28840       }
28841       function calcMotion(point2, i4, array2) {
28842         if (!isClosed && (i4 === 0 || i4 === array2.length - 1)) return [0, 0];
28843         if (nodeCount[array2[i4].id] > 1) return [0, 0];
28844         var a3 = array2[(i4 - 1 + array2.length) % array2.length].coord;
28845         var origin = point2.coord;
28846         var b3 = array2[(i4 + 1) % array2.length].coord;
28847         var p2 = geoVecSubtract(a3, origin);
28848         var q2 = geoVecSubtract(b3, origin);
28849         var scale = 2 * Math.min(geoVecLength(p2), geoVecLength(q2));
28850         p2 = geoVecNormalize(p2);
28851         q2 = geoVecNormalize(q2);
28852         var dotp2 = p2[0] * q2[0] + p2[1] * q2[1];
28853         var val = Math.abs(dotp2);
28854         if (val < lowerThreshold) {
28855           corner.i = i4;
28856           corner.dotp = val;
28857           var vec = geoVecNormalize(geoVecAdd(p2, q2));
28858           return geoVecScale(vec, 0.1 * dotp2 * scale);
28859         }
28860         return [0, 0];
28861       }
28862     };
28863     function nodeSubset(nodes, vertexID2, isClosed) {
28864       var first = isClosed ? 0 : 1;
28865       var last = isClosed ? nodes.length : nodes.length - 1;
28866       for (var i3 = first; i3 < last; i3++) {
28867         if (nodes[i3].id === vertexID2) {
28868           return [
28869             nodes[(i3 - 1 + nodes.length) % nodes.length],
28870             nodes[i3],
28871             nodes[(i3 + 1) % nodes.length]
28872           ];
28873         }
28874       }
28875       return [];
28876     }
28877     action.disabled = function(graph) {
28878       var way = graph.entity(wayID);
28879       way = way.removeNode("");
28880       graph = graph.replace(way);
28881       var isClosed = way.isClosed();
28882       var nodes = graph.childNodes(way).slice();
28883       if (isClosed) nodes.pop();
28884       var allowStraightAngles = false;
28885       if (vertexID !== void 0) {
28886         allowStraightAngles = true;
28887         nodes = nodeSubset(nodes, vertexID, isClosed);
28888         if (nodes.length !== 3) return "end_vertex";
28889       }
28890       var coords = nodes.map(function(n3) {
28891         return projection2(n3.loc);
28892       });
28893       var score = geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles);
28894       if (score === null) {
28895         return "not_squarish";
28896       } else if (score === 0) {
28897         return "square_enough";
28898       } else {
28899         return false;
28900       }
28901     };
28902     action.transitionable = true;
28903     return action;
28904   }
28905
28906   // modules/actions/restrict_turn.js
28907   function actionRestrictTurn(turn, restrictionType, restrictionID) {
28908     return function(graph) {
28909       var fromWay = graph.entity(turn.from.way);
28910       var toWay = graph.entity(turn.to.way);
28911       var viaNode = turn.via.node && graph.entity(turn.via.node);
28912       var viaWays = turn.via.ways && turn.via.ways.map(function(id2) {
28913         return graph.entity(id2);
28914       });
28915       var members = [];
28916       members.push({ id: fromWay.id, type: "way", role: "from" });
28917       if (viaNode) {
28918         members.push({ id: viaNode.id, type: "node", role: "via" });
28919       } else if (viaWays) {
28920         viaWays.forEach(function(viaWay) {
28921           members.push({ id: viaWay.id, type: "way", role: "via" });
28922         });
28923       }
28924       members.push({ id: toWay.id, type: "way", role: "to" });
28925       return graph.replace(osmRelation({
28926         id: restrictionID,
28927         tags: {
28928           type: "restriction",
28929           restriction: restrictionType
28930         },
28931         members
28932       }));
28933     };
28934   }
28935
28936   // modules/actions/revert.js
28937   function actionRevert(id2) {
28938     var action = function(graph) {
28939       var entity = graph.hasEntity(id2), base = graph.base().entities[id2];
28940       if (entity && !base) {
28941         if (entity.type === "node") {
28942           graph.parentWays(entity).forEach(function(parent) {
28943             parent = parent.removeNode(id2);
28944             graph = graph.replace(parent);
28945             if (parent.isDegenerate()) {
28946               graph = actionDeleteWay(parent.id)(graph);
28947             }
28948           });
28949         }
28950         graph.parentRelations(entity).forEach(function(parent) {
28951           parent = parent.removeMembersWithID(id2);
28952           graph = graph.replace(parent);
28953           if (parent.isDegenerate()) {
28954             graph = actionDeleteRelation(parent.id)(graph);
28955           }
28956         });
28957       }
28958       return graph.revert(id2);
28959     };
28960     return action;
28961   }
28962
28963   // modules/actions/rotate.js
28964   function actionRotate(rotateIds, pivot, angle2, projection2) {
28965     var action = function(graph) {
28966       return graph.update(function(graph2) {
28967         utilGetAllNodes(rotateIds, graph2).forEach(function(node) {
28968           var point = geoRotate([projection2(node.loc)], angle2, pivot)[0];
28969           graph2 = graph2.replace(node.move(projection2.invert(point)));
28970         });
28971       });
28972     };
28973     return action;
28974   }
28975
28976   // modules/actions/scale.js
28977   function actionScale(ids, pivotLoc, scaleFactor, projection2) {
28978     return function(graph) {
28979       return graph.update(function(graph2) {
28980         let point, radial;
28981         utilGetAllNodes(ids, graph2).forEach(function(node) {
28982           point = projection2(node.loc);
28983           radial = [
28984             point[0] - pivotLoc[0],
28985             point[1] - pivotLoc[1]
28986           ];
28987           point = [
28988             pivotLoc[0] + scaleFactor * radial[0],
28989             pivotLoc[1] + scaleFactor * radial[1]
28990           ];
28991           graph2 = graph2.replace(node.move(projection2.invert(point)));
28992         });
28993       });
28994     };
28995   }
28996
28997   // modules/actions/straighten_nodes.js
28998   function actionStraightenNodes(nodeIDs, projection2) {
28999     function positionAlongWay(a2, o2, b2) {
29000       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
29001     }
29002     function getEndpoints(points) {
29003       var ssr = geoGetSmallestSurroundingRectangle(points);
29004       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
29005       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
29006       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
29007       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
29008       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
29009       if (isLong) {
29010         return [p1, q1];
29011       }
29012       return [p2, q2];
29013     }
29014     var action = function(graph, t2) {
29015       if (t2 === null || !isFinite(t2)) t2 = 1;
29016       t2 = Math.min(Math.max(+t2, 0), 1);
29017       var nodes = nodeIDs.map(function(id2) {
29018         return graph.entity(id2);
29019       });
29020       var points = nodes.map(function(n3) {
29021         return projection2(n3.loc);
29022       });
29023       var endpoints = getEndpoints(points);
29024       var startPoint = endpoints[0];
29025       var endPoint = endpoints[1];
29026       for (var i3 = 0; i3 < points.length; i3++) {
29027         var node = nodes[i3];
29028         var point = points[i3];
29029         var u2 = positionAlongWay(point, startPoint, endPoint);
29030         var point2 = geoVecInterp(startPoint, endPoint, u2);
29031         var loc2 = projection2.invert(point2);
29032         graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
29033       }
29034       return graph;
29035     };
29036     action.disabled = function(graph) {
29037       var nodes = nodeIDs.map(function(id2) {
29038         return graph.entity(id2);
29039       });
29040       var points = nodes.map(function(n3) {
29041         return projection2(n3.loc);
29042       });
29043       var endpoints = getEndpoints(points);
29044       var startPoint = endpoints[0];
29045       var endPoint = endpoints[1];
29046       var maxDistance = 0;
29047       for (var i3 = 0; i3 < points.length; i3++) {
29048         var point = points[i3];
29049         var u2 = positionAlongWay(point, startPoint, endPoint);
29050         var p2 = geoVecInterp(startPoint, endPoint, u2);
29051         var dist = geoVecLength(p2, point);
29052         if (!isNaN(dist) && dist > maxDistance) {
29053           maxDistance = dist;
29054         }
29055       }
29056       if (maxDistance < 1e-4) {
29057         return "straight_enough";
29058       }
29059     };
29060     action.transitionable = true;
29061     return action;
29062   }
29063
29064   // modules/actions/straighten_way.js
29065   function actionStraightenWay(selectedIDs, projection2) {
29066     function positionAlongWay(a2, o2, b2) {
29067       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
29068     }
29069     function allNodes(graph) {
29070       var nodes = [];
29071       var startNodes = [];
29072       var endNodes = [];
29073       var remainingWays = [];
29074       var selectedWays = selectedIDs.filter(function(w2) {
29075         return graph.entity(w2).type === "way";
29076       });
29077       var selectedNodes = selectedIDs.filter(function(n3) {
29078         return graph.entity(n3).type === "node";
29079       });
29080       for (var i3 = 0; i3 < selectedWays.length; i3++) {
29081         var way = graph.entity(selectedWays[i3]);
29082         nodes = way.nodes.slice(0);
29083         remainingWays.push(nodes);
29084         startNodes.push(nodes[0]);
29085         endNodes.push(nodes[nodes.length - 1]);
29086       }
29087       startNodes = startNodes.filter(function(n3) {
29088         return startNodes.indexOf(n3) === startNodes.lastIndexOf(n3);
29089       });
29090       endNodes = endNodes.filter(function(n3) {
29091         return endNodes.indexOf(n3) === endNodes.lastIndexOf(n3);
29092       });
29093       var currNode = utilArrayDifference(startNodes, endNodes).concat(utilArrayDifference(endNodes, startNodes))[0];
29094       var nextWay = [];
29095       nodes = [];
29096       var getNextWay = function(currNode2, remainingWays2) {
29097         return remainingWays2.filter(function(way2) {
29098           return way2[0] === currNode2 || way2[way2.length - 1] === currNode2;
29099         })[0];
29100       };
29101       while (remainingWays.length) {
29102         nextWay = getNextWay(currNode, remainingWays);
29103         remainingWays = utilArrayDifference(remainingWays, [nextWay]);
29104         if (nextWay[0] !== currNode) {
29105           nextWay.reverse();
29106         }
29107         nodes = nodes.concat(nextWay);
29108         currNode = nodes[nodes.length - 1];
29109       }
29110       if (selectedNodes.length === 2) {
29111         var startNodeIdx = nodes.indexOf(selectedNodes[0]);
29112         var endNodeIdx = nodes.indexOf(selectedNodes[1]);
29113         var sortedStartEnd = [startNodeIdx, endNodeIdx];
29114         sortedStartEnd.sort(function(a2, b2) {
29115           return a2 - b2;
29116         });
29117         nodes = nodes.slice(sortedStartEnd[0], sortedStartEnd[1] + 1);
29118       }
29119       return nodes.map(function(n3) {
29120         return graph.entity(n3);
29121       });
29122     }
29123     function shouldKeepNode(node, graph) {
29124       return graph.parentWays(node).length > 1 || graph.parentRelations(node).length || node.hasInterestingTags();
29125     }
29126     var action = function(graph, t2) {
29127       if (t2 === null || !isFinite(t2)) t2 = 1;
29128       t2 = Math.min(Math.max(+t2, 0), 1);
29129       var nodes = allNodes(graph);
29130       var points = nodes.map(function(n3) {
29131         return projection2(n3.loc);
29132       });
29133       var startPoint = points[0];
29134       var endPoint = points[points.length - 1];
29135       var toDelete = [];
29136       var i3;
29137       for (i3 = 1; i3 < points.length - 1; i3++) {
29138         var node = nodes[i3];
29139         var point = points[i3];
29140         if (t2 < 1 || shouldKeepNode(node, graph)) {
29141           var u2 = positionAlongWay(point, startPoint, endPoint);
29142           var p2 = geoVecInterp(startPoint, endPoint, u2);
29143           var loc2 = projection2.invert(p2);
29144           graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
29145         } else {
29146           if (toDelete.indexOf(node) === -1) {
29147             toDelete.push(node);
29148           }
29149         }
29150       }
29151       for (i3 = 0; i3 < toDelete.length; i3++) {
29152         graph = actionDeleteNode(toDelete[i3].id)(graph);
29153       }
29154       return graph;
29155     };
29156     action.disabled = function(graph) {
29157       var nodes = allNodes(graph);
29158       var points = nodes.map(function(n3) {
29159         return projection2(n3.loc);
29160       });
29161       var startPoint = points[0];
29162       var endPoint = points[points.length - 1];
29163       var threshold = 0.2 * geoVecLength(startPoint, endPoint);
29164       var i3;
29165       if (threshold === 0) {
29166         return "too_bendy";
29167       }
29168       var maxDistance = 0;
29169       for (i3 = 1; i3 < points.length - 1; i3++) {
29170         var point = points[i3];
29171         var u2 = positionAlongWay(point, startPoint, endPoint);
29172         var p2 = geoVecInterp(startPoint, endPoint, u2);
29173         var dist = geoVecLength(p2, point);
29174         if (isNaN(dist) || dist > threshold) {
29175           return "too_bendy";
29176         } else if (dist > maxDistance) {
29177           maxDistance = dist;
29178         }
29179       }
29180       var keepingAllNodes = nodes.every(function(node, i4) {
29181         return i4 === 0 || i4 === nodes.length - 1 || shouldKeepNode(node, graph);
29182       });
29183       if (maxDistance < 1e-4 && // Allow straightening even if already straight in order to remove extraneous nodes
29184       keepingAllNodes) {
29185         return "straight_enough";
29186       }
29187     };
29188     action.transitionable = true;
29189     return action;
29190   }
29191
29192   // modules/actions/unrestrict_turn.js
29193   function actionUnrestrictTurn(turn) {
29194     return function(graph) {
29195       return actionDeleteRelation(turn.restrictionID)(graph);
29196     };
29197   }
29198
29199   // modules/actions/reflect.js
29200   function actionReflect(reflectIds, projection2) {
29201     var _useLongAxis = true;
29202     var action = function(graph, t2) {
29203       if (t2 === null || !isFinite(t2)) t2 = 1;
29204       t2 = Math.min(Math.max(+t2, 0), 1);
29205       var nodes = utilGetAllNodes(reflectIds, graph);
29206       var points = nodes.map(function(n3) {
29207         return projection2(n3.loc);
29208       });
29209       var ssr = geoGetSmallestSurroundingRectangle(points);
29210       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
29211       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
29212       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
29213       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
29214       var p3, q3;
29215       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
29216       if (_useLongAxis && isLong || !_useLongAxis && !isLong) {
29217         p3 = p1;
29218         q3 = q1;
29219       } else {
29220         p3 = p2;
29221         q3 = q2;
29222       }
29223       var dx = q3[0] - p3[0];
29224       var dy = q3[1] - p3[1];
29225       var a2 = (dx * dx - dy * dy) / (dx * dx + dy * dy);
29226       var b2 = 2 * dx * dy / (dx * dx + dy * dy);
29227       for (var i3 = 0; i3 < nodes.length; i3++) {
29228         var node = nodes[i3];
29229         var c2 = projection2(node.loc);
29230         var c22 = [
29231           a2 * (c2[0] - p3[0]) + b2 * (c2[1] - p3[1]) + p3[0],
29232           b2 * (c2[0] - p3[0]) - a2 * (c2[1] - p3[1]) + p3[1]
29233         ];
29234         var loc2 = projection2.invert(c22);
29235         node = node.move(geoVecInterp(node.loc, loc2, t2));
29236         graph = graph.replace(node);
29237       }
29238       return graph;
29239     };
29240     action.useLongAxis = function(val) {
29241       if (!arguments.length) return _useLongAxis;
29242       _useLongAxis = val;
29243       return action;
29244     };
29245     action.transitionable = true;
29246     return action;
29247   }
29248
29249   // modules/actions/upgrade_tags.js
29250   function actionUpgradeTags(entityId, oldTags, replaceTags) {
29251     return function(graph) {
29252       var entity = graph.entity(entityId);
29253       var tags = Object.assign({}, entity.tags);
29254       var transferValue;
29255       var semiIndex;
29256       for (var oldTagKey in oldTags) {
29257         if (!(oldTagKey in tags)) continue;
29258         if (oldTags[oldTagKey] === "*") {
29259           transferValue = tags[oldTagKey];
29260           delete tags[oldTagKey];
29261         } else if (oldTags[oldTagKey] === tags[oldTagKey]) {
29262           delete tags[oldTagKey];
29263         } else {
29264           var vals = tags[oldTagKey].split(";").filter(Boolean);
29265           var oldIndex = vals.indexOf(oldTags[oldTagKey]);
29266           if (vals.length === 1 || oldIndex === -1) {
29267             delete tags[oldTagKey];
29268           } else {
29269             if (replaceTags && replaceTags[oldTagKey]) {
29270               semiIndex = oldIndex;
29271             }
29272             vals.splice(oldIndex, 1);
29273             tags[oldTagKey] = vals.join(";");
29274           }
29275         }
29276       }
29277       if (replaceTags) {
29278         for (var replaceKey in replaceTags) {
29279           var replaceValue = replaceTags[replaceKey];
29280           if (replaceValue === "*") {
29281             if (tags[replaceKey] && tags[replaceKey] !== "no") {
29282               continue;
29283             } else {
29284               tags[replaceKey] = "yes";
29285             }
29286           } else if (replaceValue === "$1") {
29287             tags[replaceKey] = transferValue;
29288           } else {
29289             if (tags[replaceKey] && oldTags[replaceKey] && semiIndex !== void 0) {
29290               var existingVals = tags[replaceKey].split(";").filter(Boolean);
29291               if (existingVals.indexOf(replaceValue) === -1) {
29292                 existingVals.splice(semiIndex, 0, replaceValue);
29293                 tags[replaceKey] = existingVals.join(";");
29294               }
29295             } else {
29296               tags[replaceKey] = replaceValue;
29297             }
29298           }
29299         }
29300       }
29301       return graph.replace(entity.update({ tags }));
29302     };
29303   }
29304
29305   // modules/core/preferences.js
29306   var _storage;
29307   try {
29308     _storage = localStorage;
29309   } catch (e3) {
29310   }
29311   _storage = _storage || /* @__PURE__ */ (() => {
29312     let s2 = {};
29313     return {
29314       getItem: (k2) => s2[k2],
29315       setItem: (k2, v2) => s2[k2] = v2,
29316       removeItem: (k2) => delete s2[k2]
29317     };
29318   })();
29319   var _listeners = {};
29320   function corePreferences(k2, v2) {
29321     try {
29322       if (v2 === void 0) return _storage.getItem(k2);
29323       else if (v2 === null) _storage.removeItem(k2);
29324       else _storage.setItem(k2, v2);
29325       if (_listeners[k2]) {
29326         _listeners[k2].forEach((handler) => handler(v2));
29327       }
29328       return true;
29329     } catch (e3) {
29330       if (typeof console !== "undefined") {
29331         console.error("localStorage quota exceeded");
29332       }
29333       return false;
29334     }
29335   }
29336   corePreferences.onChange = function(k2, handler) {
29337     _listeners[k2] = _listeners[k2] || [];
29338     _listeners[k2].push(handler);
29339   };
29340
29341   // node_modules/@rapideditor/country-coder/dist/country-coder.mjs
29342   var import_which_polygon = __toESM(require_which_polygon(), 1);
29343   var borders_default = { type: "FeatureCollection", features: [
29344     { 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]]]] } },
29345     { 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]]]] } },
29346     { 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]]]] } },
29347     { 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]]]] } },
29348     { 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]]]] } },
29349     { 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]]]] } },
29350     { 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]]]] } },
29351     { 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]]]] } },
29352     { 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]]]] } },
29353     { 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]]]] } },
29354     { 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]]]] } },
29355     { 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]]]] } },
29356     { 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]]]] } },
29357     { 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]]]] } },
29358     { 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]]]] } },
29359     { 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]]]] } },
29360     { 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]]]] } },
29361     { 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]]]] } },
29362     { 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]]]] } },
29363     { type: "Feature", properties: { wikidata: "Q12837", nameEn: "Iberia", level: "sharedLandform" }, geometry: null },
29364     { 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]]]] } },
29365     { 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]]]] } },
29366     { type: "Feature", properties: { wikidata: "Q22890", nameEn: "Ireland", level: "sharedLandform" }, geometry: null },
29367     { type: "Feature", properties: { wikidata: "Q23666", nameEn: "Great Britain", country: "GB", level: "sharedLandform" }, geometry: null },
29368     { 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.90247, 35.07686], [33.92495, 35.06789], [33.94869, 35.07277], [33.99999, 35.07016], [34.23164, 35.1777], [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]]]] } },
29369     { 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]]]] } },
29370     { 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]]]] } },
29371     { 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]]]] } },
29372     { 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]]]] } },
29373     { 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]]]] } },
29374     { 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]]]] } },
29375     { 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]]]] } },
29376     { 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]]]] } },
29377     { 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]]]] } },
29378     { 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]]]] } },
29379     { 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]]]] } },
29380     { type: "Feature", properties: { wikidata: "Q35657", nameEn: "US States", country: "US", level: "subcountryGroup" }, geometry: null },
29381     { type: "Feature", properties: { wikidata: "Q36117", nameEn: "Borneo", level: "sharedLandform" }, geometry: null },
29382     { 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]]]] } },
29383     { type: "Feature", properties: { wikidata: "Q37362", nameEn: "Akrotiri and Dhekelia", aliases: ["SBA"], country: "GB" }, geometry: null },
29384     { 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]]]] } },
29385     { 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]]]] } },
29386     { 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]]]] } },
29387     { 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]]]] } },
29388     { 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]]]] } },
29389     { 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]]]] } },
29390     { type: "Feature", properties: { wikidata: "Q46395", nameEn: "British Overseas Territories", aliases: ["BOTS", "UKOTS"], country: "GB", level: "subcountryGroup" }, geometry: null },
29391     { 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]]]] } },
29392     { 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]]]] } },
29393     { 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]]]] } },
29394     { 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]]]] } },
29395     { type: "Feature", properties: { wikidata: "Q105472", nameEn: "Macaronesia", level: "sharedLandform" }, geometry: null },
29396     { 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]]]] } },
29397     { 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]]]] } },
29398     { 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]]]] } },
29399     { 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]]]] } },
29400     { 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]]]] } },
29401     { 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]]]] } },
29402     { 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]]]] } },
29403     { 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]]]] } },
29404     { 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]]]] } },
29405     { 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]]]] } },
29406     { type: "Feature", properties: { wikidata: "Q153732", nameEn: "Mariana Islands", level: "sharedLandform" }, geometry: null },
29407     { 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]]]] } },
29408     { 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]]]] } },
29409     { type: "Feature", properties: { wikidata: "Q185086", nameEn: "Crown Dependencies", country: "GB", level: "subcountryGroup" }, geometry: null },
29410     { 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]]]] } },
29411     { type: "Feature", properties: { wikidata: "Q191011", nameEn: "Plazas de soberan\xEDa", country: "ES" }, geometry: null },
29412     { 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]]]] } },
29413     { 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]]]] } },
29414     { 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]]]] } },
29415     { 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]]]] } },
29416     { 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]]]] } },
29417     { type: "Feature", properties: { wikidata: "Q644636", nameEn: "Cyprus", level: "sharedLandform" }, geometry: null },
29418     { type: "Feature", properties: { wikidata: "Q851132", nameEn: "New Zealand Outlying Islands", country: "NZ", level: "subcountryGroup" }, geometry: null },
29419     { 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]]]] } },
29420     { 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]]]] } },
29421     { 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]]]] } },
29422     { 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]]]] } },
29423     { type: "Feature", properties: { wikidata: "Q1352230", nameEn: "US Territories", country: "US", level: "subcountryGroup" }, geometry: null },
29424     { type: "Feature", properties: { wikidata: "Q1451600", nameEn: "Overseas Countries and Territories of the EU", aliases: ["OCT"], level: "subunion" }, geometry: null },
29425     { 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]]]] } },
29426     { 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]]]] } },
29427     { 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]]]] } },
29428     { 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]]]] } },
29429     { 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]]]] } },
29430     { 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]]]] } },
29431     { 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]]]] } },
29432     { 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]]]] } },
29433     { type: "Feature", properties: { wikidata: "Q2914565", nameEn: "Autonomous Regions of Portugal", country: "PT", level: "subcountryGroup" }, geometry: null },
29434     { 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]]]] } },
29435     { 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]]]] } },
29436     { type: "Feature", properties: { wikidata: "Q3320166", nameEn: "Outermost Regions of the EU", aliases: ["OMR"], level: "subunion" }, geometry: null },
29437     { type: "Feature", properties: { wikidata: "Q3336843", nameEn: "Countries of the United Kingdom", aliases: ["GB-UKM"], country: "GB", level: "subcountryGroup" }, geometry: null },
29438     { 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]]]] } },
29439     { 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.96312, 34.63236], [32.95516, 34.63541], [32.95323, 34.64075], [32.95471, 34.64528], [32.95277, 34.65104], [32.96154, 34.65587], [32.9639, 34.65866], [32.969, 34.6549], [32.98046, 34.65336], [32.99014, 34.65518], [32.98668, 34.67268], [32.98967, 34.67981], [32.95567, 34.6839], [32.94127, 34.67426], [32.93989, 34.67034], [32.93756, 34.67072], [32.93535, 34.66317], [32.92824, 34.66821], [32.93043, 34.67091], [32.91398, 34.67343], [32.9068, 34.66102], [32.86167, 34.68734], [32.86014, 34.70585]]]] } },
29440     { 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.90146, 34.96458], [33.86018, 34.97381], [33.84741, 34.97167], [33.84028, 34.97179], [33.83459, 34.97448], [33.84616, 34.98511], [33.85488, 34.98462], [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.87438, 35.08118], [33.89322, 35.06789], [33.90247, 35.07686], [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]]]] } },
29441     { 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]]]] } },
29442     { 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]]]] } },
29443     { 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]]]] } },
29444     { type: "Feature", properties: { m49: "001", wikidata: "Q2", nameEn: "World", aliases: ["Earth", "Planet"], level: "world" }, geometry: null },
29445     { type: "Feature", properties: { m49: "002", wikidata: "Q15", nameEn: "Africa", level: "region" }, geometry: null },
29446     { type: "Feature", properties: { m49: "003", wikidata: "Q49", nameEn: "North America", level: "subregion" }, geometry: null },
29447     { type: "Feature", properties: { m49: "005", wikidata: "Q18", nameEn: "South America", level: "intermediateRegion" }, geometry: null },
29448     { type: "Feature", properties: { m49: "009", wikidata: "Q538", nameEn: "Oceania", level: "region" }, geometry: null },
29449     { type: "Feature", properties: { m49: "011", wikidata: "Q4412", nameEn: "Western Africa", level: "intermediateRegion" }, geometry: null },
29450     { type: "Feature", properties: { m49: "013", wikidata: "Q27611", nameEn: "Central America", level: "intermediateRegion" }, geometry: null },
29451     { type: "Feature", properties: { m49: "014", wikidata: "Q27407", nameEn: "Eastern Africa", level: "intermediateRegion" }, geometry: null },
29452     { type: "Feature", properties: { m49: "015", wikidata: "Q27381", nameEn: "Northern Africa", level: "subregion" }, geometry: null },
29453     { type: "Feature", properties: { m49: "017", wikidata: "Q27433", nameEn: "Middle Africa", level: "intermediateRegion" }, geometry: null },
29454     { type: "Feature", properties: { m49: "018", wikidata: "Q27394", nameEn: "Southern Africa", level: "intermediateRegion" }, geometry: null },
29455     { type: "Feature", properties: { m49: "019", wikidata: "Q828", nameEn: "Americas", level: "region" }, geometry: null },
29456     { type: "Feature", properties: { m49: "021", wikidata: "Q2017699", nameEn: "Northern America", level: "subregion" }, geometry: null },
29457     { type: "Feature", properties: { m49: "029", wikidata: "Q664609", nameEn: "Caribbean", level: "intermediateRegion" }, geometry: null },
29458     { type: "Feature", properties: { m49: "030", wikidata: "Q27231", nameEn: "Eastern Asia", level: "subregion" }, geometry: null },
29459     { type: "Feature", properties: { m49: "034", wikidata: "Q771405", nameEn: "Southern Asia", level: "subregion" }, geometry: null },
29460     { type: "Feature", properties: { m49: "035", wikidata: "Q11708", nameEn: "South-eastern Asia", level: "subregion" }, geometry: null },
29461     { type: "Feature", properties: { m49: "039", wikidata: "Q27449", nameEn: "Southern Europe", level: "subregion" }, geometry: null },
29462     { type: "Feature", properties: { m49: "053", wikidata: "Q45256", nameEn: "Australia and New Zealand", aliases: ["Australasia"], level: "subregion" }, geometry: null },
29463     { type: "Feature", properties: { m49: "054", wikidata: "Q37394", nameEn: "Melanesia", level: "subregion" }, geometry: null },
29464     { type: "Feature", properties: { m49: "057", wikidata: "Q3359409", nameEn: "Micronesia", level: "subregion" }, geometry: null },
29465     { type: "Feature", properties: { m49: "061", wikidata: "Q35942", nameEn: "Polynesia", level: "subregion" }, geometry: null },
29466     { type: "Feature", properties: { m49: "142", wikidata: "Q48", nameEn: "Asia", level: "region" }, geometry: null },
29467     { type: "Feature", properties: { m49: "143", wikidata: "Q27275", nameEn: "Central Asia", level: "subregion" }, geometry: null },
29468     { type: "Feature", properties: { m49: "145", wikidata: "Q27293", nameEn: "Western Asia", level: "subregion" }, geometry: null },
29469     { type: "Feature", properties: { m49: "150", wikidata: "Q46", nameEn: "Europe", level: "region" }, geometry: null },
29470     { type: "Feature", properties: { m49: "151", wikidata: "Q27468", nameEn: "Eastern Europe", level: "subregion" }, geometry: null },
29471     { type: "Feature", properties: { m49: "154", wikidata: "Q27479", nameEn: "Northern Europe", level: "subregion" }, geometry: null },
29472     { type: "Feature", properties: { m49: "155", wikidata: "Q27496", nameEn: "Western Europe", level: "subregion" }, geometry: null },
29473     { type: "Feature", properties: { m49: "202", wikidata: "Q132959", nameEn: "Sub-Saharan Africa", level: "subregion" }, geometry: null },
29474     { type: "Feature", properties: { m49: "419", wikidata: "Q72829598", nameEn: "Latin America and the Caribbean", level: "subregion" }, geometry: null },
29475     { type: "Feature", properties: { m49: "830", wikidata: "Q42314", nameEn: "Channel Islands", level: "intermediateRegion" }, geometry: null },
29476     { 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]]]] } },
29477     { 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]]]] } },
29478     { 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]]]] } },
29479     { 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]]]] } },
29480     { 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]]]] } },
29481     { 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]]]] } },
29482     { 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]]]] } },
29483     { 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]]]] } },
29484     { 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]]]] } },
29485     { 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]]]] } },
29486     { 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]]]] } },
29487     { 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]]]] } },
29488     { 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]]]] } },
29489     { type: "Feature", properties: { iso1A2: "AU", iso1A3: "AUS", iso1N3: "036", wikidata: "Q408", nameEn: "Australia" }, geometry: null },
29490     { 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]]]] } },
29491     { 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]]]] } },
29492     { 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]]]] } },
29493     { 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]]]] } },
29494     { 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]]]] } },
29495     { 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]]]] } },
29496     { 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]]]] } },
29497     { 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]]]] } },
29498     { 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]]]] } },
29499     { 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]]]] } },
29500     { 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]]]] } },
29501     { 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]]]] } },
29502     { 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]]]] } },
29503     { 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]]]] } },
29504     { 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]]]] } },
29505     { 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]]]] } },
29506     { type: "Feature", properties: { iso1A2: "BQ", iso1A3: "BES", iso1N3: "535", wikidata: "Q27561", nameEn: "Caribbean Netherlands", country: "NL" }, geometry: null },
29507     { 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]]]] } },
29508     { 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]]]] } },
29509     { 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]]]] } },
29510     { 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]]]] } },
29511     { 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]]]] } },
29512     { 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]]]] } },
29513     { 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]]]] } },
29514     { 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]]]] } },
29515     { 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]]]] } },
29516     { 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]]]] } },
29517     { 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]]]] } },
29518     { 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]]]] } },
29519     { type: "Feature", properties: { iso1A2: "CH", iso1A3: "CHE", iso1N3: "756", wikidata: "Q39", nameEn: "Switzerland", groups: ["155", "150", "UN"], callingCodes: ["41"] }, 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]]]] } },
29520     { 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]]]] } },
29521     { 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]]]] } },
29522     { 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]]]] } },
29523     { 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]]]] } },
29524     { type: "Feature", properties: { iso1A2: "CN", iso1A3: "CHN", iso1N3: "156", wikidata: "Q148", nameEn: "People's Republic of China" }, geometry: null },
29525     { 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]]]] } },
29526     { 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]]]] } },
29527     { type: "Feature", properties: { iso1A2: "CQ", iso1A3: "CRQ", iso1N3: "680", m49: "680", wikidata: "Q3405693", ccTLD: null, nameEn: "Sark", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", isoStatus: "excRes", 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]]]] } },
29528     { 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]]]] } },
29529     { 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]]]] } },
29530     { 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]]]] } },
29531     { 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]]]] } },
29532     { 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]]]] } },
29533     { 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.60361, 35.16647], [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.92824, 34.66821], [32.93535, 34.66317], [32.93756, 34.67072], [32.93989, 34.67034], [32.94127, 34.67426], [32.95567, 34.6839], [32.98967, 34.67981], [32.98668, 34.67268], [32.99014, 34.65518], [32.98046, 34.65336], [32.969, 34.6549], [32.9639, 34.65866], [32.96154, 34.65587], [32.95277, 34.65104], [32.95471, 34.64528], [32.95323, 34.64075], [32.95516, 34.63541], [32.96312, 34.63236], [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]]], [[[33.7343, 35.01178], [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.77553, 34.99518], [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.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.85488, 34.98462], [33.84616, 34.98511], [33.83459, 34.97448], [33.84028, 34.97179], [33.84741, 34.97167], [33.86018, 34.97381], [33.90146, 34.96458], [33.98684, 34.76642], [35.48515, 34.70851], [35.51152, 36.10954], [34.23164, 35.1777], [33.99999, 35.07016], [33.94869, 35.07277], [33.92495, 35.06789], [33.90247, 35.07686], [33.89322, 35.06789], [33.87438, 35.08118], [33.85261, 35.0574], [33.8355, 35.05777], [33.82051, 35.0667]]]] } },
29534     { 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]]]] } },
29535     { 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]]]] } },
29536     { 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]]]] } },
29537     { 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]]]] } },
29538     { type: "Feature", properties: { iso1A2: "DK", iso1A3: "DNK", iso1N3: "208", wikidata: "Q756617", nameEn: "Kingdom of Denmark" }, geometry: null },
29539     { 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]]]] } },
29540     { 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]]]] } },
29541     { 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]]]] } },
29542     { type: "Feature", properties: { iso1A2: "EA", wikidata: "Q28868874", nameEn: "Ceuta, Melilla", country: "ES", level: "territory", isoStatus: "excRes" }, geometry: null },
29543     { type: "Feature", properties: { iso1A2: "EC", iso1A3: "ECU", iso1N3: "218", wikidata: "Q736", nameEn: "Ecuador" }, geometry: null },
29544     { 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]]]] } },
29545     { 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]]]] } },
29546     { 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]]]] } },
29547     { 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]]]] } },
29548     { type: "Feature", properties: { iso1A2: "ES", iso1A3: "ESP", iso1N3: "724", wikidata: "Q29", nameEn: "Spain" }, geometry: null },
29549     { 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]]]] } },
29550     { type: "Feature", properties: { iso1A2: "EU", iso1A3: "EUE", wikidata: "Q458", nameEn: "European Union", level: "union", isoStatus: "excRes" }, geometry: null },
29551     { type: "Feature", properties: { iso1A2: "FI", iso1A3: "FIN", iso1N3: "246", wikidata: "Q33", nameEn: "Finland", aliases: ["SF"] }, geometry: null },
29552     { 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]]]] } },
29553     { 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]]]] } },
29554     { 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]]]] } },
29555     { 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]]]] } },
29556     { type: "Feature", properties: { iso1A2: "FR", iso1A3: "FRA", iso1N3: "250", wikidata: "Q142", nameEn: "France" }, geometry: null },
29557     { 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]]]] } },
29558     { 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]]]] } },
29559     { type: "Feature", properties: { iso1A2: "GB", iso1A3: "GBR", iso1N3: "826", wikidata: "Q145", ccTLD: ".uk", nameEn: "United Kingdom", aliases: ["UK"] }, geometry: null },
29560     { 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]]]] } },
29561     { 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]]]] } },
29562     { 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]]]] } },
29563     { type: "Feature", properties: { iso1A2: "GG", iso1A3: "GGY", iso1N3: "831", wikidata: "Q25230", nameEn: "Bailiwick of Guernsey", country: "GB" }, geometry: null },
29564     { 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]]]] } },
29565     { 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]]]] } },
29566     { 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]]]] } },
29567     { 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]]]] } },
29568     { 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]]]] } },
29569     { 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]]]] } },
29570     { 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]]]] } },
29571     { 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]]]] } },
29572     { 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]]]] } },
29573     { 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]]]] } },
29574     { 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]]]] } },
29575     { 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]]]] } },
29576     { 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]]]] } },
29577     { 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]]]] } },
29578     { 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]]]] } },
29579     { 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]]]] } },
29580     { 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]]]] } },
29581     { 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]]]] } },
29582     { 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]]]] } },
29583     { 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]]]] } },
29584     { type: "Feature", properties: { iso1A2: "ID", iso1A3: "IDN", iso1N3: "360", wikidata: "Q252", nameEn: "Indonesia", aliases: ["RI"] }, geometry: null },
29585     { type: "Feature", properties: { iso1A2: "IE", iso1A3: "IRL", iso1N3: "372", wikidata: "Q27", nameEn: "Republic of Ireland", groups: ["EU", "Q22890", "154", "150", "UN"], driveSide: "left", callingCodes: ["353"] }, 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]]]] } },
29586     { 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]]]] } },
29587     { 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]]]] } },
29588     { type: "Feature", properties: { iso1A2: "IN", iso1A3: "IND", iso1N3: "356", wikidata: "Q668", nameEn: "India" }, geometry: null },
29589     { type: "Feature", properties: { iso1A2: "IO", iso1A3: "IOT", iso1N3: "086", wikidata: "Q43448", nameEn: "British Indian Ocean Territory", country: "GB" }, geometry: null },
29590     { 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]]]] } },
29591     { 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]]]] } },
29592     { 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]]]] } },
29593     { 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]]]] } },
29594     { 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]]]] } },
29595     { 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]]]] } },
29596     { 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]]]] } },
29597     { 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]]]] } },
29598     { 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]]]] } },
29599     { 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]]]] } },
29600     { 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]]]] } },
29601     { 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]]]] } },
29602     { 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]]]] } },
29603     { 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]]]] } },
29604     { 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]]]] } },
29605     { 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]]]] } },
29606     { 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]]]] } },
29607     { 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]]]] } },
29608     { 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]]]] } },
29609     { 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]]]] } },
29610     { 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]]]] } },
29611     { 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]]]] } },
29612     { 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]]]] } },
29613     { 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]]]] } },
29614     { 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]]]] } },
29615     { 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]]]] } },
29616     { 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]]]] } },
29617     { 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]]]] } },
29618     { 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]]]] } },
29619     { 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]]]] } },
29620     { 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]]]] } },
29621     { 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]]]] } },
29622     { 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]]]] } },
29623     { 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]]]] } },
29624     { 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]]]] } },
29625     { 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]]]] } },
29626     { 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]]]] } },
29627     { 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]]]] } },
29628     { 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]]]] } },
29629     { 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]]]] } },
29630     { 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]]]] } },
29631     { 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]]]] } },
29632     { 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]]]] } },
29633     { 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]]]] } },
29634     { 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]]]] } },
29635     { 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]]]] } },
29636     { 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]]]] } },
29637     { 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]]]] } },
29638     { 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]]]] } },
29639     { 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]]]] } },
29640     { 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]]]] } },
29641     { type: "Feature", properties: { iso1A2: "MY", iso1A3: "MYS", iso1N3: "458", wikidata: "Q833", nameEn: "Malaysia" }, geometry: null },
29642     { 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]]]] } },
29643     { 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]]]] } },
29644     { 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]]]] } },
29645     { 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]]]] } },
29646     { 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]]]] } },
29647     { 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]]]] } },
29648     { 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]]]] } },
29649     { type: "Feature", properties: { iso1A2: "NL", iso1A3: "NLD", iso1N3: "528", wikidata: "Q29999", nameEn: "Kingdom of the Netherlands" }, geometry: null },
29650     { type: "Feature", properties: { iso1A2: "NO", iso1A3: "NOR", iso1N3: "578", wikidata: "Q20", nameEn: "Norway" }, geometry: null },
29651     { 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]]]] } },
29652     { 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]]]] } },
29653     { 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]]]] } },
29654     { type: "Feature", properties: { iso1A2: "NZ", iso1A3: "NZL", iso1N3: "554", wikidata: "Q664", nameEn: "New Zealand" }, geometry: null },
29655     { 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]]]] } },
29656     { 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]]]] } },
29657     { 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]]]] } },
29658     { 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]]]] } },
29659     { 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]]]] } },
29660     { 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]]]] } },
29661     { 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]]]] } },
29662     { 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]]]] } },
29663     { 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]]]] } },
29664     { 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]]]] } },
29665     { 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]]]] } },
29666     { type: "Feature", properties: { iso1A2: "PS", iso1A3: "PSE", iso1N3: "275", wikidata: "Q219060", nameEn: "Palestine" }, geometry: null },
29667     { type: "Feature", properties: { iso1A2: "PT", iso1A3: "PRT", iso1N3: "620", wikidata: "Q45", nameEn: "Portugal" }, geometry: null },
29668     { 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]]]] } },
29669     { 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]]]] } },
29670     { 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]]]] } },
29671     { 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]]]] } },
29672     { 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]]]] } },
29673     { 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]]]] } },
29674     { type: "Feature", properties: { iso1A2: "RU", iso1A3: "RUS", iso1N3: "643", wikidata: "Q159", nameEn: "Russia" }, geometry: null },
29675     { 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]]]] } },
29676     { 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]]]] } },
29677     { 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]]]] } },
29678     { 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]]]] } },
29679     { 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]]]] } },
29680     { 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]]]] } },
29681     { 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]]]] } },
29682     { type: "Feature", properties: { iso1A2: "SH", iso1A3: "SHN", iso1N3: "654", wikidata: "Q192184", nameEn: "Saint Helena, Ascension and Tristan da Cunha", country: "GB" }, geometry: null },
29683     { 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]]]] } },
29684     { type: "Feature", properties: { iso1A2: "SJ", iso1A3: "SJM", iso1N3: "744", wikidata: "Q842829", nameEn: "Svalbard and Jan Mayen", country: "NO" }, geometry: null },
29685     { 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]]]] } },
29686     { 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]]]] } },
29687     { 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]]]] } },
29688     { 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]]]] } },
29689     { 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]]]] } },
29690     { 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]]]] } },
29691     { 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]]]] } },
29692     { 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]]]] } },
29693     { 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]]]] } },
29694     { 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]]]] } },
29695     { 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]]]] } },
29696     { 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]]]] } },
29697     { 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]]]] } },
29698     { 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]]]] } },
29699     { 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]]]] } },
29700     { type: "Feature", properties: { iso1A2: "TF", iso1A3: "ATF", iso1N3: "260", wikidata: "Q129003", nameEn: "French Southern Territories", country: "FR", groups: ["EU", "UN"] }, geometry: null },
29701     { 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]]]] } },
29702     { 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]]]] } },
29703     { 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]]]] } },
29704     { 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]]]] } },
29705     { 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]]]] } },
29706     { 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]]]] } },
29707     { 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]]]] } },
29708     { 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]]]] } },
29709     { 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]]]] } },
29710     { 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]]]] } },
29711     { 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]]]] } },
29712     { 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]]]] } },
29713     { 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]]]] } },
29714     { 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]]]] } },
29715     { 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]]]] } },
29716     { type: "Feature", properties: { iso1A2: "UM", iso1A3: "UMI", iso1N3: "581", wikidata: "Q16645", nameEn: "United States Minor Outlying Islands", country: "US" }, geometry: null },
29717     { type: "Feature", properties: { iso1A2: "UN", wikidata: "Q1065", nameEn: "United Nations", level: "unitedNations", isoStatus: "excRes" }, geometry: null },
29718     { type: "Feature", properties: { iso1A2: "US", iso1A3: "USA", iso1N3: "840", wikidata: "Q30", nameEn: "United States of America" }, geometry: null },
29719     { 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]]]] } },
29720     { 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]]]] } },
29721     { 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]]]] } },
29722     { 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]]]] } },
29723     { 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]]]] } },
29724     { 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]]]] } },
29725     { 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]]]] } },
29726     { 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]]]] } },
29727     { 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]]]] } },
29728     { 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]]]] } },
29729     { 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]]]] } },
29730     { 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]]]] } },
29731     { 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]]]] } },
29732     { 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]]]] } },
29733     { 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]]]] } },
29734     { 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]]]] } },
29735     { 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]]]] } }
29736   ] };
29737   var borders = borders_default;
29738   var _whichPolygon = {};
29739   var _featuresByCode = {};
29740   var idFilterRegex = /(?=(?!^(and|the|of|el|la|de)$))(\b(and|the|of|el|la|de)\b)|[-_ .,'()&[\]/]/gi;
29741   function canonicalID(id2) {
29742     const s2 = id2 || "";
29743     if (s2.charAt(0) === ".") {
29744       return s2.toUpperCase();
29745     } else {
29746       return s2.replace(idFilterRegex, "").toUpperCase();
29747     }
29748   }
29749   var levels = [
29750     "subterritory",
29751     "territory",
29752     "subcountryGroup",
29753     "country",
29754     "sharedLandform",
29755     "intermediateRegion",
29756     "subregion",
29757     "region",
29758     "subunion",
29759     "union",
29760     "unitedNations",
29761     "world"
29762   ];
29763   loadDerivedDataAndCaches(borders);
29764   function loadDerivedDataAndCaches(borders2) {
29765     const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"];
29766     let geometryFeatures = [];
29767     for (const feature22 of borders2.features) {
29768       const props = feature22.properties;
29769       props.id = props.iso1A2 || props.m49 || props.wikidata;
29770       loadM49(feature22);
29771       loadTLD(feature22);
29772       loadIsoStatus(feature22);
29773       loadLevel(feature22);
29774       loadGroups(feature22);
29775       loadFlag(feature22);
29776       cacheFeatureByIDs(feature22);
29777       if (feature22.geometry) {
29778         geometryFeatures.push(feature22);
29779       }
29780     }
29781     for (const feature22 of borders2.features) {
29782       feature22.properties.groups = feature22.properties.groups.map((groupID) => {
29783         return _featuresByCode[groupID].properties.id;
29784       });
29785       loadMembersForGroupsOf(feature22);
29786     }
29787     for (const feature22 of borders2.features) {
29788       loadRoadSpeedUnit(feature22);
29789       loadRoadHeightUnit(feature22);
29790       loadDriveSide(feature22);
29791       loadCallingCodes(feature22);
29792       loadGroupGroups(feature22);
29793     }
29794     for (const feature22 of borders2.features) {
29795       feature22.properties.groups.sort((groupID1, groupID2) => {
29796         return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level);
29797       });
29798       if (feature22.properties.members) {
29799         feature22.properties.members.sort((id1, id2) => {
29800           const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level);
29801           if (diff === 0) {
29802             return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]);
29803           }
29804           return diff;
29805         });
29806       }
29807     }
29808     const geometryOnlyCollection = {
29809       type: "FeatureCollection",
29810       features: geometryFeatures
29811     };
29812     _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection);
29813     function loadGroups(feature22) {
29814       const props = feature22.properties;
29815       if (!props.groups) {
29816         props.groups = [];
29817       }
29818       if (feature22.geometry && props.country) {
29819         props.groups.push(props.country);
29820       }
29821       if (props.m49 !== "001") {
29822         props.groups.push("001");
29823       }
29824     }
29825     function loadM49(feature22) {
29826       const props = feature22.properties;
29827       if (!props.m49 && props.iso1N3) {
29828         props.m49 = props.iso1N3;
29829       }
29830     }
29831     function loadTLD(feature22) {
29832       const props = feature22.properties;
29833       if (props.level === "unitedNations") return;
29834       if (props.ccTLD === null) return;
29835       if (!props.ccTLD && props.iso1A2) {
29836         props.ccTLD = "." + props.iso1A2.toLowerCase();
29837       }
29838     }
29839     function loadIsoStatus(feature22) {
29840       const props = feature22.properties;
29841       if (!props.isoStatus && props.iso1A2) {
29842         props.isoStatus = "official";
29843       }
29844     }
29845     function loadLevel(feature22) {
29846       const props = feature22.properties;
29847       if (props.level) return;
29848       if (!props.country) {
29849         props.level = "country";
29850       } else if (!props.iso1A2 || props.isoStatus === "official") {
29851         props.level = "territory";
29852       } else {
29853         props.level = "subterritory";
29854       }
29855     }
29856     function loadGroupGroups(feature22) {
29857       const props = feature22.properties;
29858       if (feature22.geometry || !props.members) return;
29859       const featureLevelIndex = levels.indexOf(props.level);
29860       let sharedGroups = [];
29861       props.members.forEach((memberID, index) => {
29862         const member = _featuresByCode[memberID];
29863         const memberGroups = member.properties.groups.filter((groupID) => {
29864           return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level);
29865         });
29866         if (index === 0) {
29867           sharedGroups = memberGroups;
29868         } else {
29869           sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1);
29870         }
29871       });
29872       props.groups = props.groups.concat(
29873         sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1)
29874       );
29875       for (const groupID of sharedGroups) {
29876         const groupFeature = _featuresByCode[groupID];
29877         if (groupFeature.properties.members.indexOf(props.id) === -1) {
29878           groupFeature.properties.members.push(props.id);
29879         }
29880       }
29881     }
29882     function loadRoadSpeedUnit(feature22) {
29883       const props = feature22.properties;
29884       if (feature22.geometry) {
29885         if (!props.roadSpeedUnit) props.roadSpeedUnit = "km/h";
29886       } else if (props.members) {
29887         const vals = Array.from(
29888           new Set(
29889             props.members.map((id2) => {
29890               const member = _featuresByCode[id2];
29891               if (member.geometry) return member.properties.roadSpeedUnit || "km/h";
29892             }).filter(Boolean)
29893           )
29894         );
29895         if (vals.length === 1) props.roadSpeedUnit = vals[0];
29896       }
29897     }
29898     function loadRoadHeightUnit(feature22) {
29899       const props = feature22.properties;
29900       if (feature22.geometry) {
29901         if (!props.roadHeightUnit) props.roadHeightUnit = "m";
29902       } else if (props.members) {
29903         const vals = Array.from(
29904           new Set(
29905             props.members.map((id2) => {
29906               const member = _featuresByCode[id2];
29907               if (member.geometry) return member.properties.roadHeightUnit || "m";
29908             }).filter(Boolean)
29909           )
29910         );
29911         if (vals.length === 1) props.roadHeightUnit = vals[0];
29912       }
29913     }
29914     function loadDriveSide(feature22) {
29915       const props = feature22.properties;
29916       if (feature22.geometry) {
29917         if (!props.driveSide) props.driveSide = "right";
29918       } else if (props.members) {
29919         const vals = Array.from(
29920           new Set(
29921             props.members.map((id2) => {
29922               const member = _featuresByCode[id2];
29923               if (member.geometry) return member.properties.driveSide || "right";
29924             }).filter(Boolean)
29925           )
29926         );
29927         if (vals.length === 1) props.driveSide = vals[0];
29928       }
29929     }
29930     function loadCallingCodes(feature22) {
29931       const props = feature22.properties;
29932       if (!feature22.geometry && props.members) {
29933         props.callingCodes = Array.from(
29934           new Set(
29935             props.members.reduce((array2, id2) => {
29936               const member = _featuresByCode[id2];
29937               if (member.geometry && member.properties.callingCodes) {
29938                 return array2.concat(member.properties.callingCodes);
29939               }
29940               return array2;
29941             }, [])
29942           )
29943         );
29944       }
29945     }
29946     function loadFlag(feature22) {
29947       if (!feature22.properties.iso1A2) return;
29948       const flag = feature22.properties.iso1A2.replace(/./g, function(char) {
29949         return String.fromCodePoint(char.charCodeAt(0) + 127397);
29950       });
29951       feature22.properties.emojiFlag = flag;
29952     }
29953     function loadMembersForGroupsOf(feature22) {
29954       for (const groupID of feature22.properties.groups) {
29955         const groupFeature = _featuresByCode[groupID];
29956         if (!groupFeature.properties.members) {
29957           groupFeature.properties.members = [];
29958         }
29959         groupFeature.properties.members.push(feature22.properties.id);
29960       }
29961     }
29962     function cacheFeatureByIDs(feature22) {
29963       let ids = [];
29964       for (const prop of identifierProps) {
29965         const id2 = feature22.properties[prop];
29966         if (id2) {
29967           ids.push(id2);
29968         }
29969       }
29970       for (const alias of feature22.properties.aliases || []) {
29971         ids.push(alias);
29972       }
29973       for (const id2 of ids) {
29974         const cid = canonicalID(id2);
29975         _featuresByCode[cid] = feature22;
29976       }
29977     }
29978   }
29979   function locArray(loc) {
29980     if (Array.isArray(loc)) {
29981       return loc;
29982     } else if (loc.coordinates) {
29983       return loc.coordinates;
29984     }
29985     return loc.geometry.coordinates;
29986   }
29987   function smallestFeature(loc) {
29988     const query = locArray(loc);
29989     const featureProperties = _whichPolygon(query);
29990     if (!featureProperties) return null;
29991     return _featuresByCode[featureProperties.id];
29992   }
29993   function countryFeature(loc) {
29994     const feature22 = smallestFeature(loc);
29995     if (!feature22) return null;
29996     const countryCode = feature22.properties.country || feature22.properties.iso1A2;
29997     return _featuresByCode[countryCode] || null;
29998   }
29999   var defaultOpts = {
30000     level: void 0,
30001     maxLevel: void 0,
30002     withProp: void 0
30003   };
30004   function featureForLoc(loc, opts) {
30005     const targetLevel = opts.level || "country";
30006     const maxLevel = opts.maxLevel || "world";
30007     const withProp = opts.withProp;
30008     const targetLevelIndex = levels.indexOf(targetLevel);
30009     if (targetLevelIndex === -1) return null;
30010     const maxLevelIndex = levels.indexOf(maxLevel);
30011     if (maxLevelIndex === -1) return null;
30012     if (maxLevelIndex < targetLevelIndex) return null;
30013     if (targetLevel === "country") {
30014       const fastFeature = countryFeature(loc);
30015       if (fastFeature) {
30016         if (!withProp || fastFeature.properties[withProp]) {
30017           return fastFeature;
30018         }
30019       }
30020     }
30021     const features = featuresContaining(loc);
30022     const match = features.find((feature22) => {
30023       let levelIndex = levels.indexOf(feature22.properties.level);
30024       if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up
30025       levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) {
30026         if (!withProp || feature22.properties[withProp]) {
30027           return feature22;
30028         }
30029       }
30030       return false;
30031     });
30032     return match || null;
30033   }
30034   function featureForID(id2) {
30035     let stringID;
30036     if (typeof id2 === "number") {
30037       stringID = id2.toString();
30038       if (stringID.length === 1) {
30039         stringID = "00" + stringID;
30040       } else if (stringID.length === 2) {
30041         stringID = "0" + stringID;
30042       }
30043     } else {
30044       stringID = canonicalID(id2);
30045     }
30046     return _featuresByCode[stringID] || null;
30047   }
30048   function smallestFeaturesForBbox(bbox2) {
30049     return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]);
30050   }
30051   function smallestOrMatchingFeature(query) {
30052     if (typeof query === "object") {
30053       return smallestFeature(query);
30054     }
30055     return featureForID(query);
30056   }
30057   function feature(query, opts = defaultOpts) {
30058     if (typeof query === "object") {
30059       return featureForLoc(query, opts);
30060     }
30061     return featureForID(query);
30062   }
30063   function iso1A2Code(query, opts = defaultOpts) {
30064     opts.withProp = "iso1A2";
30065     const match = feature(query, opts);
30066     if (!match) return null;
30067     return match.properties.iso1A2 || null;
30068   }
30069   function propertiesForQuery(query, property) {
30070     const features = featuresContaining(query, false);
30071     return features.map((feature22) => feature22.properties[property]).filter(Boolean);
30072   }
30073   function iso1A2Codes(query) {
30074     return propertiesForQuery(query, "iso1A2");
30075   }
30076   function featuresContaining(query, strict) {
30077     let matchingFeatures;
30078     if (Array.isArray(query) && query.length === 4) {
30079       matchingFeatures = smallestFeaturesForBbox(query);
30080     } else {
30081       const smallestOrMatching = smallestOrMatchingFeature(query);
30082       matchingFeatures = smallestOrMatching ? [smallestOrMatching] : [];
30083     }
30084     if (!matchingFeatures.length) return [];
30085     let returnFeatures;
30086     if (!strict || typeof query === "object") {
30087       returnFeatures = matchingFeatures.slice();
30088     } else {
30089       returnFeatures = [];
30090     }
30091     for (const feature22 of matchingFeatures) {
30092       const properties = feature22.properties;
30093       for (const groupID of properties.groups) {
30094         const groupFeature = _featuresByCode[groupID];
30095         if (returnFeatures.indexOf(groupFeature) === -1) {
30096           returnFeatures.push(groupFeature);
30097         }
30098       }
30099     }
30100     return returnFeatures;
30101   }
30102   function featuresIn(id2, strict) {
30103     const feature22 = featureForID(id2);
30104     if (!feature22) return [];
30105     let features = [];
30106     if (!strict) {
30107       features.push(feature22);
30108     }
30109     const properties = feature22.properties;
30110     for (const memberID of properties.members || []) {
30111       features.push(_featuresByCode[memberID]);
30112     }
30113     return features;
30114   }
30115   function aggregateFeature(id2) {
30116     var _a4;
30117     const features = featuresIn(id2, false);
30118     if (features.length === 0) return null;
30119     let aggregateCoordinates = [];
30120     for (const feature22 of features) {
30121       if (((_a4 = feature22.geometry) == null ? void 0 : _a4.type) === "MultiPolygon" && feature22.geometry.coordinates) {
30122         aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates);
30123       }
30124     }
30125     return {
30126       type: "Feature",
30127       properties: features[0].properties,
30128       geometry: {
30129         type: "MultiPolygon",
30130         coordinates: aggregateCoordinates
30131       }
30132     };
30133   }
30134   function roadSpeedUnit(query) {
30135     const feature22 = smallestOrMatchingFeature(query);
30136     return feature22 && feature22.properties.roadSpeedUnit || null;
30137   }
30138   function roadHeightUnit(query) {
30139     const feature22 = smallestOrMatchingFeature(query);
30140     return feature22 && feature22.properties.roadHeightUnit || null;
30141   }
30142
30143   // node_modules/bignumber.js/bignumber.mjs
30144   var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
30145   var mathceil = Math.ceil;
30146   var mathfloor = Math.floor;
30147   var bignumberError = "[BigNumber Error] ";
30148   var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
30149   var BASE = 1e14;
30150   var LOG_BASE = 14;
30151   var MAX_SAFE_INTEGER3 = 9007199254740991;
30152   var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
30153   var SQRT_BASE = 1e7;
30154   var MAX = 1e9;
30155   function clone(configObject) {
30156     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 = {
30157       prefix: "",
30158       groupSize: 3,
30159       secondaryGroupSize: 0,
30160       groupSeparator: ",",
30161       decimalSeparator: ".",
30162       fractionGroupSize: 0,
30163       fractionGroupSeparator: "\xA0",
30164       // non-breaking space
30165       suffix: ""
30166     }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
30167     function BigNumber2(v2, b2) {
30168       var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this;
30169       if (!(x2 instanceof BigNumber2)) return new BigNumber2(v2, b2);
30170       if (b2 == null) {
30171         if (v2 && v2._isBigNumber === true) {
30172           x2.s = v2.s;
30173           if (!v2.c || v2.e > MAX_EXP) {
30174             x2.c = x2.e = null;
30175           } else if (v2.e < MIN_EXP) {
30176             x2.c = [x2.e = 0];
30177           } else {
30178             x2.e = v2.e;
30179             x2.c = v2.c.slice();
30180           }
30181           return;
30182         }
30183         if ((isNum = typeof v2 == "number") && v2 * 0 == 0) {
30184           x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1;
30185           if (v2 === ~~v2) {
30186             for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++) ;
30187             if (e3 > MAX_EXP) {
30188               x2.c = x2.e = null;
30189             } else {
30190               x2.e = e3;
30191               x2.c = [v2];
30192             }
30193             return;
30194           }
30195           str = String(v2);
30196         } else {
30197           if (!isNumeric.test(str = String(v2))) return parseNumeric2(x2, str, isNum);
30198           x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
30199         }
30200         if ((e3 = str.indexOf(".")) > -1) str = str.replace(".", "");
30201         if ((i3 = str.search(/e/i)) > 0) {
30202           if (e3 < 0) e3 = i3;
30203           e3 += +str.slice(i3 + 1);
30204           str = str.substring(0, i3);
30205         } else if (e3 < 0) {
30206           e3 = str.length;
30207         }
30208       } else {
30209         intCheck(b2, 2, ALPHABET.length, "Base");
30210         if (b2 == 10 && alphabetHasNormalDecimalDigits) {
30211           x2 = new BigNumber2(v2);
30212           return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE);
30213         }
30214         str = String(v2);
30215         if (isNum = typeof v2 == "number") {
30216           if (v2 * 0 != 0) return parseNumeric2(x2, str, isNum, b2);
30217           x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1;
30218           if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
30219             throw Error(tooManyDigits + v2);
30220           }
30221         } else {
30222           x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
30223         }
30224         alphabet = ALPHABET.slice(0, b2);
30225         e3 = i3 = 0;
30226         for (len = str.length; i3 < len; i3++) {
30227           if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) {
30228             if (c2 == ".") {
30229               if (i3 > e3) {
30230                 e3 = len;
30231                 continue;
30232               }
30233             } else if (!caseChanged) {
30234               if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
30235                 caseChanged = true;
30236                 i3 = -1;
30237                 e3 = 0;
30238                 continue;
30239               }
30240             }
30241             return parseNumeric2(x2, String(v2), isNum, b2);
30242           }
30243         }
30244         isNum = false;
30245         str = convertBase(str, b2, 10, x2.s);
30246         if ((e3 = str.indexOf(".")) > -1) str = str.replace(".", "");
30247         else e3 = str.length;
30248       }
30249       for (i3 = 0; str.charCodeAt(i3) === 48; i3++) ;
30250       for (len = str.length; str.charCodeAt(--len) === 48; ) ;
30251       if (str = str.slice(i3, ++len)) {
30252         len -= i3;
30253         if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER3 || v2 !== mathfloor(v2))) {
30254           throw Error(tooManyDigits + x2.s * v2);
30255         }
30256         if ((e3 = e3 - i3 - 1) > MAX_EXP) {
30257           x2.c = x2.e = null;
30258         } else if (e3 < MIN_EXP) {
30259           x2.c = [x2.e = 0];
30260         } else {
30261           x2.e = e3;
30262           x2.c = [];
30263           i3 = (e3 + 1) % LOG_BASE;
30264           if (e3 < 0) i3 += LOG_BASE;
30265           if (i3 < len) {
30266             if (i3) x2.c.push(+str.slice(0, i3));
30267             for (len -= LOG_BASE; i3 < len; ) {
30268               x2.c.push(+str.slice(i3, i3 += LOG_BASE));
30269             }
30270             i3 = LOG_BASE - (str = str.slice(i3)).length;
30271           } else {
30272             i3 -= len;
30273           }
30274           for (; i3--; str += "0") ;
30275           x2.c.push(+str);
30276         }
30277       } else {
30278         x2.c = [x2.e = 0];
30279       }
30280     }
30281     BigNumber2.clone = clone;
30282     BigNumber2.ROUND_UP = 0;
30283     BigNumber2.ROUND_DOWN = 1;
30284     BigNumber2.ROUND_CEIL = 2;
30285     BigNumber2.ROUND_FLOOR = 3;
30286     BigNumber2.ROUND_HALF_UP = 4;
30287     BigNumber2.ROUND_HALF_DOWN = 5;
30288     BigNumber2.ROUND_HALF_EVEN = 6;
30289     BigNumber2.ROUND_HALF_CEIL = 7;
30290     BigNumber2.ROUND_HALF_FLOOR = 8;
30291     BigNumber2.EUCLID = 9;
30292     BigNumber2.config = BigNumber2.set = function(obj) {
30293       var p2, v2;
30294       if (obj != null) {
30295         if (typeof obj == "object") {
30296           if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) {
30297             v2 = obj[p2];
30298             intCheck(v2, 0, MAX, p2);
30299             DECIMAL_PLACES = v2;
30300           }
30301           if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) {
30302             v2 = obj[p2];
30303             intCheck(v2, 0, 8, p2);
30304             ROUNDING_MODE = v2;
30305           }
30306           if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) {
30307             v2 = obj[p2];
30308             if (v2 && v2.pop) {
30309               intCheck(v2[0], -MAX, 0, p2);
30310               intCheck(v2[1], 0, MAX, p2);
30311               TO_EXP_NEG = v2[0];
30312               TO_EXP_POS = v2[1];
30313             } else {
30314               intCheck(v2, -MAX, MAX, p2);
30315               TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2);
30316             }
30317           }
30318           if (obj.hasOwnProperty(p2 = "RANGE")) {
30319             v2 = obj[p2];
30320             if (v2 && v2.pop) {
30321               intCheck(v2[0], -MAX, -1, p2);
30322               intCheck(v2[1], 1, MAX, p2);
30323               MIN_EXP = v2[0];
30324               MAX_EXP = v2[1];
30325             } else {
30326               intCheck(v2, -MAX, MAX, p2);
30327               if (v2) {
30328                 MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2);
30329               } else {
30330                 throw Error(bignumberError + p2 + " cannot be zero: " + v2);
30331               }
30332             }
30333           }
30334           if (obj.hasOwnProperty(p2 = "CRYPTO")) {
30335             v2 = obj[p2];
30336             if (v2 === !!v2) {
30337               if (v2) {
30338                 if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
30339                   CRYPTO = v2;
30340                 } else {
30341                   CRYPTO = !v2;
30342                   throw Error(bignumberError + "crypto unavailable");
30343                 }
30344               } else {
30345                 CRYPTO = v2;
30346               }
30347             } else {
30348               throw Error(bignumberError + p2 + " not true or false: " + v2);
30349             }
30350           }
30351           if (obj.hasOwnProperty(p2 = "MODULO_MODE")) {
30352             v2 = obj[p2];
30353             intCheck(v2, 0, 9, p2);
30354             MODULO_MODE = v2;
30355           }
30356           if (obj.hasOwnProperty(p2 = "POW_PRECISION")) {
30357             v2 = obj[p2];
30358             intCheck(v2, 0, MAX, p2);
30359             POW_PRECISION = v2;
30360           }
30361           if (obj.hasOwnProperty(p2 = "FORMAT")) {
30362             v2 = obj[p2];
30363             if (typeof v2 == "object") FORMAT = v2;
30364             else throw Error(bignumberError + p2 + " not an object: " + v2);
30365           }
30366           if (obj.hasOwnProperty(p2 = "ALPHABET")) {
30367             v2 = obj[p2];
30368             if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) {
30369               alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789";
30370               ALPHABET = v2;
30371             } else {
30372               throw Error(bignumberError + p2 + " invalid: " + v2);
30373             }
30374           }
30375         } else {
30376           throw Error(bignumberError + "Object expected: " + obj);
30377         }
30378       }
30379       return {
30380         DECIMAL_PLACES,
30381         ROUNDING_MODE,
30382         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
30383         RANGE: [MIN_EXP, MAX_EXP],
30384         CRYPTO,
30385         MODULO_MODE,
30386         POW_PRECISION,
30387         FORMAT,
30388         ALPHABET
30389       };
30390     };
30391     BigNumber2.isBigNumber = function(v2) {
30392       if (!v2 || v2._isBigNumber !== true) return false;
30393       if (!BigNumber2.DEBUG) return true;
30394       var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s;
30395       out: if ({}.toString.call(c2) == "[object Array]") {
30396         if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) {
30397           if (c2[0] === 0) {
30398             if (e3 === 0 && c2.length === 1) return true;
30399             break out;
30400           }
30401           i3 = (e3 + 1) % LOG_BASE;
30402           if (i3 < 1) i3 += LOG_BASE;
30403           if (String(c2[0]).length == i3) {
30404             for (i3 = 0; i3 < c2.length; i3++) {
30405               n3 = c2[i3];
30406               if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3)) break out;
30407             }
30408             if (n3 !== 0) return true;
30409           }
30410         }
30411       } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) {
30412         return true;
30413       }
30414       throw Error(bignumberError + "Invalid BigNumber: " + v2);
30415     };
30416     BigNumber2.maximum = BigNumber2.max = function() {
30417       return maxOrMin(arguments, -1);
30418     };
30419     BigNumber2.minimum = BigNumber2.min = function() {
30420       return maxOrMin(arguments, 1);
30421     };
30422     BigNumber2.random = function() {
30423       var pow2_53 = 9007199254740992;
30424       var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
30425         return mathfloor(Math.random() * pow2_53);
30426       } : function() {
30427         return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
30428       };
30429       return function(dp) {
30430         var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE);
30431         if (dp == null) dp = DECIMAL_PLACES;
30432         else intCheck(dp, 0, MAX);
30433         k2 = mathceil(dp / LOG_BASE);
30434         if (CRYPTO) {
30435           if (crypto.getRandomValues) {
30436             a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2));
30437             for (; i3 < k2; ) {
30438               v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11);
30439               if (v2 >= 9e15) {
30440                 b2 = crypto.getRandomValues(new Uint32Array(2));
30441                 a2[i3] = b2[0];
30442                 a2[i3 + 1] = b2[1];
30443               } else {
30444                 c2.push(v2 % 1e14);
30445                 i3 += 2;
30446               }
30447             }
30448             i3 = k2 / 2;
30449           } else if (crypto.randomBytes) {
30450             a2 = crypto.randomBytes(k2 *= 7);
30451             for (; i3 < k2; ) {
30452               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];
30453               if (v2 >= 9e15) {
30454                 crypto.randomBytes(7).copy(a2, i3);
30455               } else {
30456                 c2.push(v2 % 1e14);
30457                 i3 += 7;
30458               }
30459             }
30460             i3 = k2 / 7;
30461           } else {
30462             CRYPTO = false;
30463             throw Error(bignumberError + "crypto unavailable");
30464           }
30465         }
30466         if (!CRYPTO) {
30467           for (; i3 < k2; ) {
30468             v2 = random53bitInt();
30469             if (v2 < 9e15) c2[i3++] = v2 % 1e14;
30470           }
30471         }
30472         k2 = c2[--i3];
30473         dp %= LOG_BASE;
30474         if (k2 && dp) {
30475           v2 = POWS_TEN[LOG_BASE - dp];
30476           c2[i3] = mathfloor(k2 / v2) * v2;
30477         }
30478         for (; c2[i3] === 0; c2.pop(), i3--) ;
30479         if (i3 < 0) {
30480           c2 = [e3 = 0];
30481         } else {
30482           for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE) ;
30483           for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++) ;
30484           if (i3 < LOG_BASE) e3 -= LOG_BASE - i3;
30485         }
30486         rand.e = e3;
30487         rand.c = c2;
30488         return rand;
30489       };
30490     }();
30491     BigNumber2.sum = function() {
30492       var i3 = 1, args = arguments, sum = new BigNumber2(args[0]);
30493       for (; i3 < args.length; ) sum = sum.plus(args[i3++]);
30494       return sum;
30495     };
30496     convertBase = /* @__PURE__ */ function() {
30497       var decimal = "0123456789";
30498       function toBaseOut(str, baseIn, baseOut, alphabet) {
30499         var j2, arr = [0], arrL, i3 = 0, len = str.length;
30500         for (; i3 < len; ) {
30501           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
30502           arr[0] += alphabet.indexOf(str.charAt(i3++));
30503           for (j2 = 0; j2 < arr.length; j2++) {
30504             if (arr[j2] > baseOut - 1) {
30505               if (arr[j2 + 1] == null) arr[j2 + 1] = 0;
30506               arr[j2 + 1] += arr[j2] / baseOut | 0;
30507               arr[j2] %= baseOut;
30508             }
30509           }
30510         }
30511         return arr.reverse();
30512       }
30513       return function(str, baseIn, baseOut, sign2, callerIsToString) {
30514         var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
30515         if (i3 >= 0) {
30516           k2 = POW_PRECISION;
30517           POW_PRECISION = 0;
30518           str = str.replace(".", "");
30519           y2 = new BigNumber2(baseIn);
30520           x2 = y2.pow(str.length - i3);
30521           POW_PRECISION = k2;
30522           y2.c = toBaseOut(
30523             toFixedPoint(coeffToString(x2.c), x2.e, "0"),
30524             10,
30525             baseOut,
30526             decimal
30527           );
30528           y2.e = y2.c.length;
30529         }
30530         xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
30531         e3 = k2 = xc.length;
30532         for (; xc[--k2] == 0; xc.pop()) ;
30533         if (!xc[0]) return alphabet.charAt(0);
30534         if (i3 < 0) {
30535           --e3;
30536         } else {
30537           x2.c = xc;
30538           x2.e = e3;
30539           x2.s = sign2;
30540           x2 = div(x2, y2, dp, rm, baseOut);
30541           xc = x2.c;
30542           r2 = x2.r;
30543           e3 = x2.e;
30544         }
30545         d2 = e3 + dp + 1;
30546         i3 = xc[d2];
30547         k2 = baseOut / 2;
30548         r2 = r2 || d2 < 0 || xc[d2 + 1] != null;
30549         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));
30550         if (d2 < 1 || !xc[0]) {
30551           str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
30552         } else {
30553           xc.length = d2;
30554           if (r2) {
30555             for (--baseOut; ++xc[--d2] > baseOut; ) {
30556               xc[d2] = 0;
30557               if (!d2) {
30558                 ++e3;
30559                 xc = [1].concat(xc);
30560               }
30561             }
30562           }
30563           for (k2 = xc.length; !xc[--k2]; ) ;
30564           for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++])) ;
30565           str = toFixedPoint(str, e3, alphabet.charAt(0));
30566         }
30567         return str;
30568       };
30569     }();
30570     div = /* @__PURE__ */ function() {
30571       function multiply(x2, k2, base) {
30572         var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0;
30573         for (x2 = x2.slice(); i3--; ) {
30574           xlo = x2[i3] % SQRT_BASE;
30575           xhi = x2[i3] / SQRT_BASE | 0;
30576           m2 = khi * xlo + xhi * klo;
30577           temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry;
30578           carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi;
30579           x2[i3] = temp % base;
30580         }
30581         if (carry) x2 = [carry].concat(x2);
30582         return x2;
30583       }
30584       function compare2(a2, b2, aL, bL) {
30585         var i3, cmp;
30586         if (aL != bL) {
30587           cmp = aL > bL ? 1 : -1;
30588         } else {
30589           for (i3 = cmp = 0; i3 < aL; i3++) {
30590             if (a2[i3] != b2[i3]) {
30591               cmp = a2[i3] > b2[i3] ? 1 : -1;
30592               break;
30593             }
30594           }
30595         }
30596         return cmp;
30597       }
30598       function subtract(a2, b2, aL, base) {
30599         var i3 = 0;
30600         for (; aL--; ) {
30601           a2[aL] -= i3;
30602           i3 = a2[aL] < b2[aL] ? 1 : 0;
30603           a2[aL] = i3 * base + a2[aL] - b2[aL];
30604         }
30605         for (; !a2[0] && a2.length > 1; a2.splice(0, 1)) ;
30606       }
30607       return function(x2, y2, dp, rm, base) {
30608         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;
30609         if (!xc || !xc[0] || !yc || !yc[0]) {
30610           return new BigNumber2(
30611             // Return NaN if either NaN, or both Infinity or 0.
30612             !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
30613               // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
30614               xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0
30615             )
30616           );
30617         }
30618         q2 = new BigNumber2(s2);
30619         qc = q2.c = [];
30620         e3 = x2.e - y2.e;
30621         s2 = dp + e3 + 1;
30622         if (!base) {
30623           base = BASE;
30624           e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE);
30625           s2 = s2 / LOG_BASE | 0;
30626         }
30627         for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++) ;
30628         if (yc[i3] > (xc[i3] || 0)) e3--;
30629         if (s2 < 0) {
30630           qc.push(1);
30631           more = true;
30632         } else {
30633           xL = xc.length;
30634           yL = yc.length;
30635           i3 = 0;
30636           s2 += 2;
30637           n3 = mathfloor(base / (yc[0] + 1));
30638           if (n3 > 1) {
30639             yc = multiply(yc, n3, base);
30640             xc = multiply(xc, n3, base);
30641             yL = yc.length;
30642             xL = xc.length;
30643           }
30644           xi = yL;
30645           rem = xc.slice(0, yL);
30646           remL = rem.length;
30647           for (; remL < yL; rem[remL++] = 0) ;
30648           yz = yc.slice();
30649           yz = [0].concat(yz);
30650           yc0 = yc[0];
30651           if (yc[1] >= base / 2) yc0++;
30652           do {
30653             n3 = 0;
30654             cmp = compare2(yc, rem, yL, remL);
30655             if (cmp < 0) {
30656               rem0 = rem[0];
30657               if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
30658               n3 = mathfloor(rem0 / yc0);
30659               if (n3 > 1) {
30660                 if (n3 >= base) n3 = base - 1;
30661                 prod = multiply(yc, n3, base);
30662                 prodL = prod.length;
30663                 remL = rem.length;
30664                 while (compare2(prod, rem, prodL, remL) == 1) {
30665                   n3--;
30666                   subtract(prod, yL < prodL ? yz : yc, prodL, base);
30667                   prodL = prod.length;
30668                   cmp = 1;
30669                 }
30670               } else {
30671                 if (n3 == 0) {
30672                   cmp = n3 = 1;
30673                 }
30674                 prod = yc.slice();
30675                 prodL = prod.length;
30676               }
30677               if (prodL < remL) prod = [0].concat(prod);
30678               subtract(rem, prod, remL, base);
30679               remL = rem.length;
30680               if (cmp == -1) {
30681                 while (compare2(yc, rem, yL, remL) < 1) {
30682                   n3++;
30683                   subtract(rem, yL < remL ? yz : yc, remL, base);
30684                   remL = rem.length;
30685                 }
30686               }
30687             } else if (cmp === 0) {
30688               n3++;
30689               rem = [0];
30690             }
30691             qc[i3++] = n3;
30692             if (rem[0]) {
30693               rem[remL++] = xc[xi] || 0;
30694             } else {
30695               rem = [xc[xi]];
30696               remL = 1;
30697             }
30698           } while ((xi++ < xL || rem[0] != null) && s2--);
30699           more = rem[0] != null;
30700           if (!qc[0]) qc.splice(0, 1);
30701         }
30702         if (base == BASE) {
30703           for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++) ;
30704           round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more);
30705         } else {
30706           q2.e = e3;
30707           q2.r = +more;
30708         }
30709         return q2;
30710       };
30711     }();
30712     function format2(n3, i3, rm, id2) {
30713       var c0, e3, ne2, len, str;
30714       if (rm == null) rm = ROUNDING_MODE;
30715       else intCheck(rm, 0, 8);
30716       if (!n3.c) return n3.toString();
30717       c0 = n3.c[0];
30718       ne2 = n3.e;
30719       if (i3 == null) {
30720         str = coeffToString(n3.c);
30721         str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0");
30722       } else {
30723         n3 = round(new BigNumber2(n3), i3, rm);
30724         e3 = n3.e;
30725         str = coeffToString(n3.c);
30726         len = str.length;
30727         if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) {
30728           for (; len < i3; str += "0", len++) ;
30729           str = toExponential(str, e3);
30730         } else {
30731           i3 -= ne2;
30732           str = toFixedPoint(str, e3, "0");
30733           if (e3 + 1 > len) {
30734             if (--i3 > 0) for (str += "."; i3--; str += "0") ;
30735           } else {
30736             i3 += e3 - len;
30737             if (i3 > 0) {
30738               if (e3 + 1 == len) str += ".";
30739               for (; i3--; str += "0") ;
30740             }
30741           }
30742         }
30743       }
30744       return n3.s < 0 && c0 ? "-" + str : str;
30745     }
30746     function maxOrMin(args, n3) {
30747       var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]);
30748       for (; i3 < args.length; i3++) {
30749         y2 = new BigNumber2(args[i3]);
30750         if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) {
30751           x2 = y2;
30752         }
30753       }
30754       return x2;
30755     }
30756     function normalise(n3, c2, e3) {
30757       var i3 = 1, j2 = c2.length;
30758       for (; !c2[--j2]; c2.pop()) ;
30759       for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++) ;
30760       if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) {
30761         n3.c = n3.e = null;
30762       } else if (e3 < MIN_EXP) {
30763         n3.c = [n3.e = 0];
30764       } else {
30765         n3.e = e3;
30766         n3.c = c2;
30767       }
30768       return n3;
30769     }
30770     parseNumeric2 = /* @__PURE__ */ function() {
30771       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
30772       return function(x2, str, isNum, b2) {
30773         var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, "");
30774         if (isInfinityOrNaN.test(s2)) {
30775           x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1;
30776         } else {
30777           if (!isNum) {
30778             s2 = s2.replace(basePrefix, function(m2, p1, p2) {
30779               base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
30780               return !b2 || b2 == base ? p1 : m2;
30781             });
30782             if (b2) {
30783               base = b2;
30784               s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
30785             }
30786             if (str != s2) return new BigNumber2(s2, base);
30787           }
30788           if (BigNumber2.DEBUG) {
30789             throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str);
30790           }
30791           x2.s = null;
30792         }
30793         x2.c = x2.e = null;
30794       };
30795     }();
30796     function round(x2, sd, rm, r2) {
30797       var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN;
30798       if (xc) {
30799         out: {
30800           for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++) ;
30801           i3 = sd - d2;
30802           if (i3 < 0) {
30803             i3 += LOG_BASE;
30804             j2 = sd;
30805             n3 = xc[ni = 0];
30806             rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
30807           } else {
30808             ni = mathceil((i3 + 1) / LOG_BASE);
30809             if (ni >= xc.length) {
30810               if (r2) {
30811                 for (; xc.length <= ni; xc.push(0)) ;
30812                 n3 = rd = 0;
30813                 d2 = 1;
30814                 i3 %= LOG_BASE;
30815                 j2 = i3 - LOG_BASE + 1;
30816               } else {
30817                 break out;
30818               }
30819             } else {
30820               n3 = k2 = xc[ni];
30821               for (d2 = 1; k2 >= 10; k2 /= 10, d2++) ;
30822               i3 %= LOG_BASE;
30823               j2 = i3 - LOG_BASE + d2;
30824               rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
30825             }
30826           }
30827           r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit?
30828           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right
30829           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
30830           xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]);
30831           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.
30832           (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7));
30833           if (sd < 1 || !xc[0]) {
30834             xc.length = 0;
30835             if (r2) {
30836               sd -= x2.e + 1;
30837               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
30838               x2.e = -sd || 0;
30839             } else {
30840               xc[0] = x2.e = 0;
30841             }
30842             return x2;
30843           }
30844           if (i3 == 0) {
30845             xc.length = ni;
30846             k2 = 1;
30847             ni--;
30848           } else {
30849             xc.length = ni + 1;
30850             k2 = pows10[LOG_BASE - i3];
30851             xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0;
30852           }
30853           if (r2) {
30854             for (; ; ) {
30855               if (ni == 0) {
30856                 for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++) ;
30857                 j2 = xc[0] += k2;
30858                 for (k2 = 1; j2 >= 10; j2 /= 10, k2++) ;
30859                 if (i3 != k2) {
30860                   x2.e++;
30861                   if (xc[0] == BASE) xc[0] = 1;
30862                 }
30863                 break;
30864               } else {
30865                 xc[ni] += k2;
30866                 if (xc[ni] != BASE) break;
30867                 xc[ni--] = 0;
30868                 k2 = 1;
30869               }
30870             }
30871           }
30872           for (i3 = xc.length; xc[--i3] === 0; xc.pop()) ;
30873         }
30874         if (x2.e > MAX_EXP) {
30875           x2.c = x2.e = null;
30876         } else if (x2.e < MIN_EXP) {
30877           x2.c = [x2.e = 0];
30878         }
30879       }
30880       return x2;
30881     }
30882     function valueOf(n3) {
30883       var str, e3 = n3.e;
30884       if (e3 === null) return n3.toString();
30885       str = coeffToString(n3.c);
30886       str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0");
30887       return n3.s < 0 ? "-" + str : str;
30888     }
30889     P2.absoluteValue = P2.abs = function() {
30890       var x2 = new BigNumber2(this);
30891       if (x2.s < 0) x2.s = 1;
30892       return x2;
30893     };
30894     P2.comparedTo = function(y2, b2) {
30895       return compare(this, new BigNumber2(y2, b2));
30896     };
30897     P2.decimalPlaces = P2.dp = function(dp, rm) {
30898       var c2, n3, v2, x2 = this;
30899       if (dp != null) {
30900         intCheck(dp, 0, MAX);
30901         if (rm == null) rm = ROUNDING_MODE;
30902         else intCheck(rm, 0, 8);
30903         return round(new BigNumber2(x2), dp + x2.e + 1, rm);
30904       }
30905       if (!(c2 = x2.c)) return null;
30906       n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
30907       if (v2 = c2[v2]) for (; v2 % 10 == 0; v2 /= 10, n3--) ;
30908       if (n3 < 0) n3 = 0;
30909       return n3;
30910     };
30911     P2.dividedBy = P2.div = function(y2, b2) {
30912       return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE);
30913     };
30914     P2.dividedToIntegerBy = P2.idiv = function(y2, b2) {
30915       return div(this, new BigNumber2(y2, b2), 0, 1);
30916     };
30917     P2.exponentiatedBy = P2.pow = function(n3, m2) {
30918       var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this;
30919       n3 = new BigNumber2(n3);
30920       if (n3.c && !n3.isInteger()) {
30921         throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3));
30922       }
30923       if (m2 != null) m2 = new BigNumber2(m2);
30924       nIsBig = n3.e > 14;
30925       if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) {
30926         y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3)));
30927         return m2 ? y2.mod(m2) : y2;
30928       }
30929       nIsNeg = n3.s < 0;
30930       if (m2) {
30931         if (m2.c ? !m2.c[0] : !m2.s) return new BigNumber2(NaN);
30932         isModExp = !nIsNeg && x2.isInteger() && m2.isInteger();
30933         if (isModExp) x2 = x2.mod(m2);
30934       } 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))) {
30935         k2 = x2.s < 0 && isOdd(n3) ? -0 : 0;
30936         if (x2.e > -1) k2 = 1 / k2;
30937         return new BigNumber2(nIsNeg ? 1 / k2 : k2);
30938       } else if (POW_PRECISION) {
30939         k2 = mathceil(POW_PRECISION / LOG_BASE + 2);
30940       }
30941       if (nIsBig) {
30942         half = new BigNumber2(0.5);
30943         if (nIsNeg) n3.s = 1;
30944         nIsOdd = isOdd(n3);
30945       } else {
30946         i3 = Math.abs(+valueOf(n3));
30947         nIsOdd = i3 % 2;
30948       }
30949       y2 = new BigNumber2(ONE);
30950       for (; ; ) {
30951         if (nIsOdd) {
30952           y2 = y2.times(x2);
30953           if (!y2.c) break;
30954           if (k2) {
30955             if (y2.c.length > k2) y2.c.length = k2;
30956           } else if (isModExp) {
30957             y2 = y2.mod(m2);
30958           }
30959         }
30960         if (i3) {
30961           i3 = mathfloor(i3 / 2);
30962           if (i3 === 0) break;
30963           nIsOdd = i3 % 2;
30964         } else {
30965           n3 = n3.times(half);
30966           round(n3, n3.e + 1, 1);
30967           if (n3.e > 14) {
30968             nIsOdd = isOdd(n3);
30969           } else {
30970             i3 = +valueOf(n3);
30971             if (i3 === 0) break;
30972             nIsOdd = i3 % 2;
30973           }
30974         }
30975         x2 = x2.times(x2);
30976         if (k2) {
30977           if (x2.c && x2.c.length > k2) x2.c.length = k2;
30978         } else if (isModExp) {
30979           x2 = x2.mod(m2);
30980         }
30981       }
30982       if (isModExp) return y2;
30983       if (nIsNeg) y2 = ONE.div(y2);
30984       return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2;
30985     };
30986     P2.integerValue = function(rm) {
30987       var n3 = new BigNumber2(this);
30988       if (rm == null) rm = ROUNDING_MODE;
30989       else intCheck(rm, 0, 8);
30990       return round(n3, n3.e + 1, rm);
30991     };
30992     P2.isEqualTo = P2.eq = function(y2, b2) {
30993       return compare(this, new BigNumber2(y2, b2)) === 0;
30994     };
30995     P2.isFinite = function() {
30996       return !!this.c;
30997     };
30998     P2.isGreaterThan = P2.gt = function(y2, b2) {
30999       return compare(this, new BigNumber2(y2, b2)) > 0;
31000     };
31001     P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) {
31002       return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0;
31003     };
31004     P2.isInteger = function() {
31005       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
31006     };
31007     P2.isLessThan = P2.lt = function(y2, b2) {
31008       return compare(this, new BigNumber2(y2, b2)) < 0;
31009     };
31010     P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) {
31011       return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0;
31012     };
31013     P2.isNaN = function() {
31014       return !this.s;
31015     };
31016     P2.isNegative = function() {
31017       return this.s < 0;
31018     };
31019     P2.isPositive = function() {
31020       return this.s > 0;
31021     };
31022     P2.isZero = function() {
31023       return !!this.c && this.c[0] == 0;
31024     };
31025     P2.minus = function(y2, b2) {
31026       var i3, j2, t2, xLTy, x2 = this, a2 = x2.s;
31027       y2 = new BigNumber2(y2, b2);
31028       b2 = y2.s;
31029       if (!a2 || !b2) return new BigNumber2(NaN);
31030       if (a2 != b2) {
31031         y2.s = -b2;
31032         return x2.plus(y2);
31033       }
31034       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
31035       if (!xe2 || !ye2) {
31036         if (!xc || !yc) return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN);
31037         if (!xc[0] || !yc[0]) {
31038           return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : (
31039             // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
31040             ROUNDING_MODE == 3 ? -0 : 0
31041           ));
31042         }
31043       }
31044       xe2 = bitFloor(xe2);
31045       ye2 = bitFloor(ye2);
31046       xc = xc.slice();
31047       if (a2 = xe2 - ye2) {
31048         if (xLTy = a2 < 0) {
31049           a2 = -a2;
31050           t2 = xc;
31051         } else {
31052           ye2 = xe2;
31053           t2 = yc;
31054         }
31055         t2.reverse();
31056         for (b2 = a2; b2--; t2.push(0)) ;
31057         t2.reverse();
31058       } else {
31059         j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2;
31060         for (a2 = b2 = 0; b2 < j2; b2++) {
31061           if (xc[b2] != yc[b2]) {
31062             xLTy = xc[b2] < yc[b2];
31063             break;
31064           }
31065         }
31066       }
31067       if (xLTy) {
31068         t2 = xc;
31069         xc = yc;
31070         yc = t2;
31071         y2.s = -y2.s;
31072       }
31073       b2 = (j2 = yc.length) - (i3 = xc.length);
31074       if (b2 > 0) for (; b2--; xc[i3++] = 0) ;
31075       b2 = BASE - 1;
31076       for (; j2 > a2; ) {
31077         if (xc[--j2] < yc[j2]) {
31078           for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2) ;
31079           --xc[i3];
31080           xc[j2] += BASE;
31081         }
31082         xc[j2] -= yc[j2];
31083       }
31084       for (; xc[0] == 0; xc.splice(0, 1), --ye2) ;
31085       if (!xc[0]) {
31086         y2.s = ROUNDING_MODE == 3 ? -1 : 1;
31087         y2.c = [y2.e = 0];
31088         return y2;
31089       }
31090       return normalise(y2, xc, ye2);
31091     };
31092     P2.modulo = P2.mod = function(y2, b2) {
31093       var q2, s2, x2 = this;
31094       y2 = new BigNumber2(y2, b2);
31095       if (!x2.c || !y2.s || y2.c && !y2.c[0]) {
31096         return new BigNumber2(NaN);
31097       } else if (!y2.c || x2.c && !x2.c[0]) {
31098         return new BigNumber2(x2);
31099       }
31100       if (MODULO_MODE == 9) {
31101         s2 = y2.s;
31102         y2.s = 1;
31103         q2 = div(x2, y2, 0, 3);
31104         y2.s = s2;
31105         q2.s *= s2;
31106       } else {
31107         q2 = div(x2, y2, 0, MODULO_MODE);
31108       }
31109       y2 = x2.minus(q2.times(y2));
31110       if (!y2.c[0] && MODULO_MODE == 1) y2.s = x2.s;
31111       return y2;
31112     };
31113     P2.multipliedBy = P2.times = function(y2, b2) {
31114       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;
31115       if (!xc || !yc || !xc[0] || !yc[0]) {
31116         if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
31117           y2.c = y2.e = y2.s = null;
31118         } else {
31119           y2.s *= x2.s;
31120           if (!xc || !yc) {
31121             y2.c = y2.e = null;
31122           } else {
31123             y2.c = [0];
31124             y2.e = 0;
31125           }
31126         }
31127         return y2;
31128       }
31129       e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE);
31130       y2.s *= x2.s;
31131       xcL = xc.length;
31132       ycL = yc.length;
31133       if (xcL < ycL) {
31134         zc = xc;
31135         xc = yc;
31136         yc = zc;
31137         i3 = xcL;
31138         xcL = ycL;
31139         ycL = i3;
31140       }
31141       for (i3 = xcL + ycL, zc = []; i3--; zc.push(0)) ;
31142       base = BASE;
31143       sqrtBase = SQRT_BASE;
31144       for (i3 = ycL; --i3 >= 0; ) {
31145         c2 = 0;
31146         ylo = yc[i3] % sqrtBase;
31147         yhi = yc[i3] / sqrtBase | 0;
31148         for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) {
31149           xlo = xc[--k2] % sqrtBase;
31150           xhi = xc[k2] / sqrtBase | 0;
31151           m2 = yhi * xlo + xhi * ylo;
31152           xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2;
31153           c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi;
31154           zc[j2--] = xlo % base;
31155         }
31156         zc[j2] = c2;
31157       }
31158       if (c2) {
31159         ++e3;
31160       } else {
31161         zc.splice(0, 1);
31162       }
31163       return normalise(y2, zc, e3);
31164     };
31165     P2.negated = function() {
31166       var x2 = new BigNumber2(this);
31167       x2.s = -x2.s || null;
31168       return x2;
31169     };
31170     P2.plus = function(y2, b2) {
31171       var t2, x2 = this, a2 = x2.s;
31172       y2 = new BigNumber2(y2, b2);
31173       b2 = y2.s;
31174       if (!a2 || !b2) return new BigNumber2(NaN);
31175       if (a2 != b2) {
31176         y2.s = -b2;
31177         return x2.minus(y2);
31178       }
31179       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
31180       if (!xe2 || !ye2) {
31181         if (!xc || !yc) return new BigNumber2(a2 / 0);
31182         if (!xc[0] || !yc[0]) return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0);
31183       }
31184       xe2 = bitFloor(xe2);
31185       ye2 = bitFloor(ye2);
31186       xc = xc.slice();
31187       if (a2 = xe2 - ye2) {
31188         if (a2 > 0) {
31189           ye2 = xe2;
31190           t2 = yc;
31191         } else {
31192           a2 = -a2;
31193           t2 = xc;
31194         }
31195         t2.reverse();
31196         for (; a2--; t2.push(0)) ;
31197         t2.reverse();
31198       }
31199       a2 = xc.length;
31200       b2 = yc.length;
31201       if (a2 - b2 < 0) {
31202         t2 = yc;
31203         yc = xc;
31204         xc = t2;
31205         b2 = a2;
31206       }
31207       for (a2 = 0; b2; ) {
31208         a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0;
31209         xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE;
31210       }
31211       if (a2) {
31212         xc = [a2].concat(xc);
31213         ++ye2;
31214       }
31215       return normalise(y2, xc, ye2);
31216     };
31217     P2.precision = P2.sd = function(sd, rm) {
31218       var c2, n3, v2, x2 = this;
31219       if (sd != null && sd !== !!sd) {
31220         intCheck(sd, 1, MAX);
31221         if (rm == null) rm = ROUNDING_MODE;
31222         else intCheck(rm, 0, 8);
31223         return round(new BigNumber2(x2), sd, rm);
31224       }
31225       if (!(c2 = x2.c)) return null;
31226       v2 = c2.length - 1;
31227       n3 = v2 * LOG_BASE + 1;
31228       if (v2 = c2[v2]) {
31229         for (; v2 % 10 == 0; v2 /= 10, n3--) ;
31230         for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++) ;
31231       }
31232       if (sd && x2.e + 1 > n3) n3 = x2.e + 1;
31233       return n3;
31234     };
31235     P2.shiftedBy = function(k2) {
31236       intCheck(k2, -MAX_SAFE_INTEGER3, MAX_SAFE_INTEGER3);
31237       return this.times("1e" + k2);
31238     };
31239     P2.squareRoot = P2.sqrt = function() {
31240       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");
31241       if (s2 !== 1 || !c2 || !c2[0]) {
31242         return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0);
31243       }
31244       s2 = Math.sqrt(+valueOf(x2));
31245       if (s2 == 0 || s2 == 1 / 0) {
31246         n3 = coeffToString(c2);
31247         if ((n3.length + e3) % 2 == 0) n3 += "0";
31248         s2 = Math.sqrt(+n3);
31249         e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
31250         if (s2 == 1 / 0) {
31251           n3 = "5e" + e3;
31252         } else {
31253           n3 = s2.toExponential();
31254           n3 = n3.slice(0, n3.indexOf("e") + 1) + e3;
31255         }
31256         r2 = new BigNumber2(n3);
31257       } else {
31258         r2 = new BigNumber2(s2 + "");
31259       }
31260       if (r2.c[0]) {
31261         e3 = r2.e;
31262         s2 = e3 + dp;
31263         if (s2 < 3) s2 = 0;
31264         for (; ; ) {
31265           t2 = r2;
31266           r2 = half.times(t2.plus(div(x2, t2, dp, 1)));
31267           if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) {
31268             if (r2.e < e3) --s2;
31269             n3 = n3.slice(s2 - 3, s2 + 1);
31270             if (n3 == "9999" || !rep && n3 == "4999") {
31271               if (!rep) {
31272                 round(t2, t2.e + DECIMAL_PLACES + 2, 0);
31273                 if (t2.times(t2).eq(x2)) {
31274                   r2 = t2;
31275                   break;
31276                 }
31277               }
31278               dp += 4;
31279               s2 += 4;
31280               rep = 1;
31281             } else {
31282               if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") {
31283                 round(r2, r2.e + DECIMAL_PLACES + 2, 1);
31284                 m2 = !r2.times(r2).eq(x2);
31285               }
31286               break;
31287             }
31288           }
31289         }
31290       }
31291       return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2);
31292     };
31293     P2.toExponential = function(dp, rm) {
31294       if (dp != null) {
31295         intCheck(dp, 0, MAX);
31296         dp++;
31297       }
31298       return format2(this, dp, rm, 1);
31299     };
31300     P2.toFixed = function(dp, rm) {
31301       if (dp != null) {
31302         intCheck(dp, 0, MAX);
31303         dp = dp + this.e + 1;
31304       }
31305       return format2(this, dp, rm);
31306     };
31307     P2.toFormat = function(dp, rm, format3) {
31308       var str, x2 = this;
31309       if (format3 == null) {
31310         if (dp != null && rm && typeof rm == "object") {
31311           format3 = rm;
31312           rm = null;
31313         } else if (dp && typeof dp == "object") {
31314           format3 = dp;
31315           dp = rm = null;
31316         } else {
31317           format3 = FORMAT;
31318         }
31319       } else if (typeof format3 != "object") {
31320         throw Error(bignumberError + "Argument not an object: " + format3);
31321       }
31322       str = x2.toFixed(dp, rm);
31323       if (x2.c) {
31324         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;
31325         if (g22) {
31326           i3 = g1;
31327           g1 = g22;
31328           g22 = i3;
31329           len -= i3;
31330         }
31331         if (g1 > 0 && len > 0) {
31332           i3 = len % g1 || g1;
31333           intPart = intDigits.substr(0, i3);
31334           for (; i3 < len; i3 += g1) intPart += groupSeparator + intDigits.substr(i3, g1);
31335           if (g22 > 0) intPart += groupSeparator + intDigits.slice(i3);
31336           if (isNeg) intPart = "-" + intPart;
31337         }
31338         str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace(
31339           new RegExp("\\d{" + g22 + "}\\B", "g"),
31340           "$&" + (format3.fractionGroupSeparator || "")
31341         ) : fractionPart) : intPart;
31342       }
31343       return (format3.prefix || "") + str + (format3.suffix || "");
31344     };
31345     P2.toFraction = function(md) {
31346       var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c;
31347       if (md != null) {
31348         n3 = new BigNumber2(md);
31349         if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) {
31350           throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3));
31351         }
31352       }
31353       if (!xc) return new BigNumber2(x2);
31354       d2 = new BigNumber2(ONE);
31355       n1 = d0 = new BigNumber2(ONE);
31356       d1 = n0 = new BigNumber2(ONE);
31357       s2 = coeffToString(xc);
31358       e3 = d2.e = s2.length - x2.e - 1;
31359       d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2];
31360       md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3;
31361       exp2 = MAX_EXP;
31362       MAX_EXP = 1 / 0;
31363       n3 = new BigNumber2(s2);
31364       n0.c[0] = 0;
31365       for (; ; ) {
31366         q2 = div(n3, d2, 0, 1);
31367         d22 = d0.plus(q2.times(d1));
31368         if (d22.comparedTo(md) == 1) break;
31369         d0 = d1;
31370         d1 = d22;
31371         n1 = n0.plus(q2.times(d22 = n1));
31372         n0 = d22;
31373         d2 = n3.minus(q2.times(d22 = d2));
31374         n3 = d22;
31375       }
31376       d22 = div(md.minus(d0), d1, 0, 1);
31377       n0 = n0.plus(d22.times(n1));
31378       d0 = d0.plus(d22.times(d1));
31379       n0.s = n1.s = x2.s;
31380       e3 = e3 * 2;
31381       r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo(
31382         div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs()
31383       ) < 1 ? [n1, d1] : [n0, d0];
31384       MAX_EXP = exp2;
31385       return r2;
31386     };
31387     P2.toNumber = function() {
31388       return +valueOf(this);
31389     };
31390     P2.toPrecision = function(sd, rm) {
31391       if (sd != null) intCheck(sd, 1, MAX);
31392       return format2(this, sd, rm, 2);
31393     };
31394     P2.toString = function(b2) {
31395       var str, n3 = this, s2 = n3.s, e3 = n3.e;
31396       if (e3 === null) {
31397         if (s2) {
31398           str = "Infinity";
31399           if (s2 < 0) str = "-" + str;
31400         } else {
31401           str = "NaN";
31402         }
31403       } else {
31404         if (b2 == null) {
31405           str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0");
31406         } else if (b2 === 10 && alphabetHasNormalDecimalDigits) {
31407           n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE);
31408           str = toFixedPoint(coeffToString(n3.c), n3.e, "0");
31409         } else {
31410           intCheck(b2, 2, ALPHABET.length, "Base");
31411           str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true);
31412         }
31413         if (s2 < 0 && n3.c[0]) str = "-" + str;
31414       }
31415       return str;
31416     };
31417     P2.valueOf = P2.toJSON = function() {
31418       return valueOf(this);
31419     };
31420     P2._isBigNumber = true;
31421     P2[Symbol.toStringTag] = "BigNumber";
31422     P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf;
31423     if (configObject != null) BigNumber2.set(configObject);
31424     return BigNumber2;
31425   }
31426   function bitFloor(n3) {
31427     var i3 = n3 | 0;
31428     return n3 > 0 || n3 === i3 ? i3 : i3 - 1;
31429   }
31430   function coeffToString(a2) {
31431     var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + "";
31432     for (; i3 < j2; ) {
31433       s2 = a2[i3++] + "";
31434       z2 = LOG_BASE - s2.length;
31435       for (; z2--; s2 = "0" + s2) ;
31436       r2 += s2;
31437     }
31438     for (j2 = r2.length; r2.charCodeAt(--j2) === 48; ) ;
31439     return r2.slice(0, j2 + 1 || 1);
31440   }
31441   function compare(x2, y2) {
31442     var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e;
31443     if (!i3 || !j2) return null;
31444     a2 = xc && !xc[0];
31445     b2 = yc && !yc[0];
31446     if (a2 || b2) return a2 ? b2 ? 0 : -j2 : i3;
31447     if (i3 != j2) return i3;
31448     a2 = i3 < 0;
31449     b2 = k2 == l2;
31450     if (!xc || !yc) return b2 ? 0 : !xc ^ a2 ? 1 : -1;
31451     if (!b2) return k2 > l2 ^ a2 ? 1 : -1;
31452     j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2;
31453     for (i3 = 0; i3 < j2; i3++) if (xc[i3] != yc[i3]) return xc[i3] > yc[i3] ^ a2 ? 1 : -1;
31454     return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1;
31455   }
31456   function intCheck(n3, min3, max3, name) {
31457     if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) {
31458       throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3));
31459     }
31460   }
31461   function isOdd(n3) {
31462     var k2 = n3.c.length - 1;
31463     return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0;
31464   }
31465   function toExponential(str, e3) {
31466     return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3;
31467   }
31468   function toFixedPoint(str, e3, z2) {
31469     var len, zs;
31470     if (e3 < 0) {
31471       for (zs = z2 + "."; ++e3; zs += z2) ;
31472       str = zs + str;
31473     } else {
31474       len = str.length;
31475       if (++e3 > len) {
31476         for (zs = z2, e3 -= len; --e3; zs += z2) ;
31477         str += zs;
31478       } else if (e3 < len) {
31479         str = str.slice(0, e3) + "." + str.slice(e3);
31480       }
31481     }
31482     return str;
31483   }
31484   var BigNumber = clone();
31485   var bignumber_default = BigNumber;
31486
31487   // node_modules/splaytree-ts/dist/esm/index.js
31488   var SplayTreeNode = class {
31489     constructor(key) {
31490       __publicField(this, "key");
31491       __publicField(this, "left", null);
31492       __publicField(this, "right", null);
31493       this.key = key;
31494     }
31495   };
31496   var SplayTreeSetNode = class extends SplayTreeNode {
31497     constructor(key) {
31498       super(key);
31499     }
31500   };
31501   var SplayTree = class {
31502     constructor() {
31503       __publicField(this, "size", 0);
31504       __publicField(this, "modificationCount", 0);
31505       __publicField(this, "splayCount", 0);
31506     }
31507     splay(key) {
31508       const root3 = this.root;
31509       if (root3 == null) {
31510         this.compare(key, key);
31511         return -1;
31512       }
31513       let right = null;
31514       let newTreeRight = null;
31515       let left = null;
31516       let newTreeLeft = null;
31517       let current = root3;
31518       const compare2 = this.compare;
31519       let comp;
31520       while (true) {
31521         comp = compare2(current.key, key);
31522         if (comp > 0) {
31523           let currentLeft = current.left;
31524           if (currentLeft == null) break;
31525           comp = compare2(currentLeft.key, key);
31526           if (comp > 0) {
31527             current.left = currentLeft.right;
31528             currentLeft.right = current;
31529             current = currentLeft;
31530             currentLeft = current.left;
31531             if (currentLeft == null) break;
31532           }
31533           if (right == null) {
31534             newTreeRight = current;
31535           } else {
31536             right.left = current;
31537           }
31538           right = current;
31539           current = currentLeft;
31540         } else if (comp < 0) {
31541           let currentRight = current.right;
31542           if (currentRight == null) break;
31543           comp = compare2(currentRight.key, key);
31544           if (comp < 0) {
31545             current.right = currentRight.left;
31546             currentRight.left = current;
31547             current = currentRight;
31548             currentRight = current.right;
31549             if (currentRight == null) break;
31550           }
31551           if (left == null) {
31552             newTreeLeft = current;
31553           } else {
31554             left.right = current;
31555           }
31556           left = current;
31557           current = currentRight;
31558         } else {
31559           break;
31560         }
31561       }
31562       if (left != null) {
31563         left.right = current.left;
31564         current.left = newTreeLeft;
31565       }
31566       if (right != null) {
31567         right.left = current.right;
31568         current.right = newTreeRight;
31569       }
31570       if (this.root !== current) {
31571         this.root = current;
31572         this.splayCount++;
31573       }
31574       return comp;
31575     }
31576     splayMin(node) {
31577       let current = node;
31578       let nextLeft = current.left;
31579       while (nextLeft != null) {
31580         const left = nextLeft;
31581         current.left = left.right;
31582         left.right = current;
31583         current = left;
31584         nextLeft = current.left;
31585       }
31586       return current;
31587     }
31588     splayMax(node) {
31589       let current = node;
31590       let nextRight = current.right;
31591       while (nextRight != null) {
31592         const right = nextRight;
31593         current.right = right.left;
31594         right.left = current;
31595         current = right;
31596         nextRight = current.right;
31597       }
31598       return current;
31599     }
31600     _delete(key) {
31601       if (this.root == null) return null;
31602       const comp = this.splay(key);
31603       if (comp != 0) return null;
31604       let root3 = this.root;
31605       const result = root3;
31606       const left = root3.left;
31607       this.size--;
31608       if (left == null) {
31609         this.root = root3.right;
31610       } else {
31611         const right = root3.right;
31612         root3 = this.splayMax(left);
31613         root3.right = right;
31614         this.root = root3;
31615       }
31616       this.modificationCount++;
31617       return result;
31618     }
31619     addNewRoot(node, comp) {
31620       this.size++;
31621       this.modificationCount++;
31622       const root3 = this.root;
31623       if (root3 == null) {
31624         this.root = node;
31625         return;
31626       }
31627       if (comp < 0) {
31628         node.left = root3;
31629         node.right = root3.right;
31630         root3.right = null;
31631       } else {
31632         node.right = root3;
31633         node.left = root3.left;
31634         root3.left = null;
31635       }
31636       this.root = node;
31637     }
31638     _first() {
31639       const root3 = this.root;
31640       if (root3 == null) return null;
31641       this.root = this.splayMin(root3);
31642       return this.root;
31643     }
31644     _last() {
31645       const root3 = this.root;
31646       if (root3 == null) return null;
31647       this.root = this.splayMax(root3);
31648       return this.root;
31649     }
31650     clear() {
31651       this.root = null;
31652       this.size = 0;
31653       this.modificationCount++;
31654     }
31655     has(key) {
31656       return this.validKey(key) && this.splay(key) == 0;
31657     }
31658     defaultCompare() {
31659       return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
31660     }
31661     wrap() {
31662       return {
31663         getRoot: () => {
31664           return this.root;
31665         },
31666         setRoot: (root3) => {
31667           this.root = root3;
31668         },
31669         getSize: () => {
31670           return this.size;
31671         },
31672         getModificationCount: () => {
31673           return this.modificationCount;
31674         },
31675         getSplayCount: () => {
31676           return this.splayCount;
31677         },
31678         setSplayCount: (count) => {
31679           this.splayCount = count;
31680         },
31681         splay: (key) => {
31682           return this.splay(key);
31683         },
31684         has: (key) => {
31685           return this.has(key);
31686         }
31687       };
31688     }
31689   };
31690   var _a2, _b2;
31691   var SplayTreeSet = class _SplayTreeSet extends SplayTree {
31692     constructor(compare2, isValidKey) {
31693       super();
31694       __publicField(this, "root", null);
31695       __publicField(this, "compare");
31696       __publicField(this, "validKey");
31697       __publicField(this, _a2, "[object Set]");
31698       this.compare = compare2 != null ? compare2 : this.defaultCompare();
31699       this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0;
31700     }
31701     delete(element) {
31702       if (!this.validKey(element)) return false;
31703       return this._delete(element) != null;
31704     }
31705     deleteAll(elements) {
31706       for (const element of elements) {
31707         this.delete(element);
31708       }
31709     }
31710     forEach(f2) {
31711       const nodes = this[Symbol.iterator]();
31712       let result;
31713       while (result = nodes.next(), !result.done) {
31714         f2(result.value, result.value, this);
31715       }
31716     }
31717     add(element) {
31718       const compare2 = this.splay(element);
31719       if (compare2 != 0) this.addNewRoot(new SplayTreeSetNode(element), compare2);
31720       return this;
31721     }
31722     addAndReturn(element) {
31723       const compare2 = this.splay(element);
31724       if (compare2 != 0) this.addNewRoot(new SplayTreeSetNode(element), compare2);
31725       return this.root.key;
31726     }
31727     addAll(elements) {
31728       for (const element of elements) {
31729         this.add(element);
31730       }
31731     }
31732     isEmpty() {
31733       return this.root == null;
31734     }
31735     isNotEmpty() {
31736       return this.root != null;
31737     }
31738     single() {
31739       if (this.size == 0) throw "Bad state: No element";
31740       if (this.size > 1) throw "Bad state: Too many element";
31741       return this.root.key;
31742     }
31743     first() {
31744       if (this.size == 0) throw "Bad state: No element";
31745       return this._first().key;
31746     }
31747     last() {
31748       if (this.size == 0) throw "Bad state: No element";
31749       return this._last().key;
31750     }
31751     lastBefore(element) {
31752       if (element == null) throw "Invalid arguments(s)";
31753       if (this.root == null) return null;
31754       const comp = this.splay(element);
31755       if (comp < 0) return this.root.key;
31756       let node = this.root.left;
31757       if (node == null) return null;
31758       let nodeRight = node.right;
31759       while (nodeRight != null) {
31760         node = nodeRight;
31761         nodeRight = node.right;
31762       }
31763       return node.key;
31764     }
31765     firstAfter(element) {
31766       if (element == null) throw "Invalid arguments(s)";
31767       if (this.root == null) return null;
31768       const comp = this.splay(element);
31769       if (comp > 0) return this.root.key;
31770       let node = this.root.right;
31771       if (node == null) return null;
31772       let nodeLeft = node.left;
31773       while (nodeLeft != null) {
31774         node = nodeLeft;
31775         nodeLeft = node.left;
31776       }
31777       return node.key;
31778     }
31779     retainAll(elements) {
31780       const retainSet = new _SplayTreeSet(this.compare, this.validKey);
31781       const modificationCount = this.modificationCount;
31782       for (const object of elements) {
31783         if (modificationCount != this.modificationCount) {
31784           throw "Concurrent modification during iteration.";
31785         }
31786         if (this.validKey(object) && this.splay(object) == 0) {
31787           retainSet.add(this.root.key);
31788         }
31789       }
31790       if (retainSet.size != this.size) {
31791         this.root = retainSet.root;
31792         this.size = retainSet.size;
31793         this.modificationCount++;
31794       }
31795     }
31796     lookup(object) {
31797       if (!this.validKey(object)) return null;
31798       const comp = this.splay(object);
31799       if (comp != 0) return null;
31800       return this.root.key;
31801     }
31802     intersection(other2) {
31803       const result = new _SplayTreeSet(this.compare, this.validKey);
31804       for (const element of this) {
31805         if (other2.has(element)) result.add(element);
31806       }
31807       return result;
31808     }
31809     difference(other2) {
31810       const result = new _SplayTreeSet(this.compare, this.validKey);
31811       for (const element of this) {
31812         if (!other2.has(element)) result.add(element);
31813       }
31814       return result;
31815     }
31816     union(other2) {
31817       const u2 = this.clone();
31818       u2.addAll(other2);
31819       return u2;
31820     }
31821     clone() {
31822       const set4 = new _SplayTreeSet(this.compare, this.validKey);
31823       set4.size = this.size;
31824       set4.root = this.copyNode(this.root);
31825       return set4;
31826     }
31827     copyNode(node) {
31828       if (node == null) return null;
31829       function copyChildren(node2, dest) {
31830         let left;
31831         let right;
31832         do {
31833           left = node2.left;
31834           right = node2.right;
31835           if (left != null) {
31836             const newLeft = new SplayTreeSetNode(left.key);
31837             dest.left = newLeft;
31838             copyChildren(left, newLeft);
31839           }
31840           if (right != null) {
31841             const newRight = new SplayTreeSetNode(right.key);
31842             dest.right = newRight;
31843             node2 = right;
31844             dest = newRight;
31845           }
31846         } while (right != null);
31847       }
31848       const result = new SplayTreeSetNode(node.key);
31849       copyChildren(node, result);
31850       return result;
31851     }
31852     toSet() {
31853       return this.clone();
31854     }
31855     entries() {
31856       return new SplayTreeSetEntryIterableIterator(this.wrap());
31857     }
31858     keys() {
31859       return this[Symbol.iterator]();
31860     }
31861     values() {
31862       return this[Symbol.iterator]();
31863     }
31864     [(_b2 = Symbol.iterator, _a2 = Symbol.toStringTag, _b2)]() {
31865       return new SplayTreeKeyIterableIterator(this.wrap());
31866     }
31867   };
31868   var SplayTreeIterableIterator = class {
31869     constructor(tree) {
31870       __publicField(this, "tree");
31871       __publicField(this, "path", new Array());
31872       __publicField(this, "modificationCount", null);
31873       __publicField(this, "splayCount");
31874       this.tree = tree;
31875       this.splayCount = tree.getSplayCount();
31876     }
31877     [Symbol.iterator]() {
31878       return this;
31879     }
31880     next() {
31881       if (this.moveNext()) return { done: false, value: this.current() };
31882       return { done: true, value: null };
31883     }
31884     current() {
31885       if (!this.path.length) return null;
31886       const node = this.path[this.path.length - 1];
31887       return this.getValue(node);
31888     }
31889     rebuildPath(key) {
31890       this.path.splice(0, this.path.length);
31891       this.tree.splay(key);
31892       this.path.push(this.tree.getRoot());
31893       this.splayCount = this.tree.getSplayCount();
31894     }
31895     findLeftMostDescendent(node) {
31896       while (node != null) {
31897         this.path.push(node);
31898         node = node.left;
31899       }
31900     }
31901     moveNext() {
31902       if (this.modificationCount != this.tree.getModificationCount()) {
31903         if (this.modificationCount == null) {
31904           this.modificationCount = this.tree.getModificationCount();
31905           let node2 = this.tree.getRoot();
31906           while (node2 != null) {
31907             this.path.push(node2);
31908             node2 = node2.left;
31909           }
31910           return this.path.length > 0;
31911         }
31912         throw "Concurrent modification during iteration.";
31913       }
31914       if (!this.path.length) return false;
31915       if (this.splayCount != this.tree.getSplayCount()) {
31916         this.rebuildPath(this.path[this.path.length - 1].key);
31917       }
31918       let node = this.path[this.path.length - 1];
31919       let next = node.right;
31920       if (next != null) {
31921         while (next != null) {
31922           this.path.push(next);
31923           next = next.left;
31924         }
31925         return true;
31926       }
31927       this.path.pop();
31928       while (this.path.length && this.path[this.path.length - 1].right === node) {
31929         node = this.path.pop();
31930       }
31931       return this.path.length > 0;
31932     }
31933   };
31934   var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator {
31935     getValue(node) {
31936       return node.key;
31937     }
31938   };
31939   var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator {
31940     getValue(node) {
31941       return [node.key, node.key];
31942     }
31943   };
31944
31945   // node_modules/polyclip-ts/dist/esm/index.js
31946   var constant_default6 = (x2) => {
31947     return () => {
31948       return x2;
31949     };
31950   };
31951   var compare_default = (eps) => {
31952     const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default6(false);
31953     return (a2, b2) => {
31954       if (almostEqual(a2, b2)) return 0;
31955       return a2.comparedTo(b2);
31956     };
31957   };
31958   function orient_default(eps) {
31959     const almostCollinear = eps ? (area2, ax, ay, cx, cy) => area2.exponentiatedBy(2).isLessThanOrEqualTo(
31960       cx.minus(ax).exponentiatedBy(2).plus(cy.minus(ay).exponentiatedBy(2)).times(eps)
31961     ) : constant_default6(false);
31962     return (a2, b2, c2) => {
31963       const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y;
31964       const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy)));
31965       if (almostCollinear(area2, ax, ay, cx, cy)) return 0;
31966       return area2.comparedTo(0);
31967     };
31968   }
31969   var identity_default4 = (x2) => {
31970     return x2;
31971   };
31972   var snap_default = (eps) => {
31973     if (eps) {
31974       const xTree = new SplayTreeSet(compare_default(eps));
31975       const yTree = new SplayTreeSet(compare_default(eps));
31976       const snapCoord = (coord2, tree) => {
31977         return tree.addAndReturn(coord2);
31978       };
31979       const snap = (v2) => {
31980         return {
31981           x: snapCoord(v2.x, xTree),
31982           y: snapCoord(v2.y, yTree)
31983         };
31984       };
31985       snap({ x: new bignumber_default(0), y: new bignumber_default(0) });
31986       return snap;
31987     }
31988     return identity_default4;
31989   };
31990   var set3 = (eps) => {
31991     return {
31992       set: (eps2) => {
31993         precision = set3(eps2);
31994       },
31995       reset: () => set3(eps),
31996       compare: compare_default(eps),
31997       snap: snap_default(eps),
31998       orient: orient_default(eps)
31999     };
32000   };
32001   var precision = set3();
32002   var isInBbox = (bbox2, point) => {
32003     return bbox2.ll.x.isLessThanOrEqualTo(point.x) && point.x.isLessThanOrEqualTo(bbox2.ur.x) && bbox2.ll.y.isLessThanOrEqualTo(point.y) && point.y.isLessThanOrEqualTo(bbox2.ur.y);
32004   };
32005   var getBboxOverlap = (b1, b2) => {
32006     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))
32007       return null;
32008     const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x;
32009     const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x;
32010     const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y;
32011     const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y;
32012     return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } };
32013   };
32014   var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x));
32015   var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y));
32016   var length = (v2) => dotProduct(v2, v2).sqrt();
32017   var sineOfAngle = (pShared, pBase, pAngle) => {
32018     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
32019     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
32020     return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
32021   };
32022   var cosineOfAngle = (pShared, pBase, pAngle) => {
32023     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
32024     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
32025     return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
32026   };
32027   var horizontalIntersection = (pt2, v2, y2) => {
32028     if (v2.y.isZero()) return null;
32029     return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 };
32030   };
32031   var verticalIntersection = (pt2, v2, x2) => {
32032     if (v2.x.isZero()) return null;
32033     return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) };
32034   };
32035   var intersection = (pt1, v1, pt2, v2) => {
32036     if (v1.x.isZero()) return verticalIntersection(pt2, v2, pt1.x);
32037     if (v2.x.isZero()) return verticalIntersection(pt1, v1, pt2.x);
32038     if (v1.y.isZero()) return horizontalIntersection(pt2, v2, pt1.y);
32039     if (v2.y.isZero()) return horizontalIntersection(pt1, v1, pt2.y);
32040     const kross = crossProduct(v1, v2);
32041     if (kross.isZero()) return null;
32042     const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) };
32043     const d1 = crossProduct(ve2, v1).div(kross);
32044     const d2 = crossProduct(ve2, v2).div(kross);
32045     const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x));
32046     const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y));
32047     const x3 = x12.plus(x2).div(2);
32048     const y3 = y12.plus(y2).div(2);
32049     return { x: x3, y: y3 };
32050   };
32051   var SweepEvent = class _SweepEvent {
32052     // Warning: 'point' input will be modified and re-used (for performance)
32053     constructor(point, isLeft) {
32054       __publicField(this, "point");
32055       __publicField(this, "isLeft");
32056       __publicField(this, "segment");
32057       __publicField(this, "otherSE");
32058       __publicField(this, "consumedBy");
32059       if (point.events === void 0) point.events = [this];
32060       else point.events.push(this);
32061       this.point = point;
32062       this.isLeft = isLeft;
32063     }
32064     // for ordering sweep events in the sweep event queue
32065     static compare(a2, b2) {
32066       const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point);
32067       if (ptCmp !== 0) return ptCmp;
32068       if (a2.point !== b2.point) a2.link(b2);
32069       if (a2.isLeft !== b2.isLeft) return a2.isLeft ? 1 : -1;
32070       return Segment.compare(a2.segment, b2.segment);
32071     }
32072     // for ordering points in sweep line order
32073     static comparePoints(aPt, bPt) {
32074       if (aPt.x.isLessThan(bPt.x)) return -1;
32075       if (aPt.x.isGreaterThan(bPt.x)) return 1;
32076       if (aPt.y.isLessThan(bPt.y)) return -1;
32077       if (aPt.y.isGreaterThan(bPt.y)) return 1;
32078       return 0;
32079     }
32080     link(other2) {
32081       if (other2.point === this.point) {
32082         throw new Error("Tried to link already linked events");
32083       }
32084       const otherEvents = other2.point.events;
32085       for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
32086         const evt = otherEvents[i3];
32087         this.point.events.push(evt);
32088         evt.point = this.point;
32089       }
32090       this.checkForConsuming();
32091     }
32092     /* Do a pass over our linked events and check to see if any pair
32093      * of segments match, and should be consumed. */
32094     checkForConsuming() {
32095       const numEvents = this.point.events.length;
32096       for (let i3 = 0; i3 < numEvents; i3++) {
32097         const evt1 = this.point.events[i3];
32098         if (evt1.segment.consumedBy !== void 0) continue;
32099         for (let j2 = i3 + 1; j2 < numEvents; j2++) {
32100           const evt2 = this.point.events[j2];
32101           if (evt2.consumedBy !== void 0) continue;
32102           if (evt1.otherSE.point.events !== evt2.otherSE.point.events) continue;
32103           evt1.segment.consume(evt2.segment);
32104         }
32105       }
32106     }
32107     getAvailableLinkedEvents() {
32108       const events = [];
32109       for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
32110         const evt = this.point.events[i3];
32111         if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
32112           events.push(evt);
32113         }
32114       }
32115       return events;
32116     }
32117     /**
32118      * Returns a comparator function for sorting linked events that will
32119      * favor the event that will give us the smallest left-side angle.
32120      * All ring construction starts as low as possible heading to the right,
32121      * so by always turning left as sharp as possible we'll get polygons
32122      * without uncessary loops & holes.
32123      *
32124      * The comparator function has a compute cache such that it avoids
32125      * re-computing already-computed values.
32126      */
32127     getLeftmostComparator(baseEvent) {
32128       const cache = /* @__PURE__ */ new Map();
32129       const fillCache = (linkedEvent) => {
32130         const nextEvent = linkedEvent.otherSE;
32131         cache.set(linkedEvent, {
32132           sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
32133           cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
32134         });
32135       };
32136       return (a2, b2) => {
32137         if (!cache.has(a2)) fillCache(a2);
32138         if (!cache.has(b2)) fillCache(b2);
32139         const { sine: asine, cosine: acosine } = cache.get(a2);
32140         const { sine: bsine, cosine: bcosine } = cache.get(b2);
32141         if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) {
32142           if (acosine.isLessThan(bcosine)) return 1;
32143           if (acosine.isGreaterThan(bcosine)) return -1;
32144           return 0;
32145         }
32146         if (asine.isLessThan(0) && bsine.isLessThan(0)) {
32147           if (acosine.isLessThan(bcosine)) return -1;
32148           if (acosine.isGreaterThan(bcosine)) return 1;
32149           return 0;
32150         }
32151         if (bsine.isLessThan(asine)) return -1;
32152         if (bsine.isGreaterThan(asine)) return 1;
32153         return 0;
32154       };
32155     }
32156   };
32157   var RingOut = class _RingOut {
32158     constructor(events) {
32159       __publicField(this, "events");
32160       __publicField(this, "poly");
32161       __publicField(this, "_isExteriorRing");
32162       __publicField(this, "_enclosingRing");
32163       this.events = events;
32164       for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
32165         events[i3].segment.ringOut = this;
32166       }
32167       this.poly = null;
32168     }
32169     /* Given the segments from the sweep line pass, compute & return a series
32170      * of closed rings from all the segments marked to be part of the result */
32171     static factory(allSegments) {
32172       const ringsOut = [];
32173       for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
32174         const segment = allSegments[i3];
32175         if (!segment.isInResult() || segment.ringOut) continue;
32176         let prevEvent = null;
32177         let event = segment.leftSE;
32178         let nextEvent = segment.rightSE;
32179         const events = [event];
32180         const startingPoint = event.point;
32181         const intersectionLEs = [];
32182         while (true) {
32183           prevEvent = event;
32184           event = nextEvent;
32185           events.push(event);
32186           if (event.point === startingPoint) break;
32187           while (true) {
32188             const availableLEs = event.getAvailableLinkedEvents();
32189             if (availableLEs.length === 0) {
32190               const firstPt = events[0].point;
32191               const lastPt = events[events.length - 1].point;
32192               throw new Error(
32193                 "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, "].")
32194               );
32195             }
32196             if (availableLEs.length === 1) {
32197               nextEvent = availableLEs[0].otherSE;
32198               break;
32199             }
32200             let indexLE = null;
32201             for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
32202               if (intersectionLEs[j2].point === event.point) {
32203                 indexLE = j2;
32204                 break;
32205               }
32206             }
32207             if (indexLE !== null) {
32208               const intersectionLE = intersectionLEs.splice(indexLE)[0];
32209               const ringEvents = events.splice(intersectionLE.index);
32210               ringEvents.unshift(ringEvents[0].otherSE);
32211               ringsOut.push(new _RingOut(ringEvents.reverse()));
32212               continue;
32213             }
32214             intersectionLEs.push({
32215               index: events.length,
32216               point: event.point
32217             });
32218             const comparator = event.getLeftmostComparator(prevEvent);
32219             nextEvent = availableLEs.sort(comparator)[0].otherSE;
32220             break;
32221           }
32222         }
32223         ringsOut.push(new _RingOut(events));
32224       }
32225       return ringsOut;
32226     }
32227     getGeom() {
32228       let prevPt = this.events[0].point;
32229       const points = [prevPt];
32230       for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
32231         const pt22 = this.events[i3].point;
32232         const nextPt2 = this.events[i3 + 1].point;
32233         if (precision.orient(pt22, prevPt, nextPt2) === 0) continue;
32234         points.push(pt22);
32235         prevPt = pt22;
32236       }
32237       if (points.length === 1) return null;
32238       const pt2 = points[0];
32239       const nextPt = points[1];
32240       if (precision.orient(pt2, prevPt, nextPt) === 0) points.shift();
32241       points.push(points[0]);
32242       const step = this.isExteriorRing() ? 1 : -1;
32243       const iStart = this.isExteriorRing() ? 0 : points.length - 1;
32244       const iEnd = this.isExteriorRing() ? points.length : -1;
32245       const orderedPoints = [];
32246       for (let i3 = iStart; i3 != iEnd; i3 += step)
32247         orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]);
32248       return orderedPoints;
32249     }
32250     isExteriorRing() {
32251       if (this._isExteriorRing === void 0) {
32252         const enclosing = this.enclosingRing();
32253         this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
32254       }
32255       return this._isExteriorRing;
32256     }
32257     enclosingRing() {
32258       if (this._enclosingRing === void 0) {
32259         this._enclosingRing = this._calcEnclosingRing();
32260       }
32261       return this._enclosingRing;
32262     }
32263     /* Returns the ring that encloses this one, if any */
32264     _calcEnclosingRing() {
32265       var _a4, _b3;
32266       let leftMostEvt = this.events[0];
32267       for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
32268         const evt = this.events[i3];
32269         if (SweepEvent.compare(leftMostEvt, evt) > 0) leftMostEvt = evt;
32270       }
32271       let prevSeg = leftMostEvt.segment.prevInResult();
32272       let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
32273       while (true) {
32274         if (!prevSeg) return null;
32275         if (!prevPrevSeg) return prevSeg.ringOut;
32276         if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
32277           if (((_a4 = prevPrevSeg.ringOut) == null ? void 0 : _a4.enclosingRing()) !== prevSeg.ringOut) {
32278             return prevSeg.ringOut;
32279           } else return (_b3 = prevSeg.ringOut) == null ? void 0 : _b3.enclosingRing();
32280         }
32281         prevSeg = prevPrevSeg.prevInResult();
32282         prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
32283       }
32284     }
32285   };
32286   var PolyOut = class {
32287     constructor(exteriorRing) {
32288       __publicField(this, "exteriorRing");
32289       __publicField(this, "interiorRings");
32290       this.exteriorRing = exteriorRing;
32291       exteriorRing.poly = this;
32292       this.interiorRings = [];
32293     }
32294     addInterior(ring) {
32295       this.interiorRings.push(ring);
32296       ring.poly = this;
32297     }
32298     getGeom() {
32299       const geom0 = this.exteriorRing.getGeom();
32300       if (geom0 === null) return null;
32301       const geom = [geom0];
32302       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
32303         const ringGeom = this.interiorRings[i3].getGeom();
32304         if (ringGeom === null) continue;
32305         geom.push(ringGeom);
32306       }
32307       return geom;
32308     }
32309   };
32310   var MultiPolyOut = class {
32311     constructor(rings) {
32312       __publicField(this, "rings");
32313       __publicField(this, "polys");
32314       this.rings = rings;
32315       this.polys = this._composePolys(rings);
32316     }
32317     getGeom() {
32318       const geom = [];
32319       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
32320         const polyGeom = this.polys[i3].getGeom();
32321         if (polyGeom === null) continue;
32322         geom.push(polyGeom);
32323       }
32324       return geom;
32325     }
32326     _composePolys(rings) {
32327       var _a4;
32328       const polys = [];
32329       for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
32330         const ring = rings[i3];
32331         if (ring.poly) continue;
32332         if (ring.isExteriorRing()) polys.push(new PolyOut(ring));
32333         else {
32334           const enclosingRing = ring.enclosingRing();
32335           if (!(enclosingRing == null ? void 0 : enclosingRing.poly)) polys.push(new PolyOut(enclosingRing));
32336           (_a4 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a4.addInterior(ring);
32337         }
32338       }
32339       return polys;
32340     }
32341   };
32342   var SweepLine = class {
32343     constructor(queue, comparator = Segment.compare) {
32344       __publicField(this, "queue");
32345       __publicField(this, "tree");
32346       __publicField(this, "segments");
32347       this.queue = queue;
32348       this.tree = new SplayTreeSet(comparator);
32349       this.segments = [];
32350     }
32351     process(event) {
32352       const segment = event.segment;
32353       const newEvents = [];
32354       if (event.consumedBy) {
32355         if (event.isLeft) this.queue.delete(event.otherSE);
32356         else this.tree.delete(segment);
32357         return newEvents;
32358       }
32359       if (event.isLeft) this.tree.add(segment);
32360       let prevSeg = segment;
32361       let nextSeg = segment;
32362       do {
32363         prevSeg = this.tree.lastBefore(prevSeg);
32364       } while (prevSeg != null && prevSeg.consumedBy != void 0);
32365       do {
32366         nextSeg = this.tree.firstAfter(nextSeg);
32367       } while (nextSeg != null && nextSeg.consumedBy != void 0);
32368       if (event.isLeft) {
32369         let prevMySplitter = null;
32370         if (prevSeg) {
32371           const prevInter = prevSeg.getIntersection(segment);
32372           if (prevInter !== null) {
32373             if (!segment.isAnEndpoint(prevInter)) prevMySplitter = prevInter;
32374             if (!prevSeg.isAnEndpoint(prevInter)) {
32375               const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
32376               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
32377                 newEvents.push(newEventsFromSplit[i3]);
32378               }
32379             }
32380           }
32381         }
32382         let nextMySplitter = null;
32383         if (nextSeg) {
32384           const nextInter = nextSeg.getIntersection(segment);
32385           if (nextInter !== null) {
32386             if (!segment.isAnEndpoint(nextInter)) nextMySplitter = nextInter;
32387             if (!nextSeg.isAnEndpoint(nextInter)) {
32388               const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
32389               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
32390                 newEvents.push(newEventsFromSplit[i3]);
32391               }
32392             }
32393           }
32394         }
32395         if (prevMySplitter !== null || nextMySplitter !== null) {
32396           let mySplitter = null;
32397           if (prevMySplitter === null) mySplitter = nextMySplitter;
32398           else if (nextMySplitter === null) mySplitter = prevMySplitter;
32399           else {
32400             const cmpSplitters = SweepEvent.comparePoints(
32401               prevMySplitter,
32402               nextMySplitter
32403             );
32404             mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
32405           }
32406           this.queue.delete(segment.rightSE);
32407           newEvents.push(segment.rightSE);
32408           const newEventsFromSplit = segment.split(mySplitter);
32409           for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
32410             newEvents.push(newEventsFromSplit[i3]);
32411           }
32412         }
32413         if (newEvents.length > 0) {
32414           this.tree.delete(segment);
32415           newEvents.push(event);
32416         } else {
32417           this.segments.push(segment);
32418           segment.prev = prevSeg;
32419         }
32420       } else {
32421         if (prevSeg && nextSeg) {
32422           const inter = prevSeg.getIntersection(nextSeg);
32423           if (inter !== null) {
32424             if (!prevSeg.isAnEndpoint(inter)) {
32425               const newEventsFromSplit = this._splitSafely(prevSeg, inter);
32426               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
32427                 newEvents.push(newEventsFromSplit[i3]);
32428               }
32429             }
32430             if (!nextSeg.isAnEndpoint(inter)) {
32431               const newEventsFromSplit = this._splitSafely(nextSeg, inter);
32432               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
32433                 newEvents.push(newEventsFromSplit[i3]);
32434               }
32435             }
32436           }
32437         }
32438         this.tree.delete(segment);
32439       }
32440       return newEvents;
32441     }
32442     /* Safely split a segment that is currently in the datastructures
32443      * IE - a segment other than the one that is currently being processed. */
32444     _splitSafely(seg, pt2) {
32445       this.tree.delete(seg);
32446       const rightSE = seg.rightSE;
32447       this.queue.delete(rightSE);
32448       const newEvents = seg.split(pt2);
32449       newEvents.push(rightSE);
32450       if (seg.consumedBy === void 0) this.tree.add(seg);
32451       return newEvents;
32452     }
32453   };
32454   var Operation = class {
32455     constructor() {
32456       __publicField(this, "type");
32457       __publicField(this, "numMultiPolys");
32458     }
32459     run(type2, geom, moreGeoms) {
32460       operation.type = type2;
32461       const multipolys = [new MultiPolyIn(geom, true)];
32462       for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
32463         multipolys.push(new MultiPolyIn(moreGeoms[i3], false));
32464       }
32465       operation.numMultiPolys = multipolys.length;
32466       if (operation.type === "difference") {
32467         const subject = multipolys[0];
32468         let i3 = 1;
32469         while (i3 < multipolys.length) {
32470           if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null) i3++;
32471           else multipolys.splice(i3, 1);
32472         }
32473       }
32474       if (operation.type === "intersection") {
32475         for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
32476           const mpA = multipolys[i3];
32477           for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
32478             if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null) return [];
32479           }
32480         }
32481       }
32482       const queue = new SplayTreeSet(SweepEvent.compare);
32483       for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
32484         const sweepEvents = multipolys[i3].getSweepEvents();
32485         for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
32486           queue.add(sweepEvents[j2]);
32487         }
32488       }
32489       const sweepLine = new SweepLine(queue);
32490       let evt = null;
32491       if (queue.size != 0) {
32492         evt = queue.first();
32493         queue.delete(evt);
32494       }
32495       while (evt) {
32496         const newEvents = sweepLine.process(evt);
32497         for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
32498           const evt2 = newEvents[i3];
32499           if (evt2.consumedBy === void 0) queue.add(evt2);
32500         }
32501         if (queue.size != 0) {
32502           evt = queue.first();
32503           queue.delete(evt);
32504         } else {
32505           evt = null;
32506         }
32507       }
32508       precision.reset();
32509       const ringsOut = RingOut.factory(sweepLine.segments);
32510       const result = new MultiPolyOut(ringsOut);
32511       return result.getGeom();
32512     }
32513   };
32514   var operation = new Operation();
32515   var operation_default = operation;
32516   var segmentId = 0;
32517   var Segment = class _Segment {
32518     /* Warning: a reference to ringWindings input will be stored,
32519      *  and possibly will be later modified */
32520     constructor(leftSE, rightSE, rings, windings) {
32521       __publicField(this, "id");
32522       __publicField(this, "leftSE");
32523       __publicField(this, "rightSE");
32524       __publicField(this, "rings");
32525       __publicField(this, "windings");
32526       __publicField(this, "ringOut");
32527       __publicField(this, "consumedBy");
32528       __publicField(this, "prev");
32529       __publicField(this, "_prevInResult");
32530       __publicField(this, "_beforeState");
32531       __publicField(this, "_afterState");
32532       __publicField(this, "_isInResult");
32533       this.id = ++segmentId;
32534       this.leftSE = leftSE;
32535       leftSE.segment = this;
32536       leftSE.otherSE = rightSE;
32537       this.rightSE = rightSE;
32538       rightSE.segment = this;
32539       rightSE.otherSE = leftSE;
32540       this.rings = rings;
32541       this.windings = windings;
32542     }
32543     /* This compare() function is for ordering segments in the sweep
32544      * line tree, and does so according to the following criteria:
32545      *
32546      * Consider the vertical line that lies an infinestimal step to the
32547      * right of the right-more of the two left endpoints of the input
32548      * segments. Imagine slowly moving a point up from negative infinity
32549      * in the increasing y direction. Which of the two segments will that
32550      * point intersect first? That segment comes 'before' the other one.
32551      *
32552      * If neither segment would be intersected by such a line, (if one
32553      * or more of the segments are vertical) then the line to be considered
32554      * is directly on the right-more of the two left inputs.
32555      */
32556     static compare(a2, b2) {
32557       const alx = a2.leftSE.point.x;
32558       const blx = b2.leftSE.point.x;
32559       const arx = a2.rightSE.point.x;
32560       const brx = b2.rightSE.point.x;
32561       if (brx.isLessThan(alx)) return 1;
32562       if (arx.isLessThan(blx)) return -1;
32563       const aly = a2.leftSE.point.y;
32564       const bly = b2.leftSE.point.y;
32565       const ary = a2.rightSE.point.y;
32566       const bry = b2.rightSE.point.y;
32567       if (alx.isLessThan(blx)) {
32568         if (bly.isLessThan(aly) && bly.isLessThan(ary)) return 1;
32569         if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary)) return -1;
32570         const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
32571         if (aCmpBLeft < 0) return 1;
32572         if (aCmpBLeft > 0) return -1;
32573         const bCmpARight = b2.comparePoint(a2.rightSE.point);
32574         if (bCmpARight !== 0) return bCmpARight;
32575         return -1;
32576       }
32577       if (alx.isGreaterThan(blx)) {
32578         if (aly.isLessThan(bly) && aly.isLessThan(bry)) return -1;
32579         if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry)) return 1;
32580         const bCmpALeft = b2.comparePoint(a2.leftSE.point);
32581         if (bCmpALeft !== 0) return bCmpALeft;
32582         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
32583         if (aCmpBRight < 0) return 1;
32584         if (aCmpBRight > 0) return -1;
32585         return 1;
32586       }
32587       if (aly.isLessThan(bly)) return -1;
32588       if (aly.isGreaterThan(bly)) return 1;
32589       if (arx.isLessThan(brx)) {
32590         const bCmpARight = b2.comparePoint(a2.rightSE.point);
32591         if (bCmpARight !== 0) return bCmpARight;
32592       }
32593       if (arx.isGreaterThan(brx)) {
32594         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
32595         if (aCmpBRight < 0) return 1;
32596         if (aCmpBRight > 0) return -1;
32597       }
32598       if (!arx.eq(brx)) {
32599         const ay = ary.minus(aly);
32600         const ax = arx.minus(alx);
32601         const by = bry.minus(bly);
32602         const bx = brx.minus(blx);
32603         if (ay.isGreaterThan(ax) && by.isLessThan(bx)) return 1;
32604         if (ay.isLessThan(ax) && by.isGreaterThan(bx)) return -1;
32605       }
32606       if (arx.isGreaterThan(brx)) return 1;
32607       if (arx.isLessThan(brx)) return -1;
32608       if (ary.isLessThan(bry)) return -1;
32609       if (ary.isGreaterThan(bry)) return 1;
32610       if (a2.id < b2.id) return -1;
32611       if (a2.id > b2.id) return 1;
32612       return 0;
32613     }
32614     static fromRing(pt1, pt2, ring) {
32615       let leftPt, rightPt, winding;
32616       const cmpPts = SweepEvent.comparePoints(pt1, pt2);
32617       if (cmpPts < 0) {
32618         leftPt = pt1;
32619         rightPt = pt2;
32620         winding = 1;
32621       } else if (cmpPts > 0) {
32622         leftPt = pt2;
32623         rightPt = pt1;
32624         winding = -1;
32625       } else
32626         throw new Error(
32627           "Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]")
32628         );
32629       const leftSE = new SweepEvent(leftPt, true);
32630       const rightSE = new SweepEvent(rightPt, false);
32631       return new _Segment(leftSE, rightSE, [ring], [winding]);
32632     }
32633     /* When a segment is split, the rightSE is replaced with a new sweep event */
32634     replaceRightSE(newRightSE) {
32635       this.rightSE = newRightSE;
32636       this.rightSE.segment = this;
32637       this.rightSE.otherSE = this.leftSE;
32638       this.leftSE.otherSE = this.rightSE;
32639     }
32640     bbox() {
32641       const y12 = this.leftSE.point.y;
32642       const y2 = this.rightSE.point.y;
32643       return {
32644         ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 },
32645         ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 }
32646       };
32647     }
32648     /* A vector from the left point to the right */
32649     vector() {
32650       return {
32651         x: this.rightSE.point.x.minus(this.leftSE.point.x),
32652         y: this.rightSE.point.y.minus(this.leftSE.point.y)
32653       };
32654     }
32655     isAnEndpoint(pt2) {
32656       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);
32657     }
32658     /* Compare this segment with a point.
32659      *
32660      * A point P is considered to be colinear to a segment if there
32661      * exists a distance D such that if we travel along the segment
32662      * from one * endpoint towards the other a distance D, we find
32663      * ourselves at point P.
32664      *
32665      * Return value indicates:
32666      *
32667      *   1: point lies above the segment (to the left of vertical)
32668      *   0: point is colinear to segment
32669      *  -1: point lies below the segment (to the right of vertical)
32670      */
32671     comparePoint(point) {
32672       return precision.orient(this.leftSE.point, point, this.rightSE.point);
32673     }
32674     /**
32675      * Given another segment, returns the first non-trivial intersection
32676      * between the two segments (in terms of sweep line ordering), if it exists.
32677      *
32678      * A 'non-trivial' intersection is one that will cause one or both of the
32679      * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
32680      *
32681      *   * endpoint of segA with endpoint of segB --> trivial
32682      *   * endpoint of segA with point along segB --> non-trivial
32683      *   * endpoint of segB with point along segA --> non-trivial
32684      *   * point along segA with point along segB --> non-trivial
32685      *
32686      * If no non-trivial intersection exists, return null
32687      * Else, return null.
32688      */
32689     getIntersection(other2) {
32690       const tBbox = this.bbox();
32691       const oBbox = other2.bbox();
32692       const bboxOverlap = getBboxOverlap(tBbox, oBbox);
32693       if (bboxOverlap === null) return null;
32694       const tlp = this.leftSE.point;
32695       const trp = this.rightSE.point;
32696       const olp = other2.leftSE.point;
32697       const orp = other2.rightSE.point;
32698       const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
32699       const touchesThisLSE = isInBbox(oBbox, tlp) && other2.comparePoint(tlp) === 0;
32700       const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
32701       const touchesThisRSE = isInBbox(oBbox, trp) && other2.comparePoint(trp) === 0;
32702       if (touchesThisLSE && touchesOtherLSE) {
32703         if (touchesThisRSE && !touchesOtherRSE) return trp;
32704         if (!touchesThisRSE && touchesOtherRSE) return orp;
32705         return null;
32706       }
32707       if (touchesThisLSE) {
32708         if (touchesOtherRSE) {
32709           if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y)) return null;
32710         }
32711         return tlp;
32712       }
32713       if (touchesOtherLSE) {
32714         if (touchesThisRSE) {
32715           if (trp.x.eq(olp.x) && trp.y.eq(olp.y)) return null;
32716         }
32717         return olp;
32718       }
32719       if (touchesThisRSE && touchesOtherRSE) return null;
32720       if (touchesThisRSE) return trp;
32721       if (touchesOtherRSE) return orp;
32722       const pt2 = intersection(tlp, this.vector(), olp, other2.vector());
32723       if (pt2 === null) return null;
32724       if (!isInBbox(bboxOverlap, pt2)) return null;
32725       return precision.snap(pt2);
32726     }
32727     /**
32728      * Split the given segment into multiple segments on the given points.
32729      *  * Each existing segment will retain its leftSE and a new rightSE will be
32730      *    generated for it.
32731      *  * A new segment will be generated which will adopt the original segment's
32732      *    rightSE, and a new leftSE will be generated for it.
32733      *  * If there are more than two points given to split on, new segments
32734      *    in the middle will be generated with new leftSE and rightSE's.
32735      *  * An array of the newly generated SweepEvents will be returned.
32736      *
32737      * Warning: input array of points is modified
32738      */
32739     split(point) {
32740       const newEvents = [];
32741       const alreadyLinked = point.events !== void 0;
32742       const newLeftSE = new SweepEvent(point, true);
32743       const newRightSE = new SweepEvent(point, false);
32744       const oldRightSE = this.rightSE;
32745       this.replaceRightSE(newRightSE);
32746       newEvents.push(newRightSE);
32747       newEvents.push(newLeftSE);
32748       const newSeg = new _Segment(
32749         newLeftSE,
32750         oldRightSE,
32751         this.rings.slice(),
32752         this.windings.slice()
32753       );
32754       if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
32755         newSeg.swapEvents();
32756       }
32757       if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
32758         this.swapEvents();
32759       }
32760       if (alreadyLinked) {
32761         newLeftSE.checkForConsuming();
32762         newRightSE.checkForConsuming();
32763       }
32764       return newEvents;
32765     }
32766     /* Swap which event is left and right */
32767     swapEvents() {
32768       const tmpEvt = this.rightSE;
32769       this.rightSE = this.leftSE;
32770       this.leftSE = tmpEvt;
32771       this.leftSE.isLeft = true;
32772       this.rightSE.isLeft = false;
32773       for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
32774         this.windings[i3] *= -1;
32775       }
32776     }
32777     /* Consume another segment. We take their rings under our wing
32778      * and mark them as consumed. Use for perfectly overlapping segments */
32779     consume(other2) {
32780       let consumer = this;
32781       let consumee = other2;
32782       while (consumer.consumedBy) consumer = consumer.consumedBy;
32783       while (consumee.consumedBy) consumee = consumee.consumedBy;
32784       const cmp = _Segment.compare(consumer, consumee);
32785       if (cmp === 0) return;
32786       if (cmp > 0) {
32787         const tmp = consumer;
32788         consumer = consumee;
32789         consumee = tmp;
32790       }
32791       if (consumer.prev === consumee) {
32792         const tmp = consumer;
32793         consumer = consumee;
32794         consumee = tmp;
32795       }
32796       for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
32797         const ring = consumee.rings[i3];
32798         const winding = consumee.windings[i3];
32799         const index = consumer.rings.indexOf(ring);
32800         if (index === -1) {
32801           consumer.rings.push(ring);
32802           consumer.windings.push(winding);
32803         } else consumer.windings[index] += winding;
32804       }
32805       consumee.rings = null;
32806       consumee.windings = null;
32807       consumee.consumedBy = consumer;
32808       consumee.leftSE.consumedBy = consumer.leftSE;
32809       consumee.rightSE.consumedBy = consumer.rightSE;
32810     }
32811     /* The first segment previous segment chain that is in the result */
32812     prevInResult() {
32813       if (this._prevInResult !== void 0) return this._prevInResult;
32814       if (!this.prev) this._prevInResult = null;
32815       else if (this.prev.isInResult()) this._prevInResult = this.prev;
32816       else this._prevInResult = this.prev.prevInResult();
32817       return this._prevInResult;
32818     }
32819     beforeState() {
32820       if (this._beforeState !== void 0) return this._beforeState;
32821       if (!this.prev)
32822         this._beforeState = {
32823           rings: [],
32824           windings: [],
32825           multiPolys: []
32826         };
32827       else {
32828         const seg = this.prev.consumedBy || this.prev;
32829         this._beforeState = seg.afterState();
32830       }
32831       return this._beforeState;
32832     }
32833     afterState() {
32834       if (this._afterState !== void 0) return this._afterState;
32835       const beforeState = this.beforeState();
32836       this._afterState = {
32837         rings: beforeState.rings.slice(0),
32838         windings: beforeState.windings.slice(0),
32839         multiPolys: []
32840       };
32841       const ringsAfter = this._afterState.rings;
32842       const windingsAfter = this._afterState.windings;
32843       const mpsAfter = this._afterState.multiPolys;
32844       for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
32845         const ring = this.rings[i3];
32846         const winding = this.windings[i3];
32847         const index = ringsAfter.indexOf(ring);
32848         if (index === -1) {
32849           ringsAfter.push(ring);
32850           windingsAfter.push(winding);
32851         } else windingsAfter[index] += winding;
32852       }
32853       const polysAfter = [];
32854       const polysExclude = [];
32855       for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
32856         if (windingsAfter[i3] === 0) continue;
32857         const ring = ringsAfter[i3];
32858         const poly = ring.poly;
32859         if (polysExclude.indexOf(poly) !== -1) continue;
32860         if (ring.isExterior) polysAfter.push(poly);
32861         else {
32862           if (polysExclude.indexOf(poly) === -1) polysExclude.push(poly);
32863           const index = polysAfter.indexOf(ring.poly);
32864           if (index !== -1) polysAfter.splice(index, 1);
32865         }
32866       }
32867       for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
32868         const mp = polysAfter[i3].multiPoly;
32869         if (mpsAfter.indexOf(mp) === -1) mpsAfter.push(mp);
32870       }
32871       return this._afterState;
32872     }
32873     /* Is this segment part of the final result? */
32874     isInResult() {
32875       if (this.consumedBy) return false;
32876       if (this._isInResult !== void 0) return this._isInResult;
32877       const mpsBefore = this.beforeState().multiPolys;
32878       const mpsAfter = this.afterState().multiPolys;
32879       switch (operation_default.type) {
32880         case "union": {
32881           const noBefores = mpsBefore.length === 0;
32882           const noAfters = mpsAfter.length === 0;
32883           this._isInResult = noBefores !== noAfters;
32884           break;
32885         }
32886         case "intersection": {
32887           let least;
32888           let most;
32889           if (mpsBefore.length < mpsAfter.length) {
32890             least = mpsBefore.length;
32891             most = mpsAfter.length;
32892           } else {
32893             least = mpsAfter.length;
32894             most = mpsBefore.length;
32895           }
32896           this._isInResult = most === operation_default.numMultiPolys && least < most;
32897           break;
32898         }
32899         case "xor": {
32900           const diff = Math.abs(mpsBefore.length - mpsAfter.length);
32901           this._isInResult = diff % 2 === 1;
32902           break;
32903         }
32904         case "difference": {
32905           const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
32906           this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
32907           break;
32908         }
32909       }
32910       return this._isInResult;
32911     }
32912   };
32913   var RingIn = class {
32914     constructor(geomRing, poly, isExterior) {
32915       __publicField(this, "poly");
32916       __publicField(this, "isExterior");
32917       __publicField(this, "segments");
32918       __publicField(this, "bbox");
32919       if (!Array.isArray(geomRing) || geomRing.length === 0) {
32920         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32921       }
32922       this.poly = poly;
32923       this.isExterior = isExterior;
32924       this.segments = [];
32925       if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
32926         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32927       }
32928       const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) });
32929       this.bbox = {
32930         ll: { x: firstPoint.x, y: firstPoint.y },
32931         ur: { x: firstPoint.x, y: firstPoint.y }
32932       };
32933       let prevPoint = firstPoint;
32934       for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
32935         if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
32936           throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32937         }
32938         const point = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) });
32939         if (point.x.eq(prevPoint.x) && point.y.eq(prevPoint.y)) continue;
32940         this.segments.push(Segment.fromRing(prevPoint, point, this));
32941         if (point.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = point.x;
32942         if (point.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = point.y;
32943         if (point.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = point.x;
32944         if (point.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = point.y;
32945         prevPoint = point;
32946       }
32947       if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) {
32948         this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
32949       }
32950     }
32951     getSweepEvents() {
32952       const sweepEvents = [];
32953       for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
32954         const segment = this.segments[i3];
32955         sweepEvents.push(segment.leftSE);
32956         sweepEvents.push(segment.rightSE);
32957       }
32958       return sweepEvents;
32959     }
32960   };
32961   var PolyIn = class {
32962     constructor(geomPoly, multiPoly) {
32963       __publicField(this, "multiPoly");
32964       __publicField(this, "exteriorRing");
32965       __publicField(this, "interiorRings");
32966       __publicField(this, "bbox");
32967       if (!Array.isArray(geomPoly)) {
32968         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32969       }
32970       this.exteriorRing = new RingIn(geomPoly[0], this, true);
32971       this.bbox = {
32972         ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
32973         ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
32974       };
32975       this.interiorRings = [];
32976       for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
32977         const ring = new RingIn(geomPoly[i3], this, false);
32978         if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = ring.bbox.ll.x;
32979         if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = ring.bbox.ll.y;
32980         if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = ring.bbox.ur.x;
32981         if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = ring.bbox.ur.y;
32982         this.interiorRings.push(ring);
32983       }
32984       this.multiPoly = multiPoly;
32985     }
32986     getSweepEvents() {
32987       const sweepEvents = this.exteriorRing.getSweepEvents();
32988       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
32989         const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
32990         for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
32991           sweepEvents.push(ringSweepEvents[j2]);
32992         }
32993       }
32994       return sweepEvents;
32995     }
32996   };
32997   var MultiPolyIn = class {
32998     constructor(geom, isSubject) {
32999       __publicField(this, "isSubject");
33000       __publicField(this, "polys");
33001       __publicField(this, "bbox");
33002       if (!Array.isArray(geom)) {
33003         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
33004       }
33005       try {
33006         if (typeof geom[0][0][0] === "number") geom = [geom];
33007       } catch (ex) {
33008       }
33009       this.polys = [];
33010       this.bbox = {
33011         ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) },
33012         ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) }
33013       };
33014       for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
33015         const poly = new PolyIn(geom[i3], this);
33016         if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = poly.bbox.ll.x;
33017         if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = poly.bbox.ll.y;
33018         if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = poly.bbox.ur.x;
33019         if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = poly.bbox.ur.y;
33020         this.polys.push(poly);
33021       }
33022       this.isSubject = isSubject;
33023     }
33024     getSweepEvents() {
33025       const sweepEvents = [];
33026       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
33027         const polySweepEvents = this.polys[i3].getSweepEvents();
33028         for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
33029           sweepEvents.push(polySweepEvents[j2]);
33030         }
33031       }
33032       return sweepEvents;
33033     }
33034   };
33035   var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms);
33036   var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms);
33037   var setPrecision = precision.set;
33038
33039   // node_modules/@rapideditor/location-conflation/index.mjs
33040   var import_geojson_area = __toESM(require_geojson_area(), 1);
33041   var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1);
33042   var import_geojson_precision = __toESM(require_geojson_precision(), 1);
33043   var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1);
33044   var LocationConflation = class {
33045     // constructor
33046     //
33047     // `fc`  Optional FeatureCollection of known features
33048     //
33049     // Optionally pass a GeoJSON FeatureCollection of known features which we can refer to later.
33050     // Each feature must have a filename-like `id`, for example: `something.geojson`
33051     //
33052     // {
33053     //   "type": "FeatureCollection"
33054     //   "features": [
33055     //     {
33056     //       "type": "Feature",
33057     //       "id": "philly_metro.geojson",
33058     //       "properties": { … },
33059     //       "geometry": { … }
33060     //     }
33061     //   ]
33062     // }
33063     constructor(fc) {
33064       this._cache = {};
33065       this.strict = true;
33066       if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) {
33067         fc.features.forEach((feature3) => {
33068           feature3.properties = feature3.properties || {};
33069           let props = feature3.properties;
33070           let id2 = feature3.id || props.id;
33071           if (!id2 || !/^\S+\.geojson$/i.test(id2)) return;
33072           id2 = id2.toLowerCase();
33073           feature3.id = id2;
33074           props.id = id2;
33075           if (!props.area) {
33076             const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
33077             props.area = Number(area.toFixed(2));
33078           }
33079           this._cache[id2] = feature3;
33080         });
33081       }
33082       let world = _cloneDeep(feature("Q2"));
33083       world.geometry = {
33084         type: "Polygon",
33085         coordinates: [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
33086       };
33087       world.id = "Q2";
33088       world.properties.id = "Q2";
33089       world.properties.area = import_geojson_area.default.geometry(world.geometry) / 1e6;
33090       this._cache.Q2 = world;
33091     }
33092     // validateLocation
33093     // `location`  The location to validate
33094     //
33095     // Pass a `location` value to validate
33096     //
33097     // Returns a result like:
33098     //   {
33099     //     type:     'point', 'geojson', or 'countrycoder'
33100     //     location:  the queried location
33101     //     id:        the stable identifier for the feature
33102     //   }
33103     // or `null` if the location is invalid
33104     //
33105     validateLocation(location) {
33106       if (Array.isArray(location) && (location.length === 2 || location.length === 3)) {
33107         const lon = location[0];
33108         const lat = location[1];
33109         const radius = location[2];
33110         if (Number.isFinite(lon) && lon >= -180 && lon <= 180 && Number.isFinite(lat) && lat >= -90 && lat <= 90 && (location.length === 2 || Number.isFinite(radius) && radius > 0)) {
33111           const id2 = "[" + location.toString() + "]";
33112           return { type: "point", location, id: id2 };
33113         }
33114       } else if (typeof location === "string" && /^\S+\.geojson$/i.test(location)) {
33115         const id2 = location.toLowerCase();
33116         if (this._cache[id2]) {
33117           return { type: "geojson", location, id: id2 };
33118         }
33119       } else if (typeof location === "string" || typeof location === "number") {
33120         const feature3 = feature(location);
33121         if (feature3) {
33122           const id2 = feature3.properties.wikidata;
33123           return { type: "countrycoder", location, id: id2 };
33124         }
33125       }
33126       if (this.strict) {
33127         throw new Error('validateLocation:  Invalid location: "'.concat(location, '".'));
33128       } else {
33129         return null;
33130       }
33131     }
33132     // resolveLocation
33133     // `location`  The location to resolve
33134     //
33135     // Pass a `location` value to resolve
33136     //
33137     // Returns a result like:
33138     //   {
33139     //     type:      'point', 'geojson', or 'countrycoder'
33140     //     location:  the queried location
33141     //     id:        a stable identifier for the feature
33142     //     feature:   the resolved GeoJSON feature
33143     //   }
33144     //  or `null` if the location is invalid
33145     //
33146     resolveLocation(location) {
33147       const valid = this.validateLocation(location);
33148       if (!valid) return null;
33149       const id2 = valid.id;
33150       if (this._cache[id2]) {
33151         return Object.assign(valid, { feature: this._cache[id2] });
33152       }
33153       if (valid.type === "point") {
33154         const lon = location[0];
33155         const lat = location[1];
33156         const radius = location[2] || 25;
33157         const EDGES = 10;
33158         const PRECISION = 3;
33159         const area = Math.PI * radius * radius;
33160         const feature3 = this._cache[id2] = (0, import_geojson_precision.default)({
33161           type: "Feature",
33162           id: id2,
33163           properties: { id: id2, area: Number(area.toFixed(2)) },
33164           geometry: (0, import_circle_to_polygon.default)([lon, lat], radius * 1e3, EDGES)
33165           // km to m
33166         }, PRECISION);
33167         return Object.assign(valid, { feature: feature3 });
33168       } else if (valid.type === "geojson") {
33169       } else if (valid.type === "countrycoder") {
33170         let feature3 = _cloneDeep(feature(id2));
33171         let props = feature3.properties;
33172         if (Array.isArray(props.members)) {
33173           let aggregate = aggregateFeature(id2);
33174           aggregate.geometry.coordinates = _clip([aggregate], "UNION").geometry.coordinates;
33175           feature3.geometry = aggregate.geometry;
33176         }
33177         if (!props.area) {
33178           const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
33179           props.area = Number(area.toFixed(2));
33180         }
33181         feature3.id = id2;
33182         props.id = id2;
33183         this._cache[id2] = feature3;
33184         return Object.assign(valid, { feature: feature3 });
33185       }
33186       if (this.strict) {
33187         throw new Error("resolveLocation:  Couldn't resolve location \"".concat(location, '".'));
33188       } else {
33189         return null;
33190       }
33191     }
33192     // validateLocationSet
33193     // `locationSet`  the locationSet to validate
33194     //
33195     // Pass a locationSet Object to validate like:
33196     //   {
33197     //     include: [ Array of locations ],
33198     //     exclude: [ Array of locations ]
33199     //   }
33200     //
33201     // Returns a result like:
33202     //   {
33203     //     type:         'locationset'
33204     //     locationSet:  the queried locationSet
33205     //     id:           the stable identifier for the feature
33206     //   }
33207     // or `null` if the locationSet is invalid
33208     //
33209     validateLocationSet(locationSet) {
33210       locationSet = locationSet || {};
33211       const validator = this.validateLocation.bind(this);
33212       let include = (locationSet.include || []).map(validator).filter(Boolean);
33213       let exclude = (locationSet.exclude || []).map(validator).filter(Boolean);
33214       if (!include.length) {
33215         if (this.strict) {
33216           throw new Error("validateLocationSet:  LocationSet includes nothing.");
33217         } else {
33218           locationSet.include = ["Q2"];
33219           include = [{ type: "countrycoder", location: "Q2", id: "Q2" }];
33220         }
33221       }
33222       include.sort(_sortLocations);
33223       let id2 = "+[" + include.map((d2) => d2.id).join(",") + "]";
33224       if (exclude.length) {
33225         exclude.sort(_sortLocations);
33226         id2 += "-[" + exclude.map((d2) => d2.id).join(",") + "]";
33227       }
33228       return { type: "locationset", locationSet, id: id2 };
33229     }
33230     // resolveLocationSet
33231     // `locationSet`  the locationSet to resolve
33232     //
33233     // Pass a locationSet Object to validate like:
33234     //   {
33235     //     include: [ Array of locations ],
33236     //     exclude: [ Array of locations ]
33237     //   }
33238     //
33239     // Returns a result like:
33240     //   {
33241     //     type:         'locationset'
33242     //     locationSet:  the queried locationSet
33243     //     id:           the stable identifier for the feature
33244     //     feature:      the resolved GeoJSON feature
33245     //   }
33246     // or `null` if the locationSet is invalid
33247     //
33248     resolveLocationSet(locationSet) {
33249       locationSet = locationSet || {};
33250       const valid = this.validateLocationSet(locationSet);
33251       if (!valid) return null;
33252       const id2 = valid.id;
33253       if (this._cache[id2]) {
33254         return Object.assign(valid, { feature: this._cache[id2] });
33255       }
33256       const resolver = this.resolveLocation.bind(this);
33257       const includes = (locationSet.include || []).map(resolver).filter(Boolean);
33258       const excludes = (locationSet.exclude || []).map(resolver).filter(Boolean);
33259       if (includes.length === 1 && excludes.length === 0) {
33260         return Object.assign(valid, { feature: includes[0].feature });
33261       }
33262       const includeGeoJSON = _clip(includes.map((d2) => d2.feature), "UNION");
33263       const excludeGeoJSON = _clip(excludes.map((d2) => d2.feature), "UNION");
33264       let resultGeoJSON = excludeGeoJSON ? _clip([includeGeoJSON, excludeGeoJSON], "DIFFERENCE") : includeGeoJSON;
33265       const area = import_geojson_area.default.geometry(resultGeoJSON.geometry) / 1e6;
33266       resultGeoJSON.id = id2;
33267       resultGeoJSON.properties = { id: id2, area: Number(area.toFixed(2)) };
33268       this._cache[id2] = resultGeoJSON;
33269       return Object.assign(valid, { feature: resultGeoJSON });
33270     }
33271     // stringify
33272     // convenience method to prettyStringify the given object
33273     stringify(obj, options2) {
33274       return (0, import_json_stringify_pretty_compact.default)(obj, options2);
33275     }
33276   };
33277   function _clip(features, which) {
33278     if (!Array.isArray(features) || !features.length) return null;
33279     const fn = { UNION: union, DIFFERENCE: difference }[which];
33280     const args = features.map((feature3) => feature3.geometry.coordinates);
33281     const coords = fn.apply(null, args);
33282     return {
33283       type: "Feature",
33284       properties: {},
33285       geometry: {
33286         type: whichType(coords),
33287         coordinates: coords
33288       }
33289     };
33290     function whichType(coords2) {
33291       const a2 = Array.isArray(coords2);
33292       const b2 = a2 && Array.isArray(coords2[0]);
33293       const c2 = b2 && Array.isArray(coords2[0][0]);
33294       const d2 = c2 && Array.isArray(coords2[0][0][0]);
33295       return d2 ? "MultiPolygon" : "Polygon";
33296     }
33297   }
33298   function _cloneDeep(obj) {
33299     return JSON.parse(JSON.stringify(obj));
33300   }
33301   function _sortLocations(a2, b2) {
33302     const rank = { countrycoder: 1, geojson: 2, point: 3 };
33303     const aRank = rank[a2.type];
33304     const bRank = rank[b2.type];
33305     return aRank > bRank ? 1 : aRank < bRank ? -1 : a2.id.localeCompare(b2.id);
33306   }
33307
33308   // modules/core/LocationManager.js
33309   var import_which_polygon2 = __toESM(require_which_polygon());
33310   var import_geojson_area2 = __toESM(require_geojson_area());
33311   var _loco = new LocationConflation();
33312   var LocationManager = class {
33313     /**
33314      * @constructor
33315      */
33316     constructor() {
33317       this._wp = null;
33318       this._resolved = /* @__PURE__ */ new Map();
33319       this._knownLocationSets = /* @__PURE__ */ new Map();
33320       this._locationIncludedIn = /* @__PURE__ */ new Map();
33321       this._locationExcludedIn = /* @__PURE__ */ new Map();
33322       const world = { locationSet: { include: ["Q2"] } };
33323       this._resolveLocationSet(world);
33324       this._rebuildIndex();
33325     }
33326     /**
33327      * _validateLocationSet
33328      * Pass an Object with a `locationSet` property.
33329      * Validates the `locationSet` and sets a `locationSetID` property on the object.
33330      * To avoid so much computation we only resolve the include and exclude regions, but not the locationSet itself.
33331      *
33332      * Use `_resolveLocationSet()` instead if you need to resolve geojson of locationSet, for example to render it.
33333      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
33334      *
33335      * @param  `obj`  Object to check, it should have `locationSet` property
33336      */
33337     _validateLocationSet(obj) {
33338       if (obj.locationSetID) return;
33339       try {
33340         let locationSet = obj.locationSet;
33341         if (!locationSet) {
33342           throw new Error("object missing locationSet property");
33343         }
33344         if (!locationSet.include) {
33345           locationSet.include = ["Q2"];
33346         }
33347         const locationSetID = _loco.validateLocationSet(locationSet).id;
33348         obj.locationSetID = locationSetID;
33349         if (this._knownLocationSets.has(locationSetID)) return;
33350         let area = 0;
33351         (locationSet.include || []).forEach((location) => {
33352           const locationID = _loco.validateLocation(location).id;
33353           let geojson = this._resolved.get(locationID);
33354           if (!geojson) {
33355             geojson = _loco.resolveLocation(location).feature;
33356             this._resolved.set(locationID, geojson);
33357           }
33358           area += geojson.properties.area;
33359           let s2 = this._locationIncludedIn.get(locationID);
33360           if (!s2) {
33361             s2 = /* @__PURE__ */ new Set();
33362             this._locationIncludedIn.set(locationID, s2);
33363           }
33364           s2.add(locationSetID);
33365         });
33366         (locationSet.exclude || []).forEach((location) => {
33367           const locationID = _loco.validateLocation(location).id;
33368           let geojson = this._resolved.get(locationID);
33369           if (!geojson) {
33370             geojson = _loco.resolveLocation(location).feature;
33371             this._resolved.set(locationID, geojson);
33372           }
33373           area -= geojson.properties.area;
33374           let s2 = this._locationExcludedIn.get(locationID);
33375           if (!s2) {
33376             s2 = /* @__PURE__ */ new Set();
33377             this._locationExcludedIn.set(locationID, s2);
33378           }
33379           s2.add(locationSetID);
33380         });
33381         this._knownLocationSets.set(locationSetID, area);
33382       } catch (e3) {
33383         obj.locationSet = { include: ["Q2"] };
33384         obj.locationSetID = "+[Q2]";
33385       }
33386     }
33387     /**
33388      * _resolveLocationSet
33389      * Does everything that `_validateLocationSet()` does, but then "resolves" the locationSet into GeoJSON.
33390      * This step is a bit more computationally expensive, so really only needed if you intend to render the shape.
33391      *
33392      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
33393      *
33394      * @param  `obj`  Object to check, it should have `locationSet` property
33395      */
33396     _resolveLocationSet(obj) {
33397       this._validateLocationSet(obj);
33398       if (this._resolved.has(obj.locationSetID)) return;
33399       try {
33400         const result = _loco.resolveLocationSet(obj.locationSet);
33401         const locationSetID = result.id;
33402         obj.locationSetID = locationSetID;
33403         if (!result.feature.geometry.coordinates.length || !result.feature.properties.area) {
33404           throw new Error("locationSet ".concat(locationSetID, " resolves to an empty feature."));
33405         }
33406         let geojson = JSON.parse(JSON.stringify(result.feature));
33407         geojson.id = locationSetID;
33408         geojson.properties.id = locationSetID;
33409         this._resolved.set(locationSetID, geojson);
33410       } catch (e3) {
33411         obj.locationSet = { include: ["Q2"] };
33412         obj.locationSetID = "+[Q2]";
33413       }
33414     }
33415     /**
33416      * _rebuildIndex
33417      * Rebuilds the whichPolygon index with whatever features have been resolved into GeoJSON.
33418      */
33419     _rebuildIndex() {
33420       this._wp = (0, import_which_polygon2.default)({ features: [...this._resolved.values()] });
33421     }
33422     /**
33423      * mergeCustomGeoJSON
33424      * Accepts a FeatureCollection-like object containing custom locations
33425      * Each feature must have a filename-like `id`, for example: `something.geojson`
33426      * {
33427      *   "type": "FeatureCollection"
33428      *   "features": [
33429      *     {
33430      *       "type": "Feature",
33431      *       "id": "philly_metro.geojson",
33432      *       "properties": { … },
33433      *       "geometry": { … }
33434      *     }
33435      *   ]
33436      * }
33437      *
33438      * @param  `fc`  FeatureCollection-like Object containing custom locations
33439      */
33440     mergeCustomGeoJSON(fc) {
33441       if (!fc || fc.type !== "FeatureCollection" || !Array.isArray(fc.features)) return;
33442       fc.features.forEach((feature3) => {
33443         feature3.properties = feature3.properties || {};
33444         let props = feature3.properties;
33445         let id2 = feature3.id || props.id;
33446         if (!id2 || !/^\S+\.geojson$/i.test(id2)) return;
33447         id2 = id2.toLowerCase();
33448         feature3.id = id2;
33449         props.id = id2;
33450         if (!props.area) {
33451           const area = import_geojson_area2.default.geometry(feature3.geometry) / 1e6;
33452           props.area = Number(area.toFixed(2));
33453         }
33454         _loco._cache[id2] = feature3;
33455       });
33456     }
33457     /**
33458      * mergeLocationSets
33459      * Accepts an Array of Objects containing `locationSet` properties:
33460      * [
33461      *  { id: 'preset1', locationSet: {…} },
33462      *  { id: 'preset2', locationSet: {…} },
33463      *  …
33464      * ]
33465      * After validating, the Objects will be decorated with a `locationSetID` property:
33466      * [
33467      *  { id: 'preset1', locationSet: {…}, locationSetID: '+[Q2]' },
33468      *  { id: 'preset2', locationSet: {…}, locationSetID: '+[Q30]' },
33469      *  …
33470      * ]
33471      *
33472      * @param  `objects`  Objects to check - they should have `locationSet` property
33473      * @return  Promise resolved true (this function used to be slow/async, now it's faster and sync)
33474      */
33475     mergeLocationSets(objects) {
33476       if (!Array.isArray(objects)) return Promise.reject("nothing to do");
33477       objects.forEach((obj) => this._validateLocationSet(obj));
33478       this._rebuildIndex();
33479       return Promise.resolve(objects);
33480     }
33481     /**
33482      * locationSetID
33483      * Returns a locationSetID for a given locationSet (fallback to `+[Q2]`, world)
33484      * (The locationSet doesn't necessarily need to be resolved to compute its `id`)
33485      *
33486      * @param  `locationSet`  A locationSet Object, e.g. `{ include: ['us'] }`
33487      * @return  String locationSetID, e.g. `+[Q30]`
33488      */
33489     locationSetID(locationSet) {
33490       let locationSetID;
33491       try {
33492         locationSetID = _loco.validateLocationSet(locationSet).id;
33493       } catch (e3) {
33494         locationSetID = "+[Q2]";
33495       }
33496       return locationSetID;
33497     }
33498     /**
33499      * feature
33500      * Returns the resolved GeoJSON feature for a given locationSetID (fallback to 'world')
33501      * A GeoJSON feature:
33502      * {
33503      *   type: 'Feature',
33504      *   id: '+[Q30]',
33505      *   properties: { id: '+[Q30]', area: 21817019.17, … },
33506      *   geometry: { … }
33507      * }
33508      *
33509      * @param  `locationSetID`  String identifier, e.g. `+[Q30]`
33510      * @return  GeoJSON object (fallback to world)
33511      */
33512     feature(locationSetID = "+[Q2]") {
33513       const feature3 = this._resolved.get(locationSetID);
33514       return feature3 || this._resolved.get("+[Q2]");
33515     }
33516     /**
33517      * locationSetsAt
33518      * Find all the locationSets valid at the given location.
33519      * Results include the area (in km²) to facilitate sorting.
33520      *
33521      * Object of locationSetIDs to areas (in km²)
33522      * {
33523      *   "+[Q2]": 511207893.3958111,
33524      *   "+[Q30]": 21817019.17,
33525      *   "+[new_jersey.geojson]": 22390.77,
33526      *   …
33527      * }
33528      *
33529      * @param  `loc`  `[lon,lat]` location to query, e.g. `[-74.4813, 40.7967]`
33530      * @return  Object of locationSetIDs valid at given location
33531      */
33532     locationSetsAt(loc) {
33533       let result = {};
33534       const hits = this._wp(loc, true) || [];
33535       const thiz = this;
33536       hits.forEach((prop) => {
33537         if (prop.id[0] !== "+") return;
33538         const locationSetID = prop.id;
33539         const area = thiz._knownLocationSets.get(locationSetID);
33540         if (area) {
33541           result[locationSetID] = area;
33542         }
33543       });
33544       hits.forEach((prop) => {
33545         if (prop.id[0] === "+") return;
33546         const locationID = prop.id;
33547         const included = thiz._locationIncludedIn.get(locationID);
33548         (included || []).forEach((locationSetID) => {
33549           const area = thiz._knownLocationSets.get(locationSetID);
33550           if (area) {
33551             result[locationSetID] = area;
33552           }
33553         });
33554       });
33555       hits.forEach((prop) => {
33556         if (prop.id[0] === "+") return;
33557         const locationID = prop.id;
33558         const excluded = thiz._locationExcludedIn.get(locationID);
33559         (excluded || []).forEach((locationSetID) => {
33560           delete result[locationSetID];
33561         });
33562       });
33563       return result;
33564     }
33565     // Direct access to the location-conflation resolver
33566     loco() {
33567       return _loco;
33568     }
33569   };
33570   var _sharedLocationManager = new LocationManager();
33571
33572   // modules/presets/collection.js
33573   function presetCollection(collection) {
33574     const MAXRESULTS = 50;
33575     let _this = {};
33576     let _memo = {};
33577     _this.collection = collection;
33578     _this.item = (id2) => {
33579       if (_memo[id2]) return _memo[id2];
33580       const found = _this.collection.find((d2) => d2.id === id2);
33581       if (found) _memo[id2] = found;
33582       return found;
33583     };
33584     _this.index = (id2) => _this.collection.findIndex((d2) => d2.id === id2);
33585     _this.matchGeometry = (geometry) => {
33586       return presetCollection(
33587         _this.collection.filter((d2) => d2.matchGeometry(geometry))
33588       );
33589     };
33590     _this.matchAllGeometry = (geometries) => {
33591       return presetCollection(
33592         _this.collection.filter((d2) => d2 && d2.matchAllGeometry(geometries))
33593       );
33594     };
33595     _this.matchAnyGeometry = (geometries) => {
33596       return presetCollection(
33597         _this.collection.filter((d2) => geometries.some((geom) => d2.matchGeometry(geom)))
33598       );
33599     };
33600     _this.fallback = (geometry) => {
33601       let id2 = geometry;
33602       if (id2 === "vertex") id2 = "point";
33603       return _this.item(id2);
33604     };
33605     _this.search = (value, geometry, loc) => {
33606       if (!value) return _this;
33607       value = value.toLowerCase().trim();
33608       function leading(a2) {
33609         const index = a2.indexOf(value);
33610         return index === 0 || a2[index - 1] === " ";
33611       }
33612       function leadingStrict(a2) {
33613         const index = a2.indexOf(value);
33614         return index === 0;
33615       }
33616       function sortPresets(nameProp, aliasesProp) {
33617         return function sortNames(a2, b2) {
33618           let aCompare = a2[nameProp]();
33619           let bCompare = b2[nameProp]();
33620           if (aliasesProp) {
33621             const findMatchingAlias = (strings) => {
33622               if (strings.some((s2) => s2 === value)) {
33623                 return strings.find((s2) => s2 === value);
33624               } else {
33625                 return strings.filter((s2) => s2.includes(value)).sort((a3, b3) => a3.length - b3.length)[0];
33626               }
33627             };
33628             aCompare = findMatchingAlias([aCompare].concat(a2[aliasesProp]()));
33629             bCompare = findMatchingAlias([bCompare].concat(b2[aliasesProp]()));
33630           }
33631           if (value === aCompare) return -1;
33632           if (value === bCompare) return 1;
33633           let i3 = b2.originalScore - a2.originalScore;
33634           if (i3 !== 0) return i3;
33635           i3 = aCompare.indexOf(value) - bCompare.indexOf(value);
33636           if (i3 !== 0) return i3;
33637           return aCompare.length - bCompare.length;
33638         };
33639       }
33640       let pool = _this.collection;
33641       if (Array.isArray(loc)) {
33642         const validHere = _sharedLocationManager.locationSetsAt(loc);
33643         pool = pool.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
33644       }
33645       const searchable = pool.filter((a2) => a2.searchable !== false && a2.suggestion !== true);
33646       const suggestions = pool.filter((a2) => a2.suggestion === true);
33647       const leadingNames = searchable.filter((a2) => leading(a2.searchName()) || a2.searchAliases().some(leading)).sort(sortPresets("searchName", "searchAliases"));
33648       const leadingSuggestions = suggestions.filter((a2) => leadingStrict(a2.searchName())).sort(sortPresets("searchName"));
33649       const leadingNamesStripped = searchable.filter((a2) => leading(a2.searchNameStripped()) || a2.searchAliasesStripped().some(leading)).sort(sortPresets("searchNameStripped", "searchAliasesStripped"));
33650       const leadingSuggestionsStripped = suggestions.filter((a2) => leadingStrict(a2.searchNameStripped())).sort(sortPresets("searchNameStripped"));
33651       const leadingTerms = searchable.filter((a2) => (a2.terms() || []).some(leading));
33652       const leadingSuggestionTerms = suggestions.filter((a2) => (a2.terms() || []).some(leading));
33653       const leadingTagValues = searchable.filter((a2) => Object.values(a2.tags || {}).filter((val) => val !== "*").some(leading));
33654       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);
33655       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);
33656       const similarTerms = searchable.filter((a2) => {
33657         return (a2.terms() || []).some((b2) => {
33658           return utilEditDistance(value, b2) + Math.min(value.length - b2.length, 0) < 3;
33659         });
33660       });
33661       let leadingTagKeyValues = [];
33662       if (value.includes("=")) {
33663         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]))));
33664       }
33665       let results = leadingNames.concat(
33666         leadingSuggestions,
33667         leadingNamesStripped,
33668         leadingSuggestionsStripped,
33669         leadingTerms,
33670         leadingSuggestionTerms,
33671         leadingTagValues,
33672         similarName,
33673         similarSuggestions,
33674         similarTerms,
33675         leadingTagKeyValues
33676       ).slice(0, MAXRESULTS - 1);
33677       if (geometry) {
33678         if (typeof geometry === "string") {
33679           results.push(_this.fallback(geometry));
33680         } else {
33681           geometry.forEach((geom) => results.push(_this.fallback(geom)));
33682         }
33683       }
33684       return presetCollection(utilArrayUniq(results));
33685     };
33686     return _this;
33687   }
33688
33689   // modules/presets/category.js
33690   function presetCategory(categoryID, category, allPresets) {
33691     let _this = Object.assign({}, category);
33692     let _searchName;
33693     let _searchNameStripped;
33694     _this.id = categoryID;
33695     _this.members = presetCollection(
33696       (category.members || []).map((presetID) => allPresets[presetID]).filter(Boolean)
33697     );
33698     _this.geometry = _this.members.collection.reduce((acc, preset) => {
33699       for (let i3 in preset.geometry) {
33700         const geometry = preset.geometry[i3];
33701         if (acc.indexOf(geometry) === -1) {
33702           acc.push(geometry);
33703         }
33704       }
33705       return acc;
33706     }, []);
33707     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
33708     _this.matchAllGeometry = (geometries) => _this.members.collection.some((preset) => preset.matchAllGeometry(geometries));
33709     _this.matchScore = () => -1;
33710     _this.name = () => _t("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
33711     _this.nameLabel = () => _t.append("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
33712     _this.terms = () => [];
33713     _this.searchName = () => {
33714       if (!_searchName) {
33715         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
33716       }
33717       return _searchName;
33718     };
33719     _this.searchNameStripped = () => {
33720       if (!_searchNameStripped) {
33721         _searchNameStripped = _this.searchName();
33722         if (_searchNameStripped.normalize) _searchNameStripped = _searchNameStripped.normalize("NFD");
33723         _searchNameStripped = _searchNameStripped.replace(/[\u0300-\u036f]/g, "");
33724       }
33725       return _searchNameStripped;
33726     };
33727     _this.searchAliases = () => [];
33728     _this.searchAliasesStripped = () => [];
33729     return _this;
33730   }
33731
33732   // modules/presets/field.js
33733   function presetField(fieldID, field, allFields) {
33734     allFields = allFields || {};
33735     let _this = Object.assign({}, field);
33736     _this.id = fieldID;
33737     _this.safeid = utilSafeClassName(fieldID);
33738     _this.matchGeometry = (geom) => !_this.geometry || _this.geometry.indexOf(geom) !== -1;
33739     _this.matchAllGeometry = (geometries) => {
33740       return !_this.geometry || geometries.every((geom) => _this.geometry.indexOf(geom) !== -1);
33741     };
33742     _this.t = (scope, options2) => _t("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33743     _this.t.html = (scope, options2) => _t.html("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33744     _this.t.append = (scope, options2) => _t.append("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33745     _this.hasTextForStringId = (scope) => _mainLocalizer.hasTextForStringId("_tagging.presets.fields.".concat(fieldID, ".").concat(scope));
33746     _this.resolveReference = (which) => {
33747       const referenceRegex = /^\{(.*)\}$/;
33748       const match = (field[which] || "").match(referenceRegex);
33749       if (match) {
33750         const field2 = allFields[match[1]];
33751         if (field2) {
33752           return field2;
33753         }
33754         console.error("Unable to resolve referenced field: ".concat(match[1]));
33755       }
33756       return _this;
33757     };
33758     _this.title = () => _this.overrideLabel || _this.resolveReference("label").t("label", { "default": fieldID });
33759     _this.label = () => _this.overrideLabel ? (selection2) => selection2.text(_this.overrideLabel) : _this.resolveReference("label").t.append("label", { "default": fieldID });
33760     _this.placeholder = () => _this.resolveReference("placeholder").t("placeholder", { "default": "" });
33761     _this.originalTerms = (_this.terms || []).join();
33762     _this.terms = () => _this.resolveReference("label").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
33763     _this.increment = _this.type === "number" ? _this.increment || 1 : void 0;
33764     return _this;
33765   }
33766
33767   // modules/presets/preset.js
33768   var import_lodash2 = __toESM(require_lodash());
33769   function presetPreset(presetID, preset, addable, allFields, allPresets) {
33770     allFields = allFields || {};
33771     allPresets = allPresets || {};
33772     let _this = Object.assign({}, preset);
33773     let _addable = addable || false;
33774     let _searchName;
33775     let _searchNameStripped;
33776     let _searchAliases;
33777     let _searchAliasesStripped;
33778     const referenceRegex = /^\{(.*)\}$/;
33779     _this.id = presetID;
33780     _this.safeid = utilSafeClassName(presetID);
33781     _this.originalTerms = (_this.terms || []).join();
33782     _this.originalName = _this.name || "";
33783     _this.originalAliases = (_this.aliases || []).join("\n");
33784     _this.originalScore = _this.matchScore || 1;
33785     _this.originalReference = _this.reference || {};
33786     _this.originalFields = _this.fields || [];
33787     _this.originalMoreFields = _this.moreFields || [];
33788     _this.fields = (loc) => resolveFields("fields", loc);
33789     _this.moreFields = (loc) => resolveFields("moreFields", loc);
33790     _this.tags = _this.tags || {};
33791     _this.addTags = _this.addTags || _this.tags;
33792     _this.removeTags = _this.removeTags || _this.addTags;
33793     _this.geometry = _this.geometry || [];
33794     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
33795     _this.matchAllGeometry = (geoms) => geoms.every(_this.matchGeometry);
33796     _this.matchScore = (entityTags) => {
33797       const tags = _this.tags;
33798       let seen = {};
33799       let score = 0;
33800       for (let k2 in tags) {
33801         seen[k2] = true;
33802         if (entityTags[k2] === tags[k2]) {
33803           score += _this.originalScore;
33804         } else if (tags[k2] === "*" && k2 in entityTags) {
33805           score += _this.originalScore / 2;
33806         } else {
33807           return -1;
33808         }
33809       }
33810       const addTags = _this.addTags;
33811       for (let k2 in addTags) {
33812         if (!seen[k2] && entityTags[k2] === addTags[k2]) {
33813           score += _this.originalScore;
33814         }
33815       }
33816       if (_this.searchable === false) {
33817         score *= 0.999;
33818       }
33819       return score;
33820     };
33821     _this.t = (scope, options2) => {
33822       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
33823       return _t(textID, options2);
33824     };
33825     _this.t.append = (scope, options2) => {
33826       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
33827       return _t.append(textID, options2);
33828     };
33829     function resolveReference(which) {
33830       const match = (_this[which] || "").match(referenceRegex);
33831       if (match) {
33832         const preset2 = allPresets[match[1]];
33833         if (preset2) {
33834           return preset2;
33835         }
33836         console.error("Unable to resolve referenced preset: ".concat(match[1]));
33837       }
33838       return _this;
33839     }
33840     _this.name = () => {
33841       return resolveReference("originalName").t("name", { "default": _this.originalName || presetID });
33842     };
33843     _this.nameLabel = () => {
33844       return resolveReference("originalName").t.append("name", { "default": _this.originalName || presetID });
33845     };
33846     _this.subtitle = () => {
33847       if (_this.suggestion) {
33848         let path = presetID.split("/");
33849         path.pop();
33850         return _t("_tagging.presets.presets." + path.join("/") + ".name");
33851       }
33852       return null;
33853     };
33854     _this.subtitleLabel = () => {
33855       if (_this.suggestion) {
33856         let path = presetID.split("/");
33857         path.pop();
33858         return _t.append("_tagging.presets.presets." + path.join("/") + ".name");
33859       }
33860       return null;
33861     };
33862     _this.aliases = () => {
33863       return resolveReference("originalName").t("aliases", { "default": _this.originalAliases }).trim().split(/\s*[\r\n]+\s*/);
33864     };
33865     _this.terms = () => {
33866       return resolveReference("originalName").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
33867     };
33868     _this.searchName = () => {
33869       if (!_searchName) {
33870         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
33871       }
33872       return _searchName;
33873     };
33874     _this.searchNameStripped = () => {
33875       if (!_searchNameStripped) {
33876         _searchNameStripped = stripDiacritics(_this.searchName());
33877       }
33878       return _searchNameStripped;
33879     };
33880     _this.searchAliases = () => {
33881       if (!_searchAliases) {
33882         _searchAliases = _this.aliases().map((alias) => alias.toLowerCase());
33883       }
33884       return _searchAliases;
33885     };
33886     _this.searchAliasesStripped = () => {
33887       if (!_searchAliasesStripped) {
33888         _searchAliasesStripped = _this.searchAliases();
33889         _searchAliasesStripped = _searchAliasesStripped.map(stripDiacritics);
33890       }
33891       return _searchAliasesStripped;
33892     };
33893     _this.isFallback = () => {
33894       const tagCount = Object.keys(_this.tags).length;
33895       return tagCount === 0 || tagCount === 1 && _this.tags.hasOwnProperty("area");
33896     };
33897     _this.addable = function(val) {
33898       if (!arguments.length) return _addable;
33899       _addable = val;
33900       return _this;
33901     };
33902     _this.reference = () => {
33903       const qid = _this.tags.wikidata || _this.tags["flag:wikidata"] || _this.tags["brand:wikidata"] || _this.tags["network:wikidata"] || _this.tags["operator:wikidata"];
33904       if (qid) {
33905         return { qid };
33906       }
33907       let key = _this.originalReference.key || Object.keys(utilObjectOmit(_this.tags, "name"))[0];
33908       let value = _this.originalReference.value || _this.tags[key];
33909       if (value === "*") {
33910         return { key };
33911       } else {
33912         return { key, value };
33913       }
33914     };
33915     _this.unsetTags = (tags, geometry, ignoringKeys, skipFieldDefaults, loc) => {
33916       let removeTags = ignoringKeys ? utilObjectOmit(_this.removeTags, ignoringKeys) : _this.removeTags;
33917       tags = utilObjectOmit(tags, Object.keys(removeTags));
33918       if (geometry && !skipFieldDefaults) {
33919         _this.fields(loc).forEach((field) => {
33920           if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key] && (!ignoringKeys || ignoringKeys.indexOf(field.key) === -1)) {
33921             delete tags[field.key];
33922           }
33923         });
33924       }
33925       delete tags.area;
33926       return tags;
33927     };
33928     _this.setTags = (tags, geometry, skipFieldDefaults, loc) => {
33929       const addTags = _this.addTags;
33930       tags = Object.assign({}, tags);
33931       for (let k2 in addTags) {
33932         if (addTags[k2] === "*") {
33933           if (_this.tags[k2] || !tags[k2]) {
33934             tags[k2] = "yes";
33935           }
33936         } else {
33937           tags[k2] = addTags[k2];
33938         }
33939       }
33940       if (!addTags.hasOwnProperty("area")) {
33941         delete tags.area;
33942         if (geometry === "area") {
33943           let needsAreaTag = true;
33944           for (let k2 in addTags) {
33945             if (_this.geometry.indexOf("line") === -1 && k2 in osmAreaKeys || k2 in osmAreaKeysExceptions && addTags[k2] in osmAreaKeysExceptions[k2]) {
33946               needsAreaTag = false;
33947               break;
33948             }
33949           }
33950           if (needsAreaTag) {
33951             tags.area = "yes";
33952           }
33953         }
33954       }
33955       if (geometry && !skipFieldDefaults) {
33956         _this.fields(loc).forEach((field) => {
33957           if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field.default) {
33958             tags[field.key] = field.default;
33959           }
33960         });
33961       }
33962       return tags;
33963     };
33964     function resolveFields(which, loc) {
33965       const fieldIDs = which === "fields" ? _this.originalFields : _this.originalMoreFields;
33966       let resolved = [];
33967       fieldIDs.forEach((fieldID) => {
33968         const match = fieldID.match(referenceRegex);
33969         if (match !== null) {
33970           resolved = resolved.concat(inheritFields(allPresets[match[1]], which));
33971         } else if (allFields[fieldID]) {
33972           resolved.push(allFields[fieldID]);
33973         } else {
33974           console.log('Cannot resolve "'.concat(fieldID, '" found in ').concat(_this.id, ".").concat(which));
33975         }
33976       });
33977       if (!resolved.length) {
33978         const endIndex = _this.id.lastIndexOf("/");
33979         const parentID = endIndex && _this.id.substring(0, endIndex);
33980         if (parentID) {
33981           let parent = allPresets[parentID];
33982           if (loc) {
33983             const validHere = _sharedLocationManager.locationSetsAt(loc);
33984             if ((parent == null ? void 0 : parent.locationSetID) && !validHere[parent.locationSetID]) {
33985               const candidateIDs = Object.keys(allPresets).filter((k2) => k2.startsWith(parentID));
33986               parent = allPresets[candidateIDs.find((candidateID) => {
33987                 const candidate = allPresets[candidateID];
33988                 return validHere[candidate.locationSetID] && (0, import_lodash2.isEqual)(candidate.tags, parent.tags);
33989               })];
33990             }
33991           }
33992           resolved = inheritFields(parent, which);
33993         }
33994       }
33995       return utilArrayUniq(resolved);
33996       function inheritFields(parent, which2) {
33997         if (!parent) return [];
33998         if (which2 === "fields") {
33999           return parent.fields().filter(shouldInherit);
34000         } else if (which2 === "moreFields") {
34001           return parent.moreFields();
34002         } else {
34003           return [];
34004         }
34005       }
34006       function shouldInherit(f2) {
34007         if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox
34008         f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check") return false;
34009         return true;
34010       }
34011     }
34012     function stripDiacritics(s2) {
34013       if (s2.normalize) s2 = s2.normalize("NFD");
34014       s2 = s2.replace(/[\u0300-\u036f]/g, "");
34015       return s2;
34016     }
34017     return _this;
34018   }
34019
34020   // modules/presets/index.js
34021   var _mainPresetIndex = presetIndex();
34022   function presetIndex() {
34023     const dispatch14 = dispatch_default("favoritePreset", "recentsChange");
34024     const MAXRECENTS = 30;
34025     const POINT = presetPreset("point", { name: "Point", tags: {}, geometry: ["point", "vertex"], matchScore: 0.1 });
34026     const LINE = presetPreset("line", { name: "Line", tags: {}, geometry: ["line"], matchScore: 0.1 });
34027     const AREA = presetPreset("area", { name: "Area", tags: { area: "yes" }, geometry: ["area"], matchScore: 0.1 });
34028     const RELATION = presetPreset("relation", { name: "Relation", tags: {}, geometry: ["relation"], matchScore: 0.1 });
34029     let _this = presetCollection([POINT, LINE, AREA, RELATION]);
34030     let _presets = { point: POINT, line: LINE, area: AREA, relation: RELATION };
34031     let _defaults2 = {
34032       point: presetCollection([POINT]),
34033       vertex: presetCollection([POINT]),
34034       line: presetCollection([LINE]),
34035       area: presetCollection([AREA]),
34036       relation: presetCollection([RELATION])
34037     };
34038     let _fields = {};
34039     let _categories = {};
34040     let _universal = [];
34041     let _addablePresetIDs = null;
34042     let _recents;
34043     let _favorites;
34044     let _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
34045     let _loadPromise;
34046     _this.ensureLoaded = (bypassCache) => {
34047       if (_loadPromise && !bypassCache) return _loadPromise;
34048       return _loadPromise = Promise.all([
34049         _mainFileFetcher.get("preset_categories"),
34050         _mainFileFetcher.get("preset_defaults"),
34051         _mainFileFetcher.get("preset_presets"),
34052         _mainFileFetcher.get("preset_fields")
34053       ]).then((vals) => {
34054         _this.merge({
34055           categories: vals[0],
34056           defaults: vals[1],
34057           presets: vals[2],
34058           fields: vals[3]
34059         });
34060         osmSetAreaKeys(_this.areaKeys());
34061         osmSetLineTags(_this.lineTags());
34062         osmSetPointTags(_this.pointTags());
34063         osmSetVertexTags(_this.vertexTags());
34064       });
34065     };
34066     _this.merge = (d2) => {
34067       let newLocationSets = [];
34068       if (d2.fields) {
34069         Object.keys(d2.fields).forEach((fieldID) => {
34070           let f2 = d2.fields[fieldID];
34071           if (f2) {
34072             f2 = presetField(fieldID, f2, _fields);
34073             if (f2.locationSet) newLocationSets.push(f2);
34074             _fields[fieldID] = f2;
34075           } else {
34076             delete _fields[fieldID];
34077           }
34078         });
34079       }
34080       if (d2.presets) {
34081         Object.keys(d2.presets).forEach((presetID) => {
34082           let p2 = d2.presets[presetID];
34083           if (p2) {
34084             const isAddable = !_addablePresetIDs || _addablePresetIDs.has(presetID);
34085             p2 = presetPreset(presetID, p2, isAddable, _fields, _presets);
34086             if (p2.locationSet) newLocationSets.push(p2);
34087             _presets[presetID] = p2;
34088           } else {
34089             const existing = _presets[presetID];
34090             if (existing && !existing.isFallback()) {
34091               delete _presets[presetID];
34092             }
34093           }
34094         });
34095       }
34096       if (d2.categories) {
34097         Object.keys(d2.categories).forEach((categoryID) => {
34098           let c2 = d2.categories[categoryID];
34099           if (c2) {
34100             c2 = presetCategory(categoryID, c2, _presets);
34101             if (c2.locationSet) newLocationSets.push(c2);
34102             _categories[categoryID] = c2;
34103           } else {
34104             delete _categories[categoryID];
34105           }
34106         });
34107       }
34108       _this.collection = Object.values(_presets).concat(Object.values(_categories));
34109       if (d2.defaults) {
34110         Object.keys(d2.defaults).forEach((geometry) => {
34111           const def2 = d2.defaults[geometry];
34112           if (Array.isArray(def2)) {
34113             _defaults2[geometry] = presetCollection(
34114               def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean)
34115             );
34116           } else {
34117             delete _defaults2[geometry];
34118           }
34119         });
34120       }
34121       _universal = Object.values(_fields).filter((field) => field.universal);
34122       _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
34123       _this.collection.forEach((preset) => {
34124         (preset.geometry || []).forEach((geometry) => {
34125           let g3 = _geometryIndex[geometry];
34126           for (let key in preset.tags) {
34127             g3[key] = g3[key] || {};
34128             let value = preset.tags[key];
34129             (g3[key][value] = g3[key][value] || []).push(preset);
34130           }
34131         });
34132       });
34133       if (d2.featureCollection && Array.isArray(d2.featureCollection.features)) {
34134         _sharedLocationManager.mergeCustomGeoJSON(d2.featureCollection);
34135       }
34136       if (newLocationSets.length) {
34137         _sharedLocationManager.mergeLocationSets(newLocationSets);
34138       }
34139       return _this;
34140     };
34141     _this.match = (entity, resolver) => {
34142       return resolver.transient(entity, "presetMatch", () => {
34143         let geometry = entity.geometry(resolver);
34144         if (geometry === "vertex" && entity.isOnAddressLine(resolver)) {
34145           geometry = "point";
34146         }
34147         const entityExtent = entity.extent(resolver);
34148         return _this.matchTags(entity.tags, geometry, entityExtent.center());
34149       });
34150     };
34151     _this.matchTags = (tags, geometry, loc) => {
34152       const keyIndex = _geometryIndex[geometry];
34153       let bestScore = -1;
34154       let bestMatch;
34155       let matchCandidates = [];
34156       for (let k2 in tags) {
34157         let indexMatches = [];
34158         let valueIndex = keyIndex[k2];
34159         if (!valueIndex) continue;
34160         let keyValueMatches = valueIndex[tags[k2]];
34161         if (keyValueMatches) indexMatches.push(...keyValueMatches);
34162         let keyStarMatches = valueIndex["*"];
34163         if (keyStarMatches) indexMatches.push(...keyStarMatches);
34164         if (indexMatches.length === 0) continue;
34165         for (let i3 = 0; i3 < indexMatches.length; i3++) {
34166           const candidate = indexMatches[i3];
34167           const score = candidate.matchScore(tags);
34168           if (score === -1) {
34169             continue;
34170           }
34171           matchCandidates.push({ score, candidate });
34172           if (score > bestScore) {
34173             bestScore = score;
34174             bestMatch = candidate;
34175           }
34176         }
34177       }
34178       if (bestMatch && bestMatch.locationSetID && bestMatch.locationSetID !== "+[Q2]" && Array.isArray(loc)) {
34179         const validHere = _sharedLocationManager.locationSetsAt(loc);
34180         if (!validHere[bestMatch.locationSetID]) {
34181           matchCandidates.sort((a2, b2) => a2.score < b2.score ? 1 : -1);
34182           for (let i3 = 0; i3 < matchCandidates.length; i3++) {
34183             const candidateScore = matchCandidates[i3];
34184             if (!candidateScore.candidate.locationSetID || validHere[candidateScore.candidate.locationSetID]) {
34185               bestMatch = candidateScore.candidate;
34186               bestScore = candidateScore.score;
34187               break;
34188             }
34189           }
34190         }
34191       }
34192       if (!bestMatch || bestMatch.isFallback()) {
34193         for (let k2 in tags) {
34194           if (/^addr:/.test(k2) && keyIndex["addr:*"] && keyIndex["addr:*"]["*"]) {
34195             bestMatch = keyIndex["addr:*"]["*"][0];
34196             break;
34197           }
34198         }
34199       }
34200       return bestMatch || _this.fallback(geometry);
34201     };
34202     _this.allowsVertex = (entity, resolver) => {
34203       if (entity.type !== "node") return false;
34204       if (Object.keys(entity.tags).length === 0) return true;
34205       return resolver.transient(entity, "vertexMatch", () => {
34206         if (entity.isOnAddressLine(resolver)) return true;
34207         const geometries = osmNodeGeometriesForTags(entity.tags);
34208         if (geometries.vertex) return true;
34209         if (geometries.point) return false;
34210         return true;
34211       });
34212     };
34213     _this.areaKeys = () => {
34214       const ignore = {
34215         barrier: true,
34216         highway: true,
34217         footway: true,
34218         railway: true,
34219         junction: true,
34220         type: true
34221       };
34222       let areaKeys = {};
34223       const presets = _this.collection.filter((p2) => !p2.suggestion && !p2.replacement);
34224       presets.forEach((p2) => {
34225         const keys2 = p2.tags && Object.keys(p2.tags);
34226         const key = keys2 && keys2.length && keys2[0];
34227         if (!key) return;
34228         if (ignore[key]) return;
34229         if (p2.geometry.indexOf("area") !== -1) {
34230           areaKeys[key] = areaKeys[key] || {};
34231         }
34232       });
34233       presets.forEach((p2) => {
34234         let key;
34235         for (key in p2.addTags) {
34236           const value = p2.addTags[key];
34237           if (key in areaKeys && // probably an area...
34238           p2.geometry.indexOf("line") !== -1 && // but sometimes a line
34239           value !== "*") {
34240             areaKeys[key][value] = true;
34241           }
34242         }
34243       });
34244       return areaKeys;
34245     };
34246     _this.lineTags = () => {
34247       return _this.collection.filter((lineTags, d2) => {
34248         if (d2.suggestion || d2.replacement || d2.searchable === false) return lineTags;
34249         const keys2 = d2.tags && Object.keys(d2.tags);
34250         const key = keys2 && keys2.length && keys2[0];
34251         if (!key) return lineTags;
34252         if (d2.geometry.indexOf("line") !== -1) {
34253           lineTags[key] = lineTags[key] || [];
34254           lineTags[key].push(d2.tags);
34255         }
34256         return lineTags;
34257       }, {});
34258     };
34259     _this.pointTags = () => {
34260       return _this.collection.reduce((pointTags, d2) => {
34261         if (d2.suggestion || d2.replacement || d2.searchable === false) return pointTags;
34262         const keys2 = d2.tags && Object.keys(d2.tags);
34263         const key = keys2 && keys2.length && keys2[0];
34264         if (!key) return pointTags;
34265         if (d2.geometry.indexOf("point") !== -1) {
34266           pointTags[key] = pointTags[key] || {};
34267           pointTags[key][d2.tags[key]] = true;
34268         }
34269         return pointTags;
34270       }, {});
34271     };
34272     _this.vertexTags = () => {
34273       return _this.collection.reduce((vertexTags, d2) => {
34274         if (d2.suggestion || d2.replacement || d2.searchable === false) return vertexTags;
34275         const keys2 = d2.tags && Object.keys(d2.tags);
34276         const key = keys2 && keys2.length && keys2[0];
34277         if (!key) return vertexTags;
34278         if (d2.geometry.indexOf("vertex") !== -1) {
34279           vertexTags[key] = vertexTags[key] || {};
34280           vertexTags[key][d2.tags[key]] = true;
34281         }
34282         return vertexTags;
34283       }, {});
34284     };
34285     _this.field = (id2) => _fields[id2];
34286     _this.universal = () => _universal;
34287     _this.defaults = (geometry, n3, startWithRecents, loc, extraPresets) => {
34288       let recents = [];
34289       if (startWithRecents) {
34290         recents = _this.recent().matchGeometry(geometry).collection.slice(0, 4);
34291       }
34292       let defaults;
34293       if (_addablePresetIDs) {
34294         defaults = Array.from(_addablePresetIDs).map(function(id2) {
34295           var preset = _this.item(id2);
34296           if (preset && preset.matchGeometry(geometry)) return preset;
34297           return null;
34298         }).filter(Boolean);
34299       } else {
34300         defaults = _defaults2[geometry].collection.concat(_this.fallback(geometry));
34301       }
34302       let result = presetCollection(
34303         utilArrayUniq(recents.concat(defaults).concat(extraPresets || [])).slice(0, n3 - 1)
34304       );
34305       if (Array.isArray(loc)) {
34306         const validHere = _sharedLocationManager.locationSetsAt(loc);
34307         result.collection = result.collection.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
34308       }
34309       return result;
34310     };
34311     _this.addablePresetIDs = function(val) {
34312       if (!arguments.length) return _addablePresetIDs;
34313       if (Array.isArray(val)) val = new Set(val);
34314       _addablePresetIDs = val;
34315       if (_addablePresetIDs) {
34316         _this.collection.forEach((p2) => {
34317           if (p2.addable) p2.addable(_addablePresetIDs.has(p2.id));
34318         });
34319       } else {
34320         _this.collection.forEach((p2) => {
34321           if (p2.addable) p2.addable(true);
34322         });
34323       }
34324       return _this;
34325     };
34326     _this.recent = () => {
34327       return presetCollection(
34328         utilArrayUniq(_this.getRecents().map((d2) => d2.preset).filter((d2) => d2.searchable !== false))
34329       );
34330     };
34331     function RibbonItem(preset, source) {
34332       let item = {};
34333       item.preset = preset;
34334       item.source = source;
34335       item.isFavorite = () => item.source === "favorite";
34336       item.isRecent = () => item.source === "recent";
34337       item.matches = (preset2) => item.preset.id === preset2.id;
34338       item.minified = () => ({ pID: item.preset.id });
34339       return item;
34340     }
34341     function ribbonItemForMinified(d2, source) {
34342       if (d2 && d2.pID) {
34343         const preset = _this.item(d2.pID);
34344         if (!preset) return null;
34345         return RibbonItem(preset, source);
34346       }
34347       return null;
34348     }
34349     _this.getGenericRibbonItems = () => {
34350       return ["point", "line", "area"].map((id2) => RibbonItem(_this.item(id2), "generic"));
34351     };
34352     _this.getAddable = () => {
34353       if (!_addablePresetIDs) return [];
34354       return _addablePresetIDs.map((id2) => {
34355         const preset = _this.item(id2);
34356         if (preset) return RibbonItem(preset, "addable");
34357         return null;
34358       }).filter(Boolean);
34359     };
34360     function setRecents(items) {
34361       _recents = items;
34362       const minifiedItems = items.map((d2) => d2.minified());
34363       corePreferences("preset_recents", JSON.stringify(minifiedItems));
34364       dispatch14.call("recentsChange");
34365     }
34366     _this.getRecents = () => {
34367       if (!_recents) {
34368         _recents = (JSON.parse(corePreferences("preset_recents")) || []).reduce((acc, d2) => {
34369           let item = ribbonItemForMinified(d2, "recent");
34370           if (item && item.preset.addable()) acc.push(item);
34371           return acc;
34372         }, []);
34373       }
34374       return _recents;
34375     };
34376     _this.addRecent = (preset, besidePreset, after) => {
34377       const recents = _this.getRecents();
34378       const beforeItem = _this.recentMatching(besidePreset);
34379       let toIndex = recents.indexOf(beforeItem);
34380       if (after) toIndex += 1;
34381       const newItem = RibbonItem(preset, "recent");
34382       recents.splice(toIndex, 0, newItem);
34383       setRecents(recents);
34384     };
34385     _this.removeRecent = (preset) => {
34386       const item = _this.recentMatching(preset);
34387       if (item) {
34388         let items = _this.getRecents();
34389         items.splice(items.indexOf(item), 1);
34390         setRecents(items);
34391       }
34392     };
34393     _this.recentMatching = (preset) => {
34394       const items = _this.getRecents();
34395       for (let i3 in items) {
34396         if (items[i3].matches(preset)) {
34397           return items[i3];
34398         }
34399       }
34400       return null;
34401     };
34402     _this.moveItem = (items, fromIndex, toIndex) => {
34403       if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return null;
34404       items.splice(toIndex, 0, items.splice(fromIndex, 1)[0]);
34405       return items;
34406     };
34407     _this.moveRecent = (item, beforeItem) => {
34408       const recents = _this.getRecents();
34409       const fromIndex = recents.indexOf(item);
34410       const toIndex = recents.indexOf(beforeItem);
34411       const items = _this.moveItem(recents, fromIndex, toIndex);
34412       if (items) setRecents(items);
34413     };
34414     _this.setMostRecent = (preset) => {
34415       if (preset.searchable === false) return;
34416       let items = _this.getRecents();
34417       let item = _this.recentMatching(preset);
34418       if (item) {
34419         items.splice(items.indexOf(item), 1);
34420       } else {
34421         item = RibbonItem(preset, "recent");
34422       }
34423       while (items.length >= MAXRECENTS) {
34424         items.pop();
34425       }
34426       items.unshift(item);
34427       setRecents(items);
34428     };
34429     function setFavorites(items) {
34430       _favorites = items;
34431       const minifiedItems = items.map((d2) => d2.minified());
34432       corePreferences("preset_favorites", JSON.stringify(minifiedItems));
34433       dispatch14.call("favoritePreset");
34434     }
34435     _this.addFavorite = (preset, besidePreset, after) => {
34436       const favorites = _this.getFavorites();
34437       const beforeItem = _this.favoriteMatching(besidePreset);
34438       let toIndex = favorites.indexOf(beforeItem);
34439       if (after) toIndex += 1;
34440       const newItem = RibbonItem(preset, "favorite");
34441       favorites.splice(toIndex, 0, newItem);
34442       setFavorites(favorites);
34443     };
34444     _this.toggleFavorite = (preset) => {
34445       const favs = _this.getFavorites();
34446       const favorite = _this.favoriteMatching(preset);
34447       if (favorite) {
34448         favs.splice(favs.indexOf(favorite), 1);
34449       } else {
34450         if (favs.length === 10) {
34451           favs.pop();
34452         }
34453         favs.push(RibbonItem(preset, "favorite"));
34454       }
34455       setFavorites(favs);
34456     };
34457     _this.removeFavorite = (preset) => {
34458       const item = _this.favoriteMatching(preset);
34459       if (item) {
34460         const items = _this.getFavorites();
34461         items.splice(items.indexOf(item), 1);
34462         setFavorites(items);
34463       }
34464     };
34465     _this.getFavorites = () => {
34466       if (!_favorites) {
34467         let rawFavorites = JSON.parse(corePreferences("preset_favorites"));
34468         if (!rawFavorites) {
34469           rawFavorites = [];
34470           corePreferences("preset_favorites", JSON.stringify(rawFavorites));
34471         }
34472         _favorites = rawFavorites.reduce((output, d2) => {
34473           const item = ribbonItemForMinified(d2, "favorite");
34474           if (item && item.preset.addable()) output.push(item);
34475           return output;
34476         }, []);
34477       }
34478       return _favorites;
34479     };
34480     _this.favoriteMatching = (preset) => {
34481       const favs = _this.getFavorites();
34482       for (let index in favs) {
34483         if (favs[index].matches(preset)) {
34484           return favs[index];
34485         }
34486       }
34487       return null;
34488     };
34489     return utilRebind(_this, dispatch14, "on");
34490   }
34491
34492   // modules/behavior/edit.js
34493   function behaviorEdit(context) {
34494     function behavior() {
34495       context.map().minzoom(context.minEditableZoom());
34496     }
34497     behavior.off = function() {
34498       context.map().minzoom(0);
34499     };
34500     return behavior;
34501   }
34502
34503   // modules/behavior/hover.js
34504   function behaviorHover(context) {
34505     var dispatch14 = dispatch_default("hover");
34506     var _selection = select_default2(null);
34507     var _newNodeId = null;
34508     var _initialNodeID = null;
34509     var _altDisables;
34510     var _ignoreVertex;
34511     var _targets = [];
34512     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
34513     function keydown(d3_event) {
34514       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
34515         _selection.selectAll(".hover").classed("hover-suppressed", true).classed("hover", false);
34516         _selection.classed("hover-disabled", true);
34517         dispatch14.call("hover", this, null);
34518       }
34519     }
34520     function keyup(d3_event) {
34521       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
34522         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false).classed("hover", true);
34523         _selection.classed("hover-disabled", false);
34524         dispatch14.call("hover", this, _targets);
34525       }
34526     }
34527     function behavior(selection2) {
34528       _selection = selection2;
34529       _targets = [];
34530       if (_initialNodeID) {
34531         _newNodeId = _initialNodeID;
34532         _initialNodeID = null;
34533       } else {
34534         _newNodeId = null;
34535       }
34536       _selection.on(_pointerPrefix + "over.hover", pointerover).on(_pointerPrefix + "out.hover", pointerout).on(_pointerPrefix + "down.hover", pointerover);
34537       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", pointerout, true).on("keydown.hover", keydown).on("keyup.hover", keyup);
34538       function eventTarget(d3_event) {
34539         var datum2 = d3_event.target && d3_event.target.__data__;
34540         if (typeof datum2 !== "object") return null;
34541         if (!(datum2 instanceof osmEntity) && datum2.properties && datum2.properties.entity instanceof osmEntity) {
34542           return datum2.properties.entity;
34543         }
34544         return datum2;
34545       }
34546       function pointerover(d3_event) {
34547         if (context.mode().id.indexOf("drag") === -1 && (!d3_event.pointerType || d3_event.pointerType === "mouse") && d3_event.buttons) return;
34548         var target = eventTarget(d3_event);
34549         if (target && _targets.indexOf(target) === -1) {
34550           _targets.push(target);
34551           updateHover(d3_event, _targets);
34552         }
34553       }
34554       function pointerout(d3_event) {
34555         var target = eventTarget(d3_event);
34556         var index = _targets.indexOf(target);
34557         if (index !== -1) {
34558           _targets.splice(index);
34559           updateHover(d3_event, _targets);
34560         }
34561       }
34562       function allowsVertex(d2) {
34563         return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
34564       }
34565       function modeAllowsHover(target) {
34566         var mode = context.mode();
34567         if (mode.id === "add-point") {
34568           return mode.preset.matchGeometry("vertex") || target.type !== "way" && target.geometry(context.graph()) !== "vertex";
34569         }
34570         return true;
34571       }
34572       function updateHover(d3_event, targets) {
34573         _selection.selectAll(".hover").classed("hover", false);
34574         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false);
34575         var mode = context.mode();
34576         if (!_newNodeId && (mode.id === "draw-line" || mode.id === "draw-area")) {
34577           var node = targets.find(function(target) {
34578             return target instanceof osmEntity && target.type === "node";
34579           });
34580           _newNodeId = node && node.id;
34581         }
34582         targets = targets.filter(function(datum3) {
34583           if (datum3 instanceof osmEntity) {
34584             return datum3.id !== _newNodeId && (datum3.type !== "node" || !_ignoreVertex || allowsVertex(datum3)) && modeAllowsHover(datum3);
34585           }
34586           return true;
34587         });
34588         var selector = "";
34589         for (var i3 in targets) {
34590           var datum2 = targets[i3];
34591           if (datum2.__featurehash__) {
34592             selector += ", .data" + datum2.__featurehash__;
34593           } else if (datum2 instanceof QAItem) {
34594             selector += ", ." + datum2.service + ".itemId-" + datum2.id;
34595           } else if (datum2 instanceof osmNote) {
34596             selector += ", .note-" + datum2.id;
34597           } else if (datum2 instanceof osmEntity) {
34598             selector += ", ." + datum2.id;
34599             if (datum2.type === "relation") {
34600               for (var j2 in datum2.members) {
34601                 selector += ", ." + datum2.members[j2].id;
34602               }
34603             }
34604           }
34605         }
34606         var suppressed = _altDisables && d3_event && d3_event.altKey;
34607         if (selector.trim().length) {
34608           selector = selector.slice(1);
34609           _selection.selectAll(selector).classed(suppressed ? "hover-suppressed" : "hover", true);
34610         }
34611         dispatch14.call("hover", this, !suppressed && targets);
34612       }
34613     }
34614     behavior.off = function(selection2) {
34615       selection2.selectAll(".hover").classed("hover", false);
34616       selection2.selectAll(".hover-suppressed").classed("hover-suppressed", false);
34617       selection2.classed("hover-disabled", false);
34618       selection2.on(_pointerPrefix + "over.hover", null).on(_pointerPrefix + "out.hover", null).on(_pointerPrefix + "down.hover", null);
34619       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", null, true).on("keydown.hover", null).on("keyup.hover", null);
34620     };
34621     behavior.altDisables = function(val) {
34622       if (!arguments.length) return _altDisables;
34623       _altDisables = val;
34624       return behavior;
34625     };
34626     behavior.ignoreVertex = function(val) {
34627       if (!arguments.length) return _ignoreVertex;
34628       _ignoreVertex = val;
34629       return behavior;
34630     };
34631     behavior.initialNodeID = function(nodeId) {
34632       _initialNodeID = nodeId;
34633       return behavior;
34634     };
34635     return utilRebind(behavior, dispatch14, "on");
34636   }
34637
34638   // modules/behavior/draw.js
34639   var _disableSpace = false;
34640   var _lastSpace = null;
34641   function behaviorDraw(context) {
34642     var dispatch14 = dispatch_default(
34643       "move",
34644       "down",
34645       "downcancel",
34646       "click",
34647       "clickWay",
34648       "clickNode",
34649       "undo",
34650       "cancel",
34651       "finish"
34652     );
34653     var keybinding = utilKeybinding("draw");
34654     var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true).on("hover", context.ui().sidebar.hover);
34655     var _edit = behaviorEdit(context);
34656     var _closeTolerance = 4;
34657     var _tolerance = 12;
34658     var _mouseLeave = false;
34659     var _lastMouse = null;
34660     var _lastPointerUpEvent;
34661     var _downPointer;
34662     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
34663     function datum2(d3_event) {
34664       var mode = context.mode();
34665       var isNote = mode && mode.id.indexOf("note") !== -1;
34666       if (d3_event.altKey || isNote) return {};
34667       var element;
34668       if (d3_event.type === "keydown") {
34669         element = _lastMouse && _lastMouse.target;
34670       } else {
34671         element = d3_event.target;
34672       }
34673       var d2 = element.__data__;
34674       return d2 && d2.properties && d2.properties.target ? d2 : {};
34675     }
34676     function pointerdown(d3_event) {
34677       if (_downPointer) return;
34678       var pointerLocGetter = utilFastMouse(this);
34679       _downPointer = {
34680         id: d3_event.pointerId || "mouse",
34681         pointerLocGetter,
34682         downTime: +/* @__PURE__ */ new Date(),
34683         downLoc: pointerLocGetter(d3_event)
34684       };
34685       dispatch14.call("down", this, d3_event, datum2(d3_event));
34686     }
34687     function pointerup(d3_event) {
34688       if (!_downPointer || _downPointer.id !== (d3_event.pointerId || "mouse")) return;
34689       var downPointer = _downPointer;
34690       _downPointer = null;
34691       _lastPointerUpEvent = d3_event;
34692       if (downPointer.isCancelled) return;
34693       var t2 = +/* @__PURE__ */ new Date();
34694       var p2 = downPointer.pointerLocGetter(d3_event);
34695       var dist = geoVecLength(downPointer.downLoc, p2);
34696       if (dist < _closeTolerance || dist < _tolerance && t2 - downPointer.downTime < 500) {
34697         select_default2(window).on("click.draw-block", function() {
34698           d3_event.stopPropagation();
34699         }, true);
34700         context.map().dblclickZoomEnable(false);
34701         window.setTimeout(function() {
34702           context.map().dblclickZoomEnable(true);
34703           select_default2(window).on("click.draw-block", null);
34704         }, 500);
34705         click(d3_event, p2);
34706       }
34707     }
34708     function pointermove(d3_event) {
34709       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse") && !_downPointer.isCancelled) {
34710         var p2 = _downPointer.pointerLocGetter(d3_event);
34711         var dist = geoVecLength(_downPointer.downLoc, p2);
34712         if (dist >= _closeTolerance) {
34713           _downPointer.isCancelled = true;
34714           dispatch14.call("downcancel", this);
34715         }
34716       }
34717       if (d3_event.pointerType && d3_event.pointerType !== "mouse" || d3_event.buttons || _downPointer) return;
34718       if (_lastPointerUpEvent && _lastPointerUpEvent.pointerType !== "mouse" && d3_event.timeStamp - _lastPointerUpEvent.timeStamp < 100) return;
34719       _lastMouse = d3_event;
34720       dispatch14.call("move", this, d3_event, datum2(d3_event));
34721     }
34722     function pointercancel(d3_event) {
34723       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse")) {
34724         if (!_downPointer.isCancelled) {
34725           dispatch14.call("downcancel", this);
34726         }
34727         _downPointer = null;
34728       }
34729     }
34730     function mouseenter() {
34731       _mouseLeave = false;
34732     }
34733     function mouseleave() {
34734       _mouseLeave = true;
34735     }
34736     function allowsVertex(d2) {
34737       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
34738     }
34739     function click(d3_event, loc) {
34740       var d2 = datum2(d3_event);
34741       var target = d2 && d2.properties && d2.properties.entity;
34742       var mode = context.mode();
34743       if (target && target.type === "node" && allowsVertex(target)) {
34744         dispatch14.call("clickNode", this, target, d2);
34745         return;
34746       } else if (target && target.type === "way" && (mode.id !== "add-point" || mode.preset.matchGeometry("vertex"))) {
34747         var choice = geoChooseEdge(
34748           context.graph().childNodes(target),
34749           loc,
34750           context.projection,
34751           context.activeID()
34752         );
34753         if (choice) {
34754           var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
34755           dispatch14.call("clickWay", this, choice.loc, edge, d2);
34756           return;
34757         }
34758       } else if (mode.id !== "add-point" || mode.preset.matchGeometry("point")) {
34759         var locLatLng = context.projection.invert(loc);
34760         dispatch14.call("click", this, locLatLng, d2);
34761       }
34762     }
34763     function space(d3_event) {
34764       d3_event.preventDefault();
34765       d3_event.stopPropagation();
34766       var currSpace = context.map().mouse();
34767       if (_disableSpace && _lastSpace) {
34768         var dist = geoVecLength(_lastSpace, currSpace);
34769         if (dist > _tolerance) {
34770           _disableSpace = false;
34771         }
34772       }
34773       if (_disableSpace || _mouseLeave || !_lastMouse) return;
34774       _lastSpace = currSpace;
34775       _disableSpace = true;
34776       select_default2(window).on("keyup.space-block", function() {
34777         d3_event.preventDefault();
34778         d3_event.stopPropagation();
34779         _disableSpace = false;
34780         select_default2(window).on("keyup.space-block", null);
34781       });
34782       var loc = context.map().mouse() || // or the map center if the mouse has never entered the map
34783       context.projection(context.map().center());
34784       click(d3_event, loc);
34785     }
34786     function backspace(d3_event) {
34787       d3_event.preventDefault();
34788       dispatch14.call("undo");
34789     }
34790     function del(d3_event) {
34791       d3_event.preventDefault();
34792       dispatch14.call("cancel");
34793     }
34794     function ret(d3_event) {
34795       d3_event.preventDefault();
34796       dispatch14.call("finish");
34797     }
34798     function behavior(selection2) {
34799       context.install(_hover);
34800       context.install(_edit);
34801       _downPointer = null;
34802       keybinding.on("\u232B", backspace).on("\u2326", del).on("\u238B", ret).on("\u21A9", ret).on("space", space).on("\u2325space", space);
34803       selection2.on("mouseenter.draw", mouseenter).on("mouseleave.draw", mouseleave).on(_pointerPrefix + "down.draw", pointerdown).on(_pointerPrefix + "move.draw", pointermove);
34804       select_default2(window).on(_pointerPrefix + "up.draw", pointerup, true).on("pointercancel.draw", pointercancel, true);
34805       select_default2(document).call(keybinding);
34806       return behavior;
34807     }
34808     behavior.off = function(selection2) {
34809       context.ui().sidebar.hover.cancel();
34810       context.uninstall(_hover);
34811       context.uninstall(_edit);
34812       selection2.on("mouseenter.draw", null).on("mouseleave.draw", null).on(_pointerPrefix + "down.draw", null).on(_pointerPrefix + "move.draw", null);
34813       select_default2(window).on(_pointerPrefix + "up.draw", null).on("pointercancel.draw", null);
34814       select_default2(document).call(keybinding.unbind);
34815     };
34816     behavior.hover = function() {
34817       return _hover;
34818     };
34819     return utilRebind(behavior, dispatch14, "on");
34820   }
34821
34822   // modules/behavior/breathe.js
34823   var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
34824
34825   // node_modules/d3-scale/src/init.js
34826   function initRange(domain, range3) {
34827     switch (arguments.length) {
34828       case 0:
34829         break;
34830       case 1:
34831         this.range(domain);
34832         break;
34833       default:
34834         this.range(range3).domain(domain);
34835         break;
34836     }
34837     return this;
34838   }
34839
34840   // node_modules/d3-scale/src/constant.js
34841   function constants(x2) {
34842     return function() {
34843       return x2;
34844     };
34845   }
34846
34847   // node_modules/d3-scale/src/number.js
34848   function number2(x2) {
34849     return +x2;
34850   }
34851
34852   // node_modules/d3-scale/src/continuous.js
34853   var unit = [0, 1];
34854   function identity4(x2) {
34855     return x2;
34856   }
34857   function normalize(a2, b2) {
34858     return (b2 -= a2 = +a2) ? function(x2) {
34859       return (x2 - a2) / b2;
34860     } : constants(isNaN(b2) ? NaN : 0.5);
34861   }
34862   function clamper(a2, b2) {
34863     var t2;
34864     if (a2 > b2) t2 = a2, a2 = b2, b2 = t2;
34865     return function(x2) {
34866       return Math.max(a2, Math.min(b2, x2));
34867     };
34868   }
34869   function bimap(domain, range3, interpolate) {
34870     var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1];
34871     if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
34872     else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
34873     return function(x2) {
34874       return r0(d0(x2));
34875     };
34876   }
34877   function polymap(domain, range3, interpolate) {
34878     var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1;
34879     if (domain[j2] < domain[0]) {
34880       domain = domain.slice().reverse();
34881       range3 = range3.slice().reverse();
34882     }
34883     while (++i3 < j2) {
34884       d2[i3] = normalize(domain[i3], domain[i3 + 1]);
34885       r2[i3] = interpolate(range3[i3], range3[i3 + 1]);
34886     }
34887     return function(x2) {
34888       var i4 = bisect_default(domain, x2, 1, j2) - 1;
34889       return r2[i4](d2[i4](x2));
34890     };
34891   }
34892   function copy(source, target) {
34893     return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
34894   }
34895   function transformer2() {
34896     var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity4, piecewise, output, input;
34897     function rescale() {
34898       var n3 = Math.min(domain.length, range3.length);
34899       if (clamp3 !== identity4) clamp3 = clamper(domain[0], domain[n3 - 1]);
34900       piecewise = n3 > 2 ? polymap : bimap;
34901       output = input = null;
34902       return scale;
34903     }
34904     function scale(x2) {
34905       return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2)));
34906     }
34907     scale.invert = function(y2) {
34908       return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2)));
34909     };
34910     scale.domain = function(_2) {
34911       return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice();
34912     };
34913     scale.range = function(_2) {
34914       return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice();
34915     };
34916     scale.rangeRound = function(_2) {
34917       return range3 = Array.from(_2), interpolate = round_default, rescale();
34918     };
34919     scale.clamp = function(_2) {
34920       return arguments.length ? (clamp3 = _2 ? true : identity4, rescale()) : clamp3 !== identity4;
34921     };
34922     scale.interpolate = function(_2) {
34923       return arguments.length ? (interpolate = _2, rescale()) : interpolate;
34924     };
34925     scale.unknown = function(_2) {
34926       return arguments.length ? (unknown = _2, scale) : unknown;
34927     };
34928     return function(t2, u2) {
34929       transform2 = t2, untransform = u2;
34930       return rescale();
34931     };
34932   }
34933   function continuous() {
34934     return transformer2()(identity4, identity4);
34935   }
34936
34937   // node_modules/d3-format/src/formatDecimal.js
34938   function formatDecimal_default(x2) {
34939     return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
34940   }
34941   function formatDecimalParts(x2, p2) {
34942     if ((i3 = (x2 = p2 ? x2.toExponential(p2 - 1) : x2.toExponential()).indexOf("e")) < 0) return null;
34943     var i3, coefficient = x2.slice(0, i3);
34944     return [
34945       coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
34946       +x2.slice(i3 + 1)
34947     ];
34948   }
34949
34950   // node_modules/d3-format/src/exponent.js
34951   function exponent_default(x2) {
34952     return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
34953   }
34954
34955   // node_modules/d3-format/src/formatGroup.js
34956   function formatGroup_default(grouping, thousands) {
34957     return function(value, width) {
34958       var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0;
34959       while (i3 > 0 && g3 > 0) {
34960         if (length2 + g3 + 1 > width) g3 = Math.max(1, width - length2);
34961         t2.push(value.substring(i3 -= g3, i3 + g3));
34962         if ((length2 += g3 + 1) > width) break;
34963         g3 = grouping[j2 = (j2 + 1) % grouping.length];
34964       }
34965       return t2.reverse().join(thousands);
34966     };
34967   }
34968
34969   // node_modules/d3-format/src/formatNumerals.js
34970   function formatNumerals_default(numerals) {
34971     return function(value) {
34972       return value.replace(/[0-9]/g, function(i3) {
34973         return numerals[+i3];
34974       });
34975     };
34976   }
34977
34978   // node_modules/d3-format/src/formatSpecifier.js
34979   var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
34980   function formatSpecifier(specifier) {
34981     if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
34982     var match;
34983     return new FormatSpecifier({
34984       fill: match[1],
34985       align: match[2],
34986       sign: match[3],
34987       symbol: match[4],
34988       zero: match[5],
34989       width: match[6],
34990       comma: match[7],
34991       precision: match[8] && match[8].slice(1),
34992       trim: match[9],
34993       type: match[10]
34994     });
34995   }
34996   formatSpecifier.prototype = FormatSpecifier.prototype;
34997   function FormatSpecifier(specifier) {
34998     this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
34999     this.align = specifier.align === void 0 ? ">" : specifier.align + "";
35000     this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
35001     this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
35002     this.zero = !!specifier.zero;
35003     this.width = specifier.width === void 0 ? void 0 : +specifier.width;
35004     this.comma = !!specifier.comma;
35005     this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
35006     this.trim = !!specifier.trim;
35007     this.type = specifier.type === void 0 ? "" : specifier.type + "";
35008   }
35009   FormatSpecifier.prototype.toString = function() {
35010     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;
35011   };
35012
35013   // node_modules/d3-format/src/formatTrim.js
35014   function formatTrim_default(s2) {
35015     out: for (var n3 = s2.length, i3 = 1, i0 = -1, i1; i3 < n3; ++i3) {
35016       switch (s2[i3]) {
35017         case ".":
35018           i0 = i1 = i3;
35019           break;
35020         case "0":
35021           if (i0 === 0) i0 = i3;
35022           i1 = i3;
35023           break;
35024         default:
35025           if (!+s2[i3]) break out;
35026           if (i0 > 0) i0 = 0;
35027           break;
35028       }
35029     }
35030     return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2;
35031   }
35032
35033   // node_modules/d3-format/src/formatPrefixAuto.js
35034   var prefixExponent;
35035   function formatPrefixAuto_default(x2, p2) {
35036     var d2 = formatDecimalParts(x2, p2);
35037     if (!d2) return x2 + "";
35038     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;
35039     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];
35040   }
35041
35042   // node_modules/d3-format/src/formatRounded.js
35043   function formatRounded_default(x2, p2) {
35044     var d2 = formatDecimalParts(x2, p2);
35045     if (!d2) return x2 + "";
35046     var coefficient = d2[0], exponent = d2[1];
35047     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");
35048   }
35049
35050   // node_modules/d3-format/src/formatTypes.js
35051   var formatTypes_default = {
35052     "%": (x2, p2) => (x2 * 100).toFixed(p2),
35053     "b": (x2) => Math.round(x2).toString(2),
35054     "c": (x2) => x2 + "",
35055     "d": formatDecimal_default,
35056     "e": (x2, p2) => x2.toExponential(p2),
35057     "f": (x2, p2) => x2.toFixed(p2),
35058     "g": (x2, p2) => x2.toPrecision(p2),
35059     "o": (x2) => Math.round(x2).toString(8),
35060     "p": (x2, p2) => formatRounded_default(x2 * 100, p2),
35061     "r": formatRounded_default,
35062     "s": formatPrefixAuto_default,
35063     "X": (x2) => Math.round(x2).toString(16).toUpperCase(),
35064     "x": (x2) => Math.round(x2).toString(16)
35065   };
35066
35067   // node_modules/d3-format/src/identity.js
35068   function identity_default5(x2) {
35069     return x2;
35070   }
35071
35072   // node_modules/d3-format/src/locale.js
35073   var map = Array.prototype.map;
35074   var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
35075   function locale_default(locale2) {
35076     var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default5 : 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_default5 : 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 + "";
35077     function newFormat(specifier) {
35078       specifier = formatSpecifier(specifier);
35079       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;
35080       if (type2 === "n") comma = true, type2 = "g";
35081       else if (!formatTypes_default[type2]) precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g";
35082       if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
35083       var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : "";
35084       var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2);
35085       precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3));
35086       function format2(value) {
35087         var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2;
35088         if (type2 === "c") {
35089           valueSuffix = formatType(value) + valueSuffix;
35090           value = "";
35091         } else {
35092           value = +value;
35093           var valueNegative = value < 0 || 1 / value < 0;
35094           value = isNaN(value) ? nan : formatType(Math.abs(value), precision3);
35095           if (trim) value = formatTrim_default(value);
35096           if (valueNegative && +value === 0 && sign2 !== "+") valueNegative = false;
35097           valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
35098           valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
35099           if (maybeSuffix) {
35100             i3 = -1, n3 = value.length;
35101             while (++i3 < n3) {
35102               if (c2 = value.charCodeAt(i3), 48 > c2 || c2 > 57) {
35103                 valueSuffix = (c2 === 46 ? decimal + value.slice(i3 + 1) : value.slice(i3)) + valueSuffix;
35104                 value = value.slice(0, i3);
35105                 break;
35106               }
35107             }
35108           }
35109         }
35110         if (comma && !zero3) value = group(value, Infinity);
35111         var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : "";
35112         if (comma && zero3) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
35113         switch (align) {
35114           case "<":
35115             value = valuePrefix + value + valueSuffix + padding;
35116             break;
35117           case "=":
35118             value = valuePrefix + padding + value + valueSuffix;
35119             break;
35120           case "^":
35121             value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2);
35122             break;
35123           default:
35124             value = padding + valuePrefix + value + valueSuffix;
35125             break;
35126         }
35127         return numerals(value);
35128       }
35129       format2.toString = function() {
35130         return specifier + "";
35131       };
35132       return format2;
35133     }
35134     function formatPrefix2(specifier, value) {
35135       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];
35136       return function(value2) {
35137         return f2(k2 * value2) + prefix;
35138       };
35139     }
35140     return {
35141       format: newFormat,
35142       formatPrefix: formatPrefix2
35143     };
35144   }
35145
35146   // node_modules/d3-format/src/defaultLocale.js
35147   var locale;
35148   var format;
35149   var formatPrefix;
35150   defaultLocale({
35151     thousands: ",",
35152     grouping: [3],
35153     currency: ["$", ""]
35154   });
35155   function defaultLocale(definition) {
35156     locale = locale_default(definition);
35157     format = locale.format;
35158     formatPrefix = locale.formatPrefix;
35159     return locale;
35160   }
35161
35162   // node_modules/d3-format/src/precisionFixed.js
35163   function precisionFixed_default(step) {
35164     return Math.max(0, -exponent_default(Math.abs(step)));
35165   }
35166
35167   // node_modules/d3-format/src/precisionPrefix.js
35168   function precisionPrefix_default(step, value) {
35169     return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
35170   }
35171
35172   // node_modules/d3-format/src/precisionRound.js
35173   function precisionRound_default(step, max3) {
35174     step = Math.abs(step), max3 = Math.abs(max3) - step;
35175     return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
35176   }
35177
35178   // node_modules/d3-scale/src/tickFormat.js
35179   function tickFormat(start2, stop, count, specifier) {
35180     var step = tickStep(start2, stop, count), precision3;
35181     specifier = formatSpecifier(specifier == null ? ",f" : specifier);
35182     switch (specifier.type) {
35183       case "s": {
35184         var value = Math.max(Math.abs(start2), Math.abs(stop));
35185         if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value))) specifier.precision = precision3;
35186         return formatPrefix(specifier, value);
35187       }
35188       case "":
35189       case "e":
35190       case "g":
35191       case "p":
35192       case "r": {
35193         if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop))))) specifier.precision = precision3 - (specifier.type === "e");
35194         break;
35195       }
35196       case "f":
35197       case "%": {
35198         if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step))) specifier.precision = precision3 - (specifier.type === "%") * 2;
35199         break;
35200       }
35201     }
35202     return format(specifier);
35203   }
35204
35205   // node_modules/d3-scale/src/linear.js
35206   function linearish(scale) {
35207     var domain = scale.domain;
35208     scale.ticks = function(count) {
35209       var d2 = domain();
35210       return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count);
35211     };
35212     scale.tickFormat = function(count, specifier) {
35213       var d2 = domain();
35214       return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier);
35215     };
35216     scale.nice = function(count) {
35217       if (count == null) count = 10;
35218       var d2 = domain();
35219       var i0 = 0;
35220       var i1 = d2.length - 1;
35221       var start2 = d2[i0];
35222       var stop = d2[i1];
35223       var prestep;
35224       var step;
35225       var maxIter = 10;
35226       if (stop < start2) {
35227         step = start2, start2 = stop, stop = step;
35228         step = i0, i0 = i1, i1 = step;
35229       }
35230       while (maxIter-- > 0) {
35231         step = tickIncrement(start2, stop, count);
35232         if (step === prestep) {
35233           d2[i0] = start2;
35234           d2[i1] = stop;
35235           return domain(d2);
35236         } else if (step > 0) {
35237           start2 = Math.floor(start2 / step) * step;
35238           stop = Math.ceil(stop / step) * step;
35239         } else if (step < 0) {
35240           start2 = Math.ceil(start2 * step) / step;
35241           stop = Math.floor(stop * step) / step;
35242         } else {
35243           break;
35244         }
35245         prestep = step;
35246       }
35247       return scale;
35248     };
35249     return scale;
35250   }
35251   function linear3() {
35252     var scale = continuous();
35253     scale.copy = function() {
35254       return copy(scale, linear3());
35255     };
35256     initRange.apply(scale, arguments);
35257     return linearish(scale);
35258   }
35259
35260   // node_modules/d3-scale/src/quantize.js
35261   function quantize() {
35262     var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown;
35263     function scale(x2) {
35264       return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown;
35265     }
35266     function rescale() {
35267       var i3 = -1;
35268       domain = new Array(n3);
35269       while (++i3 < n3) domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1);
35270       return scale;
35271     }
35272     scale.domain = function(_2) {
35273       return arguments.length ? ([x05, x12] = _2, x05 = +x05, x12 = +x12, rescale()) : [x05, x12];
35274     };
35275     scale.range = function(_2) {
35276       return arguments.length ? (n3 = (range3 = Array.from(_2)).length - 1, rescale()) : range3.slice();
35277     };
35278     scale.invertExtent = function(y2) {
35279       var i3 = range3.indexOf(y2);
35280       return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]];
35281     };
35282     scale.unknown = function(_2) {
35283       return arguments.length ? (unknown = _2, scale) : scale;
35284     };
35285     scale.thresholds = function() {
35286       return domain.slice();
35287     };
35288     scale.copy = function() {
35289       return quantize().domain([x05, x12]).range(range3).unknown(unknown);
35290     };
35291     return initRange.apply(linearish(scale), arguments);
35292   }
35293
35294   // modules/behavior/breathe.js
35295   function behaviorBreathe() {
35296     var duration = 800;
35297     var steps = 4;
35298     var selector = ".selected.shadow, .selected .shadow";
35299     var _selected = select_default2(null);
35300     var _classed = "";
35301     var _params = {};
35302     var _done = false;
35303     var _timer;
35304     function ratchetyInterpolator(a2, b2, steps2, units) {
35305       a2 = Number(a2);
35306       b2 = Number(b2);
35307       var sample = quantize().domain([0, 1]).range(quantize_default(number_default(a2, b2), steps2));
35308       return function(t2) {
35309         return String(sample(t2)) + (units || "");
35310       };
35311     }
35312     function reset(selection2) {
35313       selection2.style("stroke-opacity", null).style("stroke-width", null).style("fill-opacity", null).style("r", null);
35314     }
35315     function setAnimationParams(transition2, fromTo) {
35316       var toFrom = fromTo === "from" ? "to" : "from";
35317       transition2.styleTween("stroke-opacity", function(d2) {
35318         return ratchetyInterpolator(
35319           _params[d2.id][toFrom].opacity,
35320           _params[d2.id][fromTo].opacity,
35321           steps
35322         );
35323       }).styleTween("stroke-width", function(d2) {
35324         return ratchetyInterpolator(
35325           _params[d2.id][toFrom].width,
35326           _params[d2.id][fromTo].width,
35327           steps,
35328           "px"
35329         );
35330       }).styleTween("fill-opacity", function(d2) {
35331         return ratchetyInterpolator(
35332           _params[d2.id][toFrom].opacity,
35333           _params[d2.id][fromTo].opacity,
35334           steps
35335         );
35336       }).styleTween("r", function(d2) {
35337         return ratchetyInterpolator(
35338           _params[d2.id][toFrom].width,
35339           _params[d2.id][fromTo].width,
35340           steps,
35341           "px"
35342         );
35343       });
35344     }
35345     function calcAnimationParams(selection2) {
35346       selection2.call(reset).each(function(d2) {
35347         var s2 = select_default2(this);
35348         var tag2 = s2.node().tagName;
35349         var p2 = { "from": {}, "to": {} };
35350         var opacity;
35351         var width;
35352         if (tag2 === "circle") {
35353           opacity = Number(s2.style("fill-opacity") || 0.5);
35354           width = Number(s2.style("r") || 15.5);
35355         } else {
35356           opacity = Number(s2.style("stroke-opacity") || 0.7);
35357           width = Number(s2.style("stroke-width") || 10);
35358         }
35359         p2.tag = tag2;
35360         p2.from.opacity = opacity * 0.6;
35361         p2.to.opacity = opacity * 1.25;
35362         p2.from.width = width * 0.7;
35363         p2.to.width = width * (tag2 === "circle" ? 1.5 : 1);
35364         _params[d2.id] = p2;
35365       });
35366     }
35367     function run(surface, fromTo) {
35368       var toFrom = fromTo === "from" ? "to" : "from";
35369       var currSelected = surface.selectAll(selector);
35370       var currClassed = surface.attr("class");
35371       if (_done || currSelected.empty()) {
35372         _selected.call(reset);
35373         _selected = select_default2(null);
35374         return;
35375       }
35376       if (!(0, import_fast_deep_equal2.default)(currSelected.data(), _selected.data()) || currClassed !== _classed) {
35377         _selected.call(reset);
35378         _classed = currClassed;
35379         _selected = currSelected.call(calcAnimationParams);
35380       }
35381       var didCallNextRun = false;
35382       _selected.transition().duration(duration).call(setAnimationParams, fromTo).on("end", function() {
35383         if (!didCallNextRun) {
35384           surface.call(run, toFrom);
35385           didCallNextRun = true;
35386         }
35387         if (!select_default2(this).classed("selected")) {
35388           reset(select_default2(this));
35389         }
35390       });
35391     }
35392     function behavior(surface) {
35393       _done = false;
35394       _timer = timer(function() {
35395         if (surface.selectAll(selector).empty()) {
35396           return false;
35397         }
35398         surface.call(run, "from");
35399         _timer.stop();
35400         return true;
35401       }, 20);
35402     }
35403     behavior.restartIfNeeded = function(surface) {
35404       if (_selected.empty()) {
35405         surface.call(run, "from");
35406         if (_timer) {
35407           _timer.stop();
35408         }
35409       }
35410     };
35411     behavior.off = function() {
35412       _done = true;
35413       if (_timer) {
35414         _timer.stop();
35415       }
35416       _selected.interrupt().call(reset);
35417     };
35418     return behavior;
35419   }
35420
35421   // modules/behavior/operation.js
35422   function behaviorOperation(context) {
35423     var _operation;
35424     function keypress(d3_event) {
35425       if (!context.map().withinEditableZoom()) return;
35426       if (_operation.availableForKeypress && !_operation.availableForKeypress()) return;
35427       d3_event.preventDefault();
35428       var disabled = _operation.disabled();
35429       if (disabled) {
35430         context.ui().flash.duration(4e3).iconName("#iD-operation-" + _operation.id).iconClass("operation disabled").label(_operation.tooltip())();
35431       } else {
35432         context.ui().flash.duration(2e3).iconName("#iD-operation-" + _operation.id).iconClass("operation").label(_operation.annotation() || _operation.title)();
35433         if (_operation.point) _operation.point(null);
35434         _operation(d3_event);
35435       }
35436     }
35437     function behavior() {
35438       if (_operation && _operation.available()) {
35439         context.keybinding().on(_operation.keys, keypress);
35440       }
35441       return behavior;
35442     }
35443     behavior.off = function() {
35444       context.keybinding().off(_operation.keys);
35445     };
35446     behavior.which = function(_2) {
35447       if (!arguments.length) return _operation;
35448       _operation = _2;
35449       return behavior;
35450     };
35451     return behavior;
35452   }
35453
35454   // modules/operations/circularize.js
35455   function operationCircularize(context, selectedIDs) {
35456     var _extent;
35457     var _actions = selectedIDs.map(getAction).filter(Boolean);
35458     var _amount = _actions.length === 1 ? "single" : "multiple";
35459     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
35460       return n3.loc;
35461     });
35462     function getAction(entityID) {
35463       var entity = context.entity(entityID);
35464       if (entity.type !== "way" || new Set(entity.nodes).size <= 1) return null;
35465       if (!_extent) {
35466         _extent = entity.extent(context.graph());
35467       } else {
35468         _extent = _extent.extend(entity.extent(context.graph()));
35469       }
35470       return actionCircularize(entityID, context.projection);
35471     }
35472     var operation2 = function() {
35473       if (!_actions.length) return;
35474       var combinedAction = function(graph, t2) {
35475         _actions.forEach(function(action) {
35476           if (!action.disabled(graph)) {
35477             graph = action(graph, t2);
35478           }
35479         });
35480         return graph;
35481       };
35482       combinedAction.transitionable = true;
35483       context.perform(combinedAction, operation2.annotation());
35484       window.setTimeout(function() {
35485         context.validator().validate();
35486       }, 300);
35487     };
35488     operation2.available = function() {
35489       return _actions.length && selectedIDs.length === _actions.length;
35490     };
35491     operation2.disabled = function() {
35492       if (!_actions.length) return "";
35493       var actionDisableds = _actions.map(function(action) {
35494         return action.disabled(context.graph());
35495       }).filter(Boolean);
35496       if (actionDisableds.length === _actions.length) {
35497         if (new Set(actionDisableds).size > 1) {
35498           return "multiple_blockers";
35499         }
35500         return actionDisableds[0];
35501       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
35502         return "too_large";
35503       } else if (someMissing()) {
35504         return "not_downloaded";
35505       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35506         return "connected_to_hidden";
35507       }
35508       return false;
35509       function someMissing() {
35510         if (context.inIntro()) return false;
35511         var osm = context.connection();
35512         if (osm) {
35513           var missing = _coords.filter(function(loc) {
35514             return !osm.isDataLoaded(loc);
35515           });
35516           if (missing.length) {
35517             missing.forEach(function(loc) {
35518               context.loadTileAtLoc(loc);
35519             });
35520             return true;
35521           }
35522         }
35523         return false;
35524       }
35525     };
35526     operation2.tooltip = function() {
35527       var disable = operation2.disabled();
35528       return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount);
35529     };
35530     operation2.annotation = function() {
35531       return _t("operations.circularize.annotation.feature", { n: _actions.length });
35532     };
35533     operation2.id = "circularize";
35534     operation2.keys = [_t("operations.circularize.key")];
35535     operation2.title = _t.append("operations.circularize.title");
35536     operation2.behavior = behaviorOperation(context).which(operation2);
35537     return operation2;
35538   }
35539
35540   // modules/ui/cmd.js
35541   var uiCmd = function(code) {
35542     var detected = utilDetect();
35543     if (detected.os === "mac") {
35544       return code;
35545     }
35546     if (detected.os === "win") {
35547       if (code === "\u2318\u21E7Z") return "Ctrl+Y";
35548     }
35549     var result = "", replacements = {
35550       "\u2318": "Ctrl",
35551       "\u21E7": "Shift",
35552       "\u2325": "Alt",
35553       "\u232B": "Backspace",
35554       "\u2326": "Delete"
35555     };
35556     for (var i3 = 0; i3 < code.length; i3++) {
35557       if (code[i3] in replacements) {
35558         result += replacements[code[i3]] + (i3 < code.length - 1 ? "+" : "");
35559       } else {
35560         result += code[i3];
35561       }
35562     }
35563     return result;
35564   };
35565   uiCmd.display = function(code) {
35566     if (code.length !== 1) return code;
35567     var detected = utilDetect();
35568     var mac = detected.os === "mac";
35569     var replacements = {
35570       "\u2318": mac ? "\u2318 " + _t("shortcuts.key.cmd") : _t("shortcuts.key.ctrl"),
35571       "\u21E7": mac ? "\u21E7 " + _t("shortcuts.key.shift") : _t("shortcuts.key.shift"),
35572       "\u2325": mac ? "\u2325 " + _t("shortcuts.key.option") : _t("shortcuts.key.alt"),
35573       "\u2303": mac ? "\u2303 " + _t("shortcuts.key.ctrl") : _t("shortcuts.key.ctrl"),
35574       "\u232B": mac ? "\u232B " + _t("shortcuts.key.delete") : _t("shortcuts.key.backspace"),
35575       "\u2326": mac ? "\u2326 " + _t("shortcuts.key.del") : _t("shortcuts.key.del"),
35576       "\u2196": mac ? "\u2196 " + _t("shortcuts.key.pgup") : _t("shortcuts.key.pgup"),
35577       "\u2198": mac ? "\u2198 " + _t("shortcuts.key.pgdn") : _t("shortcuts.key.pgdn"),
35578       "\u21DE": mac ? "\u21DE " + _t("shortcuts.key.home") : _t("shortcuts.key.home"),
35579       "\u21DF": mac ? "\u21DF " + _t("shortcuts.key.end") : _t("shortcuts.key.end"),
35580       "\u21B5": mac ? "\u23CE " + _t("shortcuts.key.return") : _t("shortcuts.key.enter"),
35581       "\u238B": mac ? "\u238B " + _t("shortcuts.key.esc") : _t("shortcuts.key.esc"),
35582       "\u2630": mac ? "\u2630 " + _t("shortcuts.key.menu") : _t("shortcuts.key.menu")
35583     };
35584     return replacements[code] || code;
35585   };
35586
35587   // modules/operations/delete.js
35588   function operationDelete(context, selectedIDs) {
35589     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35590     var action = actionDeleteMultiple(selectedIDs);
35591     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35592     var coords = nodes.map(function(n3) {
35593       return n3.loc;
35594     });
35595     var extent = utilTotalExtent(selectedIDs, context.graph());
35596     var operation2 = function() {
35597       var nextSelectedID;
35598       var nextSelectedLoc;
35599       if (selectedIDs.length === 1) {
35600         var id2 = selectedIDs[0];
35601         var entity = context.entity(id2);
35602         var geometry = entity.geometry(context.graph());
35603         var parents = context.graph().parentWays(entity);
35604         var parent = parents[0];
35605         if (geometry === "vertex") {
35606           var nodes2 = parent.nodes;
35607           var i3 = nodes2.indexOf(id2);
35608           if (i3 === 0) {
35609             i3++;
35610           } else if (i3 === nodes2.length - 1) {
35611             i3--;
35612           } else {
35613             var a2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 - 1]).loc);
35614             var b2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 + 1]).loc);
35615             i3 = a2 < b2 ? i3 - 1 : i3 + 1;
35616           }
35617           nextSelectedID = nodes2[i3];
35618           nextSelectedLoc = context.entity(nextSelectedID).loc;
35619         }
35620       }
35621       context.perform(action, operation2.annotation());
35622       context.validator().validate();
35623       if (nextSelectedID && nextSelectedLoc) {
35624         if (context.hasEntity(nextSelectedID)) {
35625           context.enter(modeSelect(context, [nextSelectedID]).follow(true));
35626         } else {
35627           context.map().centerEase(nextSelectedLoc);
35628           context.enter(modeBrowse(context));
35629         }
35630       } else {
35631         context.enter(modeBrowse(context));
35632       }
35633     };
35634     operation2.available = function() {
35635       return true;
35636     };
35637     operation2.disabled = function() {
35638       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35639         return "too_large";
35640       } else if (someMissing()) {
35641         return "not_downloaded";
35642       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35643         return "connected_to_hidden";
35644       } else if (selectedIDs.some(protectedMember)) {
35645         return "part_of_relation";
35646       } else if (selectedIDs.some(incompleteRelation)) {
35647         return "incomplete_relation";
35648       } else if (selectedIDs.some(hasWikidataTag)) {
35649         return "has_wikidata_tag";
35650       }
35651       return false;
35652       function someMissing() {
35653         if (context.inIntro()) return false;
35654         var osm = context.connection();
35655         if (osm) {
35656           var missing = coords.filter(function(loc) {
35657             return !osm.isDataLoaded(loc);
35658           });
35659           if (missing.length) {
35660             missing.forEach(function(loc) {
35661               context.loadTileAtLoc(loc);
35662             });
35663             return true;
35664           }
35665         }
35666         return false;
35667       }
35668       function hasWikidataTag(id2) {
35669         var entity = context.entity(id2);
35670         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
35671       }
35672       function incompleteRelation(id2) {
35673         var entity = context.entity(id2);
35674         return entity.type === "relation" && !entity.isComplete(context.graph());
35675       }
35676       function protectedMember(id2) {
35677         var entity = context.entity(id2);
35678         if (entity.type !== "way") return false;
35679         var parents = context.graph().parentRelations(entity);
35680         for (var i3 = 0; i3 < parents.length; i3++) {
35681           var parent = parents[i3];
35682           var type2 = parent.tags.type;
35683           var role = parent.memberById(id2).role || "outer";
35684           if (type2 === "route" || type2 === "boundary" || type2 === "multipolygon" && role === "outer") {
35685             return true;
35686           }
35687         }
35688         return false;
35689       }
35690     };
35691     operation2.tooltip = function() {
35692       var disable = operation2.disabled();
35693       return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi);
35694     };
35695     operation2.annotation = function() {
35696       return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length });
35697     };
35698     operation2.id = "delete";
35699     operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")];
35700     operation2.title = _t.append("operations.delete.title");
35701     operation2.behavior = behaviorOperation(context).which(operation2);
35702     return operation2;
35703   }
35704
35705   // modules/operations/orthogonalize.js
35706   function operationOrthogonalize(context, selectedIDs) {
35707     var _extent;
35708     var _type;
35709     var _actions = selectedIDs.map(chooseAction).filter(Boolean);
35710     var _amount = _actions.length === 1 ? "single" : "multiple";
35711     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
35712       return n3.loc;
35713     });
35714     function chooseAction(entityID) {
35715       var entity = context.entity(entityID);
35716       var geometry = entity.geometry(context.graph());
35717       if (!_extent) {
35718         _extent = entity.extent(context.graph());
35719       } else {
35720         _extent = _extent.extend(entity.extent(context.graph()));
35721       }
35722       if (entity.type === "way" && new Set(entity.nodes).size > 2) {
35723         if (_type && _type !== "feature") return null;
35724         _type = "feature";
35725         return actionOrthogonalize(entityID, context.projection);
35726       } else if (geometry === "vertex") {
35727         if (_type && _type !== "corner") return null;
35728         _type = "corner";
35729         var graph = context.graph();
35730         var parents = graph.parentWays(entity);
35731         if (parents.length === 1) {
35732           var way = parents[0];
35733           if (way.nodes.indexOf(entityID) !== -1) {
35734             return actionOrthogonalize(way.id, context.projection, entityID);
35735           }
35736         }
35737       }
35738       return null;
35739     }
35740     var operation2 = function() {
35741       if (!_actions.length) return;
35742       var combinedAction = function(graph, t2) {
35743         _actions.forEach(function(action) {
35744           if (!action.disabled(graph)) {
35745             graph = action(graph, t2);
35746           }
35747         });
35748         return graph;
35749       };
35750       combinedAction.transitionable = true;
35751       context.perform(combinedAction, operation2.annotation());
35752       window.setTimeout(function() {
35753         context.validator().validate();
35754       }, 300);
35755     };
35756     operation2.available = function() {
35757       return _actions.length && selectedIDs.length === _actions.length;
35758     };
35759     operation2.disabled = function() {
35760       if (!_actions.length) return "";
35761       var actionDisableds = _actions.map(function(action) {
35762         return action.disabled(context.graph());
35763       }).filter(Boolean);
35764       if (actionDisableds.length === _actions.length) {
35765         if (new Set(actionDisableds).size > 1) {
35766           return "multiple_blockers";
35767         }
35768         return actionDisableds[0];
35769       } else if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
35770         return "too_large";
35771       } else if (someMissing()) {
35772         return "not_downloaded";
35773       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35774         return "connected_to_hidden";
35775       }
35776       return false;
35777       function someMissing() {
35778         if (context.inIntro()) return false;
35779         var osm = context.connection();
35780         if (osm) {
35781           var missing = _coords.filter(function(loc) {
35782             return !osm.isDataLoaded(loc);
35783           });
35784           if (missing.length) {
35785             missing.forEach(function(loc) {
35786               context.loadTileAtLoc(loc);
35787             });
35788             return true;
35789           }
35790         }
35791         return false;
35792       }
35793     };
35794     operation2.tooltip = function() {
35795       var disable = operation2.disabled();
35796       return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount);
35797     };
35798     operation2.annotation = function() {
35799       return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length });
35800     };
35801     operation2.id = "orthogonalize";
35802     operation2.keys = [_t("operations.orthogonalize.key")];
35803     operation2.title = _t.append("operations.orthogonalize.title");
35804     operation2.behavior = behaviorOperation(context).which(operation2);
35805     return operation2;
35806   }
35807
35808   // modules/operations/reflect.js
35809   function operationReflectShort(context, selectedIDs) {
35810     return operationReflect(context, selectedIDs, "short");
35811   }
35812   function operationReflectLong(context, selectedIDs) {
35813     return operationReflect(context, selectedIDs, "long");
35814   }
35815   function operationReflect(context, selectedIDs, axis) {
35816     axis = axis || "long";
35817     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35818     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35819     var coords = nodes.map(function(n3) {
35820       return n3.loc;
35821     });
35822     var extent = utilTotalExtent(selectedIDs, context.graph());
35823     var operation2 = function() {
35824       var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long"));
35825       context.perform(action, operation2.annotation());
35826       window.setTimeout(function() {
35827         context.validator().validate();
35828       }, 300);
35829     };
35830     operation2.available = function() {
35831       return nodes.length >= 3;
35832     };
35833     operation2.disabled = function() {
35834       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35835         return "too_large";
35836       } else if (someMissing()) {
35837         return "not_downloaded";
35838       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35839         return "connected_to_hidden";
35840       } else if (selectedIDs.some(incompleteRelation)) {
35841         return "incomplete_relation";
35842       }
35843       return false;
35844       function someMissing() {
35845         if (context.inIntro()) return false;
35846         var osm = context.connection();
35847         if (osm) {
35848           var missing = coords.filter(function(loc) {
35849             return !osm.isDataLoaded(loc);
35850           });
35851           if (missing.length) {
35852             missing.forEach(function(loc) {
35853               context.loadTileAtLoc(loc);
35854             });
35855             return true;
35856           }
35857         }
35858         return false;
35859       }
35860       function incompleteRelation(id2) {
35861         var entity = context.entity(id2);
35862         return entity.type === "relation" && !entity.isComplete(context.graph());
35863       }
35864     };
35865     operation2.tooltip = function() {
35866       var disable = operation2.disabled();
35867       return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi);
35868     };
35869     operation2.annotation = function() {
35870       return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length });
35871     };
35872     operation2.id = "reflect-" + axis;
35873     operation2.keys = [_t("operations.reflect.key." + axis)];
35874     operation2.title = _t.append("operations.reflect.title." + axis);
35875     operation2.behavior = behaviorOperation(context).which(operation2);
35876     return operation2;
35877   }
35878
35879   // modules/operations/move.js
35880   function operationMove(context, selectedIDs) {
35881     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35882     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35883     var coords = nodes.map(function(n3) {
35884       return n3.loc;
35885     });
35886     var extent = utilTotalExtent(selectedIDs, context.graph());
35887     var operation2 = function() {
35888       context.enter(modeMove(context, selectedIDs));
35889     };
35890     operation2.available = function() {
35891       return selectedIDs.length > 0;
35892     };
35893     operation2.disabled = function() {
35894       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35895         return "too_large";
35896       } else if (someMissing()) {
35897         return "not_downloaded";
35898       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35899         return "connected_to_hidden";
35900       } else if (selectedIDs.some(incompleteRelation)) {
35901         return "incomplete_relation";
35902       }
35903       return false;
35904       function someMissing() {
35905         if (context.inIntro()) return false;
35906         var osm = context.connection();
35907         if (osm) {
35908           var missing = coords.filter(function(loc) {
35909             return !osm.isDataLoaded(loc);
35910           });
35911           if (missing.length) {
35912             missing.forEach(function(loc) {
35913               context.loadTileAtLoc(loc);
35914             });
35915             return true;
35916           }
35917         }
35918         return false;
35919       }
35920       function incompleteRelation(id2) {
35921         var entity = context.entity(id2);
35922         return entity.type === "relation" && !entity.isComplete(context.graph());
35923       }
35924     };
35925     operation2.tooltip = function() {
35926       var disable = operation2.disabled();
35927       return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi);
35928     };
35929     operation2.annotation = function() {
35930       return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length });
35931     };
35932     operation2.id = "move";
35933     operation2.keys = [_t("operations.move.key")];
35934     operation2.title = _t.append("operations.move.title");
35935     operation2.behavior = behaviorOperation(context).which(operation2);
35936     operation2.mouseOnly = true;
35937     return operation2;
35938   }
35939
35940   // modules/modes/rotate.js
35941   function modeRotate(context, entityIDs) {
35942     var _tolerancePx = 4;
35943     var mode = {
35944       id: "rotate",
35945       button: "browse"
35946     };
35947     var keybinding = utilKeybinding("rotate");
35948     var behaviors = [
35949       behaviorEdit(context),
35950       operationCircularize(context, entityIDs).behavior,
35951       operationDelete(context, entityIDs).behavior,
35952       operationMove(context, entityIDs).behavior,
35953       operationOrthogonalize(context, entityIDs).behavior,
35954       operationReflectLong(context, entityIDs).behavior,
35955       operationReflectShort(context, entityIDs).behavior
35956     ];
35957     var annotation = entityIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.rotate.annotation.feature", { n: entityIDs.length });
35958     var _prevGraph;
35959     var _prevAngle;
35960     var _prevTransform;
35961     var _pivot;
35962     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
35963     function doRotate(d3_event) {
35964       var fn;
35965       if (context.graph() !== _prevGraph) {
35966         fn = context.perform;
35967       } else {
35968         fn = context.replace;
35969       }
35970       var projection2 = context.projection;
35971       var currTransform = projection2.transform();
35972       if (!_prevTransform || currTransform.k !== _prevTransform.k || currTransform.x !== _prevTransform.x || currTransform.y !== _prevTransform.y) {
35973         var nodes = utilGetAllNodes(entityIDs, context.graph());
35974         var points = nodes.map(function(n3) {
35975           return projection2(n3.loc);
35976         });
35977         _pivot = getPivot(points);
35978         _prevAngle = void 0;
35979       }
35980       var currMouse = context.map().mouse(d3_event);
35981       var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
35982       if (typeof _prevAngle === "undefined") _prevAngle = currAngle;
35983       var delta = currAngle - _prevAngle;
35984       fn(actionRotate(entityIDs, _pivot, delta, projection2));
35985       _prevTransform = currTransform;
35986       _prevAngle = currAngle;
35987       _prevGraph = context.graph();
35988     }
35989     function getPivot(points) {
35990       var _pivot2;
35991       if (points.length === 1) {
35992         _pivot2 = points[0];
35993       } else if (points.length === 2) {
35994         _pivot2 = geoVecInterp(points[0], points[1], 0.5);
35995       } else {
35996         var polygonHull = hull_default(points);
35997         if (polygonHull.length === 2) {
35998           _pivot2 = geoVecInterp(points[0], points[1], 0.5);
35999         } else {
36000           _pivot2 = centroid_default2(hull_default(points));
36001         }
36002       }
36003       return _pivot2;
36004     }
36005     function finish(d3_event) {
36006       d3_event.stopPropagation();
36007       context.replace(actionNoop(), annotation);
36008       context.enter(modeSelect(context, entityIDs));
36009     }
36010     function cancel() {
36011       if (_prevGraph) context.pop();
36012       context.enter(modeSelect(context, entityIDs));
36013     }
36014     function undone() {
36015       context.enter(modeBrowse(context));
36016     }
36017     mode.enter = function() {
36018       _prevGraph = null;
36019       context.features().forceVisible(entityIDs);
36020       behaviors.forEach(context.install);
36021       var downEvent;
36022       context.surface().on(_pointerPrefix + "down.modeRotate", function(d3_event) {
36023         downEvent = d3_event;
36024       });
36025       select_default2(window).on(_pointerPrefix + "move.modeRotate", doRotate, true).on(_pointerPrefix + "up.modeRotate", function(d3_event) {
36026         if (!downEvent) return;
36027         var mapNode = context.container().select(".main-map").node();
36028         var pointGetter = utilFastMouse(mapNode);
36029         var p1 = pointGetter(downEvent);
36030         var p2 = pointGetter(d3_event);
36031         var dist = geoVecLength(p1, p2);
36032         if (dist <= _tolerancePx) finish(d3_event);
36033         downEvent = null;
36034       }, true);
36035       context.history().on("undone.modeRotate", undone);
36036       keybinding.on("\u238B", cancel).on("\u21A9", finish);
36037       select_default2(document).call(keybinding);
36038     };
36039     mode.exit = function() {
36040       behaviors.forEach(context.uninstall);
36041       context.surface().on(_pointerPrefix + "down.modeRotate", null);
36042       select_default2(window).on(_pointerPrefix + "move.modeRotate", null, true).on(_pointerPrefix + "up.modeRotate", null, true);
36043       context.history().on("undone.modeRotate", null);
36044       select_default2(document).call(keybinding.unbind);
36045       context.features().forceVisible([]);
36046     };
36047     mode.selectedIDs = function() {
36048       if (!arguments.length) return entityIDs;
36049       return mode;
36050     };
36051     return mode;
36052   }
36053
36054   // modules/operations/rotate.js
36055   function operationRotate(context, selectedIDs) {
36056     var multi = selectedIDs.length === 1 ? "single" : "multiple";
36057     var nodes = utilGetAllNodes(selectedIDs, context.graph());
36058     var coords = nodes.map(function(n3) {
36059       return n3.loc;
36060     });
36061     var extent = utilTotalExtent(selectedIDs, context.graph());
36062     var operation2 = function() {
36063       context.enter(modeRotate(context, selectedIDs));
36064     };
36065     operation2.available = function() {
36066       return nodes.length >= 2;
36067     };
36068     operation2.disabled = function() {
36069       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
36070         return "too_large";
36071       } else if (someMissing()) {
36072         return "not_downloaded";
36073       } else if (selectedIDs.some(context.hasHiddenConnections)) {
36074         return "connected_to_hidden";
36075       } else if (selectedIDs.some(incompleteRelation)) {
36076         return "incomplete_relation";
36077       }
36078       return false;
36079       function someMissing() {
36080         if (context.inIntro()) return false;
36081         var osm = context.connection();
36082         if (osm) {
36083           var missing = coords.filter(function(loc) {
36084             return !osm.isDataLoaded(loc);
36085           });
36086           if (missing.length) {
36087             missing.forEach(function(loc) {
36088               context.loadTileAtLoc(loc);
36089             });
36090             return true;
36091           }
36092         }
36093         return false;
36094       }
36095       function incompleteRelation(id2) {
36096         var entity = context.entity(id2);
36097         return entity.type === "relation" && !entity.isComplete(context.graph());
36098       }
36099     };
36100     operation2.tooltip = function() {
36101       var disable = operation2.disabled();
36102       return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi);
36103     };
36104     operation2.annotation = function() {
36105       return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length });
36106     };
36107     operation2.id = "rotate";
36108     operation2.keys = [_t("operations.rotate.key")];
36109     operation2.title = _t.append("operations.rotate.title");
36110     operation2.behavior = behaviorOperation(context).which(operation2);
36111     operation2.mouseOnly = true;
36112     return operation2;
36113   }
36114
36115   // modules/modes/move.js
36116   function modeMove(context, entityIDs, baseGraph) {
36117     var _tolerancePx = 4;
36118     var mode = {
36119       id: "move",
36120       button: "browse"
36121     };
36122     var keybinding = utilKeybinding("move");
36123     var behaviors = [
36124       behaviorEdit(context),
36125       operationCircularize(context, entityIDs).behavior,
36126       operationDelete(context, entityIDs).behavior,
36127       operationOrthogonalize(context, entityIDs).behavior,
36128       operationReflectLong(context, entityIDs).behavior,
36129       operationReflectShort(context, entityIDs).behavior,
36130       operationRotate(context, entityIDs).behavior
36131     ];
36132     var annotation = entityIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.move.annotation.feature", { n: entityIDs.length });
36133     var _prevGraph;
36134     var _cache5;
36135     var _origin;
36136     var _nudgeInterval;
36137     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36138     function doMove(nudge) {
36139       nudge = nudge || [0, 0];
36140       var fn;
36141       if (_prevGraph !== context.graph()) {
36142         _cache5 = {};
36143         _origin = context.map().mouseCoordinates();
36144         fn = context.perform;
36145       } else {
36146         fn = context.overwrite;
36147       }
36148       var currMouse = context.map().mouse();
36149       var origMouse = context.projection(_origin);
36150       var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
36151       fn(actionMove(entityIDs, delta, context.projection, _cache5));
36152       _prevGraph = context.graph();
36153     }
36154     function startNudge(nudge) {
36155       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
36156       _nudgeInterval = window.setInterval(function() {
36157         context.map().pan(nudge);
36158         doMove(nudge);
36159       }, 50);
36160     }
36161     function stopNudge() {
36162       if (_nudgeInterval) {
36163         window.clearInterval(_nudgeInterval);
36164         _nudgeInterval = null;
36165       }
36166     }
36167     function move() {
36168       doMove();
36169       var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
36170       if (nudge) {
36171         startNudge(nudge);
36172       } else {
36173         stopNudge();
36174       }
36175     }
36176     function finish(d3_event) {
36177       d3_event.stopPropagation();
36178       context.replace(actionNoop(), annotation);
36179       context.enter(modeSelect(context, entityIDs));
36180       stopNudge();
36181     }
36182     function cancel() {
36183       if (baseGraph) {
36184         while (context.graph() !== baseGraph) context.pop();
36185         context.enter(modeBrowse(context));
36186       } else {
36187         if (_prevGraph) context.pop();
36188         context.enter(modeSelect(context, entityIDs));
36189       }
36190       stopNudge();
36191     }
36192     function undone() {
36193       context.enter(modeBrowse(context));
36194     }
36195     mode.enter = function() {
36196       _origin = context.map().mouseCoordinates();
36197       _prevGraph = null;
36198       _cache5 = {};
36199       context.features().forceVisible(entityIDs);
36200       behaviors.forEach(context.install);
36201       var downEvent;
36202       context.surface().on(_pointerPrefix + "down.modeMove", function(d3_event) {
36203         downEvent = d3_event;
36204       });
36205       select_default2(window).on(_pointerPrefix + "move.modeMove", move, true).on(_pointerPrefix + "up.modeMove", function(d3_event) {
36206         if (!downEvent) return;
36207         var mapNode = context.container().select(".main-map").node();
36208         var pointGetter = utilFastMouse(mapNode);
36209         var p1 = pointGetter(downEvent);
36210         var p2 = pointGetter(d3_event);
36211         var dist = geoVecLength(p1, p2);
36212         if (dist <= _tolerancePx) finish(d3_event);
36213         downEvent = null;
36214       }, true);
36215       context.history().on("undone.modeMove", undone);
36216       keybinding.on("\u238B", cancel).on("\u21A9", finish);
36217       select_default2(document).call(keybinding);
36218     };
36219     mode.exit = function() {
36220       stopNudge();
36221       behaviors.forEach(function(behavior) {
36222         context.uninstall(behavior);
36223       });
36224       context.surface().on(_pointerPrefix + "down.modeMove", null);
36225       select_default2(window).on(_pointerPrefix + "move.modeMove", null, true).on(_pointerPrefix + "up.modeMove", null, true);
36226       context.history().on("undone.modeMove", null);
36227       select_default2(document).call(keybinding.unbind);
36228       context.features().forceVisible([]);
36229     };
36230     mode.selectedIDs = function() {
36231       if (!arguments.length) return entityIDs;
36232       return mode;
36233     };
36234     return mode;
36235   }
36236
36237   // modules/behavior/paste.js
36238   function behaviorPaste(context) {
36239     function doPaste(d3_event) {
36240       if (!context.map().withinEditableZoom()) return;
36241       const isOsmLayerEnabled = context.layers().layer("osm").enabled();
36242       if (!isOsmLayerEnabled) return;
36243       d3_event.preventDefault();
36244       var baseGraph = context.graph();
36245       var mouse = context.map().mouse();
36246       var projection2 = context.projection;
36247       var viewport = geoExtent(projection2.clipExtent()).polygon();
36248       if (!geoPointInPolygon(mouse, viewport)) return;
36249       var oldIDs = context.copyIDs();
36250       if (!oldIDs.length) return;
36251       var extent = geoExtent();
36252       var oldGraph = context.copyGraph();
36253       var newIDs = [];
36254       var action = actionCopyEntities(oldIDs, oldGraph);
36255       context.perform(action);
36256       var copies = action.copies();
36257       var originals = /* @__PURE__ */ new Set();
36258       Object.values(copies).forEach(function(entity) {
36259         originals.add(entity.id);
36260       });
36261       for (var id2 in copies) {
36262         var oldEntity = oldGraph.entity(id2);
36263         var newEntity = copies[id2];
36264         extent._extend(oldEntity.extent(oldGraph));
36265         var parents = context.graph().parentWays(newEntity);
36266         var parentCopied = parents.some(function(parent) {
36267           return originals.has(parent.id);
36268         });
36269         if (!parentCopied) {
36270           newIDs.push(newEntity.id);
36271         }
36272       }
36273       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
36274       var delta = geoVecSubtract(mouse, copyPoint);
36275       context.perform(actionMove(newIDs, delta, projection2));
36276       context.enter(modeMove(context, newIDs, baseGraph));
36277     }
36278     function behavior() {
36279       context.keybinding().on(uiCmd("\u2318V"), doPaste);
36280       return behavior;
36281     }
36282     behavior.off = function() {
36283       context.keybinding().off(uiCmd("\u2318V"));
36284     };
36285     return behavior;
36286   }
36287
36288   // modules/behavior/drag.js
36289   function behaviorDrag() {
36290     var dispatch14 = dispatch_default("start", "move", "end");
36291     var _tolerancePx = 1;
36292     var _penTolerancePx = 4;
36293     var _origin = null;
36294     var _selector = "";
36295     var _targetNode;
36296     var _targetEntity;
36297     var _surface;
36298     var _pointerId;
36299     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36300     var d3_event_userSelectProperty = utilPrefixCSSProperty("UserSelect");
36301     var d3_event_userSelectSuppress = function() {
36302       var selection2 = selection_default();
36303       var select = selection2.style(d3_event_userSelectProperty);
36304       selection2.style(d3_event_userSelectProperty, "none");
36305       return function() {
36306         selection2.style(d3_event_userSelectProperty, select);
36307       };
36308     };
36309     function pointerdown(d3_event) {
36310       if (_pointerId) return;
36311       _pointerId = d3_event.pointerId || "mouse";
36312       _targetNode = this;
36313       var pointerLocGetter = utilFastMouse(_surface || _targetNode.parentNode);
36314       var offset;
36315       var startOrigin = pointerLocGetter(d3_event);
36316       var started = false;
36317       var selectEnable = d3_event_userSelectSuppress();
36318       select_default2(window).on(_pointerPrefix + "move.drag", pointermove).on(_pointerPrefix + "up.drag pointercancel.drag", pointerup, true);
36319       if (_origin) {
36320         offset = _origin.call(_targetNode, _targetEntity);
36321         offset = [offset[0] - startOrigin[0], offset[1] - startOrigin[1]];
36322       } else {
36323         offset = [0, 0];
36324       }
36325       d3_event.stopPropagation();
36326       function pointermove(d3_event2) {
36327         if (_pointerId !== (d3_event2.pointerId || "mouse")) return;
36328         var p2 = pointerLocGetter(d3_event2);
36329         if (!started) {
36330           var dist = geoVecLength(startOrigin, p2);
36331           var tolerance = d3_event2.pointerType === "pen" ? _penTolerancePx : _tolerancePx;
36332           if (dist < tolerance) return;
36333           started = true;
36334           dispatch14.call("start", this, d3_event2, _targetEntity);
36335         } else {
36336           startOrigin = p2;
36337           d3_event2.stopPropagation();
36338           d3_event2.preventDefault();
36339           var dx = p2[0] - startOrigin[0];
36340           var dy = p2[1] - startOrigin[1];
36341           dispatch14.call("move", this, d3_event2, _targetEntity, [p2[0] + offset[0], p2[1] + offset[1]], [dx, dy]);
36342         }
36343       }
36344       function pointerup(d3_event2) {
36345         if (_pointerId !== (d3_event2.pointerId || "mouse")) return;
36346         _pointerId = null;
36347         if (started) {
36348           dispatch14.call("end", this, d3_event2, _targetEntity);
36349           d3_event2.preventDefault();
36350         }
36351         select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
36352         selectEnable();
36353       }
36354     }
36355     function behavior(selection2) {
36356       var matchesSelector = utilPrefixDOMProperty("matchesSelector");
36357       var delegate = pointerdown;
36358       if (_selector) {
36359         delegate = function(d3_event) {
36360           var root3 = this;
36361           var target = d3_event.target;
36362           for (; target && target !== root3; target = target.parentNode) {
36363             var datum2 = target.__data__;
36364             _targetEntity = datum2 instanceof osmNote ? datum2 : datum2 && datum2.properties && datum2.properties.entity;
36365             if (_targetEntity && target[matchesSelector](_selector)) {
36366               return pointerdown.call(target, d3_event);
36367             }
36368           }
36369         };
36370       }
36371       selection2.on(_pointerPrefix + "down.drag" + _selector, delegate);
36372     }
36373     behavior.off = function(selection2) {
36374       selection2.on(_pointerPrefix + "down.drag" + _selector, null);
36375     };
36376     behavior.selector = function(_2) {
36377       if (!arguments.length) return _selector;
36378       _selector = _2;
36379       return behavior;
36380     };
36381     behavior.origin = function(_2) {
36382       if (!arguments.length) return _origin;
36383       _origin = _2;
36384       return behavior;
36385     };
36386     behavior.cancel = function() {
36387       select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
36388       return behavior;
36389     };
36390     behavior.targetNode = function(_2) {
36391       if (!arguments.length) return _targetNode;
36392       _targetNode = _2;
36393       return behavior;
36394     };
36395     behavior.targetEntity = function(_2) {
36396       if (!arguments.length) return _targetEntity;
36397       _targetEntity = _2;
36398       return behavior;
36399     };
36400     behavior.surface = function(_2) {
36401       if (!arguments.length) return _surface;
36402       _surface = _2;
36403       return behavior;
36404     };
36405     return utilRebind(behavior, dispatch14, "on");
36406   }
36407
36408   // modules/modes/drag_node.js
36409   function modeDragNode(context) {
36410     var mode = {
36411       id: "drag-node",
36412       button: "browse"
36413     };
36414     var hover = behaviorHover(context).altDisables(true).on("hover", context.ui().sidebar.hover);
36415     var edit2 = behaviorEdit(context);
36416     var _nudgeInterval;
36417     var _restoreSelectedIDs = [];
36418     var _wasMidpoint = false;
36419     var _isCancelled = false;
36420     var _activeEntity;
36421     var _startLoc;
36422     var _lastLoc;
36423     function startNudge(d3_event, entity, nudge) {
36424       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
36425       _nudgeInterval = window.setInterval(function() {
36426         context.map().pan(nudge);
36427         doMove(d3_event, entity, nudge);
36428       }, 50);
36429     }
36430     function stopNudge() {
36431       if (_nudgeInterval) {
36432         window.clearInterval(_nudgeInterval);
36433         _nudgeInterval = null;
36434       }
36435     }
36436     function moveAnnotation(entity) {
36437       return _t("operations.move.annotation." + entity.geometry(context.graph()));
36438     }
36439     function connectAnnotation(nodeEntity, targetEntity) {
36440       var nodeGeometry = nodeEntity.geometry(context.graph());
36441       var targetGeometry = targetEntity.geometry(context.graph());
36442       if (nodeGeometry === "vertex" && targetGeometry === "vertex") {
36443         var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
36444         var targetParentWayIDs = context.graph().parentWays(targetEntity);
36445         var sharedParentWays = utilArrayIntersection(nodeParentWayIDs, targetParentWayIDs);
36446         if (sharedParentWays.length !== 0) {
36447           if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
36448             return _t("operations.connect.annotation.from_vertex.to_adjacent_vertex");
36449           }
36450           return _t("operations.connect.annotation.from_vertex.to_sibling_vertex");
36451         }
36452       }
36453       return _t("operations.connect.annotation.from_" + nodeGeometry + ".to_" + targetGeometry);
36454     }
36455     function shouldSnapToNode(target) {
36456       if (!_activeEntity) return false;
36457       return _activeEntity.geometry(context.graph()) !== "vertex" || (target.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(target, context.graph()));
36458     }
36459     function origin(entity) {
36460       return context.projection(entity.loc);
36461     }
36462     function keydown(d3_event) {
36463       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36464         if (context.surface().classed("nope")) {
36465           context.surface().classed("nope-suppressed", true);
36466         }
36467         context.surface().classed("nope", false).classed("nope-disabled", true);
36468       }
36469     }
36470     function keyup(d3_event) {
36471       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36472         if (context.surface().classed("nope-suppressed")) {
36473           context.surface().classed("nope", true);
36474         }
36475         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
36476       }
36477     }
36478     function start2(d3_event, entity) {
36479       _wasMidpoint = entity.type === "midpoint";
36480       var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
36481       _isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
36482       if (_isCancelled) {
36483         if (hasHidden) {
36484           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("modes.drag_node.connected_to_hidden"))();
36485         }
36486         return drag.cancel();
36487       }
36488       if (_wasMidpoint) {
36489         var midpoint = entity;
36490         entity = osmNode();
36491         context.perform(actionAddMidpoint(midpoint, entity));
36492         entity = context.entity(entity.id);
36493         var vertex = context.surface().selectAll("." + entity.id);
36494         drag.targetNode(vertex.node()).targetEntity(entity);
36495       } else {
36496         context.perform(actionNoop());
36497       }
36498       _activeEntity = entity;
36499       _startLoc = entity.loc;
36500       hover.ignoreVertex(entity.geometry(context.graph()) === "vertex");
36501       context.surface().selectAll("." + _activeEntity.id).classed("active", true);
36502       context.enter(mode);
36503     }
36504     function datum2(d3_event) {
36505       if (!d3_event || d3_event.altKey) {
36506         return {};
36507       } else {
36508         var d2 = d3_event.target.__data__;
36509         return d2 && d2.properties && d2.properties.target ? d2 : {};
36510       }
36511     }
36512     function doMove(d3_event, entity, nudge) {
36513       nudge = nudge || [0, 0];
36514       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
36515       var currMouse = geoVecSubtract(currPoint, nudge);
36516       var loc = context.projection.invert(currMouse);
36517       var target, edge;
36518       if (!_nudgeInterval) {
36519         var d2 = datum2(d3_event);
36520         target = d2 && d2.properties && d2.properties.entity;
36521         var targetLoc = target && target.loc;
36522         var targetNodes = d2 && d2.properties && d2.properties.nodes;
36523         if (targetLoc) {
36524           if (shouldSnapToNode(target)) {
36525             loc = targetLoc;
36526           }
36527         } else if (targetNodes) {
36528           edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
36529           if (edge) {
36530             loc = edge.loc;
36531           }
36532         }
36533       }
36534       context.replace(
36535         actionMoveNode(entity.id, loc)
36536       );
36537       var isInvalid = false;
36538       if (target) {
36539         isInvalid = hasRelationConflict(entity, target, edge, context.graph());
36540       }
36541       if (!isInvalid) {
36542         isInvalid = hasInvalidGeometry(entity, context.graph());
36543       }
36544       var nope = context.surface().classed("nope");
36545       if (isInvalid === "relation" || isInvalid === "restriction") {
36546         if (!nope) {
36547           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(
36548             "operations.connect." + isInvalid,
36549             { relation: _mainPresetIndex.item("type/restriction").name() }
36550           ))();
36551         }
36552       } else if (isInvalid) {
36553         var errorID = isInvalid === "line" ? "lines" : "areas";
36554         context.ui().flash.duration(3e3).iconName("#iD-icon-no").label(_t.append("self_intersection.error." + errorID))();
36555       } else {
36556         if (nope) {
36557           context.ui().flash.duration(1).label("")();
36558         }
36559       }
36560       var nopeDisabled = context.surface().classed("nope-disabled");
36561       if (nopeDisabled) {
36562         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
36563       } else {
36564         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
36565       }
36566       _lastLoc = loc;
36567     }
36568     function hasRelationConflict(entity, target, edge, graph) {
36569       var testGraph = graph.update();
36570       if (edge) {
36571         var midpoint = osmNode();
36572         var action = actionAddMidpoint({
36573           loc: edge.loc,
36574           edge: [target.nodes[edge.index - 1], target.nodes[edge.index]]
36575         }, midpoint);
36576         testGraph = action(testGraph);
36577         target = midpoint;
36578       }
36579       var ids = [entity.id, target.id];
36580       return actionConnect(ids).disabled(testGraph);
36581     }
36582     function hasInvalidGeometry(entity, graph) {
36583       var parents = graph.parentWays(entity);
36584       var i3, j2, k2;
36585       for (i3 = 0; i3 < parents.length; i3++) {
36586         var parent = parents[i3];
36587         var nodes = [];
36588         var activeIndex = null;
36589         var relations = graph.parentRelations(parent);
36590         for (j2 = 0; j2 < relations.length; j2++) {
36591           if (!relations[j2].isMultipolygon()) continue;
36592           var rings = osmJoinWays(relations[j2].members, graph);
36593           for (k2 = 0; k2 < rings.length; k2++) {
36594             nodes = rings[k2].nodes;
36595             if (nodes.find(function(n3) {
36596               return n3.id === entity.id;
36597             })) {
36598               activeIndex = k2;
36599               if (geoHasSelfIntersections(nodes, entity.id)) {
36600                 return "multipolygonMember";
36601               }
36602             }
36603             rings[k2].coords = nodes.map(function(n3) {
36604               return n3.loc;
36605             });
36606           }
36607           for (k2 = 0; k2 < rings.length; k2++) {
36608             if (k2 === activeIndex) continue;
36609             if (geoHasLineIntersections(rings[activeIndex].nodes, rings[k2].nodes, entity.id)) {
36610               return "multipolygonRing";
36611             }
36612           }
36613         }
36614         if (activeIndex === null) {
36615           nodes = parent.nodes.map(function(nodeID) {
36616             return graph.entity(nodeID);
36617           });
36618           if (nodes.length && geoHasSelfIntersections(nodes, entity.id)) {
36619             return parent.geometry(graph);
36620           }
36621         }
36622       }
36623       return false;
36624     }
36625     function move(d3_event, entity, point) {
36626       if (_isCancelled) return;
36627       d3_event.stopPropagation();
36628       context.surface().classed("nope-disabled", d3_event.altKey);
36629       _lastLoc = context.projection.invert(point);
36630       doMove(d3_event, entity);
36631       var nudge = geoViewportEdge(point, context.map().dimensions());
36632       if (nudge) {
36633         startNudge(d3_event, entity, nudge);
36634       } else {
36635         stopNudge();
36636       }
36637     }
36638     function end(d3_event, entity) {
36639       if (_isCancelled) return;
36640       var wasPoint = entity.geometry(context.graph()) === "point";
36641       var d2 = datum2(d3_event);
36642       var nope = d2 && d2.properties && d2.properties.nope || context.surface().classed("nope");
36643       var target = d2 && d2.properties && d2.properties.entity;
36644       if (nope) {
36645         context.perform(
36646           _actionBounceBack(entity.id, _startLoc)
36647         );
36648       } else if (target && target.type === "way") {
36649         var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
36650         context.replace(
36651           actionAddMidpoint({
36652             loc: choice.loc,
36653             edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
36654           }, entity),
36655           connectAnnotation(entity, target)
36656         );
36657       } else if (target && target.type === "node" && shouldSnapToNode(target)) {
36658         context.replace(
36659           actionConnect([target.id, entity.id]),
36660           connectAnnotation(entity, target)
36661         );
36662       } else if (_wasMidpoint) {
36663         context.replace(
36664           actionNoop(),
36665           _t("operations.add.annotation.vertex")
36666         );
36667       } else {
36668         context.replace(
36669           actionNoop(),
36670           moveAnnotation(entity)
36671         );
36672       }
36673       if (wasPoint) {
36674         context.enter(modeSelect(context, [entity.id]));
36675       } else {
36676         var reselection = _restoreSelectedIDs.filter(function(id2) {
36677           return context.graph().hasEntity(id2);
36678         });
36679         if (reselection.length) {
36680           context.enter(modeSelect(context, reselection));
36681         } else {
36682           context.enter(modeBrowse(context));
36683         }
36684       }
36685     }
36686     function _actionBounceBack(nodeID, toLoc) {
36687       var moveNode = actionMoveNode(nodeID, toLoc);
36688       var action = function(graph, t2) {
36689         if (t2 === 1) context.pop();
36690         return moveNode(graph, t2);
36691       };
36692       action.transitionable = true;
36693       return action;
36694     }
36695     function cancel() {
36696       drag.cancel();
36697       context.enter(modeBrowse(context));
36698     }
36699     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);
36700     mode.enter = function() {
36701       context.install(hover);
36702       context.install(edit2);
36703       select_default2(window).on("keydown.dragNode", keydown).on("keyup.dragNode", keyup);
36704       context.history().on("undone.drag-node", cancel);
36705     };
36706     mode.exit = function() {
36707       context.ui().sidebar.hover.cancel();
36708       context.uninstall(hover);
36709       context.uninstall(edit2);
36710       select_default2(window).on("keydown.dragNode", null).on("keyup.dragNode", null);
36711       context.history().on("undone.drag-node", null);
36712       _activeEntity = null;
36713       context.surface().classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false).selectAll(".active").classed("active", false);
36714       stopNudge();
36715     };
36716     mode.selectedIDs = function() {
36717       if (!arguments.length) return _activeEntity ? [_activeEntity.id] : [];
36718       return mode;
36719     };
36720     mode.activeID = function() {
36721       if (!arguments.length) return _activeEntity && _activeEntity.id;
36722       return mode;
36723     };
36724     mode.restoreSelectedIDs = function(_2) {
36725       if (!arguments.length) return _restoreSelectedIDs;
36726       _restoreSelectedIDs = _2;
36727       return mode;
36728     };
36729     mode.behavior = drag;
36730     return mode;
36731   }
36732
36733   // node_modules/quickselect/index.js
36734   function quickselect2(arr, k2, left = 0, right = arr.length - 1, compare2 = defaultCompare) {
36735     while (right > left) {
36736       if (right - left > 600) {
36737         const n3 = right - left + 1;
36738         const m2 = k2 - left + 1;
36739         const z2 = Math.log(n3);
36740         const s2 = 0.5 * Math.exp(2 * z2 / 3);
36741         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
36742         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
36743         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
36744         quickselect2(arr, k2, newLeft, newRight, compare2);
36745       }
36746       const t2 = arr[k2];
36747       let i3 = left;
36748       let j2 = right;
36749       swap2(arr, left, k2);
36750       if (compare2(arr[right], t2) > 0) swap2(arr, left, right);
36751       while (i3 < j2) {
36752         swap2(arr, i3, j2);
36753         i3++;
36754         j2--;
36755         while (compare2(arr[i3], t2) < 0) i3++;
36756         while (compare2(arr[j2], t2) > 0) j2--;
36757       }
36758       if (compare2(arr[left], t2) === 0) swap2(arr, left, j2);
36759       else {
36760         j2++;
36761         swap2(arr, j2, right);
36762       }
36763       if (j2 <= k2) left = j2 + 1;
36764       if (k2 <= j2) right = j2 - 1;
36765     }
36766   }
36767   function swap2(arr, i3, j2) {
36768     const tmp = arr[i3];
36769     arr[i3] = arr[j2];
36770     arr[j2] = tmp;
36771   }
36772   function defaultCompare(a2, b2) {
36773     return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
36774   }
36775
36776   // node_modules/rbush/index.js
36777   var RBush = class {
36778     constructor(maxEntries = 9) {
36779       this._maxEntries = Math.max(4, maxEntries);
36780       this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
36781       this.clear();
36782     }
36783     all() {
36784       return this._all(this.data, []);
36785     }
36786     search(bbox2) {
36787       let node = this.data;
36788       const result = [];
36789       if (!intersects(bbox2, node)) return result;
36790       const toBBox = this.toBBox;
36791       const nodesToSearch = [];
36792       while (node) {
36793         for (let i3 = 0; i3 < node.children.length; i3++) {
36794           const child = node.children[i3];
36795           const childBBox = node.leaf ? toBBox(child) : child;
36796           if (intersects(bbox2, childBBox)) {
36797             if (node.leaf) result.push(child);
36798             else if (contains(bbox2, childBBox)) this._all(child, result);
36799             else nodesToSearch.push(child);
36800           }
36801         }
36802         node = nodesToSearch.pop();
36803       }
36804       return result;
36805     }
36806     collides(bbox2) {
36807       let node = this.data;
36808       if (!intersects(bbox2, node)) return false;
36809       const nodesToSearch = [];
36810       while (node) {
36811         for (let i3 = 0; i3 < node.children.length; i3++) {
36812           const child = node.children[i3];
36813           const childBBox = node.leaf ? this.toBBox(child) : child;
36814           if (intersects(bbox2, childBBox)) {
36815             if (node.leaf || contains(bbox2, childBBox)) return true;
36816             nodesToSearch.push(child);
36817           }
36818         }
36819         node = nodesToSearch.pop();
36820       }
36821       return false;
36822     }
36823     load(data) {
36824       if (!(data && data.length)) return this;
36825       if (data.length < this._minEntries) {
36826         for (let i3 = 0; i3 < data.length; i3++) {
36827           this.insert(data[i3]);
36828         }
36829         return this;
36830       }
36831       let node = this._build(data.slice(), 0, data.length - 1, 0);
36832       if (!this.data.children.length) {
36833         this.data = node;
36834       } else if (this.data.height === node.height) {
36835         this._splitRoot(this.data, node);
36836       } else {
36837         if (this.data.height < node.height) {
36838           const tmpNode = this.data;
36839           this.data = node;
36840           node = tmpNode;
36841         }
36842         this._insert(node, this.data.height - node.height - 1, true);
36843       }
36844       return this;
36845     }
36846     insert(item) {
36847       if (item) this._insert(item, this.data.height - 1);
36848       return this;
36849     }
36850     clear() {
36851       this.data = createNode([]);
36852       return this;
36853     }
36854     remove(item, equalsFn) {
36855       if (!item) return this;
36856       let node = this.data;
36857       const bbox2 = this.toBBox(item);
36858       const path = [];
36859       const indexes = [];
36860       let i3, parent, goingUp;
36861       while (node || path.length) {
36862         if (!node) {
36863           node = path.pop();
36864           parent = path[path.length - 1];
36865           i3 = indexes.pop();
36866           goingUp = true;
36867         }
36868         if (node.leaf) {
36869           const index = findItem(item, node.children, equalsFn);
36870           if (index !== -1) {
36871             node.children.splice(index, 1);
36872             path.push(node);
36873             this._condense(path);
36874             return this;
36875           }
36876         }
36877         if (!goingUp && !node.leaf && contains(node, bbox2)) {
36878           path.push(node);
36879           indexes.push(i3);
36880           i3 = 0;
36881           parent = node;
36882           node = node.children[0];
36883         } else if (parent) {
36884           i3++;
36885           node = parent.children[i3];
36886           goingUp = false;
36887         } else node = null;
36888       }
36889       return this;
36890     }
36891     toBBox(item) {
36892       return item;
36893     }
36894     compareMinX(a2, b2) {
36895       return a2.minX - b2.minX;
36896     }
36897     compareMinY(a2, b2) {
36898       return a2.minY - b2.minY;
36899     }
36900     toJSON() {
36901       return this.data;
36902     }
36903     fromJSON(data) {
36904       this.data = data;
36905       return this;
36906     }
36907     _all(node, result) {
36908       const nodesToSearch = [];
36909       while (node) {
36910         if (node.leaf) result.push(...node.children);
36911         else nodesToSearch.push(...node.children);
36912         node = nodesToSearch.pop();
36913       }
36914       return result;
36915     }
36916     _build(items, left, right, height) {
36917       const N2 = right - left + 1;
36918       let M2 = this._maxEntries;
36919       let node;
36920       if (N2 <= M2) {
36921         node = createNode(items.slice(left, right + 1));
36922         calcBBox(node, this.toBBox);
36923         return node;
36924       }
36925       if (!height) {
36926         height = Math.ceil(Math.log(N2) / Math.log(M2));
36927         M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
36928       }
36929       node = createNode([]);
36930       node.leaf = false;
36931       node.height = height;
36932       const N22 = Math.ceil(N2 / M2);
36933       const N1 = N22 * Math.ceil(Math.sqrt(M2));
36934       multiSelect(items, left, right, N1, this.compareMinX);
36935       for (let i3 = left; i3 <= right; i3 += N1) {
36936         const right2 = Math.min(i3 + N1 - 1, right);
36937         multiSelect(items, i3, right2, N22, this.compareMinY);
36938         for (let j2 = i3; j2 <= right2; j2 += N22) {
36939           const right3 = Math.min(j2 + N22 - 1, right2);
36940           node.children.push(this._build(items, j2, right3, height - 1));
36941         }
36942       }
36943       calcBBox(node, this.toBBox);
36944       return node;
36945     }
36946     _chooseSubtree(bbox2, node, level, path) {
36947       while (true) {
36948         path.push(node);
36949         if (node.leaf || path.length - 1 === level) break;
36950         let minArea = Infinity;
36951         let minEnlargement = Infinity;
36952         let targetNode;
36953         for (let i3 = 0; i3 < node.children.length; i3++) {
36954           const child = node.children[i3];
36955           const area = bboxArea(child);
36956           const enlargement = enlargedArea(bbox2, child) - area;
36957           if (enlargement < minEnlargement) {
36958             minEnlargement = enlargement;
36959             minArea = area < minArea ? area : minArea;
36960             targetNode = child;
36961           } else if (enlargement === minEnlargement) {
36962             if (area < minArea) {
36963               minArea = area;
36964               targetNode = child;
36965             }
36966           }
36967         }
36968         node = targetNode || node.children[0];
36969       }
36970       return node;
36971     }
36972     _insert(item, level, isNode) {
36973       const bbox2 = isNode ? item : this.toBBox(item);
36974       const insertPath = [];
36975       const node = this._chooseSubtree(bbox2, this.data, level, insertPath);
36976       node.children.push(item);
36977       extend2(node, bbox2);
36978       while (level >= 0) {
36979         if (insertPath[level].children.length > this._maxEntries) {
36980           this._split(insertPath, level);
36981           level--;
36982         } else break;
36983       }
36984       this._adjustParentBBoxes(bbox2, insertPath, level);
36985     }
36986     // split overflowed node into two
36987     _split(insertPath, level) {
36988       const node = insertPath[level];
36989       const M2 = node.children.length;
36990       const m2 = this._minEntries;
36991       this._chooseSplitAxis(node, m2, M2);
36992       const splitIndex = this._chooseSplitIndex(node, m2, M2);
36993       const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
36994       newNode.height = node.height;
36995       newNode.leaf = node.leaf;
36996       calcBBox(node, this.toBBox);
36997       calcBBox(newNode, this.toBBox);
36998       if (level) insertPath[level - 1].children.push(newNode);
36999       else this._splitRoot(node, newNode);
37000     }
37001     _splitRoot(node, newNode) {
37002       this.data = createNode([node, newNode]);
37003       this.data.height = node.height + 1;
37004       this.data.leaf = false;
37005       calcBBox(this.data, this.toBBox);
37006     }
37007     _chooseSplitIndex(node, m2, M2) {
37008       let index;
37009       let minOverlap = Infinity;
37010       let minArea = Infinity;
37011       for (let i3 = m2; i3 <= M2 - m2; i3++) {
37012         const bbox1 = distBBox(node, 0, i3, this.toBBox);
37013         const bbox2 = distBBox(node, i3, M2, this.toBBox);
37014         const overlap = intersectionArea(bbox1, bbox2);
37015         const area = bboxArea(bbox1) + bboxArea(bbox2);
37016         if (overlap < minOverlap) {
37017           minOverlap = overlap;
37018           index = i3;
37019           minArea = area < minArea ? area : minArea;
37020         } else if (overlap === minOverlap) {
37021           if (area < minArea) {
37022             minArea = area;
37023             index = i3;
37024           }
37025         }
37026       }
37027       return index || M2 - m2;
37028     }
37029     // sorts node children by the best axis for split
37030     _chooseSplitAxis(node, m2, M2) {
37031       const compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
37032       const compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
37033       const xMargin = this._allDistMargin(node, m2, M2, compareMinX);
37034       const yMargin = this._allDistMargin(node, m2, M2, compareMinY);
37035       if (xMargin < yMargin) node.children.sort(compareMinX);
37036     }
37037     // total margin of all possible split distributions where each node is at least m full
37038     _allDistMargin(node, m2, M2, compare2) {
37039       node.children.sort(compare2);
37040       const toBBox = this.toBBox;
37041       const leftBBox = distBBox(node, 0, m2, toBBox);
37042       const rightBBox = distBBox(node, M2 - m2, M2, toBBox);
37043       let margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
37044       for (let i3 = m2; i3 < M2 - m2; i3++) {
37045         const child = node.children[i3];
37046         extend2(leftBBox, node.leaf ? toBBox(child) : child);
37047         margin += bboxMargin(leftBBox);
37048       }
37049       for (let i3 = M2 - m2 - 1; i3 >= m2; i3--) {
37050         const child = node.children[i3];
37051         extend2(rightBBox, node.leaf ? toBBox(child) : child);
37052         margin += bboxMargin(rightBBox);
37053       }
37054       return margin;
37055     }
37056     _adjustParentBBoxes(bbox2, path, level) {
37057       for (let i3 = level; i3 >= 0; i3--) {
37058         extend2(path[i3], bbox2);
37059       }
37060     }
37061     _condense(path) {
37062       for (let i3 = path.length - 1, siblings; i3 >= 0; i3--) {
37063         if (path[i3].children.length === 0) {
37064           if (i3 > 0) {
37065             siblings = path[i3 - 1].children;
37066             siblings.splice(siblings.indexOf(path[i3]), 1);
37067           } else this.clear();
37068         } else calcBBox(path[i3], this.toBBox);
37069       }
37070     }
37071   };
37072   function findItem(item, items, equalsFn) {
37073     if (!equalsFn) return items.indexOf(item);
37074     for (let i3 = 0; i3 < items.length; i3++) {
37075       if (equalsFn(item, items[i3])) return i3;
37076     }
37077     return -1;
37078   }
37079   function calcBBox(node, toBBox) {
37080     distBBox(node, 0, node.children.length, toBBox, node);
37081   }
37082   function distBBox(node, k2, p2, toBBox, destNode) {
37083     if (!destNode) destNode = createNode(null);
37084     destNode.minX = Infinity;
37085     destNode.minY = Infinity;
37086     destNode.maxX = -Infinity;
37087     destNode.maxY = -Infinity;
37088     for (let i3 = k2; i3 < p2; i3++) {
37089       const child = node.children[i3];
37090       extend2(destNode, node.leaf ? toBBox(child) : child);
37091     }
37092     return destNode;
37093   }
37094   function extend2(a2, b2) {
37095     a2.minX = Math.min(a2.minX, b2.minX);
37096     a2.minY = Math.min(a2.minY, b2.minY);
37097     a2.maxX = Math.max(a2.maxX, b2.maxX);
37098     a2.maxY = Math.max(a2.maxY, b2.maxY);
37099     return a2;
37100   }
37101   function compareNodeMinX(a2, b2) {
37102     return a2.minX - b2.minX;
37103   }
37104   function compareNodeMinY(a2, b2) {
37105     return a2.minY - b2.minY;
37106   }
37107   function bboxArea(a2) {
37108     return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
37109   }
37110   function bboxMargin(a2) {
37111     return a2.maxX - a2.minX + (a2.maxY - a2.minY);
37112   }
37113   function enlargedArea(a2, b2) {
37114     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));
37115   }
37116   function intersectionArea(a2, b2) {
37117     const minX = Math.max(a2.minX, b2.minX);
37118     const minY = Math.max(a2.minY, b2.minY);
37119     const maxX = Math.min(a2.maxX, b2.maxX);
37120     const maxY = Math.min(a2.maxY, b2.maxY);
37121     return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
37122   }
37123   function contains(a2, b2) {
37124     return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
37125   }
37126   function intersects(a2, b2) {
37127     return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
37128   }
37129   function createNode(children2) {
37130     return {
37131       children: children2,
37132       height: 1,
37133       leaf: true,
37134       minX: Infinity,
37135       minY: Infinity,
37136       maxX: -Infinity,
37137       maxY: -Infinity
37138     };
37139   }
37140   function multiSelect(arr, left, right, n3, compare2) {
37141     const stack = [left, right];
37142     while (stack.length) {
37143       right = stack.pop();
37144       left = stack.pop();
37145       if (right - left <= n3) continue;
37146       const mid = left + Math.ceil((right - left) / n3 / 2) * n3;
37147       quickselect2(arr, mid, left, right, compare2);
37148       stack.push(left, mid, mid, right);
37149     }
37150   }
37151
37152   // node_modules/d3-fetch/src/text.js
37153   function responseText(response) {
37154     if (!response.ok) throw new Error(response.status + " " + response.statusText);
37155     return response.text();
37156   }
37157   function text_default3(input, init2) {
37158     return fetch(input, init2).then(responseText);
37159   }
37160
37161   // node_modules/d3-fetch/src/json.js
37162   function responseJson(response) {
37163     if (!response.ok) throw new Error(response.status + " " + response.statusText);
37164     if (response.status === 204 || response.status === 205) return;
37165     return response.json();
37166   }
37167   function json_default(input, init2) {
37168     return fetch(input, init2).then(responseJson);
37169   }
37170
37171   // node_modules/d3-fetch/src/xml.js
37172   function parser(type2) {
37173     return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2));
37174   }
37175   var xml_default = parser("application/xml");
37176   var html = parser("text/html");
37177   var svg = parser("image/svg+xml");
37178
37179   // modules/services/keepRight.js
37180   var tiler = utilTiler();
37181   var dispatch2 = dispatch_default("loaded");
37182   var _tileZoom = 14;
37183   var _krUrlRoot = "https://www.keepright.at";
37184   var _krData = { errorTypes: {}, localizeStrings: {} };
37185   var _cache;
37186   var _krRuleset = [
37187     // no 20 - multiple node on same spot - these are mostly boundaries overlapping roads
37188     30,
37189     40,
37190     50,
37191     60,
37192     70,
37193     90,
37194     100,
37195     110,
37196     120,
37197     130,
37198     150,
37199     160,
37200     170,
37201     180,
37202     190,
37203     191,
37204     192,
37205     193,
37206     194,
37207     195,
37208     196,
37209     197,
37210     198,
37211     200,
37212     201,
37213     202,
37214     203,
37215     204,
37216     205,
37217     206,
37218     207,
37219     208,
37220     210,
37221     220,
37222     230,
37223     231,
37224     232,
37225     270,
37226     280,
37227     281,
37228     282,
37229     283,
37230     284,
37231     285,
37232     290,
37233     291,
37234     292,
37235     293,
37236     294,
37237     295,
37238     296,
37239     297,
37240     298,
37241     300,
37242     310,
37243     311,
37244     312,
37245     313,
37246     320,
37247     350,
37248     360,
37249     370,
37250     380,
37251     390,
37252     400,
37253     401,
37254     402,
37255     410,
37256     411,
37257     412,
37258     413
37259   ];
37260   function abortRequest(controller) {
37261     if (controller) {
37262       controller.abort();
37263     }
37264   }
37265   function abortUnwantedRequests(cache, tiles) {
37266     Object.keys(cache.inflightTile).forEach((k2) => {
37267       const wanted = tiles.find((tile) => k2 === tile.id);
37268       if (!wanted) {
37269         abortRequest(cache.inflightTile[k2]);
37270         delete cache.inflightTile[k2];
37271       }
37272     });
37273   }
37274   function encodeIssueRtree(d2) {
37275     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
37276   }
37277   function updateRtree(item, replace) {
37278     _cache.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
37279     if (replace) {
37280       _cache.rtree.insert(item);
37281     }
37282   }
37283   function tokenReplacements(d2) {
37284     if (!(d2 instanceof QAItem)) return;
37285     const replacements = {};
37286     const issueTemplate = _krData.errorTypes[d2.whichType];
37287     if (!issueTemplate) {
37288       console.log("No Template: ", d2.whichType);
37289       console.log("  ", d2.description);
37290       return;
37291     }
37292     if (!issueTemplate.regex) return;
37293     const errorRegex = new RegExp(issueTemplate.regex, "i");
37294     const errorMatch = errorRegex.exec(d2.description);
37295     if (!errorMatch) {
37296       console.log("Unmatched: ", d2.whichType);
37297       console.log("  ", d2.description);
37298       console.log("  ", errorRegex);
37299       return;
37300     }
37301     for (let i3 = 1; i3 < errorMatch.length; i3++) {
37302       let capture = errorMatch[i3];
37303       let idType;
37304       idType = "IDs" in issueTemplate ? issueTemplate.IDs[i3 - 1] : "";
37305       if (idType && capture) {
37306         capture = parseError(capture, idType);
37307       } else {
37308         const compare2 = capture.toLowerCase();
37309         if (_krData.localizeStrings[compare2]) {
37310           capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
37311         } else {
37312           capture = unescape_default(capture);
37313         }
37314       }
37315       replacements["var" + i3] = capture;
37316     }
37317     return replacements;
37318   }
37319   function parseError(capture, idType) {
37320     const compare2 = capture.toLowerCase();
37321     if (_krData.localizeStrings[compare2]) {
37322       capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
37323     }
37324     switch (idType) {
37325       // link a string like "this node"
37326       case "this":
37327         capture = linkErrorObject(capture);
37328         break;
37329       case "url":
37330         capture = linkURL(capture);
37331         break;
37332       // link an entity ID
37333       case "n":
37334       case "w":
37335       case "r":
37336         capture = linkEntity(idType + capture);
37337         break;
37338       // some errors have more complex ID lists/variance
37339       case "20":
37340         capture = parse20(capture);
37341         break;
37342       case "211":
37343         capture = parse211(capture);
37344         break;
37345       case "231":
37346         capture = parse231(capture);
37347         break;
37348       case "294":
37349         capture = parse294(capture);
37350         break;
37351       case "370":
37352         capture = parse370(capture);
37353         break;
37354     }
37355     return capture;
37356     function linkErrorObject(d2) {
37357       return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
37358     }
37359     function linkEntity(d2) {
37360       return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
37361     }
37362     function linkURL(d2) {
37363       return { html: '<a class="kr_external_link" target="_blank" href="'.concat(d2, '">').concat(d2, "</a>") };
37364     }
37365     function parse211(capture2) {
37366       let newList = [];
37367       const items = capture2.split(", ");
37368       items.forEach((item) => {
37369         let id2 = linkEntity("n" + item.slice(1));
37370         newList.push(id2);
37371       });
37372       return newList.join(", ");
37373     }
37374     function parse231(capture2) {
37375       let newList = [];
37376       const items = capture2.split("),");
37377       items.forEach((item) => {
37378         const match = item.match(/\#(\d+)\((.+)\)?/);
37379         if (match !== null && match.length > 2) {
37380           newList.push(
37381             linkEntity("w" + match[1]) + " " + _t("QA.keepRight.errorTypes.231.layer", { layer: match[2] })
37382           );
37383         }
37384       });
37385       return newList.join(", ");
37386     }
37387     function parse294(capture2) {
37388       let newList = [];
37389       const items = capture2.split(",");
37390       items.forEach((item) => {
37391         item = item.split(" ");
37392         const role = '"'.concat(item[0], '"');
37393         const idType2 = item[1].slice(0, 1);
37394         let id2 = item[2].slice(1);
37395         id2 = linkEntity(idType2 + id2);
37396         newList.push("".concat(role, " ").concat(item[1], " ").concat(id2));
37397       });
37398       return newList.join(", ");
37399     }
37400     function parse370(capture2) {
37401       if (!capture2) return "";
37402       const match = capture2.match(/\(including the name (\'.+\')\)/);
37403       if (match && match.length) {
37404         return _t("QA.keepRight.errorTypes.370.including_the_name", { name: match[1] });
37405       }
37406       return "";
37407     }
37408     function parse20(capture2) {
37409       let newList = [];
37410       const items = capture2.split(",");
37411       items.forEach((item) => {
37412         const id2 = linkEntity("n" + item.slice(1));
37413         newList.push(id2);
37414       });
37415       return newList.join(", ");
37416     }
37417   }
37418   var keepRight_default = {
37419     title: "keepRight",
37420     init() {
37421       _mainFileFetcher.get("keepRight").then((d2) => _krData = d2);
37422       if (!_cache) {
37423         this.reset();
37424       }
37425       this.event = utilRebind(this, dispatch2, "on");
37426     },
37427     reset() {
37428       if (_cache) {
37429         Object.values(_cache.inflightTile).forEach(abortRequest);
37430       }
37431       _cache = {
37432         data: {},
37433         loadedTile: {},
37434         inflightTile: {},
37435         inflightPost: {},
37436         closed: {},
37437         rtree: new RBush()
37438       };
37439     },
37440     // KeepRight API:  http://osm.mueschelsoft.de/keepright/interfacing.php
37441     loadIssues(projection2) {
37442       const options2 = {
37443         format: "geojson",
37444         ch: _krRuleset
37445       };
37446       const tiles = tiler.zoomExtent([_tileZoom, _tileZoom]).getTiles(projection2);
37447       abortUnwantedRequests(_cache, tiles);
37448       tiles.forEach((tile) => {
37449         if (_cache.loadedTile[tile.id] || _cache.inflightTile[tile.id]) return;
37450         const [left, top, right, bottom] = tile.extent.rectangle();
37451         const params = Object.assign({}, options2, { left, bottom, right, top });
37452         const url = "".concat(_krUrlRoot, "/export.php?") + utilQsString(params);
37453         const controller = new AbortController();
37454         _cache.inflightTile[tile.id] = controller;
37455         json_default(url, { signal: controller.signal }).then((data) => {
37456           delete _cache.inflightTile[tile.id];
37457           _cache.loadedTile[tile.id] = true;
37458           if (!data || !data.features || !data.features.length) {
37459             throw new Error("No Data");
37460           }
37461           data.features.forEach((feature3) => {
37462             const {
37463               properties: {
37464                 error_type: itemType,
37465                 error_id: id2,
37466                 comment = null,
37467                 object_id: objectId,
37468                 object_type: objectType,
37469                 schema,
37470                 title
37471               }
37472             } = feature3;
37473             let {
37474               geometry: { coordinates: loc },
37475               properties: { description = "" }
37476             } = feature3;
37477             const issueTemplate = _krData.errorTypes[itemType];
37478             const parentIssueType = (Math.floor(itemType / 10) * 10).toString();
37479             const whichType = issueTemplate ? itemType : parentIssueType;
37480             const whichTemplate = _krData.errorTypes[whichType];
37481             switch (whichType) {
37482               case "170":
37483                 description = "This feature has a FIXME tag: ".concat(description);
37484                 break;
37485               case "292":
37486               case "293":
37487                 description = description.replace("A turn-", "This turn-");
37488                 break;
37489               case "294":
37490               case "295":
37491               case "296":
37492               case "297":
37493               case "298":
37494                 description = "This turn-restriction~".concat(description);
37495                 break;
37496               case "300":
37497                 description = "This highway is missing a maxspeed tag";
37498                 break;
37499               case "411":
37500               case "412":
37501               case "413":
37502                 description = "This feature~".concat(description);
37503                 break;
37504             }
37505             let coincident = false;
37506             do {
37507               let delta = coincident ? [1e-5, 0] : [0, 1e-5];
37508               loc = geoVecAdd(loc, delta);
37509               let bbox2 = geoExtent(loc).bbox();
37510               coincident = _cache.rtree.search(bbox2).length;
37511             } while (coincident);
37512             let d2 = new QAItem(loc, this, itemType, id2, {
37513               comment,
37514               description,
37515               whichType,
37516               parentIssueType,
37517               severity: whichTemplate.severity || "error",
37518               objectId,
37519               objectType,
37520               schema,
37521               title
37522             });
37523             d2.replacements = tokenReplacements(d2);
37524             _cache.data[id2] = d2;
37525             _cache.rtree.insert(encodeIssueRtree(d2));
37526           });
37527           dispatch2.call("loaded");
37528         }).catch(() => {
37529           delete _cache.inflightTile[tile.id];
37530           _cache.loadedTile[tile.id] = true;
37531         });
37532       });
37533     },
37534     postUpdate(d2, callback) {
37535       if (_cache.inflightPost[d2.id]) {
37536         return callback({ message: "Error update already inflight", status: -2 }, d2);
37537       }
37538       const params = { schema: d2.schema, id: d2.id };
37539       if (d2.newStatus) {
37540         params.st = d2.newStatus;
37541       }
37542       if (d2.newComment !== void 0) {
37543         params.co = d2.newComment;
37544       }
37545       const url = "".concat(_krUrlRoot, "/comment.php?") + utilQsString(params);
37546       const controller = new AbortController();
37547       _cache.inflightPost[d2.id] = controller;
37548       json_default(url, { signal: controller.signal }).finally(() => {
37549         delete _cache.inflightPost[d2.id];
37550         if (d2.newStatus === "ignore") {
37551           this.removeItem(d2);
37552         } else if (d2.newStatus === "ignore_t") {
37553           this.removeItem(d2);
37554           _cache.closed["".concat(d2.schema, ":").concat(d2.id)] = true;
37555         } else {
37556           d2 = this.replaceItem(d2.update({
37557             comment: d2.newComment,
37558             newComment: void 0,
37559             newState: void 0
37560           }));
37561         }
37562         if (callback) callback(null, d2);
37563       });
37564     },
37565     // Get all cached QAItems covering the viewport
37566     getItems(projection2) {
37567       const viewport = projection2.clipExtent();
37568       const min3 = [viewport[0][0], viewport[1][1]];
37569       const max3 = [viewport[1][0], viewport[0][1]];
37570       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
37571       return _cache.rtree.search(bbox2).map((d2) => d2.data);
37572     },
37573     // Get a QAItem from cache
37574     // NOTE: Don't change method name until UI v3 is merged
37575     getError(id2) {
37576       return _cache.data[id2];
37577     },
37578     // Replace a single QAItem in the cache
37579     replaceItem(item) {
37580       if (!(item instanceof QAItem) || !item.id) return;
37581       _cache.data[item.id] = item;
37582       updateRtree(encodeIssueRtree(item), true);
37583       return item;
37584     },
37585     // Remove a single QAItem from the cache
37586     removeItem(item) {
37587       if (!(item instanceof QAItem) || !item.id) return;
37588       delete _cache.data[item.id];
37589       updateRtree(encodeIssueRtree(item), false);
37590     },
37591     issueURL(item) {
37592       return "".concat(_krUrlRoot, "/report_map.php?schema=").concat(item.schema, "&error=").concat(item.id);
37593     },
37594     // Get an array of issues closed during this session.
37595     // Used to populate `closed:keepright` changeset tag
37596     getClosedIDs() {
37597       return Object.keys(_cache.closed).sort();
37598     }
37599   };
37600
37601   // node_modules/marked/lib/marked.esm.js
37602   function _getDefaults() {
37603     return {
37604       async: false,
37605       breaks: false,
37606       extensions: null,
37607       gfm: true,
37608       hooks: null,
37609       pedantic: false,
37610       renderer: null,
37611       silent: false,
37612       tokenizer: null,
37613       walkTokens: null
37614     };
37615   }
37616   var _defaults = _getDefaults();
37617   function changeDefaults(newDefaults) {
37618     _defaults = newDefaults;
37619   }
37620   var noopTest = { exec: () => null };
37621   function edit(regex, opt = "") {
37622     let source = typeof regex === "string" ? regex : regex.source;
37623     const obj = {
37624       replace: (name, val) => {
37625         let valSource = typeof val === "string" ? val : val.source;
37626         valSource = valSource.replace(other.caret, "$1");
37627         source = source.replace(name, valSource);
37628         return obj;
37629       },
37630       getRegex: () => {
37631         return new RegExp(source, opt);
37632       }
37633     };
37634     return obj;
37635   }
37636   var other = {
37637     codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
37638     outputLinkReplace: /\\([\[\]])/g,
37639     indentCodeCompensation: /^(\s+)(?:```)/,
37640     beginningSpace: /^\s+/,
37641     endingHash: /#$/,
37642     startingSpaceChar: /^ /,
37643     endingSpaceChar: / $/,
37644     nonSpaceChar: /[^ ]/,
37645     newLineCharGlobal: /\n/g,
37646     tabCharGlobal: /\t/g,
37647     multipleSpaceGlobal: /\s+/g,
37648     blankLine: /^[ \t]*$/,
37649     doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
37650     blockquoteStart: /^ {0,3}>/,
37651     blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
37652     blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
37653     listReplaceTabs: /^\t+/,
37654     listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
37655     listIsTask: /^\[[ xX]\] /,
37656     listReplaceTask: /^\[[ xX]\] +/,
37657     anyLine: /\n.*\n/,
37658     hrefBrackets: /^<(.*)>$/,
37659     tableDelimiter: /[:|]/,
37660     tableAlignChars: /^\||\| *$/g,
37661     tableRowBlankLine: /\n[ \t]*$/,
37662     tableAlignRight: /^ *-+: *$/,
37663     tableAlignCenter: /^ *:-+: *$/,
37664     tableAlignLeft: /^ *:-+ *$/,
37665     startATag: /^<a /i,
37666     endATag: /^<\/a>/i,
37667     startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
37668     endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
37669     startAngleBracket: /^</,
37670     endAngleBracket: />$/,
37671     pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
37672     unicodeAlphaNumeric: new RegExp("[\\p{L}\\p{N}]", "u"),
37673     escapeTest: /[&<>"']/,
37674     escapeReplace: /[&<>"']/g,
37675     escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
37676     escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
37677     unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
37678     caret: /(^|[^\[])\^/g,
37679     percentDecode: /%25/g,
37680     findPipe: /\|/g,
37681     splitPipe: / \|/,
37682     slashPipe: /\\\|/g,
37683     carriageReturn: /\r\n|\r/g,
37684     spaceLine: /^ +$/gm,
37685     notSpaceStart: /^\S*/,
37686     endingNewline: /\n$/,
37687     listItemRegex: (bull) => new RegExp("^( {0,3}".concat(bull, ")((?:[  ][^\\n]*)?(?:\\n|$))")),
37688     nextBulletRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[       ][^\\n]*)?(?:\\n|$))")),
37689     hrRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)")),
37690     fencesBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)")),
37691     headingBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#")),
37692     htmlBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}<(?:[a-z].*>|!--)"), "i")
37693   };
37694   var newline = /^(?:[ \t]*(?:\n|$))+/;
37695   var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
37696   var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
37697   var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
37698   var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
37699   var bullet = /(?:[*+-]|\d{1,9}[.)])/;
37700   var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
37701   var lheading = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
37702   var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
37703   var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
37704   var blockText = /^[^\n]+/;
37705   var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
37706   var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
37707   var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
37708   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";
37709   var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
37710   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();
37711   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();
37712   var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
37713   var blockNormal = {
37714     blockquote,
37715     code: blockCode,
37716     def,
37717     fences,
37718     heading,
37719     hr,
37720     html: html2,
37721     lheading,
37722     list,
37723     newline,
37724     paragraph,
37725     table: noopTest,
37726     text: blockText
37727   };
37728   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}| {0,3}     )[^\\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();
37729   var blockGfm = __spreadProps(__spreadValues({}, blockNormal), {
37730     lheading: lheadingGfm,
37731     table: gfmTable,
37732     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()
37733   });
37734   var blockPedantic = __spreadProps(__spreadValues({}, blockNormal), {
37735     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(),
37736     def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
37737     heading: /^(#{1,6})(.*)(?:\n+|$)/,
37738     fences: noopTest,
37739     // fences not supported
37740     lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
37741     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()
37742   });
37743   var escape$1 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
37744   var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
37745   var br = /^( {2,}|\\)\n(?!\s*$)/;
37746   var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
37747   var _punctuation = new RegExp("[\\p{P}\\p{S}]", "u");
37748   var _punctuationOrSpace = new RegExp("[\\s\\p{P}\\p{S}]", "u");
37749   var _notPunctuationOrSpace = new RegExp("[^\\s\\p{P}\\p{S}]", "u");
37750   var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
37751   var _punctuationGfmStrongEm = new RegExp("(?!~)[\\p{P}\\p{S}]", "u");
37752   var _punctuationOrSpaceGfmStrongEm = new RegExp("(?!~)[\\s\\p{P}\\p{S}]", "u");
37753   var _notPunctuationOrSpaceGfmStrongEm = new RegExp("(?:[^\\s\\p{P}\\p{S}]|~)", "u");
37754   var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
37755   var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
37756   var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
37757   var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
37758   var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
37759   var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
37760   var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
37761   var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
37762   var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
37763   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();
37764   var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
37765   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();
37766   var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
37767   var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
37768   var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
37769   var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
37770   var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
37771   var inlineNormal = {
37772     _backpedal: noopTest,
37773     // only used for GFM url
37774     anyPunctuation,
37775     autolink,
37776     blockSkip,
37777     br,
37778     code: inlineCode,
37779     del: noopTest,
37780     emStrongLDelim,
37781     emStrongRDelimAst,
37782     emStrongRDelimUnd,
37783     escape: escape$1,
37784     link: link2,
37785     nolink,
37786     punctuation,
37787     reflink,
37788     reflinkSearch,
37789     tag,
37790     text: inlineText,
37791     url: noopTest
37792   };
37793   var inlinePedantic = __spreadProps(__spreadValues({}, inlineNormal), {
37794     link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
37795     reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
37796   });
37797   var inlineGfm = __spreadProps(__spreadValues({}, inlineNormal), {
37798     emStrongRDelimAst: emStrongRDelimAstGfm,
37799     emStrongLDelim: emStrongLDelimGfm,
37800     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(),
37801     _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
37802     del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
37803     text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
37804   });
37805   var inlineBreaks = __spreadProps(__spreadValues({}, inlineGfm), {
37806     br: edit(br).replace("{2,}", "*").getRegex(),
37807     text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
37808   });
37809   var block = {
37810     normal: blockNormal,
37811     gfm: blockGfm,
37812     pedantic: blockPedantic
37813   };
37814   var inline = {
37815     normal: inlineNormal,
37816     gfm: inlineGfm,
37817     breaks: inlineBreaks,
37818     pedantic: inlinePedantic
37819   };
37820   var escapeReplacements = {
37821     "&": "&amp;",
37822     "<": "&lt;",
37823     ">": "&gt;",
37824     '"': "&quot;",
37825     "'": "&#39;"
37826   };
37827   var getEscapeReplacement = (ch) => escapeReplacements[ch];
37828   function escape4(html3, encode) {
37829     if (encode) {
37830       if (other.escapeTest.test(html3)) {
37831         return html3.replace(other.escapeReplace, getEscapeReplacement);
37832       }
37833     } else {
37834       if (other.escapeTestNoEncode.test(html3)) {
37835         return html3.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
37836       }
37837     }
37838     return html3;
37839   }
37840   function cleanUrl(href) {
37841     try {
37842       href = encodeURI(href).replace(other.percentDecode, "%");
37843     } catch (e3) {
37844       return null;
37845     }
37846     return href;
37847   }
37848   function splitCells(tableRow, count) {
37849     var _a4;
37850     const row = tableRow.replace(other.findPipe, (match, offset, str) => {
37851       let escaped = false;
37852       let curr = offset;
37853       while (--curr >= 0 && str[curr] === "\\")
37854         escaped = !escaped;
37855       if (escaped) {
37856         return "|";
37857       } else {
37858         return " |";
37859       }
37860     }), cells = row.split(other.splitPipe);
37861     let i3 = 0;
37862     if (!cells[0].trim()) {
37863       cells.shift();
37864     }
37865     if (cells.length > 0 && !((_a4 = cells.at(-1)) == null ? void 0 : _a4.trim())) {
37866       cells.pop();
37867     }
37868     if (count) {
37869       if (cells.length > count) {
37870         cells.splice(count);
37871       } else {
37872         while (cells.length < count)
37873           cells.push("");
37874       }
37875     }
37876     for (; i3 < cells.length; i3++) {
37877       cells[i3] = cells[i3].trim().replace(other.slashPipe, "|");
37878     }
37879     return cells;
37880   }
37881   function rtrim(str, c2, invert) {
37882     const l2 = str.length;
37883     if (l2 === 0) {
37884       return "";
37885     }
37886     let suffLen = 0;
37887     while (suffLen < l2) {
37888       const currChar = str.charAt(l2 - suffLen - 1);
37889       if (currChar === c2 && true) {
37890         suffLen++;
37891       } else {
37892         break;
37893       }
37894     }
37895     return str.slice(0, l2 - suffLen);
37896   }
37897   function findClosingBracket(str, b2) {
37898     if (str.indexOf(b2[1]) === -1) {
37899       return -1;
37900     }
37901     let level = 0;
37902     for (let i3 = 0; i3 < str.length; i3++) {
37903       if (str[i3] === "\\") {
37904         i3++;
37905       } else if (str[i3] === b2[0]) {
37906         level++;
37907       } else if (str[i3] === b2[1]) {
37908         level--;
37909         if (level < 0) {
37910           return i3;
37911         }
37912       }
37913     }
37914     return -1;
37915   }
37916   function outputLink(cap, link3, raw, lexer2, rules) {
37917     const href = link3.href;
37918     const title = link3.title || null;
37919     const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
37920     if (cap[0].charAt(0) !== "!") {
37921       lexer2.state.inLink = true;
37922       const token = {
37923         type: "link",
37924         raw,
37925         href,
37926         title,
37927         text,
37928         tokens: lexer2.inlineTokens(text)
37929       };
37930       lexer2.state.inLink = false;
37931       return token;
37932     }
37933     return {
37934       type: "image",
37935       raw,
37936       href,
37937       title,
37938       text
37939     };
37940   }
37941   function indentCodeCompensation(raw, text, rules) {
37942     const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
37943     if (matchIndentToCode === null) {
37944       return text;
37945     }
37946     const indentToCode = matchIndentToCode[1];
37947     return text.split("\n").map((node) => {
37948       const matchIndentInNode = node.match(rules.other.beginningSpace);
37949       if (matchIndentInNode === null) {
37950         return node;
37951       }
37952       const [indentInNode] = matchIndentInNode;
37953       if (indentInNode.length >= indentToCode.length) {
37954         return node.slice(indentToCode.length);
37955       }
37956       return node;
37957     }).join("\n");
37958   }
37959   var _Tokenizer = class {
37960     // set by the lexer
37961     constructor(options2) {
37962       __publicField(this, "options");
37963       __publicField(this, "rules");
37964       // set by the lexer
37965       __publicField(this, "lexer");
37966       this.options = options2 || _defaults;
37967     }
37968     space(src) {
37969       const cap = this.rules.block.newline.exec(src);
37970       if (cap && cap[0].length > 0) {
37971         return {
37972           type: "space",
37973           raw: cap[0]
37974         };
37975       }
37976     }
37977     code(src) {
37978       const cap = this.rules.block.code.exec(src);
37979       if (cap) {
37980         const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
37981         return {
37982           type: "code",
37983           raw: cap[0],
37984           codeBlockStyle: "indented",
37985           text: !this.options.pedantic ? rtrim(text, "\n") : text
37986         };
37987       }
37988     }
37989     fences(src) {
37990       const cap = this.rules.block.fences.exec(src);
37991       if (cap) {
37992         const raw = cap[0];
37993         const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
37994         return {
37995           type: "code",
37996           raw,
37997           lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
37998           text
37999         };
38000       }
38001     }
38002     heading(src) {
38003       const cap = this.rules.block.heading.exec(src);
38004       if (cap) {
38005         let text = cap[2].trim();
38006         if (this.rules.other.endingHash.test(text)) {
38007           const trimmed = rtrim(text, "#");
38008           if (this.options.pedantic) {
38009             text = trimmed.trim();
38010           } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
38011             text = trimmed.trim();
38012           }
38013         }
38014         return {
38015           type: "heading",
38016           raw: cap[0],
38017           depth: cap[1].length,
38018           text,
38019           tokens: this.lexer.inline(text)
38020         };
38021       }
38022     }
38023     hr(src) {
38024       const cap = this.rules.block.hr.exec(src);
38025       if (cap) {
38026         return {
38027           type: "hr",
38028           raw: rtrim(cap[0], "\n")
38029         };
38030       }
38031     }
38032     blockquote(src) {
38033       const cap = this.rules.block.blockquote.exec(src);
38034       if (cap) {
38035         let lines = rtrim(cap[0], "\n").split("\n");
38036         let raw = "";
38037         let text = "";
38038         const tokens = [];
38039         while (lines.length > 0) {
38040           let inBlockquote = false;
38041           const currentLines = [];
38042           let i3;
38043           for (i3 = 0; i3 < lines.length; i3++) {
38044             if (this.rules.other.blockquoteStart.test(lines[i3])) {
38045               currentLines.push(lines[i3]);
38046               inBlockquote = true;
38047             } else if (!inBlockquote) {
38048               currentLines.push(lines[i3]);
38049             } else {
38050               break;
38051             }
38052           }
38053           lines = lines.slice(i3);
38054           const currentRaw = currentLines.join("\n");
38055           const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n    $1").replace(this.rules.other.blockquoteSetextReplace2, "");
38056           raw = raw ? "".concat(raw, "\n").concat(currentRaw) : currentRaw;
38057           text = text ? "".concat(text, "\n").concat(currentText) : currentText;
38058           const top = this.lexer.state.top;
38059           this.lexer.state.top = true;
38060           this.lexer.blockTokens(currentText, tokens, true);
38061           this.lexer.state.top = top;
38062           if (lines.length === 0) {
38063             break;
38064           }
38065           const lastToken = tokens.at(-1);
38066           if ((lastToken == null ? void 0 : lastToken.type) === "code") {
38067             break;
38068           } else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
38069             const oldToken = lastToken;
38070             const newText = oldToken.raw + "\n" + lines.join("\n");
38071             const newToken = this.blockquote(newText);
38072             tokens[tokens.length - 1] = newToken;
38073             raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
38074             text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
38075             break;
38076           } else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
38077             const oldToken = lastToken;
38078             const newText = oldToken.raw + "\n" + lines.join("\n");
38079             const newToken = this.list(newText);
38080             tokens[tokens.length - 1] = newToken;
38081             raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
38082             text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
38083             lines = newText.substring(tokens.at(-1).raw.length).split("\n");
38084             continue;
38085           }
38086         }
38087         return {
38088           type: "blockquote",
38089           raw,
38090           tokens,
38091           text
38092         };
38093       }
38094     }
38095     list(src) {
38096       let cap = this.rules.block.list.exec(src);
38097       if (cap) {
38098         let bull = cap[1].trim();
38099         const isordered = bull.length > 1;
38100         const list2 = {
38101           type: "list",
38102           raw: "",
38103           ordered: isordered,
38104           start: isordered ? +bull.slice(0, -1) : "",
38105           loose: false,
38106           items: []
38107         };
38108         bull = isordered ? "\\d{1,9}\\".concat(bull.slice(-1)) : "\\".concat(bull);
38109         if (this.options.pedantic) {
38110           bull = isordered ? bull : "[*+-]";
38111         }
38112         const itemRegex = this.rules.other.listItemRegex(bull);
38113         let endsWithBlankLine = false;
38114         while (src) {
38115           let endEarly = false;
38116           let raw = "";
38117           let itemContents = "";
38118           if (!(cap = itemRegex.exec(src))) {
38119             break;
38120           }
38121           if (this.rules.block.hr.test(src)) {
38122             break;
38123           }
38124           raw = cap[0];
38125           src = src.substring(raw.length);
38126           let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t2) => " ".repeat(3 * t2.length));
38127           let nextLine = src.split("\n", 1)[0];
38128           let blankLine = !line.trim();
38129           let indent = 0;
38130           if (this.options.pedantic) {
38131             indent = 2;
38132             itemContents = line.trimStart();
38133           } else if (blankLine) {
38134             indent = cap[1].length + 1;
38135           } else {
38136             indent = cap[2].search(this.rules.other.nonSpaceChar);
38137             indent = indent > 4 ? 1 : indent;
38138             itemContents = line.slice(indent);
38139             indent += cap[1].length;
38140           }
38141           if (blankLine && this.rules.other.blankLine.test(nextLine)) {
38142             raw += nextLine + "\n";
38143             src = src.substring(nextLine.length + 1);
38144             endEarly = true;
38145           }
38146           if (!endEarly) {
38147             const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
38148             const hrRegex = this.rules.other.hrRegex(indent);
38149             const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
38150             const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
38151             const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
38152             while (src) {
38153               const rawLine = src.split("\n", 1)[0];
38154               let nextLineWithoutTabs;
38155               nextLine = rawLine;
38156               if (this.options.pedantic) {
38157                 nextLine = nextLine.replace(this.rules.other.listReplaceNesting, "  ");
38158                 nextLineWithoutTabs = nextLine;
38159               } else {
38160                 nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, "    ");
38161               }
38162               if (fencesBeginRegex.test(nextLine)) {
38163                 break;
38164               }
38165               if (headingBeginRegex.test(nextLine)) {
38166                 break;
38167               }
38168               if (htmlBeginRegex.test(nextLine)) {
38169                 break;
38170               }
38171               if (nextBulletRegex.test(nextLine)) {
38172                 break;
38173               }
38174               if (hrRegex.test(nextLine)) {
38175                 break;
38176               }
38177               if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
38178                 itemContents += "\n" + nextLineWithoutTabs.slice(indent);
38179               } else {
38180                 if (blankLine) {
38181                   break;
38182                 }
38183                 if (line.replace(this.rules.other.tabCharGlobal, "    ").search(this.rules.other.nonSpaceChar) >= 4) {
38184                   break;
38185                 }
38186                 if (fencesBeginRegex.test(line)) {
38187                   break;
38188                 }
38189                 if (headingBeginRegex.test(line)) {
38190                   break;
38191                 }
38192                 if (hrRegex.test(line)) {
38193                   break;
38194                 }
38195                 itemContents += "\n" + nextLine;
38196               }
38197               if (!blankLine && !nextLine.trim()) {
38198                 blankLine = true;
38199               }
38200               raw += rawLine + "\n";
38201               src = src.substring(rawLine.length + 1);
38202               line = nextLineWithoutTabs.slice(indent);
38203             }
38204           }
38205           if (!list2.loose) {
38206             if (endsWithBlankLine) {
38207               list2.loose = true;
38208             } else if (this.rules.other.doubleBlankLine.test(raw)) {
38209               endsWithBlankLine = true;
38210             }
38211           }
38212           let istask = null;
38213           let ischecked;
38214           if (this.options.gfm) {
38215             istask = this.rules.other.listIsTask.exec(itemContents);
38216             if (istask) {
38217               ischecked = istask[0] !== "[ ] ";
38218               itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
38219             }
38220           }
38221           list2.items.push({
38222             type: "list_item",
38223             raw,
38224             task: !!istask,
38225             checked: ischecked,
38226             loose: false,
38227             text: itemContents,
38228             tokens: []
38229           });
38230           list2.raw += raw;
38231         }
38232         const lastItem = list2.items.at(-1);
38233         if (lastItem) {
38234           lastItem.raw = lastItem.raw.trimEnd();
38235           lastItem.text = lastItem.text.trimEnd();
38236         } else {
38237           return;
38238         }
38239         list2.raw = list2.raw.trimEnd();
38240         for (let i3 = 0; i3 < list2.items.length; i3++) {
38241           this.lexer.state.top = false;
38242           list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
38243           if (!list2.loose) {
38244             const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space");
38245             const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => this.rules.other.anyLine.test(t2.raw));
38246             list2.loose = hasMultipleLineBreaks;
38247           }
38248         }
38249         if (list2.loose) {
38250           for (let i3 = 0; i3 < list2.items.length; i3++) {
38251             list2.items[i3].loose = true;
38252           }
38253         }
38254         return list2;
38255       }
38256     }
38257     html(src) {
38258       const cap = this.rules.block.html.exec(src);
38259       if (cap) {
38260         const token = {
38261           type: "html",
38262           block: true,
38263           raw: cap[0],
38264           pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
38265           text: cap[0]
38266         };
38267         return token;
38268       }
38269     }
38270     def(src) {
38271       const cap = this.rules.block.def.exec(src);
38272       if (cap) {
38273         const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
38274         const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
38275         const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
38276         return {
38277           type: "def",
38278           tag: tag2,
38279           raw: cap[0],
38280           href,
38281           title
38282         };
38283       }
38284     }
38285     table(src) {
38286       var _a4;
38287       const cap = this.rules.block.table.exec(src);
38288       if (!cap) {
38289         return;
38290       }
38291       if (!this.rules.other.tableDelimiter.test(cap[2])) {
38292         return;
38293       }
38294       const headers = splitCells(cap[1]);
38295       const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
38296       const rows = ((_a4 = cap[3]) == null ? void 0 : _a4.trim()) ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
38297       const item = {
38298         type: "table",
38299         raw: cap[0],
38300         header: [],
38301         align: [],
38302         rows: []
38303       };
38304       if (headers.length !== aligns.length) {
38305         return;
38306       }
38307       for (const align of aligns) {
38308         if (this.rules.other.tableAlignRight.test(align)) {
38309           item.align.push("right");
38310         } else if (this.rules.other.tableAlignCenter.test(align)) {
38311           item.align.push("center");
38312         } else if (this.rules.other.tableAlignLeft.test(align)) {
38313           item.align.push("left");
38314         } else {
38315           item.align.push(null);
38316         }
38317       }
38318       for (let i3 = 0; i3 < headers.length; i3++) {
38319         item.header.push({
38320           text: headers[i3],
38321           tokens: this.lexer.inline(headers[i3]),
38322           header: true,
38323           align: item.align[i3]
38324         });
38325       }
38326       for (const row of rows) {
38327         item.rows.push(splitCells(row, item.header.length).map((cell, i3) => {
38328           return {
38329             text: cell,
38330             tokens: this.lexer.inline(cell),
38331             header: false,
38332             align: item.align[i3]
38333           };
38334         }));
38335       }
38336       return item;
38337     }
38338     lheading(src) {
38339       const cap = this.rules.block.lheading.exec(src);
38340       if (cap) {
38341         return {
38342           type: "heading",
38343           raw: cap[0],
38344           depth: cap[2].charAt(0) === "=" ? 1 : 2,
38345           text: cap[1],
38346           tokens: this.lexer.inline(cap[1])
38347         };
38348       }
38349     }
38350     paragraph(src) {
38351       const cap = this.rules.block.paragraph.exec(src);
38352       if (cap) {
38353         const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
38354         return {
38355           type: "paragraph",
38356           raw: cap[0],
38357           text,
38358           tokens: this.lexer.inline(text)
38359         };
38360       }
38361     }
38362     text(src) {
38363       const cap = this.rules.block.text.exec(src);
38364       if (cap) {
38365         return {
38366           type: "text",
38367           raw: cap[0],
38368           text: cap[0],
38369           tokens: this.lexer.inline(cap[0])
38370         };
38371       }
38372     }
38373     escape(src) {
38374       const cap = this.rules.inline.escape.exec(src);
38375       if (cap) {
38376         return {
38377           type: "escape",
38378           raw: cap[0],
38379           text: cap[1]
38380         };
38381       }
38382     }
38383     tag(src) {
38384       const cap = this.rules.inline.tag.exec(src);
38385       if (cap) {
38386         if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
38387           this.lexer.state.inLink = true;
38388         } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
38389           this.lexer.state.inLink = false;
38390         }
38391         if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
38392           this.lexer.state.inRawBlock = true;
38393         } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
38394           this.lexer.state.inRawBlock = false;
38395         }
38396         return {
38397           type: "html",
38398           raw: cap[0],
38399           inLink: this.lexer.state.inLink,
38400           inRawBlock: this.lexer.state.inRawBlock,
38401           block: false,
38402           text: cap[0]
38403         };
38404       }
38405     }
38406     link(src) {
38407       const cap = this.rules.inline.link.exec(src);
38408       if (cap) {
38409         const trimmedUrl = cap[2].trim();
38410         if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
38411           if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
38412             return;
38413           }
38414           const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
38415           if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
38416             return;
38417           }
38418         } else {
38419           const lastParenIndex = findClosingBracket(cap[2], "()");
38420           if (lastParenIndex > -1) {
38421             const start2 = cap[0].indexOf("!") === 0 ? 5 : 4;
38422             const linkLen = start2 + cap[1].length + lastParenIndex;
38423             cap[2] = cap[2].substring(0, lastParenIndex);
38424             cap[0] = cap[0].substring(0, linkLen).trim();
38425             cap[3] = "";
38426           }
38427         }
38428         let href = cap[2];
38429         let title = "";
38430         if (this.options.pedantic) {
38431           const link3 = this.rules.other.pedanticHrefTitle.exec(href);
38432           if (link3) {
38433             href = link3[1];
38434             title = link3[3];
38435           }
38436         } else {
38437           title = cap[3] ? cap[3].slice(1, -1) : "";
38438         }
38439         href = href.trim();
38440         if (this.rules.other.startAngleBracket.test(href)) {
38441           if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
38442             href = href.slice(1);
38443           } else {
38444             href = href.slice(1, -1);
38445           }
38446         }
38447         return outputLink(cap, {
38448           href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
38449           title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
38450         }, cap[0], this.lexer, this.rules);
38451       }
38452     }
38453     reflink(src, links) {
38454       let cap;
38455       if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
38456         const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
38457         const link3 = links[linkString.toLowerCase()];
38458         if (!link3) {
38459           const text = cap[0].charAt(0);
38460           return {
38461             type: "text",
38462             raw: text,
38463             text
38464           };
38465         }
38466         return outputLink(cap, link3, cap[0], this.lexer, this.rules);
38467       }
38468     }
38469     emStrong(src, maskedSrc, prevChar = "") {
38470       let match = this.rules.inline.emStrongLDelim.exec(src);
38471       if (!match)
38472         return;
38473       if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric))
38474         return;
38475       const nextChar = match[1] || match[2] || "";
38476       if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
38477         const lLength = [...match[0]].length - 1;
38478         let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
38479         const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
38480         endReg.lastIndex = 0;
38481         maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
38482         while ((match = endReg.exec(maskedSrc)) != null) {
38483           rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
38484           if (!rDelim)
38485             continue;
38486           rLength = [...rDelim].length;
38487           if (match[3] || match[4]) {
38488             delimTotal += rLength;
38489             continue;
38490           } else if (match[5] || match[6]) {
38491             if (lLength % 3 && !((lLength + rLength) % 3)) {
38492               midDelimTotal += rLength;
38493               continue;
38494             }
38495           }
38496           delimTotal -= rLength;
38497           if (delimTotal > 0)
38498             continue;
38499           rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
38500           const lastCharLength = [...match[0]][0].length;
38501           const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
38502           if (Math.min(lLength, rLength) % 2) {
38503             const text2 = raw.slice(1, -1);
38504             return {
38505               type: "em",
38506               raw,
38507               text: text2,
38508               tokens: this.lexer.inlineTokens(text2)
38509             };
38510           }
38511           const text = raw.slice(2, -2);
38512           return {
38513             type: "strong",
38514             raw,
38515             text,
38516             tokens: this.lexer.inlineTokens(text)
38517           };
38518         }
38519       }
38520     }
38521     codespan(src) {
38522       const cap = this.rules.inline.code.exec(src);
38523       if (cap) {
38524         let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
38525         const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
38526         const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
38527         if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
38528           text = text.substring(1, text.length - 1);
38529         }
38530         return {
38531           type: "codespan",
38532           raw: cap[0],
38533           text
38534         };
38535       }
38536     }
38537     br(src) {
38538       const cap = this.rules.inline.br.exec(src);
38539       if (cap) {
38540         return {
38541           type: "br",
38542           raw: cap[0]
38543         };
38544       }
38545     }
38546     del(src) {
38547       const cap = this.rules.inline.del.exec(src);
38548       if (cap) {
38549         return {
38550           type: "del",
38551           raw: cap[0],
38552           text: cap[2],
38553           tokens: this.lexer.inlineTokens(cap[2])
38554         };
38555       }
38556     }
38557     autolink(src) {
38558       const cap = this.rules.inline.autolink.exec(src);
38559       if (cap) {
38560         let text, href;
38561         if (cap[2] === "@") {
38562           text = cap[1];
38563           href = "mailto:" + text;
38564         } else {
38565           text = cap[1];
38566           href = text;
38567         }
38568         return {
38569           type: "link",
38570           raw: cap[0],
38571           text,
38572           href,
38573           tokens: [
38574             {
38575               type: "text",
38576               raw: text,
38577               text
38578             }
38579           ]
38580         };
38581       }
38582     }
38583     url(src) {
38584       var _a4, _b3;
38585       let cap;
38586       if (cap = this.rules.inline.url.exec(src)) {
38587         let text, href;
38588         if (cap[2] === "@") {
38589           text = cap[0];
38590           href = "mailto:" + text;
38591         } else {
38592           let prevCapZero;
38593           do {
38594             prevCapZero = cap[0];
38595             cap[0] = (_b3 = (_a4 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a4[0]) != null ? _b3 : "";
38596           } while (prevCapZero !== cap[0]);
38597           text = cap[0];
38598           if (cap[1] === "www.") {
38599             href = "http://" + cap[0];
38600           } else {
38601             href = cap[0];
38602           }
38603         }
38604         return {
38605           type: "link",
38606           raw: cap[0],
38607           text,
38608           href,
38609           tokens: [
38610             {
38611               type: "text",
38612               raw: text,
38613               text
38614             }
38615           ]
38616         };
38617       }
38618     }
38619     inlineText(src) {
38620       const cap = this.rules.inline.text.exec(src);
38621       if (cap) {
38622         const escaped = this.lexer.state.inRawBlock;
38623         return {
38624           type: "text",
38625           raw: cap[0],
38626           text: cap[0],
38627           escaped
38628         };
38629       }
38630     }
38631   };
38632   var _Lexer = class __Lexer {
38633     constructor(options2) {
38634       __publicField(this, "tokens");
38635       __publicField(this, "options");
38636       __publicField(this, "state");
38637       __publicField(this, "tokenizer");
38638       __publicField(this, "inlineQueue");
38639       this.tokens = [];
38640       this.tokens.links = /* @__PURE__ */ Object.create(null);
38641       this.options = options2 || _defaults;
38642       this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
38643       this.tokenizer = this.options.tokenizer;
38644       this.tokenizer.options = this.options;
38645       this.tokenizer.lexer = this;
38646       this.inlineQueue = [];
38647       this.state = {
38648         inLink: false,
38649         inRawBlock: false,
38650         top: true
38651       };
38652       const rules = {
38653         other,
38654         block: block.normal,
38655         inline: inline.normal
38656       };
38657       if (this.options.pedantic) {
38658         rules.block = block.pedantic;
38659         rules.inline = inline.pedantic;
38660       } else if (this.options.gfm) {
38661         rules.block = block.gfm;
38662         if (this.options.breaks) {
38663           rules.inline = inline.breaks;
38664         } else {
38665           rules.inline = inline.gfm;
38666         }
38667       }
38668       this.tokenizer.rules = rules;
38669     }
38670     /**
38671      * Expose Rules
38672      */
38673     static get rules() {
38674       return {
38675         block,
38676         inline
38677       };
38678     }
38679     /**
38680      * Static Lex Method
38681      */
38682     static lex(src, options2) {
38683       const lexer2 = new __Lexer(options2);
38684       return lexer2.lex(src);
38685     }
38686     /**
38687      * Static Lex Inline Method
38688      */
38689     static lexInline(src, options2) {
38690       const lexer2 = new __Lexer(options2);
38691       return lexer2.inlineTokens(src);
38692     }
38693     /**
38694      * Preprocessing
38695      */
38696     lex(src) {
38697       src = src.replace(other.carriageReturn, "\n");
38698       this.blockTokens(src, this.tokens);
38699       for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
38700         const next = this.inlineQueue[i3];
38701         this.inlineTokens(next.src, next.tokens);
38702       }
38703       this.inlineQueue = [];
38704       return this.tokens;
38705     }
38706     blockTokens(src, tokens = [], lastParagraphClipped = false) {
38707       var _a4, _b3, _c2;
38708       if (this.options.pedantic) {
38709         src = src.replace(other.tabCharGlobal, "    ").replace(other.spaceLine, "");
38710       }
38711       while (src) {
38712         let token;
38713         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.block) == null ? void 0 : _b3.some((extTokenizer) => {
38714           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
38715             src = src.substring(token.raw.length);
38716             tokens.push(token);
38717             return true;
38718           }
38719           return false;
38720         })) {
38721           continue;
38722         }
38723         if (token = this.tokenizer.space(src)) {
38724           src = src.substring(token.raw.length);
38725           const lastToken = tokens.at(-1);
38726           if (token.raw.length === 1 && lastToken !== void 0) {
38727             lastToken.raw += "\n";
38728           } else {
38729             tokens.push(token);
38730           }
38731           continue;
38732         }
38733         if (token = this.tokenizer.code(src)) {
38734           src = src.substring(token.raw.length);
38735           const lastToken = tokens.at(-1);
38736           if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
38737             lastToken.raw += "\n" + token.raw;
38738             lastToken.text += "\n" + token.text;
38739             this.inlineQueue.at(-1).src = lastToken.text;
38740           } else {
38741             tokens.push(token);
38742           }
38743           continue;
38744         }
38745         if (token = this.tokenizer.fences(src)) {
38746           src = src.substring(token.raw.length);
38747           tokens.push(token);
38748           continue;
38749         }
38750         if (token = this.tokenizer.heading(src)) {
38751           src = src.substring(token.raw.length);
38752           tokens.push(token);
38753           continue;
38754         }
38755         if (token = this.tokenizer.hr(src)) {
38756           src = src.substring(token.raw.length);
38757           tokens.push(token);
38758           continue;
38759         }
38760         if (token = this.tokenizer.blockquote(src)) {
38761           src = src.substring(token.raw.length);
38762           tokens.push(token);
38763           continue;
38764         }
38765         if (token = this.tokenizer.list(src)) {
38766           src = src.substring(token.raw.length);
38767           tokens.push(token);
38768           continue;
38769         }
38770         if (token = this.tokenizer.html(src)) {
38771           src = src.substring(token.raw.length);
38772           tokens.push(token);
38773           continue;
38774         }
38775         if (token = this.tokenizer.def(src)) {
38776           src = src.substring(token.raw.length);
38777           const lastToken = tokens.at(-1);
38778           if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
38779             lastToken.raw += "\n" + token.raw;
38780             lastToken.text += "\n" + token.raw;
38781             this.inlineQueue.at(-1).src = lastToken.text;
38782           } else if (!this.tokens.links[token.tag]) {
38783             this.tokens.links[token.tag] = {
38784               href: token.href,
38785               title: token.title
38786             };
38787           }
38788           continue;
38789         }
38790         if (token = this.tokenizer.table(src)) {
38791           src = src.substring(token.raw.length);
38792           tokens.push(token);
38793           continue;
38794         }
38795         if (token = this.tokenizer.lheading(src)) {
38796           src = src.substring(token.raw.length);
38797           tokens.push(token);
38798           continue;
38799         }
38800         let cutSrc = src;
38801         if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startBlock) {
38802           let startIndex = Infinity;
38803           const tempSrc = src.slice(1);
38804           let tempStart;
38805           this.options.extensions.startBlock.forEach((getStartIndex) => {
38806             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
38807             if (typeof tempStart === "number" && tempStart >= 0) {
38808               startIndex = Math.min(startIndex, tempStart);
38809             }
38810           });
38811           if (startIndex < Infinity && startIndex >= 0) {
38812             cutSrc = src.substring(0, startIndex + 1);
38813           }
38814         }
38815         if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
38816           const lastToken = tokens.at(-1);
38817           if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
38818             lastToken.raw += "\n" + token.raw;
38819             lastToken.text += "\n" + token.text;
38820             this.inlineQueue.pop();
38821             this.inlineQueue.at(-1).src = lastToken.text;
38822           } else {
38823             tokens.push(token);
38824           }
38825           lastParagraphClipped = cutSrc.length !== src.length;
38826           src = src.substring(token.raw.length);
38827           continue;
38828         }
38829         if (token = this.tokenizer.text(src)) {
38830           src = src.substring(token.raw.length);
38831           const lastToken = tokens.at(-1);
38832           if ((lastToken == null ? void 0 : lastToken.type) === "text") {
38833             lastToken.raw += "\n" + token.raw;
38834             lastToken.text += "\n" + token.text;
38835             this.inlineQueue.pop();
38836             this.inlineQueue.at(-1).src = lastToken.text;
38837           } else {
38838             tokens.push(token);
38839           }
38840           continue;
38841         }
38842         if (src) {
38843           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
38844           if (this.options.silent) {
38845             console.error(errMsg);
38846             break;
38847           } else {
38848             throw new Error(errMsg);
38849           }
38850         }
38851       }
38852       this.state.top = true;
38853       return tokens;
38854     }
38855     inline(src, tokens = []) {
38856       this.inlineQueue.push({ src, tokens });
38857       return tokens;
38858     }
38859     /**
38860      * Lexing/Compiling
38861      */
38862     inlineTokens(src, tokens = []) {
38863       var _a4, _b3, _c2;
38864       let maskedSrc = src;
38865       let match = null;
38866       if (this.tokens.links) {
38867         const links = Object.keys(this.tokens.links);
38868         if (links.length > 0) {
38869           while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
38870             if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
38871               maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
38872             }
38873           }
38874         }
38875       }
38876       while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
38877         maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
38878       }
38879       while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
38880         maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
38881       }
38882       let keepPrevChar = false;
38883       let prevChar = "";
38884       while (src) {
38885         if (!keepPrevChar) {
38886           prevChar = "";
38887         }
38888         keepPrevChar = false;
38889         let token;
38890         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.inline) == null ? void 0 : _b3.some((extTokenizer) => {
38891           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
38892             src = src.substring(token.raw.length);
38893             tokens.push(token);
38894             return true;
38895           }
38896           return false;
38897         })) {
38898           continue;
38899         }
38900         if (token = this.tokenizer.escape(src)) {
38901           src = src.substring(token.raw.length);
38902           tokens.push(token);
38903           continue;
38904         }
38905         if (token = this.tokenizer.tag(src)) {
38906           src = src.substring(token.raw.length);
38907           tokens.push(token);
38908           continue;
38909         }
38910         if (token = this.tokenizer.link(src)) {
38911           src = src.substring(token.raw.length);
38912           tokens.push(token);
38913           continue;
38914         }
38915         if (token = this.tokenizer.reflink(src, this.tokens.links)) {
38916           src = src.substring(token.raw.length);
38917           const lastToken = tokens.at(-1);
38918           if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") {
38919             lastToken.raw += token.raw;
38920             lastToken.text += token.text;
38921           } else {
38922             tokens.push(token);
38923           }
38924           continue;
38925         }
38926         if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
38927           src = src.substring(token.raw.length);
38928           tokens.push(token);
38929           continue;
38930         }
38931         if (token = this.tokenizer.codespan(src)) {
38932           src = src.substring(token.raw.length);
38933           tokens.push(token);
38934           continue;
38935         }
38936         if (token = this.tokenizer.br(src)) {
38937           src = src.substring(token.raw.length);
38938           tokens.push(token);
38939           continue;
38940         }
38941         if (token = this.tokenizer.del(src)) {
38942           src = src.substring(token.raw.length);
38943           tokens.push(token);
38944           continue;
38945         }
38946         if (token = this.tokenizer.autolink(src)) {
38947           src = src.substring(token.raw.length);
38948           tokens.push(token);
38949           continue;
38950         }
38951         if (!this.state.inLink && (token = this.tokenizer.url(src))) {
38952           src = src.substring(token.raw.length);
38953           tokens.push(token);
38954           continue;
38955         }
38956         let cutSrc = src;
38957         if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startInline) {
38958           let startIndex = Infinity;
38959           const tempSrc = src.slice(1);
38960           let tempStart;
38961           this.options.extensions.startInline.forEach((getStartIndex) => {
38962             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
38963             if (typeof tempStart === "number" && tempStart >= 0) {
38964               startIndex = Math.min(startIndex, tempStart);
38965             }
38966           });
38967           if (startIndex < Infinity && startIndex >= 0) {
38968             cutSrc = src.substring(0, startIndex + 1);
38969           }
38970         }
38971         if (token = this.tokenizer.inlineText(cutSrc)) {
38972           src = src.substring(token.raw.length);
38973           if (token.raw.slice(-1) !== "_") {
38974             prevChar = token.raw.slice(-1);
38975           }
38976           keepPrevChar = true;
38977           const lastToken = tokens.at(-1);
38978           if ((lastToken == null ? void 0 : lastToken.type) === "text") {
38979             lastToken.raw += token.raw;
38980             lastToken.text += token.text;
38981           } else {
38982             tokens.push(token);
38983           }
38984           continue;
38985         }
38986         if (src) {
38987           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
38988           if (this.options.silent) {
38989             console.error(errMsg);
38990             break;
38991           } else {
38992             throw new Error(errMsg);
38993           }
38994         }
38995       }
38996       return tokens;
38997     }
38998   };
38999   var _Renderer = class {
39000     // set by the parser
39001     constructor(options2) {
39002       __publicField(this, "options");
39003       __publicField(this, "parser");
39004       this.options = options2 || _defaults;
39005     }
39006     space(token) {
39007       return "";
39008     }
39009     code({ text, lang, escaped }) {
39010       var _a4;
39011       const langString = (_a4 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a4[0];
39012       const code = text.replace(other.endingNewline, "") + "\n";
39013       if (!langString) {
39014         return "<pre><code>" + (escaped ? code : escape4(code, true)) + "</code></pre>\n";
39015       }
39016       return '<pre><code class="language-' + escape4(langString) + '">' + (escaped ? code : escape4(code, true)) + "</code></pre>\n";
39017     }
39018     blockquote({ tokens }) {
39019       const body = this.parser.parse(tokens);
39020       return "<blockquote>\n".concat(body, "</blockquote>\n");
39021     }
39022     html({ text }) {
39023       return text;
39024     }
39025     heading({ tokens, depth }) {
39026       return "<h".concat(depth, ">").concat(this.parser.parseInline(tokens), "</h").concat(depth, ">\n");
39027     }
39028     hr(token) {
39029       return "<hr>\n";
39030     }
39031     list(token) {
39032       const ordered = token.ordered;
39033       const start2 = token.start;
39034       let body = "";
39035       for (let j2 = 0; j2 < token.items.length; j2++) {
39036         const item = token.items[j2];
39037         body += this.listitem(item);
39038       }
39039       const type2 = ordered ? "ol" : "ul";
39040       const startAttr = ordered && start2 !== 1 ? ' start="' + start2 + '"' : "";
39041       return "<" + type2 + startAttr + ">\n" + body + "</" + type2 + ">\n";
39042     }
39043     listitem(item) {
39044       var _a4;
39045       let itemBody = "";
39046       if (item.task) {
39047         const checkbox = this.checkbox({ checked: !!item.checked });
39048         if (item.loose) {
39049           if (((_a4 = item.tokens[0]) == null ? void 0 : _a4.type) === "paragraph") {
39050             item.tokens[0].text = checkbox + " " + item.tokens[0].text;
39051             if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
39052               item.tokens[0].tokens[0].text = checkbox + " " + escape4(item.tokens[0].tokens[0].text);
39053               item.tokens[0].tokens[0].escaped = true;
39054             }
39055           } else {
39056             item.tokens.unshift({
39057               type: "text",
39058               raw: checkbox + " ",
39059               text: checkbox + " ",
39060               escaped: true
39061             });
39062           }
39063         } else {
39064           itemBody += checkbox + " ";
39065         }
39066       }
39067       itemBody += this.parser.parse(item.tokens, !!item.loose);
39068       return "<li>".concat(itemBody, "</li>\n");
39069     }
39070     checkbox({ checked }) {
39071       return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
39072     }
39073     paragraph({ tokens }) {
39074       return "<p>".concat(this.parser.parseInline(tokens), "</p>\n");
39075     }
39076     table(token) {
39077       let header = "";
39078       let cell = "";
39079       for (let j2 = 0; j2 < token.header.length; j2++) {
39080         cell += this.tablecell(token.header[j2]);
39081       }
39082       header += this.tablerow({ text: cell });
39083       let body = "";
39084       for (let j2 = 0; j2 < token.rows.length; j2++) {
39085         const row = token.rows[j2];
39086         cell = "";
39087         for (let k2 = 0; k2 < row.length; k2++) {
39088           cell += this.tablecell(row[k2]);
39089         }
39090         body += this.tablerow({ text: cell });
39091       }
39092       if (body)
39093         body = "<tbody>".concat(body, "</tbody>");
39094       return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
39095     }
39096     tablerow({ text }) {
39097       return "<tr>\n".concat(text, "</tr>\n");
39098     }
39099     tablecell(token) {
39100       const content = this.parser.parseInline(token.tokens);
39101       const type2 = token.header ? "th" : "td";
39102       const tag2 = token.align ? "<".concat(type2, ' align="').concat(token.align, '">') : "<".concat(type2, ">");
39103       return tag2 + content + "</".concat(type2, ">\n");
39104     }
39105     /**
39106      * span level renderer
39107      */
39108     strong({ tokens }) {
39109       return "<strong>".concat(this.parser.parseInline(tokens), "</strong>");
39110     }
39111     em({ tokens }) {
39112       return "<em>".concat(this.parser.parseInline(tokens), "</em>");
39113     }
39114     codespan({ text }) {
39115       return "<code>".concat(escape4(text, true), "</code>");
39116     }
39117     br(token) {
39118       return "<br>";
39119     }
39120     del({ tokens }) {
39121       return "<del>".concat(this.parser.parseInline(tokens), "</del>");
39122     }
39123     link({ href, title, tokens }) {
39124       const text = this.parser.parseInline(tokens);
39125       const cleanHref = cleanUrl(href);
39126       if (cleanHref === null) {
39127         return text;
39128       }
39129       href = cleanHref;
39130       let out = '<a href="' + href + '"';
39131       if (title) {
39132         out += ' title="' + escape4(title) + '"';
39133       }
39134       out += ">" + text + "</a>";
39135       return out;
39136     }
39137     image({ href, title, text }) {
39138       const cleanHref = cleanUrl(href);
39139       if (cleanHref === null) {
39140         return escape4(text);
39141       }
39142       href = cleanHref;
39143       let out = '<img src="'.concat(href, '" alt="').concat(text, '"');
39144       if (title) {
39145         out += ' title="'.concat(escape4(title), '"');
39146       }
39147       out += ">";
39148       return out;
39149     }
39150     text(token) {
39151       return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape4(token.text);
39152     }
39153   };
39154   var _TextRenderer = class {
39155     // no need for block level renderers
39156     strong({ text }) {
39157       return text;
39158     }
39159     em({ text }) {
39160       return text;
39161     }
39162     codespan({ text }) {
39163       return text;
39164     }
39165     del({ text }) {
39166       return text;
39167     }
39168     html({ text }) {
39169       return text;
39170     }
39171     text({ text }) {
39172       return text;
39173     }
39174     link({ text }) {
39175       return "" + text;
39176     }
39177     image({ text }) {
39178       return "" + text;
39179     }
39180     br() {
39181       return "";
39182     }
39183   };
39184   var _Parser = class __Parser {
39185     constructor(options2) {
39186       __publicField(this, "options");
39187       __publicField(this, "renderer");
39188       __publicField(this, "textRenderer");
39189       this.options = options2 || _defaults;
39190       this.options.renderer = this.options.renderer || new _Renderer();
39191       this.renderer = this.options.renderer;
39192       this.renderer.options = this.options;
39193       this.renderer.parser = this;
39194       this.textRenderer = new _TextRenderer();
39195     }
39196     /**
39197      * Static Parse Method
39198      */
39199     static parse(tokens, options2) {
39200       const parser3 = new __Parser(options2);
39201       return parser3.parse(tokens);
39202     }
39203     /**
39204      * Static Parse Inline Method
39205      */
39206     static parseInline(tokens, options2) {
39207       const parser3 = new __Parser(options2);
39208       return parser3.parseInline(tokens);
39209     }
39210     /**
39211      * Parse Loop
39212      */
39213     parse(tokens, top = true) {
39214       var _a4, _b3;
39215       let out = "";
39216       for (let i3 = 0; i3 < tokens.length; i3++) {
39217         const anyToken = tokens[i3];
39218         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.renderers) == null ? void 0 : _b3[anyToken.type]) {
39219           const genericToken = anyToken;
39220           const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
39221           if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
39222             out += ret || "";
39223             continue;
39224           }
39225         }
39226         const token = anyToken;
39227         switch (token.type) {
39228           case "space": {
39229             out += this.renderer.space(token);
39230             continue;
39231           }
39232           case "hr": {
39233             out += this.renderer.hr(token);
39234             continue;
39235           }
39236           case "heading": {
39237             out += this.renderer.heading(token);
39238             continue;
39239           }
39240           case "code": {
39241             out += this.renderer.code(token);
39242             continue;
39243           }
39244           case "table": {
39245             out += this.renderer.table(token);
39246             continue;
39247           }
39248           case "blockquote": {
39249             out += this.renderer.blockquote(token);
39250             continue;
39251           }
39252           case "list": {
39253             out += this.renderer.list(token);
39254             continue;
39255           }
39256           case "html": {
39257             out += this.renderer.html(token);
39258             continue;
39259           }
39260           case "paragraph": {
39261             out += this.renderer.paragraph(token);
39262             continue;
39263           }
39264           case "text": {
39265             let textToken = token;
39266             let body = this.renderer.text(textToken);
39267             while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
39268               textToken = tokens[++i3];
39269               body += "\n" + this.renderer.text(textToken);
39270             }
39271             if (top) {
39272               out += this.renderer.paragraph({
39273                 type: "paragraph",
39274                 raw: body,
39275                 text: body,
39276                 tokens: [{ type: "text", raw: body, text: body, escaped: true }]
39277               });
39278             } else {
39279               out += body;
39280             }
39281             continue;
39282           }
39283           default: {
39284             const errMsg = 'Token with "' + token.type + '" type was not found.';
39285             if (this.options.silent) {
39286               console.error(errMsg);
39287               return "";
39288             } else {
39289               throw new Error(errMsg);
39290             }
39291           }
39292         }
39293       }
39294       return out;
39295     }
39296     /**
39297      * Parse Inline Tokens
39298      */
39299     parseInline(tokens, renderer = this.renderer) {
39300       var _a4, _b3;
39301       let out = "";
39302       for (let i3 = 0; i3 < tokens.length; i3++) {
39303         const anyToken = tokens[i3];
39304         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.renderers) == null ? void 0 : _b3[anyToken.type]) {
39305           const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
39306           if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
39307             out += ret || "";
39308             continue;
39309           }
39310         }
39311         const token = anyToken;
39312         switch (token.type) {
39313           case "escape": {
39314             out += renderer.text(token);
39315             break;
39316           }
39317           case "html": {
39318             out += renderer.html(token);
39319             break;
39320           }
39321           case "link": {
39322             out += renderer.link(token);
39323             break;
39324           }
39325           case "image": {
39326             out += renderer.image(token);
39327             break;
39328           }
39329           case "strong": {
39330             out += renderer.strong(token);
39331             break;
39332           }
39333           case "em": {
39334             out += renderer.em(token);
39335             break;
39336           }
39337           case "codespan": {
39338             out += renderer.codespan(token);
39339             break;
39340           }
39341           case "br": {
39342             out += renderer.br(token);
39343             break;
39344           }
39345           case "del": {
39346             out += renderer.del(token);
39347             break;
39348           }
39349           case "text": {
39350             out += renderer.text(token);
39351             break;
39352           }
39353           default: {
39354             const errMsg = 'Token with "' + token.type + '" type was not found.';
39355             if (this.options.silent) {
39356               console.error(errMsg);
39357               return "";
39358             } else {
39359               throw new Error(errMsg);
39360             }
39361           }
39362         }
39363       }
39364       return out;
39365     }
39366   };
39367   var _Hooks = class {
39368     constructor(options2) {
39369       __publicField(this, "options");
39370       __publicField(this, "block");
39371       this.options = options2 || _defaults;
39372     }
39373     /**
39374      * Process markdown before marked
39375      */
39376     preprocess(markdown) {
39377       return markdown;
39378     }
39379     /**
39380      * Process HTML after marked is finished
39381      */
39382     postprocess(html3) {
39383       return html3;
39384     }
39385     /**
39386      * Process all tokens before walk tokens
39387      */
39388     processAllTokens(tokens) {
39389       return tokens;
39390     }
39391     /**
39392      * Provide function to tokenize markdown
39393      */
39394     provideLexer() {
39395       return this.block ? _Lexer.lex : _Lexer.lexInline;
39396     }
39397     /**
39398      * Provide function to parse tokens
39399      */
39400     provideParser() {
39401       return this.block ? _Parser.parse : _Parser.parseInline;
39402     }
39403   };
39404   __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
39405     "preprocess",
39406     "postprocess",
39407     "processAllTokens"
39408   ]));
39409   var Marked = class {
39410     constructor(...args) {
39411       __publicField(this, "defaults", _getDefaults());
39412       __publicField(this, "options", this.setOptions);
39413       __publicField(this, "parse", this.parseMarkdown(true));
39414       __publicField(this, "parseInline", this.parseMarkdown(false));
39415       __publicField(this, "Parser", _Parser);
39416       __publicField(this, "Renderer", _Renderer);
39417       __publicField(this, "TextRenderer", _TextRenderer);
39418       __publicField(this, "Lexer", _Lexer);
39419       __publicField(this, "Tokenizer", _Tokenizer);
39420       __publicField(this, "Hooks", _Hooks);
39421       this.use(...args);
39422     }
39423     /**
39424      * Run callback for every token
39425      */
39426     walkTokens(tokens, callback) {
39427       var _a4, _b3;
39428       let values = [];
39429       for (const token of tokens) {
39430         values = values.concat(callback.call(this, token));
39431         switch (token.type) {
39432           case "table": {
39433             const tableToken = token;
39434             for (const cell of tableToken.header) {
39435               values = values.concat(this.walkTokens(cell.tokens, callback));
39436             }
39437             for (const row of tableToken.rows) {
39438               for (const cell of row) {
39439                 values = values.concat(this.walkTokens(cell.tokens, callback));
39440               }
39441             }
39442             break;
39443           }
39444           case "list": {
39445             const listToken = token;
39446             values = values.concat(this.walkTokens(listToken.items, callback));
39447             break;
39448           }
39449           default: {
39450             const genericToken = token;
39451             if ((_b3 = (_a4 = this.defaults.extensions) == null ? void 0 : _a4.childTokens) == null ? void 0 : _b3[genericToken.type]) {
39452               this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
39453                 const tokens2 = genericToken[childTokens].flat(Infinity);
39454                 values = values.concat(this.walkTokens(tokens2, callback));
39455               });
39456             } else if (genericToken.tokens) {
39457               values = values.concat(this.walkTokens(genericToken.tokens, callback));
39458             }
39459           }
39460         }
39461       }
39462       return values;
39463     }
39464     use(...args) {
39465       const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
39466       args.forEach((pack) => {
39467         const opts = __spreadValues({}, pack);
39468         opts.async = this.defaults.async || opts.async || false;
39469         if (pack.extensions) {
39470           pack.extensions.forEach((ext) => {
39471             if (!ext.name) {
39472               throw new Error("extension name required");
39473             }
39474             if ("renderer" in ext) {
39475               const prevRenderer = extensions.renderers[ext.name];
39476               if (prevRenderer) {
39477                 extensions.renderers[ext.name] = function(...args2) {
39478                   let ret = ext.renderer.apply(this, args2);
39479                   if (ret === false) {
39480                     ret = prevRenderer.apply(this, args2);
39481                   }
39482                   return ret;
39483                 };
39484               } else {
39485                 extensions.renderers[ext.name] = ext.renderer;
39486               }
39487             }
39488             if ("tokenizer" in ext) {
39489               if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
39490                 throw new Error("extension level must be 'block' or 'inline'");
39491               }
39492               const extLevel = extensions[ext.level];
39493               if (extLevel) {
39494                 extLevel.unshift(ext.tokenizer);
39495               } else {
39496                 extensions[ext.level] = [ext.tokenizer];
39497               }
39498               if (ext.start) {
39499                 if (ext.level === "block") {
39500                   if (extensions.startBlock) {
39501                     extensions.startBlock.push(ext.start);
39502                   } else {
39503                     extensions.startBlock = [ext.start];
39504                   }
39505                 } else if (ext.level === "inline") {
39506                   if (extensions.startInline) {
39507                     extensions.startInline.push(ext.start);
39508                   } else {
39509                     extensions.startInline = [ext.start];
39510                   }
39511                 }
39512               }
39513             }
39514             if ("childTokens" in ext && ext.childTokens) {
39515               extensions.childTokens[ext.name] = ext.childTokens;
39516             }
39517           });
39518           opts.extensions = extensions;
39519         }
39520         if (pack.renderer) {
39521           const renderer = this.defaults.renderer || new _Renderer(this.defaults);
39522           for (const prop in pack.renderer) {
39523             if (!(prop in renderer)) {
39524               throw new Error("renderer '".concat(prop, "' does not exist"));
39525             }
39526             if (["options", "parser"].includes(prop)) {
39527               continue;
39528             }
39529             const rendererProp = prop;
39530             const rendererFunc = pack.renderer[rendererProp];
39531             const prevRenderer = renderer[rendererProp];
39532             renderer[rendererProp] = (...args2) => {
39533               let ret = rendererFunc.apply(renderer, args2);
39534               if (ret === false) {
39535                 ret = prevRenderer.apply(renderer, args2);
39536               }
39537               return ret || "";
39538             };
39539           }
39540           opts.renderer = renderer;
39541         }
39542         if (pack.tokenizer) {
39543           const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
39544           for (const prop in pack.tokenizer) {
39545             if (!(prop in tokenizer)) {
39546               throw new Error("tokenizer '".concat(prop, "' does not exist"));
39547             }
39548             if (["options", "rules", "lexer"].includes(prop)) {
39549               continue;
39550             }
39551             const tokenizerProp = prop;
39552             const tokenizerFunc = pack.tokenizer[tokenizerProp];
39553             const prevTokenizer = tokenizer[tokenizerProp];
39554             tokenizer[tokenizerProp] = (...args2) => {
39555               let ret = tokenizerFunc.apply(tokenizer, args2);
39556               if (ret === false) {
39557                 ret = prevTokenizer.apply(tokenizer, args2);
39558               }
39559               return ret;
39560             };
39561           }
39562           opts.tokenizer = tokenizer;
39563         }
39564         if (pack.hooks) {
39565           const hooks = this.defaults.hooks || new _Hooks();
39566           for (const prop in pack.hooks) {
39567             if (!(prop in hooks)) {
39568               throw new Error("hook '".concat(prop, "' does not exist"));
39569             }
39570             if (["options", "block"].includes(prop)) {
39571               continue;
39572             }
39573             const hooksProp = prop;
39574             const hooksFunc = pack.hooks[hooksProp];
39575             const prevHook = hooks[hooksProp];
39576             if (_Hooks.passThroughHooks.has(prop)) {
39577               hooks[hooksProp] = (arg) => {
39578                 if (this.defaults.async) {
39579                   return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
39580                     return prevHook.call(hooks, ret2);
39581                   });
39582                 }
39583                 const ret = hooksFunc.call(hooks, arg);
39584                 return prevHook.call(hooks, ret);
39585               };
39586             } else {
39587               hooks[hooksProp] = (...args2) => {
39588                 let ret = hooksFunc.apply(hooks, args2);
39589                 if (ret === false) {
39590                   ret = prevHook.apply(hooks, args2);
39591                 }
39592                 return ret;
39593               };
39594             }
39595           }
39596           opts.hooks = hooks;
39597         }
39598         if (pack.walkTokens) {
39599           const walkTokens2 = this.defaults.walkTokens;
39600           const packWalktokens = pack.walkTokens;
39601           opts.walkTokens = function(token) {
39602             let values = [];
39603             values.push(packWalktokens.call(this, token));
39604             if (walkTokens2) {
39605               values = values.concat(walkTokens2.call(this, token));
39606             }
39607             return values;
39608           };
39609         }
39610         this.defaults = __spreadValues(__spreadValues({}, this.defaults), opts);
39611       });
39612       return this;
39613     }
39614     setOptions(opt) {
39615       this.defaults = __spreadValues(__spreadValues({}, this.defaults), opt);
39616       return this;
39617     }
39618     lexer(src, options2) {
39619       return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
39620     }
39621     parser(tokens, options2) {
39622       return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
39623     }
39624     parseMarkdown(blockType) {
39625       const parse = (src, options2) => {
39626         const origOpt = __spreadValues({}, options2);
39627         const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt);
39628         const throwError = this.onError(!!opt.silent, !!opt.async);
39629         if (this.defaults.async === true && origOpt.async === false) {
39630           return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
39631         }
39632         if (typeof src === "undefined" || src === null) {
39633           return throwError(new Error("marked(): input parameter is undefined or null"));
39634         }
39635         if (typeof src !== "string") {
39636           return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
39637         }
39638         if (opt.hooks) {
39639           opt.hooks.options = opt;
39640           opt.hooks.block = blockType;
39641         }
39642         const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
39643         const parser3 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
39644         if (opt.async) {
39645           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);
39646         }
39647         try {
39648           if (opt.hooks) {
39649             src = opt.hooks.preprocess(src);
39650           }
39651           let tokens = lexer2(src, opt);
39652           if (opt.hooks) {
39653             tokens = opt.hooks.processAllTokens(tokens);
39654           }
39655           if (opt.walkTokens) {
39656             this.walkTokens(tokens, opt.walkTokens);
39657           }
39658           let html3 = parser3(tokens, opt);
39659           if (opt.hooks) {
39660             html3 = opt.hooks.postprocess(html3);
39661           }
39662           return html3;
39663         } catch (e3) {
39664           return throwError(e3);
39665         }
39666       };
39667       return parse;
39668     }
39669     onError(silent, async) {
39670       return (e3) => {
39671         e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
39672         if (silent) {
39673           const msg = "<p>An error occurred:</p><pre>" + escape4(e3.message + "", true) + "</pre>";
39674           if (async) {
39675             return Promise.resolve(msg);
39676           }
39677           return msg;
39678         }
39679         if (async) {
39680           return Promise.reject(e3);
39681         }
39682         throw e3;
39683       };
39684     }
39685   };
39686   var markedInstance = new Marked();
39687   function marked(src, opt) {
39688     return markedInstance.parse(src, opt);
39689   }
39690   marked.options = marked.setOptions = function(options2) {
39691     markedInstance.setOptions(options2);
39692     marked.defaults = markedInstance.defaults;
39693     changeDefaults(marked.defaults);
39694     return marked;
39695   };
39696   marked.getDefaults = _getDefaults;
39697   marked.defaults = _defaults;
39698   marked.use = function(...args) {
39699     markedInstance.use(...args);
39700     marked.defaults = markedInstance.defaults;
39701     changeDefaults(marked.defaults);
39702     return marked;
39703   };
39704   marked.walkTokens = function(tokens, callback) {
39705     return markedInstance.walkTokens(tokens, callback);
39706   };
39707   marked.parseInline = markedInstance.parseInline;
39708   marked.Parser = _Parser;
39709   marked.parser = _Parser.parse;
39710   marked.Renderer = _Renderer;
39711   marked.TextRenderer = _TextRenderer;
39712   marked.Lexer = _Lexer;
39713   marked.lexer = _Lexer.lex;
39714   marked.Tokenizer = _Tokenizer;
39715   marked.Hooks = _Hooks;
39716   marked.parse = marked;
39717   var options = marked.options;
39718   var setOptions = marked.setOptions;
39719   var use = marked.use;
39720   var walkTokens = marked.walkTokens;
39721   var parseInline = marked.parseInline;
39722   var parser2 = _Parser.parse;
39723   var lexer = _Lexer.lex;
39724
39725   // modules/services/osmose.js
39726   var tiler2 = utilTiler();
39727   var dispatch3 = dispatch_default("loaded");
39728   var _tileZoom2 = 14;
39729   var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3";
39730   var _osmoseData = { icons: {}, items: [] };
39731   var _cache2;
39732   function abortRequest2(controller) {
39733     if (controller) {
39734       controller.abort();
39735     }
39736   }
39737   function abortUnwantedRequests2(cache, tiles) {
39738     Object.keys(cache.inflightTile).forEach((k2) => {
39739       let wanted = tiles.find((tile) => k2 === tile.id);
39740       if (!wanted) {
39741         abortRequest2(cache.inflightTile[k2]);
39742         delete cache.inflightTile[k2];
39743       }
39744     });
39745   }
39746   function encodeIssueRtree2(d2) {
39747     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39748   }
39749   function updateRtree2(item, replace) {
39750     _cache2.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39751     if (replace) {
39752       _cache2.rtree.insert(item);
39753     }
39754   }
39755   function preventCoincident(loc) {
39756     let coincident = false;
39757     do {
39758       let delta = coincident ? [1e-5, 0] : [0, 1e-5];
39759       loc = geoVecAdd(loc, delta);
39760       let bbox2 = geoExtent(loc).bbox();
39761       coincident = _cache2.rtree.search(bbox2).length;
39762     } while (coincident);
39763     return loc;
39764   }
39765   var osmose_default = {
39766     title: "osmose",
39767     init() {
39768       _mainFileFetcher.get("qa_data").then((d2) => {
39769         _osmoseData = d2.osmose;
39770         _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []);
39771       });
39772       if (!_cache2) {
39773         this.reset();
39774       }
39775       this.event = utilRebind(this, dispatch3, "on");
39776     },
39777     reset() {
39778       let _strings = {};
39779       let _colors = {};
39780       if (_cache2) {
39781         Object.values(_cache2.inflightTile).forEach(abortRequest2);
39782         _strings = _cache2.strings;
39783         _colors = _cache2.colors;
39784       }
39785       _cache2 = {
39786         data: {},
39787         loadedTile: {},
39788         inflightTile: {},
39789         inflightPost: {},
39790         closed: {},
39791         rtree: new RBush(),
39792         strings: _strings,
39793         colors: _colors
39794       };
39795     },
39796     loadIssues(projection2) {
39797       let params = {
39798         // Tiles return a maximum # of issues
39799         // So we want to filter our request for only types iD supports
39800         item: _osmoseData.items
39801       };
39802       let tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2);
39803       abortUnwantedRequests2(_cache2, tiles);
39804       tiles.forEach((tile) => {
39805         if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id]) return;
39806         let [x2, y2, z2] = tile.xyz;
39807         let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params);
39808         let controller = new AbortController();
39809         _cache2.inflightTile[tile.id] = controller;
39810         json_default(url, { signal: controller.signal }).then((data) => {
39811           delete _cache2.inflightTile[tile.id];
39812           _cache2.loadedTile[tile.id] = true;
39813           if (data.features) {
39814             data.features.forEach((issue) => {
39815               const { item, class: cl, uuid: id2 } = issue.properties;
39816               const itemType = "".concat(item, "-").concat(cl);
39817               if (itemType in _osmoseData.icons) {
39818                 let loc = issue.geometry.coordinates;
39819                 loc = preventCoincident(loc);
39820                 let d2 = new QAItem(loc, this, itemType, id2, { item });
39821                 if (item === 8300 || item === 8360) {
39822                   d2.elems = [];
39823                 }
39824                 _cache2.data[d2.id] = d2;
39825                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39826               }
39827             });
39828           }
39829           dispatch3.call("loaded");
39830         }).catch(() => {
39831           delete _cache2.inflightTile[tile.id];
39832           _cache2.loadedTile[tile.id] = true;
39833         });
39834       });
39835     },
39836     loadIssueDetail(issue) {
39837       if (issue.elems !== void 0) {
39838         return Promise.resolve(issue);
39839       }
39840       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode());
39841       const cacheDetails = (data) => {
39842         issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id);
39843         issue.detail = data.subtitle ? marked(data.subtitle.auto) : "";
39844         this.replaceItem(issue);
39845       };
39846       return json_default(url).then(cacheDetails).then(() => issue);
39847     },
39848     loadStrings(locale2 = _mainLocalizer.localeCode()) {
39849       const items = Object.keys(_osmoseData.icons);
39850       if (locale2 in _cache2.strings && Object.keys(_cache2.strings[locale2]).length === items.length) {
39851         return Promise.resolve(_cache2.strings[locale2]);
39852       }
39853       if (!(locale2 in _cache2.strings)) {
39854         _cache2.strings[locale2] = {};
39855       }
39856       const allRequests = items.map((itemType) => {
39857         if (itemType in _cache2.strings[locale2]) return null;
39858         const cacheData = (data) => {
39859           const [cat = { items: [] }] = data.categories;
39860           const [item2 = { class: [] }] = cat.items;
39861           const [cl2 = null] = item2.class;
39862           if (!cl2) {
39863             console.log("Osmose strings request (".concat(itemType, ") had unexpected data"));
39864             return;
39865           }
39866           const { item: itemInt, color: color2 } = item2;
39867           if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) {
39868             _cache2.colors[itemInt] = color2;
39869           }
39870           const { title, detail, fix, trap } = cl2;
39871           let issueStrings = {};
39872           if (title) issueStrings.title = title.auto;
39873           if (detail) issueStrings.detail = marked(detail.auto);
39874           if (trap) issueStrings.trap = marked(trap.auto);
39875           if (fix) issueStrings.fix = marked(fix.auto);
39876           _cache2.strings[locale2][itemType] = issueStrings;
39877         };
39878         const [item, cl] = itemType.split("-");
39879         const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2);
39880         return json_default(url).then(cacheData);
39881       }).filter(Boolean);
39882       return Promise.all(allRequests).then(() => _cache2.strings[locale2]);
39883     },
39884     getStrings(itemType, locale2 = _mainLocalizer.localeCode()) {
39885       return locale2 in _cache2.strings ? _cache2.strings[locale2][itemType] : {};
39886     },
39887     getColor(itemType) {
39888       return itemType in _cache2.colors ? _cache2.colors[itemType] : "#FFFFFF";
39889     },
39890     postUpdate(issue, callback) {
39891       if (_cache2.inflightPost[issue.id]) {
39892         return callback({ message: "Issue update already inflight", status: -2 }, issue);
39893       }
39894       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus);
39895       const controller = new AbortController();
39896       const after = () => {
39897         delete _cache2.inflightPost[issue.id];
39898         this.removeItem(issue);
39899         if (issue.newStatus === "done") {
39900           if (!(issue.item in _cache2.closed)) {
39901             _cache2.closed[issue.item] = 0;
39902           }
39903           _cache2.closed[issue.item] += 1;
39904         }
39905         if (callback) callback(null, issue);
39906       };
39907       _cache2.inflightPost[issue.id] = controller;
39908       fetch(url, { signal: controller.signal }).then(after).catch((err) => {
39909         delete _cache2.inflightPost[issue.id];
39910         if (callback) callback(err.message);
39911       });
39912     },
39913     // Get all cached QAItems covering the viewport
39914     getItems(projection2) {
39915       const viewport = projection2.clipExtent();
39916       const min3 = [viewport[0][0], viewport[1][1]];
39917       const max3 = [viewport[1][0], viewport[0][1]];
39918       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39919       return _cache2.rtree.search(bbox2).map((d2) => d2.data);
39920     },
39921     // Get a QAItem from cache
39922     // NOTE: Don't change method name until UI v3 is merged
39923     getError(id2) {
39924       return _cache2.data[id2];
39925     },
39926     // get the name of the icon to display for this item
39927     getIcon(itemType) {
39928       return _osmoseData.icons[itemType];
39929     },
39930     // Replace a single QAItem in the cache
39931     replaceItem(item) {
39932       if (!(item instanceof QAItem) || !item.id) return;
39933       _cache2.data[item.id] = item;
39934       updateRtree2(encodeIssueRtree2(item), true);
39935       return item;
39936     },
39937     // Remove a single QAItem from the cache
39938     removeItem(item) {
39939       if (!(item instanceof QAItem) || !item.id) return;
39940       delete _cache2.data[item.id];
39941       updateRtree2(encodeIssueRtree2(item), false);
39942     },
39943     // Used to populate `closed:osmose:*` changeset tags
39944     getClosedCounts() {
39945       return _cache2.closed;
39946     },
39947     itemURL(item) {
39948       return "https://osmose.openstreetmap.fr/en/error/".concat(item.id);
39949     }
39950   };
39951
39952   // node_modules/pbf/index.js
39953   var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
39954   var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
39955   var TEXT_DECODER_MIN_LENGTH = 12;
39956   var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8");
39957   var PBF_VARINT = 0;
39958   var PBF_FIXED64 = 1;
39959   var PBF_BYTES = 2;
39960   var PBF_FIXED32 = 5;
39961   var Pbf = class {
39962     /**
39963      * @param {Uint8Array | ArrayBuffer} [buf]
39964      */
39965     constructor(buf = new Uint8Array(16)) {
39966       this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);
39967       this.dataView = new DataView(this.buf.buffer);
39968       this.pos = 0;
39969       this.type = 0;
39970       this.length = this.buf.length;
39971     }
39972     // === READING =================================================================
39973     /**
39974      * @template T
39975      * @param {(tag: number, result: T, pbf: Pbf) => void} readField
39976      * @param {T} result
39977      * @param {number} [end]
39978      */
39979     readFields(readField, result, end = this.length) {
39980       while (this.pos < end) {
39981         const val = this.readVarint(), tag2 = val >> 3, startPos = this.pos;
39982         this.type = val & 7;
39983         readField(tag2, result, this);
39984         if (this.pos === startPos) this.skip(val);
39985       }
39986       return result;
39987     }
39988     /**
39989      * @template T
39990      * @param {(tag: number, result: T, pbf: Pbf) => void} readField
39991      * @param {T} result
39992      */
39993     readMessage(readField, result) {
39994       return this.readFields(readField, result, this.readVarint() + this.pos);
39995     }
39996     readFixed32() {
39997       const val = this.dataView.getUint32(this.pos, true);
39998       this.pos += 4;
39999       return val;
40000     }
40001     readSFixed32() {
40002       const val = this.dataView.getInt32(this.pos, true);
40003       this.pos += 4;
40004       return val;
40005     }
40006     // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
40007     readFixed64() {
40008       const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;
40009       this.pos += 8;
40010       return val;
40011     }
40012     readSFixed64() {
40013       const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;
40014       this.pos += 8;
40015       return val;
40016     }
40017     readFloat() {
40018       const val = this.dataView.getFloat32(this.pos, true);
40019       this.pos += 4;
40020       return val;
40021     }
40022     readDouble() {
40023       const val = this.dataView.getFloat64(this.pos, true);
40024       this.pos += 8;
40025       return val;
40026     }
40027     /**
40028      * @param {boolean} [isSigned]
40029      */
40030     readVarint(isSigned) {
40031       const buf = this.buf;
40032       let val, b2;
40033       b2 = buf[this.pos++];
40034       val = b2 & 127;
40035       if (b2 < 128) return val;
40036       b2 = buf[this.pos++];
40037       val |= (b2 & 127) << 7;
40038       if (b2 < 128) return val;
40039       b2 = buf[this.pos++];
40040       val |= (b2 & 127) << 14;
40041       if (b2 < 128) return val;
40042       b2 = buf[this.pos++];
40043       val |= (b2 & 127) << 21;
40044       if (b2 < 128) return val;
40045       b2 = buf[this.pos];
40046       val |= (b2 & 15) << 28;
40047       return readVarintRemainder(val, isSigned, this);
40048     }
40049     readVarint64() {
40050       return this.readVarint(true);
40051     }
40052     readSVarint() {
40053       const num = this.readVarint();
40054       return num % 2 === 1 ? (num + 1) / -2 : num / 2;
40055     }
40056     readBoolean() {
40057       return Boolean(this.readVarint());
40058     }
40059     readString() {
40060       const end = this.readVarint() + this.pos;
40061       const pos = this.pos;
40062       this.pos = end;
40063       if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
40064         return utf8TextDecoder.decode(this.buf.subarray(pos, end));
40065       }
40066       return readUtf8(this.buf, pos, end);
40067     }
40068     readBytes() {
40069       const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
40070       this.pos = end;
40071       return buffer;
40072     }
40073     // verbose for performance reasons; doesn't affect gzipped size
40074     /**
40075      * @param {number[]} [arr]
40076      * @param {boolean} [isSigned]
40077      */
40078     readPackedVarint(arr = [], isSigned) {
40079       const end = this.readPackedEnd();
40080       while (this.pos < end) arr.push(this.readVarint(isSigned));
40081       return arr;
40082     }
40083     /** @param {number[]} [arr] */
40084     readPackedSVarint(arr = []) {
40085       const end = this.readPackedEnd();
40086       while (this.pos < end) arr.push(this.readSVarint());
40087       return arr;
40088     }
40089     /** @param {boolean[]} [arr] */
40090     readPackedBoolean(arr = []) {
40091       const end = this.readPackedEnd();
40092       while (this.pos < end) arr.push(this.readBoolean());
40093       return arr;
40094     }
40095     /** @param {number[]} [arr] */
40096     readPackedFloat(arr = []) {
40097       const end = this.readPackedEnd();
40098       while (this.pos < end) arr.push(this.readFloat());
40099       return arr;
40100     }
40101     /** @param {number[]} [arr] */
40102     readPackedDouble(arr = []) {
40103       const end = this.readPackedEnd();
40104       while (this.pos < end) arr.push(this.readDouble());
40105       return arr;
40106     }
40107     /** @param {number[]} [arr] */
40108     readPackedFixed32(arr = []) {
40109       const end = this.readPackedEnd();
40110       while (this.pos < end) arr.push(this.readFixed32());
40111       return arr;
40112     }
40113     /** @param {number[]} [arr] */
40114     readPackedSFixed32(arr = []) {
40115       const end = this.readPackedEnd();
40116       while (this.pos < end) arr.push(this.readSFixed32());
40117       return arr;
40118     }
40119     /** @param {number[]} [arr] */
40120     readPackedFixed64(arr = []) {
40121       const end = this.readPackedEnd();
40122       while (this.pos < end) arr.push(this.readFixed64());
40123       return arr;
40124     }
40125     /** @param {number[]} [arr] */
40126     readPackedSFixed64(arr = []) {
40127       const end = this.readPackedEnd();
40128       while (this.pos < end) arr.push(this.readSFixed64());
40129       return arr;
40130     }
40131     readPackedEnd() {
40132       return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;
40133     }
40134     /** @param {number} val */
40135     skip(val) {
40136       const type2 = val & 7;
40137       if (type2 === PBF_VARINT) while (this.buf[this.pos++] > 127) {
40138       }
40139       else if (type2 === PBF_BYTES) this.pos = this.readVarint() + this.pos;
40140       else if (type2 === PBF_FIXED32) this.pos += 4;
40141       else if (type2 === PBF_FIXED64) this.pos += 8;
40142       else throw new Error("Unimplemented type: ".concat(type2));
40143     }
40144     // === WRITING =================================================================
40145     /**
40146      * @param {number} tag
40147      * @param {number} type
40148      */
40149     writeTag(tag2, type2) {
40150       this.writeVarint(tag2 << 3 | type2);
40151     }
40152     /** @param {number} min */
40153     realloc(min3) {
40154       let length2 = this.length || 16;
40155       while (length2 < this.pos + min3) length2 *= 2;
40156       if (length2 !== this.length) {
40157         const buf = new Uint8Array(length2);
40158         buf.set(this.buf);
40159         this.buf = buf;
40160         this.dataView = new DataView(buf.buffer);
40161         this.length = length2;
40162       }
40163     }
40164     finish() {
40165       this.length = this.pos;
40166       this.pos = 0;
40167       return this.buf.subarray(0, this.length);
40168     }
40169     /** @param {number} val */
40170     writeFixed32(val) {
40171       this.realloc(4);
40172       this.dataView.setInt32(this.pos, val, true);
40173       this.pos += 4;
40174     }
40175     /** @param {number} val */
40176     writeSFixed32(val) {
40177       this.realloc(4);
40178       this.dataView.setInt32(this.pos, val, true);
40179       this.pos += 4;
40180     }
40181     /** @param {number} val */
40182     writeFixed64(val) {
40183       this.realloc(8);
40184       this.dataView.setInt32(this.pos, val & -1, true);
40185       this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
40186       this.pos += 8;
40187     }
40188     /** @param {number} val */
40189     writeSFixed64(val) {
40190       this.realloc(8);
40191       this.dataView.setInt32(this.pos, val & -1, true);
40192       this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
40193       this.pos += 8;
40194     }
40195     /** @param {number} val */
40196     writeVarint(val) {
40197       val = +val || 0;
40198       if (val > 268435455 || val < 0) {
40199         writeBigVarint(val, this);
40200         return;
40201       }
40202       this.realloc(4);
40203       this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
40204       if (val <= 127) return;
40205       this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
40206       if (val <= 127) return;
40207       this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
40208       if (val <= 127) return;
40209       this.buf[this.pos++] = val >>> 7 & 127;
40210     }
40211     /** @param {number} val */
40212     writeSVarint(val) {
40213       this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
40214     }
40215     /** @param {boolean} val */
40216     writeBoolean(val) {
40217       this.writeVarint(+val);
40218     }
40219     /** @param {string} str */
40220     writeString(str) {
40221       str = String(str);
40222       this.realloc(str.length * 4);
40223       this.pos++;
40224       const startPos = this.pos;
40225       this.pos = writeUtf8(this.buf, str, this.pos);
40226       const len = this.pos - startPos;
40227       if (len >= 128) makeRoomForExtraLength(startPos, len, this);
40228       this.pos = startPos - 1;
40229       this.writeVarint(len);
40230       this.pos += len;
40231     }
40232     /** @param {number} val */
40233     writeFloat(val) {
40234       this.realloc(4);
40235       this.dataView.setFloat32(this.pos, val, true);
40236       this.pos += 4;
40237     }
40238     /** @param {number} val */
40239     writeDouble(val) {
40240       this.realloc(8);
40241       this.dataView.setFloat64(this.pos, val, true);
40242       this.pos += 8;
40243     }
40244     /** @param {Uint8Array} buffer */
40245     writeBytes(buffer) {
40246       const len = buffer.length;
40247       this.writeVarint(len);
40248       this.realloc(len);
40249       for (let i3 = 0; i3 < len; i3++) this.buf[this.pos++] = buffer[i3];
40250     }
40251     /**
40252      * @template T
40253      * @param {(obj: T, pbf: Pbf) => void} fn
40254      * @param {T} obj
40255      */
40256     writeRawMessage(fn, obj) {
40257       this.pos++;
40258       const startPos = this.pos;
40259       fn(obj, this);
40260       const len = this.pos - startPos;
40261       if (len >= 128) makeRoomForExtraLength(startPos, len, this);
40262       this.pos = startPos - 1;
40263       this.writeVarint(len);
40264       this.pos += len;
40265     }
40266     /**
40267      * @template T
40268      * @param {number} tag
40269      * @param {(obj: T, pbf: Pbf) => void} fn
40270      * @param {T} obj
40271      */
40272     writeMessage(tag2, fn, obj) {
40273       this.writeTag(tag2, PBF_BYTES);
40274       this.writeRawMessage(fn, obj);
40275     }
40276     /**
40277      * @param {number} tag
40278      * @param {number[]} arr
40279      */
40280     writePackedVarint(tag2, arr) {
40281       if (arr.length) this.writeMessage(tag2, writePackedVarint, arr);
40282     }
40283     /**
40284      * @param {number} tag
40285      * @param {number[]} arr
40286      */
40287     writePackedSVarint(tag2, arr) {
40288       if (arr.length) this.writeMessage(tag2, writePackedSVarint, arr);
40289     }
40290     /**
40291      * @param {number} tag
40292      * @param {boolean[]} arr
40293      */
40294     writePackedBoolean(tag2, arr) {
40295       if (arr.length) this.writeMessage(tag2, writePackedBoolean, arr);
40296     }
40297     /**
40298      * @param {number} tag
40299      * @param {number[]} arr
40300      */
40301     writePackedFloat(tag2, arr) {
40302       if (arr.length) this.writeMessage(tag2, writePackedFloat, arr);
40303     }
40304     /**
40305      * @param {number} tag
40306      * @param {number[]} arr
40307      */
40308     writePackedDouble(tag2, arr) {
40309       if (arr.length) this.writeMessage(tag2, writePackedDouble, arr);
40310     }
40311     /**
40312      * @param {number} tag
40313      * @param {number[]} arr
40314      */
40315     writePackedFixed32(tag2, arr) {
40316       if (arr.length) this.writeMessage(tag2, writePackedFixed32, arr);
40317     }
40318     /**
40319      * @param {number} tag
40320      * @param {number[]} arr
40321      */
40322     writePackedSFixed32(tag2, arr) {
40323       if (arr.length) this.writeMessage(tag2, writePackedSFixed32, arr);
40324     }
40325     /**
40326      * @param {number} tag
40327      * @param {number[]} arr
40328      */
40329     writePackedFixed64(tag2, arr) {
40330       if (arr.length) this.writeMessage(tag2, writePackedFixed64, arr);
40331     }
40332     /**
40333      * @param {number} tag
40334      * @param {number[]} arr
40335      */
40336     writePackedSFixed64(tag2, arr) {
40337       if (arr.length) this.writeMessage(tag2, writePackedSFixed64, arr);
40338     }
40339     /**
40340      * @param {number} tag
40341      * @param {Uint8Array} buffer
40342      */
40343     writeBytesField(tag2, buffer) {
40344       this.writeTag(tag2, PBF_BYTES);
40345       this.writeBytes(buffer);
40346     }
40347     /**
40348      * @param {number} tag
40349      * @param {number} val
40350      */
40351     writeFixed32Field(tag2, val) {
40352       this.writeTag(tag2, PBF_FIXED32);
40353       this.writeFixed32(val);
40354     }
40355     /**
40356      * @param {number} tag
40357      * @param {number} val
40358      */
40359     writeSFixed32Field(tag2, val) {
40360       this.writeTag(tag2, PBF_FIXED32);
40361       this.writeSFixed32(val);
40362     }
40363     /**
40364      * @param {number} tag
40365      * @param {number} val
40366      */
40367     writeFixed64Field(tag2, val) {
40368       this.writeTag(tag2, PBF_FIXED64);
40369       this.writeFixed64(val);
40370     }
40371     /**
40372      * @param {number} tag
40373      * @param {number} val
40374      */
40375     writeSFixed64Field(tag2, val) {
40376       this.writeTag(tag2, PBF_FIXED64);
40377       this.writeSFixed64(val);
40378     }
40379     /**
40380      * @param {number} tag
40381      * @param {number} val
40382      */
40383     writeVarintField(tag2, val) {
40384       this.writeTag(tag2, PBF_VARINT);
40385       this.writeVarint(val);
40386     }
40387     /**
40388      * @param {number} tag
40389      * @param {number} val
40390      */
40391     writeSVarintField(tag2, val) {
40392       this.writeTag(tag2, PBF_VARINT);
40393       this.writeSVarint(val);
40394     }
40395     /**
40396      * @param {number} tag
40397      * @param {string} str
40398      */
40399     writeStringField(tag2, str) {
40400       this.writeTag(tag2, PBF_BYTES);
40401       this.writeString(str);
40402     }
40403     /**
40404      * @param {number} tag
40405      * @param {number} val
40406      */
40407     writeFloatField(tag2, val) {
40408       this.writeTag(tag2, PBF_FIXED32);
40409       this.writeFloat(val);
40410     }
40411     /**
40412      * @param {number} tag
40413      * @param {number} val
40414      */
40415     writeDoubleField(tag2, val) {
40416       this.writeTag(tag2, PBF_FIXED64);
40417       this.writeDouble(val);
40418     }
40419     /**
40420      * @param {number} tag
40421      * @param {boolean} val
40422      */
40423     writeBooleanField(tag2, val) {
40424       this.writeVarintField(tag2, +val);
40425     }
40426   };
40427   function readVarintRemainder(l2, s2, p2) {
40428     const buf = p2.buf;
40429     let h2, b2;
40430     b2 = buf[p2.pos++];
40431     h2 = (b2 & 112) >> 4;
40432     if (b2 < 128) return toNum(l2, h2, s2);
40433     b2 = buf[p2.pos++];
40434     h2 |= (b2 & 127) << 3;
40435     if (b2 < 128) return toNum(l2, h2, s2);
40436     b2 = buf[p2.pos++];
40437     h2 |= (b2 & 127) << 10;
40438     if (b2 < 128) return toNum(l2, h2, s2);
40439     b2 = buf[p2.pos++];
40440     h2 |= (b2 & 127) << 17;
40441     if (b2 < 128) return toNum(l2, h2, s2);
40442     b2 = buf[p2.pos++];
40443     h2 |= (b2 & 127) << 24;
40444     if (b2 < 128) return toNum(l2, h2, s2);
40445     b2 = buf[p2.pos++];
40446     h2 |= (b2 & 1) << 31;
40447     if (b2 < 128) return toNum(l2, h2, s2);
40448     throw new Error("Expected varint not more than 10 bytes");
40449   }
40450   function toNum(low, high, isSigned) {
40451     return isSigned ? high * 4294967296 + (low >>> 0) : (high >>> 0) * 4294967296 + (low >>> 0);
40452   }
40453   function writeBigVarint(val, pbf) {
40454     let low, high;
40455     if (val >= 0) {
40456       low = val % 4294967296 | 0;
40457       high = val / 4294967296 | 0;
40458     } else {
40459       low = ~(-val % 4294967296);
40460       high = ~(-val / 4294967296);
40461       if (low ^ 4294967295) {
40462         low = low + 1 | 0;
40463       } else {
40464         low = 0;
40465         high = high + 1 | 0;
40466       }
40467     }
40468     if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
40469       throw new Error("Given varint doesn't fit into 10 bytes");
40470     }
40471     pbf.realloc(10);
40472     writeBigVarintLow(low, high, pbf);
40473     writeBigVarintHigh(high, pbf);
40474   }
40475   function writeBigVarintLow(low, high, pbf) {
40476     pbf.buf[pbf.pos++] = low & 127 | 128;
40477     low >>>= 7;
40478     pbf.buf[pbf.pos++] = low & 127 | 128;
40479     low >>>= 7;
40480     pbf.buf[pbf.pos++] = low & 127 | 128;
40481     low >>>= 7;
40482     pbf.buf[pbf.pos++] = low & 127 | 128;
40483     low >>>= 7;
40484     pbf.buf[pbf.pos] = low & 127;
40485   }
40486   function writeBigVarintHigh(high, pbf) {
40487     const lsb = (high & 7) << 4;
40488     pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
40489     if (!high) return;
40490     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40491     if (!high) return;
40492     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40493     if (!high) return;
40494     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40495     if (!high) return;
40496     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40497     if (!high) return;
40498     pbf.buf[pbf.pos++] = high & 127;
40499   }
40500   function makeRoomForExtraLength(startPos, len, pbf) {
40501     const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
40502     pbf.realloc(extraLen);
40503     for (let i3 = pbf.pos - 1; i3 >= startPos; i3--) pbf.buf[i3 + extraLen] = pbf.buf[i3];
40504   }
40505   function writePackedVarint(arr, pbf) {
40506     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeVarint(arr[i3]);
40507   }
40508   function writePackedSVarint(arr, pbf) {
40509     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSVarint(arr[i3]);
40510   }
40511   function writePackedFloat(arr, pbf) {
40512     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFloat(arr[i3]);
40513   }
40514   function writePackedDouble(arr, pbf) {
40515     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeDouble(arr[i3]);
40516   }
40517   function writePackedBoolean(arr, pbf) {
40518     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeBoolean(arr[i3]);
40519   }
40520   function writePackedFixed32(arr, pbf) {
40521     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFixed32(arr[i3]);
40522   }
40523   function writePackedSFixed32(arr, pbf) {
40524     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSFixed32(arr[i3]);
40525   }
40526   function writePackedFixed64(arr, pbf) {
40527     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFixed64(arr[i3]);
40528   }
40529   function writePackedSFixed64(arr, pbf) {
40530     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSFixed64(arr[i3]);
40531   }
40532   function readUtf8(buf, pos, end) {
40533     let str = "";
40534     let i3 = pos;
40535     while (i3 < end) {
40536       const b0 = buf[i3];
40537       let c2 = null;
40538       let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
40539       if (i3 + bytesPerSequence > end) break;
40540       let b1, b2, b3;
40541       if (bytesPerSequence === 1) {
40542         if (b0 < 128) {
40543           c2 = b0;
40544         }
40545       } else if (bytesPerSequence === 2) {
40546         b1 = buf[i3 + 1];
40547         if ((b1 & 192) === 128) {
40548           c2 = (b0 & 31) << 6 | b1 & 63;
40549           if (c2 <= 127) {
40550             c2 = null;
40551           }
40552         }
40553       } else if (bytesPerSequence === 3) {
40554         b1 = buf[i3 + 1];
40555         b2 = buf[i3 + 2];
40556         if ((b1 & 192) === 128 && (b2 & 192) === 128) {
40557           c2 = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
40558           if (c2 <= 2047 || c2 >= 55296 && c2 <= 57343) {
40559             c2 = null;
40560           }
40561         }
40562       } else if (bytesPerSequence === 4) {
40563         b1 = buf[i3 + 1];
40564         b2 = buf[i3 + 2];
40565         b3 = buf[i3 + 3];
40566         if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
40567           c2 = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
40568           if (c2 <= 65535 || c2 >= 1114112) {
40569             c2 = null;
40570           }
40571         }
40572       }
40573       if (c2 === null) {
40574         c2 = 65533;
40575         bytesPerSequence = 1;
40576       } else if (c2 > 65535) {
40577         c2 -= 65536;
40578         str += String.fromCharCode(c2 >>> 10 & 1023 | 55296);
40579         c2 = 56320 | c2 & 1023;
40580       }
40581       str += String.fromCharCode(c2);
40582       i3 += bytesPerSequence;
40583     }
40584     return str;
40585   }
40586   function writeUtf8(buf, str, pos) {
40587     for (let i3 = 0, c2, lead; i3 < str.length; i3++) {
40588       c2 = str.charCodeAt(i3);
40589       if (c2 > 55295 && c2 < 57344) {
40590         if (lead) {
40591           if (c2 < 56320) {
40592             buf[pos++] = 239;
40593             buf[pos++] = 191;
40594             buf[pos++] = 189;
40595             lead = c2;
40596             continue;
40597           } else {
40598             c2 = lead - 55296 << 10 | c2 - 56320 | 65536;
40599             lead = null;
40600           }
40601         } else {
40602           if (c2 > 56319 || i3 + 1 === str.length) {
40603             buf[pos++] = 239;
40604             buf[pos++] = 191;
40605             buf[pos++] = 189;
40606           } else {
40607             lead = c2;
40608           }
40609           continue;
40610         }
40611       } else if (lead) {
40612         buf[pos++] = 239;
40613         buf[pos++] = 191;
40614         buf[pos++] = 189;
40615         lead = null;
40616       }
40617       if (c2 < 128) {
40618         buf[pos++] = c2;
40619       } else {
40620         if (c2 < 2048) {
40621           buf[pos++] = c2 >> 6 | 192;
40622         } else {
40623           if (c2 < 65536) {
40624             buf[pos++] = c2 >> 12 | 224;
40625           } else {
40626             buf[pos++] = c2 >> 18 | 240;
40627             buf[pos++] = c2 >> 12 & 63 | 128;
40628           }
40629           buf[pos++] = c2 >> 6 & 63 | 128;
40630         }
40631         buf[pos++] = c2 & 63 | 128;
40632       }
40633     }
40634     return pos;
40635   }
40636
40637   // node_modules/@mapbox/point-geometry/index.js
40638   function Point(x2, y2) {
40639     this.x = x2;
40640     this.y = y2;
40641   }
40642   Point.prototype = {
40643     /**
40644      * Clone this point, returning a new point that can be modified
40645      * without affecting the old one.
40646      * @return {Point} the clone
40647      */
40648     clone() {
40649       return new Point(this.x, this.y);
40650     },
40651     /**
40652      * Add this point's x & y coordinates to another point,
40653      * yielding a new point.
40654      * @param {Point} p the other point
40655      * @return {Point} output point
40656      */
40657     add(p2) {
40658       return this.clone()._add(p2);
40659     },
40660     /**
40661      * Subtract this point's x & y coordinates to from point,
40662      * yielding a new point.
40663      * @param {Point} p the other point
40664      * @return {Point} output point
40665      */
40666     sub(p2) {
40667       return this.clone()._sub(p2);
40668     },
40669     /**
40670      * Multiply this point's x & y coordinates by point,
40671      * yielding a new point.
40672      * @param {Point} p the other point
40673      * @return {Point} output point
40674      */
40675     multByPoint(p2) {
40676       return this.clone()._multByPoint(p2);
40677     },
40678     /**
40679      * Divide this point's x & y coordinates by point,
40680      * yielding a new point.
40681      * @param {Point} p the other point
40682      * @return {Point} output point
40683      */
40684     divByPoint(p2) {
40685       return this.clone()._divByPoint(p2);
40686     },
40687     /**
40688      * Multiply this point's x & y coordinates by a factor,
40689      * yielding a new point.
40690      * @param {number} k factor
40691      * @return {Point} output point
40692      */
40693     mult(k2) {
40694       return this.clone()._mult(k2);
40695     },
40696     /**
40697      * Divide this point's x & y coordinates by a factor,
40698      * yielding a new point.
40699      * @param {number} k factor
40700      * @return {Point} output point
40701      */
40702     div(k2) {
40703       return this.clone()._div(k2);
40704     },
40705     /**
40706      * Rotate this point around the 0, 0 origin by an angle a,
40707      * given in radians
40708      * @param {number} a angle to rotate around, in radians
40709      * @return {Point} output point
40710      */
40711     rotate(a2) {
40712       return this.clone()._rotate(a2);
40713     },
40714     /**
40715      * Rotate this point around p point by an angle a,
40716      * given in radians
40717      * @param {number} a angle to rotate around, in radians
40718      * @param {Point} p Point to rotate around
40719      * @return {Point} output point
40720      */
40721     rotateAround(a2, p2) {
40722       return this.clone()._rotateAround(a2, p2);
40723     },
40724     /**
40725      * Multiply this point by a 4x1 transformation matrix
40726      * @param {[number, number, number, number]} m transformation matrix
40727      * @return {Point} output point
40728      */
40729     matMult(m2) {
40730       return this.clone()._matMult(m2);
40731     },
40732     /**
40733      * Calculate this point but as a unit vector from 0, 0, meaning
40734      * that the distance from the resulting point to the 0, 0
40735      * coordinate will be equal to 1 and the angle from the resulting
40736      * point to the 0, 0 coordinate will be the same as before.
40737      * @return {Point} unit vector point
40738      */
40739     unit() {
40740       return this.clone()._unit();
40741     },
40742     /**
40743      * Compute a perpendicular point, where the new y coordinate
40744      * is the old x coordinate and the new x coordinate is the old y
40745      * coordinate multiplied by -1
40746      * @return {Point} perpendicular point
40747      */
40748     perp() {
40749       return this.clone()._perp();
40750     },
40751     /**
40752      * Return a version of this point with the x & y coordinates
40753      * rounded to integers.
40754      * @return {Point} rounded point
40755      */
40756     round() {
40757       return this.clone()._round();
40758     },
40759     /**
40760      * Return the magnitude of this point: this is the Euclidean
40761      * distance from the 0, 0 coordinate to this point's x and y
40762      * coordinates.
40763      * @return {number} magnitude
40764      */
40765     mag() {
40766       return Math.sqrt(this.x * this.x + this.y * this.y);
40767     },
40768     /**
40769      * Judge whether this point is equal to another point, returning
40770      * true or false.
40771      * @param {Point} other the other point
40772      * @return {boolean} whether the points are equal
40773      */
40774     equals(other2) {
40775       return this.x === other2.x && this.y === other2.y;
40776     },
40777     /**
40778      * Calculate the distance from this point to another point
40779      * @param {Point} p the other point
40780      * @return {number} distance
40781      */
40782     dist(p2) {
40783       return Math.sqrt(this.distSqr(p2));
40784     },
40785     /**
40786      * Calculate the distance from this point to another point,
40787      * without the square root step. Useful if you're comparing
40788      * relative distances.
40789      * @param {Point} p the other point
40790      * @return {number} distance
40791      */
40792     distSqr(p2) {
40793       const dx = p2.x - this.x, dy = p2.y - this.y;
40794       return dx * dx + dy * dy;
40795     },
40796     /**
40797      * Get the angle from the 0, 0 coordinate to this point, in radians
40798      * coordinates.
40799      * @return {number} angle
40800      */
40801     angle() {
40802       return Math.atan2(this.y, this.x);
40803     },
40804     /**
40805      * Get the angle from this point to another point, in radians
40806      * @param {Point} b the other point
40807      * @return {number} angle
40808      */
40809     angleTo(b2) {
40810       return Math.atan2(this.y - b2.y, this.x - b2.x);
40811     },
40812     /**
40813      * Get the angle between this point and another point, in radians
40814      * @param {Point} b the other point
40815      * @return {number} angle
40816      */
40817     angleWith(b2) {
40818       return this.angleWithSep(b2.x, b2.y);
40819     },
40820     /**
40821      * Find the angle of the two vectors, solving the formula for
40822      * the cross product a x b = |a||b|sin(θ) for θ.
40823      * @param {number} x the x-coordinate
40824      * @param {number} y the y-coordinate
40825      * @return {number} the angle in radians
40826      */
40827     angleWithSep(x2, y2) {
40828       return Math.atan2(
40829         this.x * y2 - this.y * x2,
40830         this.x * x2 + this.y * y2
40831       );
40832     },
40833     /** @param {[number, number, number, number]} m */
40834     _matMult(m2) {
40835       const x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y;
40836       this.x = x2;
40837       this.y = y2;
40838       return this;
40839     },
40840     /** @param {Point} p */
40841     _add(p2) {
40842       this.x += p2.x;
40843       this.y += p2.y;
40844       return this;
40845     },
40846     /** @param {Point} p */
40847     _sub(p2) {
40848       this.x -= p2.x;
40849       this.y -= p2.y;
40850       return this;
40851     },
40852     /** @param {number} k */
40853     _mult(k2) {
40854       this.x *= k2;
40855       this.y *= k2;
40856       return this;
40857     },
40858     /** @param {number} k */
40859     _div(k2) {
40860       this.x /= k2;
40861       this.y /= k2;
40862       return this;
40863     },
40864     /** @param {Point} p */
40865     _multByPoint(p2) {
40866       this.x *= p2.x;
40867       this.y *= p2.y;
40868       return this;
40869     },
40870     /** @param {Point} p */
40871     _divByPoint(p2) {
40872       this.x /= p2.x;
40873       this.y /= p2.y;
40874       return this;
40875     },
40876     _unit() {
40877       this._div(this.mag());
40878       return this;
40879     },
40880     _perp() {
40881       const y2 = this.y;
40882       this.y = this.x;
40883       this.x = -y2;
40884       return this;
40885     },
40886     /** @param {number} angle */
40887     _rotate(angle2) {
40888       const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y;
40889       this.x = x2;
40890       this.y = y2;
40891       return this;
40892     },
40893     /**
40894      * @param {number} angle
40895      * @param {Point} p
40896      */
40897     _rotateAround(angle2, p2) {
40898       const 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);
40899       this.x = x2;
40900       this.y = y2;
40901       return this;
40902     },
40903     _round() {
40904       this.x = Math.round(this.x);
40905       this.y = Math.round(this.y);
40906       return this;
40907     },
40908     constructor: Point
40909   };
40910   Point.convert = function(p2) {
40911     if (p2 instanceof Point) {
40912       return (
40913         /** @type {Point} */
40914         p2
40915       );
40916     }
40917     if (Array.isArray(p2)) {
40918       return new Point(+p2[0], +p2[1]);
40919     }
40920     if (p2.x !== void 0 && p2.y !== void 0) {
40921       return new Point(+p2.x, +p2.y);
40922     }
40923     throw new Error("Expected [x, y] or {x, y} point format");
40924   };
40925
40926   // node_modules/@mapbox/vector-tile/index.js
40927   var VectorTileFeature = class {
40928     /**
40929      * @param {Pbf} pbf
40930      * @param {number} end
40931      * @param {number} extent
40932      * @param {string[]} keys
40933      * @param {unknown[]} values
40934      */
40935     constructor(pbf, end, extent, keys2, values) {
40936       this.properties = {};
40937       this.extent = extent;
40938       this.type = 0;
40939       this.id = void 0;
40940       this._pbf = pbf;
40941       this._geometry = -1;
40942       this._keys = keys2;
40943       this._values = values;
40944       pbf.readFields(readFeature, this, end);
40945     }
40946     loadGeometry() {
40947       const pbf = this._pbf;
40948       pbf.pos = this._geometry;
40949       const end = pbf.readVarint() + pbf.pos;
40950       const lines = [];
40951       let line;
40952       let cmd = 1;
40953       let length2 = 0;
40954       let x2 = 0;
40955       let y2 = 0;
40956       while (pbf.pos < end) {
40957         if (length2 <= 0) {
40958           const cmdLen = pbf.readVarint();
40959           cmd = cmdLen & 7;
40960           length2 = cmdLen >> 3;
40961         }
40962         length2--;
40963         if (cmd === 1 || cmd === 2) {
40964           x2 += pbf.readSVarint();
40965           y2 += pbf.readSVarint();
40966           if (cmd === 1) {
40967             if (line) lines.push(line);
40968             line = [];
40969           }
40970           if (line) line.push(new Point(x2, y2));
40971         } else if (cmd === 7) {
40972           if (line) {
40973             line.push(line[0].clone());
40974           }
40975         } else {
40976           throw new Error("unknown command ".concat(cmd));
40977         }
40978       }
40979       if (line) lines.push(line);
40980       return lines;
40981     }
40982     bbox() {
40983       const pbf = this._pbf;
40984       pbf.pos = this._geometry;
40985       const end = pbf.readVarint() + pbf.pos;
40986       let cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity;
40987       while (pbf.pos < end) {
40988         if (length2 <= 0) {
40989           const cmdLen = pbf.readVarint();
40990           cmd = cmdLen & 7;
40991           length2 = cmdLen >> 3;
40992         }
40993         length2--;
40994         if (cmd === 1 || cmd === 2) {
40995           x2 += pbf.readSVarint();
40996           y2 += pbf.readSVarint();
40997           if (x2 < x12) x12 = x2;
40998           if (x2 > x22) x22 = x2;
40999           if (y2 < y12) y12 = y2;
41000           if (y2 > y22) y22 = y2;
41001         } else if (cmd !== 7) {
41002           throw new Error("unknown command ".concat(cmd));
41003         }
41004       }
41005       return [x12, y12, x22, y22];
41006     }
41007     /**
41008      * @param {number} x
41009      * @param {number} y
41010      * @param {number} z
41011      * @return {Feature}
41012      */
41013     toGeoJSON(x2, y2, z2) {
41014       const size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, vtCoords = this.loadGeometry();
41015       function projectPoint(p2) {
41016         return [
41017           (p2.x + x05) * 360 / size - 180,
41018           360 / Math.PI * Math.atan(Math.exp((1 - (p2.y + y05) * 2 / size) * Math.PI)) - 90
41019         ];
41020       }
41021       function projectLine(line) {
41022         return line.map(projectPoint);
41023       }
41024       let geometry;
41025       if (this.type === 1) {
41026         const points = [];
41027         for (const line of vtCoords) {
41028           points.push(line[0]);
41029         }
41030         const coordinates = projectLine(points);
41031         geometry = points.length === 1 ? { type: "Point", coordinates: coordinates[0] } : { type: "MultiPoint", coordinates };
41032       } else if (this.type === 2) {
41033         const coordinates = vtCoords.map(projectLine);
41034         geometry = coordinates.length === 1 ? { type: "LineString", coordinates: coordinates[0] } : { type: "MultiLineString", coordinates };
41035       } else if (this.type === 3) {
41036         const polygons = classifyRings(vtCoords);
41037         const coordinates = [];
41038         for (const polygon2 of polygons) {
41039           coordinates.push(polygon2.map(projectLine));
41040         }
41041         geometry = coordinates.length === 1 ? { type: "Polygon", coordinates: coordinates[0] } : { type: "MultiPolygon", coordinates };
41042       } else {
41043         throw new Error("unknown feature type");
41044       }
41045       const result = {
41046         type: "Feature",
41047         geometry,
41048         properties: this.properties
41049       };
41050       if (this.id != null) {
41051         result.id = this.id;
41052       }
41053       return result;
41054     }
41055   };
41056   VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"];
41057   function readFeature(tag2, feature3, pbf) {
41058     if (tag2 === 1) feature3.id = pbf.readVarint();
41059     else if (tag2 === 2) readTag(pbf, feature3);
41060     else if (tag2 === 3) feature3.type = /** @type {0 | 1 | 2 | 3} */
41061     pbf.readVarint();
41062     else if (tag2 === 4) feature3._geometry = pbf.pos;
41063   }
41064   function readTag(pbf, feature3) {
41065     const end = pbf.readVarint() + pbf.pos;
41066     while (pbf.pos < end) {
41067       const key = feature3._keys[pbf.readVarint()], value = feature3._values[pbf.readVarint()];
41068       feature3.properties[key] = value;
41069     }
41070   }
41071   function classifyRings(rings) {
41072     const len = rings.length;
41073     if (len <= 1) return [rings];
41074     const polygons = [];
41075     let polygon2, ccw;
41076     for (let i3 = 0; i3 < len; i3++) {
41077       const area = signedArea(rings[i3]);
41078       if (area === 0) continue;
41079       if (ccw === void 0) ccw = area < 0;
41080       if (ccw === area < 0) {
41081         if (polygon2) polygons.push(polygon2);
41082         polygon2 = [rings[i3]];
41083       } else if (polygon2) {
41084         polygon2.push(rings[i3]);
41085       }
41086     }
41087     if (polygon2) polygons.push(polygon2);
41088     return polygons;
41089   }
41090   function signedArea(ring) {
41091     let sum = 0;
41092     for (let i3 = 0, len = ring.length, j2 = len - 1, p1, p2; i3 < len; j2 = i3++) {
41093       p1 = ring[i3];
41094       p2 = ring[j2];
41095       sum += (p2.x - p1.x) * (p1.y + p2.y);
41096     }
41097     return sum;
41098   }
41099   var VectorTileLayer = class {
41100     /**
41101      * @param {Pbf} pbf
41102      * @param {number} [end]
41103      */
41104     constructor(pbf, end) {
41105       this.version = 1;
41106       this.name = "";
41107       this.extent = 4096;
41108       this.length = 0;
41109       this._pbf = pbf;
41110       this._keys = [];
41111       this._values = [];
41112       this._features = [];
41113       pbf.readFields(readLayer, this, end);
41114       this.length = this._features.length;
41115     }
41116     /** return feature `i` from this layer as a `VectorTileFeature`
41117      * @param {number} i
41118      */
41119     feature(i3) {
41120       if (i3 < 0 || i3 >= this._features.length) throw new Error("feature index out of bounds");
41121       this._pbf.pos = this._features[i3];
41122       const end = this._pbf.readVarint() + this._pbf.pos;
41123       return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
41124     }
41125   };
41126   function readLayer(tag2, layer, pbf) {
41127     if (tag2 === 15) layer.version = pbf.readVarint();
41128     else if (tag2 === 1) layer.name = pbf.readString();
41129     else if (tag2 === 5) layer.extent = pbf.readVarint();
41130     else if (tag2 === 2) layer._features.push(pbf.pos);
41131     else if (tag2 === 3) layer._keys.push(pbf.readString());
41132     else if (tag2 === 4) layer._values.push(readValueMessage(pbf));
41133   }
41134   function readValueMessage(pbf) {
41135     let value = null;
41136     const end = pbf.readVarint() + pbf.pos;
41137     while (pbf.pos < end) {
41138       const tag2 = pbf.readVarint() >> 3;
41139       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;
41140     }
41141     return value;
41142   }
41143   var VectorTile = class {
41144     /**
41145      * @param {Pbf} pbf
41146      * @param {number} [end]
41147      */
41148     constructor(pbf, end) {
41149       this.layers = pbf.readFields(readTile, {}, end);
41150     }
41151   };
41152   function readTile(tag2, layers, pbf) {
41153     if (tag2 === 3) {
41154       const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
41155       if (layer.length) layers[layer.name] = layer;
41156     }
41157   }
41158
41159   // modules/services/mapillary.js
41160   var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf";
41161   var apiUrl = "https://graph.mapillary.com/";
41162   var baseTileUrl = "https://tiles.mapillary.com/maps/vtp";
41163   var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41164   var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41165   var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41166   var viewercss = "mapillary-js/mapillary.css";
41167   var viewerjs = "mapillary-js/mapillary.js";
41168   var minZoom = 14;
41169   var dispatch4 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged");
41170   var _loadViewerPromise;
41171   var _mlyActiveImage;
41172   var _mlyCache;
41173   var _mlyFallback = false;
41174   var _mlyHighlightedDetection;
41175   var _mlyShowFeatureDetections = false;
41176   var _mlyShowSignDetections = false;
41177   var _mlyViewer;
41178   var _mlyViewerFilter = ["all"];
41179   var _isViewerOpen = false;
41180   function loadTiles(which, url, maxZoom2, projection2) {
41181     const tiler8 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true);
41182     const tiles = tiler8.getTiles(projection2);
41183     tiles.forEach(function(tile) {
41184       loadTile(which, url, tile);
41185     });
41186   }
41187   function loadTile(which, url, tile) {
41188     const cache = _mlyCache.requests;
41189     const tileId = "".concat(tile.id, "-").concat(which);
41190     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
41191     const controller = new AbortController();
41192     cache.inflight[tileId] = controller;
41193     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
41194     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
41195       if (!response.ok) {
41196         throw new Error(response.status + " " + response.statusText);
41197       }
41198       cache.loaded[tileId] = true;
41199       delete cache.inflight[tileId];
41200       return response.arrayBuffer();
41201     }).then(function(data) {
41202       if (!data) {
41203         throw new Error("No Data");
41204       }
41205       loadTileDataToCache(data, tile, which);
41206       if (which === "images") {
41207         dispatch4.call("loadedImages");
41208       } else if (which === "signs") {
41209         dispatch4.call("loadedSigns");
41210       } else if (which === "points") {
41211         dispatch4.call("loadedMapFeatures");
41212       }
41213     }).catch(function() {
41214       cache.loaded[tileId] = true;
41215       delete cache.inflight[tileId];
41216     });
41217   }
41218   function loadTileDataToCache(data, tile, which) {
41219     const vectorTile = new VectorTile(new Pbf(data));
41220     let features, cache, layer, i3, feature3, loc, d2;
41221     if (vectorTile.layers.hasOwnProperty("image")) {
41222       features = [];
41223       cache = _mlyCache.images;
41224       layer = vectorTile.layers.image;
41225       for (i3 = 0; i3 < layer.length; i3++) {
41226         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
41227         loc = feature3.geometry.coordinates;
41228         d2 = {
41229           loc,
41230           captured_at: feature3.properties.captured_at,
41231           ca: feature3.properties.compass_angle,
41232           id: feature3.properties.id,
41233           is_pano: feature3.properties.is_pano,
41234           sequence_id: feature3.properties.sequence_id
41235         };
41236         cache.forImageId[d2.id] = d2;
41237         features.push({
41238           minX: loc[0],
41239           minY: loc[1],
41240           maxX: loc[0],
41241           maxY: loc[1],
41242           data: d2
41243         });
41244       }
41245       if (cache.rtree) {
41246         cache.rtree.load(features);
41247       }
41248     }
41249     if (vectorTile.layers.hasOwnProperty("sequence")) {
41250       features = [];
41251       cache = _mlyCache.sequences;
41252       layer = vectorTile.layers.sequence;
41253       for (i3 = 0; i3 < layer.length; i3++) {
41254         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
41255         if (cache.lineString[feature3.properties.id]) {
41256           cache.lineString[feature3.properties.id].push(feature3);
41257         } else {
41258           cache.lineString[feature3.properties.id] = [feature3];
41259         }
41260       }
41261     }
41262     if (vectorTile.layers.hasOwnProperty("point")) {
41263       features = [];
41264       cache = _mlyCache[which];
41265       layer = vectorTile.layers.point;
41266       for (i3 = 0; i3 < layer.length; i3++) {
41267         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
41268         loc = feature3.geometry.coordinates;
41269         d2 = {
41270           loc,
41271           id: feature3.properties.id,
41272           first_seen_at: feature3.properties.first_seen_at,
41273           last_seen_at: feature3.properties.last_seen_at,
41274           value: feature3.properties.value
41275         };
41276         features.push({
41277           minX: loc[0],
41278           minY: loc[1],
41279           maxX: loc[0],
41280           maxY: loc[1],
41281           data: d2
41282         });
41283       }
41284       if (cache.rtree) {
41285         cache.rtree.load(features);
41286       }
41287     }
41288     if (vectorTile.layers.hasOwnProperty("traffic_sign")) {
41289       features = [];
41290       cache = _mlyCache[which];
41291       layer = vectorTile.layers.traffic_sign;
41292       for (i3 = 0; i3 < layer.length; i3++) {
41293         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
41294         loc = feature3.geometry.coordinates;
41295         d2 = {
41296           loc,
41297           id: feature3.properties.id,
41298           first_seen_at: feature3.properties.first_seen_at,
41299           last_seen_at: feature3.properties.last_seen_at,
41300           value: feature3.properties.value
41301         };
41302         features.push({
41303           minX: loc[0],
41304           minY: loc[1],
41305           maxX: loc[0],
41306           maxY: loc[1],
41307           data: d2
41308         });
41309       }
41310       if (cache.rtree) {
41311         cache.rtree.load(features);
41312       }
41313     }
41314   }
41315   function loadData(url) {
41316     return fetch(url).then(function(response) {
41317       if (!response.ok) {
41318         throw new Error(response.status + " " + response.statusText);
41319       }
41320       return response.json();
41321     }).then(function(result) {
41322       if (!result) {
41323         return [];
41324       }
41325       return result.data || [];
41326     });
41327   }
41328   function partitionViewport(projection2) {
41329     const z2 = geoScaleToZoom(projection2.scale());
41330     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
41331     const tiler8 = utilTiler().zoomExtent([z22, z22]);
41332     return tiler8.getTiles(projection2).map(function(tile) {
41333       return tile.extent;
41334     });
41335   }
41336   function searchLimited(limit, projection2, rtree) {
41337     limit = limit || 5;
41338     return partitionViewport(projection2).reduce(function(result, extent) {
41339       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
41340         return d2.data;
41341       });
41342       return found.length ? result.concat(found) : result;
41343     }, []);
41344   }
41345   var mapillary_default = {
41346     // Initialize Mapillary
41347     init: function() {
41348       if (!_mlyCache) {
41349         this.reset();
41350       }
41351       this.event = utilRebind(this, dispatch4, "on");
41352     },
41353     // Reset cache and state
41354     reset: function() {
41355       if (_mlyCache) {
41356         Object.values(_mlyCache.requests.inflight).forEach(function(request3) {
41357           request3.abort();
41358         });
41359       }
41360       _mlyCache = {
41361         images: { rtree: new RBush(), forImageId: {} },
41362         image_detections: { forImageId: {} },
41363         signs: { rtree: new RBush() },
41364         points: { rtree: new RBush() },
41365         sequences: { rtree: new RBush(), lineString: {} },
41366         requests: { loaded: {}, inflight: {} }
41367       };
41368       _mlyActiveImage = null;
41369     },
41370     // Get visible images
41371     images: function(projection2) {
41372       const limit = 5;
41373       return searchLimited(limit, projection2, _mlyCache.images.rtree);
41374     },
41375     // Get visible traffic signs
41376     signs: function(projection2) {
41377       const limit = 5;
41378       return searchLimited(limit, projection2, _mlyCache.signs.rtree);
41379     },
41380     // Get visible map (point) features
41381     mapFeatures: function(projection2) {
41382       const limit = 5;
41383       return searchLimited(limit, projection2, _mlyCache.points.rtree);
41384     },
41385     // Get cached image by id
41386     cachedImage: function(imageId) {
41387       return _mlyCache.images.forImageId[imageId];
41388     },
41389     // Get visible sequences
41390     sequences: function(projection2) {
41391       const viewport = projection2.clipExtent();
41392       const min3 = [viewport[0][0], viewport[1][1]];
41393       const max3 = [viewport[1][0], viewport[0][1]];
41394       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
41395       const sequenceIds = {};
41396       let lineStrings = [];
41397       _mlyCache.images.rtree.search(bbox2).forEach(function(d2) {
41398         if (d2.data.sequence_id) {
41399           sequenceIds[d2.data.sequence_id] = true;
41400         }
41401       });
41402       Object.keys(sequenceIds).forEach(function(sequenceId) {
41403         if (_mlyCache.sequences.lineString[sequenceId]) {
41404           lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]);
41405         }
41406       });
41407       return lineStrings;
41408     },
41409     // Load images in the visible area
41410     loadImages: function(projection2) {
41411       loadTiles("images", tileUrl, 14, projection2);
41412     },
41413     // Load traffic signs in the visible area
41414     loadSigns: function(projection2) {
41415       loadTiles("signs", trafficSignTileUrl, 14, projection2);
41416     },
41417     // Load map (point) features in the visible area
41418     loadMapFeatures: function(projection2) {
41419       loadTiles("points", mapFeatureTileUrl, 14, projection2);
41420     },
41421     // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading
41422     ensureViewerLoaded: function(context) {
41423       if (_loadViewerPromise) return _loadViewerPromise;
41424       const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]);
41425       wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true);
41426       const that = this;
41427       _loadViewerPromise = new Promise((resolve, reject) => {
41428         let loadedCount = 0;
41429         function loaded() {
41430           loadedCount += 1;
41431           if (loadedCount === 2) resolve();
41432         }
41433         const head = select_default2("head");
41434         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() {
41435           reject();
41436         });
41437         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() {
41438           reject();
41439         });
41440       }).catch(function() {
41441         _loadViewerPromise = null;
41442       }).then(function() {
41443         that.initViewer(context);
41444       });
41445       return _loadViewerPromise;
41446     },
41447     // Load traffic sign image sprites
41448     loadSignResources: function(context) {
41449       context.ui().svgDefs.addSprites(
41450         ["mapillary-sprite"],
41451         false
41452         /* don't override colors */
41453       );
41454       return this;
41455     },
41456     // Load map (point) feature image sprites
41457     loadObjectResources: function(context) {
41458       context.ui().svgDefs.addSprites(
41459         ["mapillary-object-sprite"],
41460         false
41461         /* don't override colors */
41462       );
41463       return this;
41464     },
41465     // Remove previous detections in image viewer
41466     resetTags: function() {
41467       if (_mlyViewer && !_mlyFallback) {
41468         _mlyViewer.getComponent("tag").removeAll();
41469       }
41470     },
41471     // Show map feature detections in image viewer
41472     showFeatureDetections: function(value) {
41473       _mlyShowFeatureDetections = value;
41474       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
41475         this.resetTags();
41476       }
41477     },
41478     // Show traffic sign detections in image viewer
41479     showSignDetections: function(value) {
41480       _mlyShowSignDetections = value;
41481       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
41482         this.resetTags();
41483       }
41484     },
41485     // Apply filter to image viewer
41486     filterViewer: function(context) {
41487       const showsPano = context.photos().showsPanoramic();
41488       const showsFlat = context.photos().showsFlat();
41489       const fromDate = context.photos().fromDate();
41490       const toDate = context.photos().toDate();
41491       const filter2 = ["all"];
41492       if (!showsPano) filter2.push(["!=", "cameraType", "spherical"]);
41493       if (!showsFlat && showsPano) filter2.push(["==", "pano", true]);
41494       if (fromDate) {
41495         filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]);
41496       }
41497       if (toDate) {
41498         filter2.push([">=", "capturedAt", new Date(toDate).getTime()]);
41499       }
41500       if (_mlyViewer) {
41501         _mlyViewer.setFilter(filter2);
41502       }
41503       _mlyViewerFilter = filter2;
41504       return filter2;
41505     },
41506     // Make the image viewer visible
41507     showViewer: function(context) {
41508       const wrap2 = context.container().select(".photoviewer").classed("hide", false);
41509       const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size();
41510       if (isHidden && _mlyViewer) {
41511         wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true);
41512         wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false);
41513         _mlyViewer.resize();
41514       }
41515       _isViewerOpen = true;
41516       return this;
41517     },
41518     // Hide the image viewer and resets map markers
41519     hideViewer: function(context) {
41520       _mlyActiveImage = null;
41521       if (!_mlyFallback && _mlyViewer) {
41522         _mlyViewer.getComponent("sequence").stop();
41523       }
41524       const viewer = context.container().select(".photoviewer");
41525       if (!viewer.empty()) viewer.datum(null);
41526       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
41527       this.updateUrlImage(null);
41528       dispatch4.call("imageChanged");
41529       dispatch4.call("loadedMapFeatures");
41530       dispatch4.call("loadedSigns");
41531       _isViewerOpen = false;
41532       return this.setStyles(context, null);
41533     },
41534     // Get viewer status
41535     isViewerOpen: function() {
41536       return _isViewerOpen;
41537     },
41538     // Update the URL with current image id
41539     updateUrlImage: function(imageId) {
41540       if (!window.mocha) {
41541         const hash2 = utilStringQs(window.location.hash);
41542         if (imageId) {
41543           hash2.photo = "mapillary/" + imageId;
41544         } else {
41545           delete hash2.photo;
41546         }
41547         window.location.replace("#" + utilQsString(hash2, true));
41548       }
41549     },
41550     // Highlight the detection in the viewer that is related to the clicked map feature
41551     highlightDetection: function(detection) {
41552       if (detection) {
41553         _mlyHighlightedDetection = detection.id;
41554       }
41555       return this;
41556     },
41557     // Initialize image viewer (Mapillar JS)
41558     initViewer: function(context) {
41559       const that = this;
41560       if (!window.mapillary) return;
41561       const opts = {
41562         accessToken,
41563         component: {
41564           cover: false,
41565           keyboard: false,
41566           tag: true
41567         },
41568         container: "ideditor-mly"
41569       };
41570       if (!mapillary.isSupported() && mapillary.isFallbackSupported()) {
41571         _mlyFallback = true;
41572         opts.component = {
41573           cover: false,
41574           direction: false,
41575           imagePlane: false,
41576           keyboard: false,
41577           mouse: false,
41578           sequence: false,
41579           tag: false,
41580           image: true,
41581           // fallback
41582           navigation: true
41583           // fallback
41584         };
41585       }
41586       _mlyViewer = new mapillary.Viewer(opts);
41587       _mlyViewer.on("image", imageChanged);
41588       _mlyViewer.on("bearing", bearingChanged);
41589       if (_mlyViewerFilter) {
41590         _mlyViewer.setFilter(_mlyViewerFilter);
41591       }
41592       context.ui().photoviewer.on("resize.mapillary", function() {
41593         if (_mlyViewer) _mlyViewer.resize();
41594       });
41595       function imageChanged(node) {
41596         that.resetTags();
41597         const image = node.image;
41598         that.setActiveImage(image);
41599         that.setStyles(context, null);
41600         const loc = [image.originalLngLat.lng, image.originalLngLat.lat];
41601         context.map().centerEase(loc);
41602         that.updateUrlImage(image.id);
41603         if (_mlyShowFeatureDetections || _mlyShowSignDetections) {
41604           that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value"));
41605         }
41606         dispatch4.call("imageChanged");
41607       }
41608       function bearingChanged(e3) {
41609         dispatch4.call("bearingChanged", void 0, e3);
41610       }
41611     },
41612     // Move to an image
41613     selectImage: function(context, imageId) {
41614       if (_mlyViewer && imageId) {
41615         _mlyViewer.moveTo(imageId).catch(function(e3) {
41616           console.error("mly3", e3);
41617         });
41618       }
41619       return this;
41620     },
41621     // Return the currently displayed image
41622     getActiveImage: function() {
41623       return _mlyActiveImage;
41624     },
41625     // Return a list of detection objects for the given id
41626     getDetections: function(id2) {
41627       return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image"));
41628     },
41629     // Set the currently visible image
41630     setActiveImage: function(image) {
41631       if (image) {
41632         _mlyActiveImage = {
41633           ca: image.originalCompassAngle,
41634           id: image.id,
41635           loc: [image.originalLngLat.lng, image.originalLngLat.lat],
41636           is_pano: image.cameraType === "spherical",
41637           sequence_id: image.sequenceId
41638         };
41639       } else {
41640         _mlyActiveImage = null;
41641       }
41642     },
41643     // Update the currently highlighted sequence and selected bubble.
41644     setStyles: function(context, hovered) {
41645       const hoveredImageId = hovered && hovered.id;
41646       const hoveredSequenceId = hovered && hovered.sequence_id;
41647       const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id;
41648       context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) {
41649         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
41650       }).classed("hovered", function(d2) {
41651         return d2.id === hoveredImageId;
41652       });
41653       context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) {
41654         return d2.properties.id === hoveredSequenceId;
41655       }).classed("currentView", function(d2) {
41656         return d2.properties.id === selectedSequenceId;
41657       });
41658       return this;
41659     },
41660     // Get detections for the current image and shows them in the image viewer
41661     updateDetections: function(imageId, url) {
41662       if (!_mlyViewer || _mlyFallback) return;
41663       if (!imageId) return;
41664       const cache = _mlyCache.image_detections;
41665       if (cache.forImageId[imageId]) {
41666         showDetections(_mlyCache.image_detections.forImageId[imageId]);
41667       } else {
41668         loadData(url).then((detections) => {
41669           detections.forEach(function(detection) {
41670             if (!cache.forImageId[imageId]) {
41671               cache.forImageId[imageId] = [];
41672             }
41673             cache.forImageId[imageId].push({
41674               geometry: detection.geometry,
41675               id: detection.id,
41676               image_id: imageId,
41677               value: detection.value
41678             });
41679           });
41680           showDetections(_mlyCache.image_detections.forImageId[imageId] || []);
41681         });
41682       }
41683       function showDetections(detections) {
41684         const tagComponent = _mlyViewer.getComponent("tag");
41685         detections.forEach(function(data) {
41686           const tag2 = makeTag(data);
41687           if (tag2) {
41688             tagComponent.add([tag2]);
41689           }
41690         });
41691       }
41692       function makeTag(data) {
41693         const valueParts = data.value.split("--");
41694         if (!valueParts.length) return;
41695         let tag2;
41696         let text;
41697         let color2 = 16777215;
41698         if (_mlyHighlightedDetection === data.id) {
41699           color2 = 16776960;
41700           text = valueParts[1];
41701           if (text === "flat" || text === "discrete" || text === "sign") {
41702             text = valueParts[2];
41703           }
41704           text = text.replace(/-/g, " ");
41705           text = text.charAt(0).toUpperCase() + text.slice(1);
41706           _mlyHighlightedDetection = null;
41707         }
41708         var decodedGeometry = window.atob(data.geometry);
41709         var uintArray = new Uint8Array(decodedGeometry.length);
41710         for (var i3 = 0; i3 < decodedGeometry.length; i3++) {
41711           uintArray[i3] = decodedGeometry.charCodeAt(i3);
41712         }
41713         const tile = new VectorTile(new Pbf(uintArray.buffer));
41714         const layer = tile.layers["mpy-or"];
41715         const geometries = layer.feature(0).loadGeometry();
41716         const polygon2 = geometries.map((ring) => ring.map((point) => [point.x / layer.extent, point.y / layer.extent]));
41717         tag2 = new mapillary.OutlineTag(
41718           data.id,
41719           new mapillary.PolygonGeometry(polygon2[0]),
41720           {
41721             text,
41722             textColor: color2,
41723             lineColor: color2,
41724             lineWidth: 2,
41725             fillColor: color2,
41726             fillOpacity: 0.3
41727           }
41728         );
41729         return tag2;
41730       }
41731     },
41732     // Return the current cache
41733     cache: function() {
41734       return _mlyCache;
41735     }
41736   };
41737
41738   // modules/core/validation/models.js
41739   function validationIssue(attrs) {
41740     this.type = attrs.type;
41741     this.subtype = attrs.subtype;
41742     this.severity = attrs.severity;
41743     this.message = attrs.message;
41744     this.reference = attrs.reference;
41745     this.entityIds = attrs.entityIds;
41746     this.loc = attrs.loc;
41747     this.data = attrs.data;
41748     this.dynamicFixes = attrs.dynamicFixes;
41749     this.hash = attrs.hash;
41750     this.id = generateID.apply(this);
41751     this.key = generateKey.apply(this);
41752     this.autoFix = null;
41753     function generateID() {
41754       var parts = [this.type];
41755       if (this.hash) {
41756         parts.push(this.hash);
41757       }
41758       if (this.subtype) {
41759         parts.push(this.subtype);
41760       }
41761       if (this.entityIds) {
41762         var entityKeys = this.entityIds.slice().sort();
41763         parts.push.apply(parts, entityKeys);
41764       }
41765       return parts.join(":");
41766     }
41767     function generateKey() {
41768       return this.id + ":" + Date.now().toString();
41769     }
41770     this.extent = function(resolver) {
41771       if (this.loc) {
41772         return geoExtent(this.loc);
41773       }
41774       if (this.entityIds && this.entityIds.length) {
41775         return this.entityIds.reduce(function(extent, entityId) {
41776           return extent.extend(resolver.entity(entityId).extent(resolver));
41777         }, geoExtent());
41778       }
41779       return null;
41780     };
41781     this.fixes = function(context) {
41782       var fixes = this.dynamicFixes ? this.dynamicFixes(context) : [];
41783       var issue = this;
41784       if (issue.severity === "warning") {
41785         fixes.push(new validationIssueFix({
41786           title: _t.append("issues.fix.ignore_issue.title"),
41787           icon: "iD-icon-close",
41788           onClick: function() {
41789             context.validator().ignoreIssue(this.issue.id);
41790           }
41791         }));
41792       }
41793       fixes.forEach(function(fix) {
41794         fix.id = fix.title.stringId;
41795         fix.issue = issue;
41796         if (fix.autoArgs) {
41797           issue.autoFix = fix;
41798         }
41799       });
41800       return fixes;
41801     };
41802   }
41803   function validationIssueFix(attrs) {
41804     this.title = attrs.title;
41805     this.onClick = attrs.onClick;
41806     this.disabledReason = attrs.disabledReason;
41807     this.icon = attrs.icon;
41808     this.entityIds = attrs.entityIds || [];
41809     this.autoArgs = attrs.autoArgs;
41810     this.issue = null;
41811   }
41812
41813   // modules/services/maprules.js
41814   var buildRuleChecks = function() {
41815     return {
41816       equals: function(equals) {
41817         return function(tags) {
41818           return Object.keys(equals).every(function(k2) {
41819             return equals[k2] === tags[k2];
41820           });
41821         };
41822       },
41823       notEquals: function(notEquals) {
41824         return function(tags) {
41825           return Object.keys(notEquals).some(function(k2) {
41826             return notEquals[k2] !== tags[k2];
41827           });
41828         };
41829       },
41830       absence: function(absence) {
41831         return function(tags) {
41832           return Object.keys(tags).indexOf(absence) === -1;
41833         };
41834       },
41835       presence: function(presence) {
41836         return function(tags) {
41837           return Object.keys(tags).indexOf(presence) > -1;
41838         };
41839       },
41840       greaterThan: function(greaterThan) {
41841         var key = Object.keys(greaterThan)[0];
41842         var value = greaterThan[key];
41843         return function(tags) {
41844           return tags[key] > value;
41845         };
41846       },
41847       greaterThanEqual: function(greaterThanEqual) {
41848         var key = Object.keys(greaterThanEqual)[0];
41849         var value = greaterThanEqual[key];
41850         return function(tags) {
41851           return tags[key] >= value;
41852         };
41853       },
41854       lessThan: function(lessThan) {
41855         var key = Object.keys(lessThan)[0];
41856         var value = lessThan[key];
41857         return function(tags) {
41858           return tags[key] < value;
41859         };
41860       },
41861       lessThanEqual: function(lessThanEqual) {
41862         var key = Object.keys(lessThanEqual)[0];
41863         var value = lessThanEqual[key];
41864         return function(tags) {
41865           return tags[key] <= value;
41866         };
41867       },
41868       positiveRegex: function(positiveRegex) {
41869         var tagKey = Object.keys(positiveRegex)[0];
41870         var expression = positiveRegex[tagKey].join("|");
41871         var regex = new RegExp(expression);
41872         return function(tags) {
41873           return regex.test(tags[tagKey]);
41874         };
41875       },
41876       negativeRegex: function(negativeRegex) {
41877         var tagKey = Object.keys(negativeRegex)[0];
41878         var expression = negativeRegex[tagKey].join("|");
41879         var regex = new RegExp(expression);
41880         return function(tags) {
41881           return !regex.test(tags[tagKey]);
41882         };
41883       }
41884     };
41885   };
41886   var buildLineKeys = function() {
41887     return {
41888       highway: {
41889         rest_area: true,
41890         services: true
41891       },
41892       railway: {
41893         roundhouse: true,
41894         station: true,
41895         traverser: true,
41896         turntable: true,
41897         wash: true
41898       }
41899     };
41900   };
41901   var maprules_default = {
41902     init: function() {
41903       this._ruleChecks = buildRuleChecks();
41904       this._validationRules = [];
41905       this._areaKeys = osmAreaKeys;
41906       this._lineKeys = buildLineKeys();
41907     },
41908     // list of rules only relevant to tag checks...
41909     filterRuleChecks: function(selector) {
41910       var _ruleChecks = this._ruleChecks;
41911       return Object.keys(selector).reduce(function(rules, key) {
41912         if (["geometry", "error", "warning"].indexOf(key) === -1) {
41913           rules.push(_ruleChecks[key](selector[key]));
41914         }
41915         return rules;
41916       }, []);
41917     },
41918     // builds tagMap from mapcss-parse selector object...
41919     buildTagMap: function(selector) {
41920       var getRegexValues = function(regexes) {
41921         return regexes.map(function(regex) {
41922           return regex.replace(/\$|\^/g, "");
41923         });
41924       };
41925       var tagMap = Object.keys(selector).reduce(function(expectedTags, key) {
41926         var values;
41927         var isRegex = /regex/gi.test(key);
41928         var isEqual5 = /equals/gi.test(key);
41929         if (isRegex || isEqual5) {
41930           Object.keys(selector[key]).forEach(function(selectorKey) {
41931             values = isEqual5 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]);
41932             if (expectedTags.hasOwnProperty(selectorKey)) {
41933               values = values.concat(expectedTags[selectorKey]);
41934             }
41935             expectedTags[selectorKey] = values;
41936           });
41937         } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) {
41938           var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0];
41939           values = [selector[key][tagKey]];
41940           if (expectedTags.hasOwnProperty(tagKey)) {
41941             values = values.concat(expectedTags[tagKey]);
41942           }
41943           expectedTags[tagKey] = values;
41944         }
41945         return expectedTags;
41946       }, {});
41947       return tagMap;
41948     },
41949     // inspired by osmWay#isArea()
41950     inferGeometry: function(tagMap) {
41951       var _lineKeys = this._lineKeys;
41952       var _areaKeys = this._areaKeys;
41953       var keyValueDoesNotImplyArea = function(key2) {
41954         return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0;
41955       };
41956       var keyValueImpliesLine = function(key2) {
41957         return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0;
41958       };
41959       if (tagMap.hasOwnProperty("area")) {
41960         if (tagMap.area.indexOf("yes") > -1) {
41961           return "area";
41962         }
41963         if (tagMap.area.indexOf("no") > -1) {
41964           return "line";
41965         }
41966       }
41967       for (var key in tagMap) {
41968         if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) {
41969           return "area";
41970         }
41971         if (key in _lineKeys && keyValueImpliesLine(key)) {
41972           return "area";
41973         }
41974       }
41975       return "line";
41976     },
41977     // adds from mapcss-parse selector check...
41978     addRule: function(selector) {
41979       var rule = {
41980         // checks relevant to mapcss-selector
41981         checks: this.filterRuleChecks(selector),
41982         // true if all conditions for a tag error are true..
41983         matches: function(entity) {
41984           return this.checks.every(function(check) {
41985             return check(entity.tags);
41986           });
41987         },
41988         // borrowed from Way#isArea()
41989         inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys),
41990         geometryMatches: function(entity, graph) {
41991           if (entity.type === "node" || entity.type === "relation") {
41992             return selector.geometry === entity.type;
41993           } else if (entity.type === "way") {
41994             return this.inferredGeometry === entity.geometry(graph);
41995           }
41996         },
41997         // when geometries match and tag matches are present, return a warning...
41998         findIssues: function(entity, graph, issues) {
41999           if (this.geometryMatches(entity, graph) && this.matches(entity)) {
42000             var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning";
42001             var message = selector[severity];
42002             issues.push(new validationIssue({
42003               type: "maprules",
42004               severity,
42005               message: function() {
42006                 return message;
42007               },
42008               entityIds: [entity.id]
42009             }));
42010           }
42011         }
42012       };
42013       this._validationRules.push(rule);
42014     },
42015     clearRules: function() {
42016       this._validationRules = [];
42017     },
42018     // returns validationRules...
42019     validationRules: function() {
42020       return this._validationRules;
42021     },
42022     // returns ruleChecks
42023     ruleChecks: function() {
42024       return this._ruleChecks;
42025     }
42026   };
42027
42028   // modules/core/difference.js
42029   var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
42030   function coreDifference(base, head) {
42031     var _changes = {};
42032     var _didChange = {};
42033     var _diff = {};
42034     function checkEntityID(id2) {
42035       var h2 = head.entities[id2];
42036       var b2 = base.entities[id2];
42037       if (h2 === b2) return;
42038       if (_changes[id2]) return;
42039       if (!h2 && b2) {
42040         _changes[id2] = { base: b2, head: h2 };
42041         _didChange.deletion = true;
42042         return;
42043       }
42044       if (h2 && !b2) {
42045         _changes[id2] = { base: b2, head: h2 };
42046         _didChange.addition = true;
42047         return;
42048       }
42049       if (h2 && b2) {
42050         if (h2.members && b2.members && !(0, import_fast_deep_equal3.default)(h2.members, b2.members)) {
42051           _changes[id2] = { base: b2, head: h2 };
42052           _didChange.geometry = true;
42053           _didChange.properties = true;
42054           return;
42055         }
42056         if (h2.loc && b2.loc && !geoVecEqual(h2.loc, b2.loc)) {
42057           _changes[id2] = { base: b2, head: h2 };
42058           _didChange.geometry = true;
42059         }
42060         if (h2.nodes && b2.nodes && !(0, import_fast_deep_equal3.default)(h2.nodes, b2.nodes)) {
42061           _changes[id2] = { base: b2, head: h2 };
42062           _didChange.geometry = true;
42063         }
42064         if (h2.tags && b2.tags && !(0, import_fast_deep_equal3.default)(h2.tags, b2.tags)) {
42065           _changes[id2] = { base: b2, head: h2 };
42066           _didChange.properties = true;
42067         }
42068       }
42069     }
42070     function load() {
42071       var ids = utilArrayUniq(Object.keys(head.entities).concat(Object.keys(base.entities)));
42072       for (var i3 = 0; i3 < ids.length; i3++) {
42073         checkEntityID(ids[i3]);
42074       }
42075     }
42076     load();
42077     _diff.length = function length2() {
42078       return Object.keys(_changes).length;
42079     };
42080     _diff.changes = function changes() {
42081       return _changes;
42082     };
42083     _diff.didChange = _didChange;
42084     _diff.extantIDs = function extantIDs(includeRelMembers) {
42085       var result = /* @__PURE__ */ new Set();
42086       Object.keys(_changes).forEach(function(id2) {
42087         if (_changes[id2].head) {
42088           result.add(id2);
42089         }
42090         var h2 = _changes[id2].head;
42091         var b2 = _changes[id2].base;
42092         var entity = h2 || b2;
42093         if (includeRelMembers && entity.type === "relation") {
42094           var mh = h2 ? h2.members.map(function(m2) {
42095             return m2.id;
42096           }) : [];
42097           var mb = b2 ? b2.members.map(function(m2) {
42098             return m2.id;
42099           }) : [];
42100           utilArrayUnion(mh, mb).forEach(function(memberID) {
42101             if (head.hasEntity(memberID)) {
42102               result.add(memberID);
42103             }
42104           });
42105         }
42106       });
42107       return Array.from(result);
42108     };
42109     _diff.modified = function modified() {
42110       var result = [];
42111       Object.values(_changes).forEach(function(change) {
42112         if (change.base && change.head) {
42113           result.push(change.head);
42114         }
42115       });
42116       return result;
42117     };
42118     _diff.created = function created() {
42119       var result = [];
42120       Object.values(_changes).forEach(function(change) {
42121         if (!change.base && change.head) {
42122           result.push(change.head);
42123         }
42124       });
42125       return result;
42126     };
42127     _diff.deleted = function deleted() {
42128       var result = [];
42129       Object.values(_changes).forEach(function(change) {
42130         if (change.base && !change.head) {
42131           result.push(change.base);
42132         }
42133       });
42134       return result;
42135     };
42136     _diff.summary = function summary() {
42137       var relevant = {};
42138       var keys2 = Object.keys(_changes);
42139       for (var i3 = 0; i3 < keys2.length; i3++) {
42140         var change = _changes[keys2[i3]];
42141         if (change.head && change.head.geometry(head) !== "vertex") {
42142           addEntity(change.head, head, change.base ? "modified" : "created");
42143         } else if (change.base && change.base.geometry(base) !== "vertex") {
42144           addEntity(change.base, base, "deleted");
42145         } else if (change.base && change.head) {
42146           var moved = !(0, import_fast_deep_equal3.default)(change.base.loc, change.head.loc);
42147           var retagged = !(0, import_fast_deep_equal3.default)(change.base.tags, change.head.tags);
42148           if (moved) {
42149             addParents(change.head);
42150           }
42151           if (retagged || moved && change.head.hasInterestingTags()) {
42152             addEntity(change.head, head, "modified");
42153           }
42154         } else if (change.head && change.head.hasInterestingTags()) {
42155           addEntity(change.head, head, "created");
42156         } else if (change.base && change.base.hasInterestingTags()) {
42157           addEntity(change.base, base, "deleted");
42158         }
42159       }
42160       return Object.values(relevant);
42161       function addEntity(entity, graph, changeType) {
42162         relevant[entity.id] = {
42163           entity,
42164           graph,
42165           changeType
42166         };
42167       }
42168       function addParents(entity) {
42169         var parents = head.parentWays(entity);
42170         for (var j2 = parents.length - 1; j2 >= 0; j2--) {
42171           var parent = parents[j2];
42172           if (!(parent.id in relevant)) {
42173             addEntity(parent, head, "modified");
42174           }
42175         }
42176       }
42177     };
42178     _diff.complete = function complete(extent) {
42179       var result = {};
42180       var id2, change;
42181       for (id2 in _changes) {
42182         change = _changes[id2];
42183         var h2 = change.head;
42184         var b2 = change.base;
42185         var entity = h2 || b2;
42186         var i3;
42187         if (extent && (!h2 || !h2.intersects(extent, head)) && (!b2 || !b2.intersects(extent, base))) {
42188           continue;
42189         }
42190         result[id2] = h2;
42191         if (entity.type === "way") {
42192           var nh = h2 ? h2.nodes : [];
42193           var nb = b2 ? b2.nodes : [];
42194           var diff;
42195           diff = utilArrayDifference(nh, nb);
42196           for (i3 = 0; i3 < diff.length; i3++) {
42197             result[diff[i3]] = head.hasEntity(diff[i3]);
42198           }
42199           diff = utilArrayDifference(nb, nh);
42200           for (i3 = 0; i3 < diff.length; i3++) {
42201             result[diff[i3]] = head.hasEntity(diff[i3]);
42202           }
42203         }
42204         if (entity.type === "relation" && entity.isMultipolygon()) {
42205           var mh = h2 ? h2.members.map(function(m2) {
42206             return m2.id;
42207           }) : [];
42208           var mb = b2 ? b2.members.map(function(m2) {
42209             return m2.id;
42210           }) : [];
42211           var ids = utilArrayUnion(mh, mb);
42212           for (i3 = 0; i3 < ids.length; i3++) {
42213             var member = head.hasEntity(ids[i3]);
42214             if (!member) continue;
42215             if (extent && !member.intersects(extent, head)) continue;
42216             result[ids[i3]] = member;
42217           }
42218         }
42219         addParents(head.parentWays(entity), result);
42220         addParents(head.parentRelations(entity), result);
42221       }
42222       return result;
42223       function addParents(parents, result2) {
42224         for (var i4 = 0; i4 < parents.length; i4++) {
42225           var parent = parents[i4];
42226           if (parent.id in result2) continue;
42227           result2[parent.id] = parent;
42228           addParents(head.parentRelations(parent), result2);
42229         }
42230       }
42231     };
42232     return _diff;
42233   }
42234
42235   // modules/core/tree.js
42236   function coreTree(head) {
42237     var _rtree = new RBush();
42238     var _bboxes = {};
42239     var _segmentsRTree = new RBush();
42240     var _segmentsBBoxes = {};
42241     var _segmentsByWayId = {};
42242     var tree = {};
42243     function entityBBox(entity) {
42244       var bbox2 = entity.extent(head).bbox();
42245       bbox2.id = entity.id;
42246       _bboxes[entity.id] = bbox2;
42247       return bbox2;
42248     }
42249     function segmentBBox(segment) {
42250       var extent = segment.extent(head);
42251       if (!extent) return null;
42252       var bbox2 = extent.bbox();
42253       bbox2.segment = segment;
42254       _segmentsBBoxes[segment.id] = bbox2;
42255       return bbox2;
42256     }
42257     function removeEntity(entity) {
42258       _rtree.remove(_bboxes[entity.id]);
42259       delete _bboxes[entity.id];
42260       if (_segmentsByWayId[entity.id]) {
42261         _segmentsByWayId[entity.id].forEach(function(segment) {
42262           _segmentsRTree.remove(_segmentsBBoxes[segment.id]);
42263           delete _segmentsBBoxes[segment.id];
42264         });
42265         delete _segmentsByWayId[entity.id];
42266       }
42267     }
42268     function loadEntities(entities) {
42269       _rtree.load(entities.map(entityBBox));
42270       var segments = [];
42271       entities.forEach(function(entity) {
42272         if (entity.segments) {
42273           var entitySegments = entity.segments(head);
42274           _segmentsByWayId[entity.id] = entitySegments;
42275           segments = segments.concat(entitySegments);
42276         }
42277       });
42278       if (segments.length) _segmentsRTree.load(segments.map(segmentBBox).filter(Boolean));
42279     }
42280     function updateParents(entity, insertions, memo) {
42281       head.parentWays(entity).forEach(function(way) {
42282         if (_bboxes[way.id]) {
42283           removeEntity(way);
42284           insertions[way.id] = way;
42285         }
42286         updateParents(way, insertions, memo);
42287       });
42288       head.parentRelations(entity).forEach(function(relation) {
42289         if (memo[relation.id]) return;
42290         memo[relation.id] = true;
42291         if (_bboxes[relation.id]) {
42292           removeEntity(relation);
42293           insertions[relation.id] = relation;
42294         }
42295         updateParents(relation, insertions, memo);
42296       });
42297     }
42298     tree.rebase = function(entities, force) {
42299       var insertions = {};
42300       for (var i3 = 0; i3 < entities.length; i3++) {
42301         var entity = entities[i3];
42302         if (!entity.visible) continue;
42303         if (head.entities.hasOwnProperty(entity.id) || _bboxes[entity.id]) {
42304           if (!force) {
42305             continue;
42306           } else if (_bboxes[entity.id]) {
42307             removeEntity(entity);
42308           }
42309         }
42310         insertions[entity.id] = entity;
42311         updateParents(entity, insertions, {});
42312       }
42313       loadEntities(Object.values(insertions));
42314       return tree;
42315     };
42316     function updateToGraph(graph) {
42317       if (graph === head) return;
42318       var diff = coreDifference(head, graph);
42319       head = graph;
42320       var changed = diff.didChange;
42321       if (!changed.addition && !changed.deletion && !changed.geometry) return;
42322       var insertions = {};
42323       if (changed.deletion) {
42324         diff.deleted().forEach(function(entity) {
42325           removeEntity(entity);
42326         });
42327       }
42328       if (changed.geometry) {
42329         diff.modified().forEach(function(entity) {
42330           removeEntity(entity);
42331           insertions[entity.id] = entity;
42332           updateParents(entity, insertions, {});
42333         });
42334       }
42335       if (changed.addition) {
42336         diff.created().forEach(function(entity) {
42337           insertions[entity.id] = entity;
42338         });
42339       }
42340       loadEntities(Object.values(insertions));
42341     }
42342     tree.intersects = function(extent, graph) {
42343       updateToGraph(graph);
42344       return _rtree.search(extent.bbox()).map(function(bbox2) {
42345         return graph.entity(bbox2.id);
42346       });
42347     };
42348     tree.waySegments = function(extent, graph) {
42349       updateToGraph(graph);
42350       return _segmentsRTree.search(extent.bbox()).map(function(bbox2) {
42351         return bbox2.segment;
42352       });
42353     };
42354     return tree;
42355   }
42356
42357   // modules/svg/icon.js
42358   function svgIcon(name, svgklass, useklass) {
42359     return function drawIcon(selection2) {
42360       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);
42361     };
42362   }
42363
42364   // modules/ui/modal.js
42365   function uiModal(selection2, blocking) {
42366     let keybinding = utilKeybinding("modal");
42367     let previous = selection2.select("div.modal");
42368     let animate = previous.empty();
42369     previous.transition().duration(200).style("opacity", 0).remove();
42370     let shaded = selection2.append("div").attr("class", "shaded").style("opacity", 0);
42371     shaded.close = () => {
42372       shaded.transition().duration(200).style("opacity", 0).remove();
42373       modal.transition().duration(200).style("top", "0px");
42374       select_default2(document).call(keybinding.unbind);
42375     };
42376     let modal = shaded.append("div").attr("class", "modal fillL");
42377     modal.append("input").attr("class", "keytrap keytrap-first").on("focus.keytrap", moveFocusToLast);
42378     if (!blocking) {
42379       shaded.on("click.remove-modal", (d3_event) => {
42380         if (d3_event.target === this) {
42381           shaded.close();
42382         }
42383       });
42384       modal.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", shaded.close).call(svgIcon("#iD-icon-close"));
42385       keybinding.on("\u232B", shaded.close).on("\u238B", shaded.close);
42386       select_default2(document).call(keybinding);
42387     }
42388     modal.append("div").attr("class", "content");
42389     modal.append("input").attr("class", "keytrap keytrap-last").on("focus.keytrap", moveFocusToFirst);
42390     if (animate) {
42391       shaded.transition().style("opacity", 1);
42392     } else {
42393       shaded.style("opacity", 1);
42394     }
42395     return shaded;
42396     function moveFocusToFirst() {
42397       let node = modal.select("a, button, input:not(.keytrap), select, textarea").node();
42398       if (node) {
42399         node.focus();
42400       } else {
42401         select_default2(this).node().blur();
42402       }
42403     }
42404     function moveFocusToLast() {
42405       let nodes = modal.selectAll("a, button, input:not(.keytrap), select, textarea").nodes();
42406       if (nodes.length) {
42407         nodes[nodes.length - 1].focus();
42408       } else {
42409         select_default2(this).node().blur();
42410       }
42411     }
42412   }
42413
42414   // modules/ui/loading.js
42415   function uiLoading(context) {
42416     let _modalSelection = select_default2(null);
42417     let _message = "";
42418     let _blocking = false;
42419     let loading = (selection2) => {
42420       _modalSelection = uiModal(selection2, _blocking);
42421       let loadertext = _modalSelection.select(".content").classed("loading-modal", true).append("div").attr("class", "modal-section fillL");
42422       loadertext.append("img").attr("class", "loader").attr("src", context.imagePath("loader-white.gif"));
42423       loadertext.append("h3").html(_message);
42424       _modalSelection.select("button.close").attr("class", "hide");
42425       return loading;
42426     };
42427     loading.message = function(val) {
42428       if (!arguments.length) return _message;
42429       _message = val;
42430       return loading;
42431     };
42432     loading.blocking = function(val) {
42433       if (!arguments.length) return _blocking;
42434       _blocking = val;
42435       return loading;
42436     };
42437     loading.close = () => {
42438       _modalSelection.remove();
42439     };
42440     loading.isShown = () => {
42441       return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode;
42442     };
42443     return loading;
42444   }
42445
42446   // modules/core/history.js
42447   function coreHistory(context) {
42448     var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error");
42449     var lock = utilSessionMutex("lock");
42450     var _hasUnresolvedRestorableChanges = lock.lock() && !!corePreferences(getKey("saved_history"));
42451     var duration = 150;
42452     var _imageryUsed = [];
42453     var _photoOverlaysUsed = [];
42454     var _checkpoints = {};
42455     var _pausedGraph;
42456     var _stack;
42457     var _index;
42458     var _tree;
42459     function _act(actions, t2) {
42460       actions = Array.prototype.slice.call(actions);
42461       var annotation;
42462       if (typeof actions[actions.length - 1] !== "function") {
42463         annotation = actions.pop();
42464       }
42465       var graph = _stack[_index].graph;
42466       for (var i3 = 0; i3 < actions.length; i3++) {
42467         graph = actions[i3](graph, t2);
42468       }
42469       return {
42470         graph,
42471         annotation,
42472         imageryUsed: _imageryUsed,
42473         photoOverlaysUsed: _photoOverlaysUsed,
42474         transform: context.projection.transform(),
42475         selectedIDs: context.selectedIDs()
42476       };
42477     }
42478     function _perform(args, t2) {
42479       var previous = _stack[_index].graph;
42480       _stack = _stack.slice(0, _index + 1);
42481       var actionResult = _act(args, t2);
42482       _stack.push(actionResult);
42483       _index++;
42484       return change(previous);
42485     }
42486     function _replace(args, t2) {
42487       var previous = _stack[_index].graph;
42488       var actionResult = _act(args, t2);
42489       _stack[_index] = actionResult;
42490       return change(previous);
42491     }
42492     function _overwrite(args, t2) {
42493       var previous = _stack[_index].graph;
42494       if (_index > 0) {
42495         _index--;
42496         _stack.pop();
42497       }
42498       _stack = _stack.slice(0, _index + 1);
42499       var actionResult = _act(args, t2);
42500       _stack.push(actionResult);
42501       _index++;
42502       return change(previous);
42503     }
42504     function change(previous) {
42505       var difference2 = coreDifference(previous, history.graph());
42506       if (!_pausedGraph) {
42507         dispatch14.call("change", this, difference2);
42508       }
42509       return difference2;
42510     }
42511     function getKey(n3) {
42512       return "iD_" + window.location.origin + "_" + n3;
42513     }
42514     var history = {
42515       graph: function() {
42516         return _stack[_index].graph;
42517       },
42518       tree: function() {
42519         return _tree;
42520       },
42521       base: function() {
42522         return _stack[0].graph;
42523       },
42524       merge: function(entities) {
42525         var stack = _stack.map(function(state) {
42526           return state.graph;
42527         });
42528         _stack[0].graph.rebase(entities, stack, false);
42529         _tree.rebase(entities, false);
42530         dispatch14.call("merge", this, entities);
42531       },
42532       perform: function() {
42533         select_default2(document).interrupt("history.perform");
42534         var transitionable = false;
42535         var action0 = arguments[0];
42536         if (arguments.length === 1 || arguments.length === 2 && typeof arguments[1] !== "function") {
42537           transitionable = !!action0.transitionable;
42538         }
42539         if (transitionable) {
42540           var origArguments = arguments;
42541           select_default2(document).transition("history.perform").duration(duration).ease(linear2).tween("history.tween", function() {
42542             return function(t2) {
42543               if (t2 < 1) _overwrite([action0], t2);
42544             };
42545           }).on("start", function() {
42546             _perform([action0], 0);
42547           }).on("end interrupt", function() {
42548             _overwrite(origArguments, 1);
42549           });
42550         } else {
42551           return _perform(arguments);
42552         }
42553       },
42554       replace: function() {
42555         select_default2(document).interrupt("history.perform");
42556         return _replace(arguments, 1);
42557       },
42558       // Same as calling pop and then perform
42559       overwrite: function() {
42560         select_default2(document).interrupt("history.perform");
42561         return _overwrite(arguments, 1);
42562       },
42563       pop: function(n3) {
42564         select_default2(document).interrupt("history.perform");
42565         var previous = _stack[_index].graph;
42566         if (isNaN(+n3) || +n3 < 0) {
42567           n3 = 1;
42568         }
42569         while (n3-- > 0 && _index > 0) {
42570           _index--;
42571           _stack.pop();
42572         }
42573         return change(previous);
42574       },
42575       // Back to the previous annotated state or _index = 0.
42576       undo: function() {
42577         select_default2(document).interrupt("history.perform");
42578         var previousStack = _stack[_index];
42579         var previous = previousStack.graph;
42580         while (_index > 0) {
42581           _index--;
42582           if (_stack[_index].annotation) break;
42583         }
42584         dispatch14.call("undone", this, _stack[_index], previousStack);
42585         return change(previous);
42586       },
42587       // Forward to the next annotated state.
42588       redo: function() {
42589         select_default2(document).interrupt("history.perform");
42590         var previousStack = _stack[_index];
42591         var previous = previousStack.graph;
42592         var tryIndex = _index;
42593         while (tryIndex < _stack.length - 1) {
42594           tryIndex++;
42595           if (_stack[tryIndex].annotation) {
42596             _index = tryIndex;
42597             dispatch14.call("redone", this, _stack[_index], previousStack);
42598             break;
42599           }
42600         }
42601         return change(previous);
42602       },
42603       pauseChangeDispatch: function() {
42604         if (!_pausedGraph) {
42605           _pausedGraph = _stack[_index].graph;
42606         }
42607       },
42608       resumeChangeDispatch: function() {
42609         if (_pausedGraph) {
42610           var previous = _pausedGraph;
42611           _pausedGraph = null;
42612           return change(previous);
42613         }
42614       },
42615       undoAnnotation: function() {
42616         var i3 = _index;
42617         while (i3 >= 0) {
42618           if (_stack[i3].annotation) return _stack[i3].annotation;
42619           i3--;
42620         }
42621       },
42622       redoAnnotation: function() {
42623         var i3 = _index + 1;
42624         while (i3 <= _stack.length - 1) {
42625           if (_stack[i3].annotation) return _stack[i3].annotation;
42626           i3++;
42627         }
42628       },
42629       // Returns the entities from the active graph with bounding boxes
42630       // overlapping the given `extent`.
42631       intersects: function(extent) {
42632         return _tree.intersects(extent, _stack[_index].graph);
42633       },
42634       difference: function() {
42635         var base = _stack[0].graph;
42636         var head = _stack[_index].graph;
42637         return coreDifference(base, head);
42638       },
42639       changes: function(action) {
42640         var base = _stack[0].graph;
42641         var head = _stack[_index].graph;
42642         if (action) {
42643           head = action(head);
42644         }
42645         var difference2 = coreDifference(base, head);
42646         return {
42647           modified: difference2.modified(),
42648           created: difference2.created(),
42649           deleted: difference2.deleted()
42650         };
42651       },
42652       hasChanges: function() {
42653         return this.difference().length() > 0;
42654       },
42655       imageryUsed: function(sources) {
42656         if (sources) {
42657           _imageryUsed = sources;
42658           return history;
42659         } else {
42660           var s2 = /* @__PURE__ */ new Set();
42661           _stack.slice(1, _index + 1).forEach(function(state) {
42662             state.imageryUsed.forEach(function(source) {
42663               if (source !== "Custom") {
42664                 s2.add(source);
42665               }
42666             });
42667           });
42668           return Array.from(s2);
42669         }
42670       },
42671       photoOverlaysUsed: function(sources) {
42672         if (sources) {
42673           _photoOverlaysUsed = sources;
42674           return history;
42675         } else {
42676           var s2 = /* @__PURE__ */ new Set();
42677           _stack.slice(1, _index + 1).forEach(function(state) {
42678             if (state.photoOverlaysUsed && Array.isArray(state.photoOverlaysUsed)) {
42679               state.photoOverlaysUsed.forEach(function(photoOverlay) {
42680                 s2.add(photoOverlay);
42681               });
42682             }
42683           });
42684           return Array.from(s2);
42685         }
42686       },
42687       // save the current history state
42688       checkpoint: function(key) {
42689         _checkpoints[key] = {
42690           stack: _stack,
42691           index: _index
42692         };
42693         return history;
42694       },
42695       // restore history state to a given checkpoint or reset completely
42696       reset: function(key) {
42697         if (key !== void 0 && _checkpoints.hasOwnProperty(key)) {
42698           _stack = _checkpoints[key].stack;
42699           _index = _checkpoints[key].index;
42700         } else {
42701           _stack = [{ graph: coreGraph() }];
42702           _index = 0;
42703           _tree = coreTree(_stack[0].graph);
42704           _checkpoints = {};
42705         }
42706         dispatch14.call("reset");
42707         dispatch14.call("change");
42708         return history;
42709       },
42710       // `toIntroGraph()` is used to export the intro graph used by the walkthrough.
42711       //
42712       // To use it:
42713       //  1. Start the walkthrough.
42714       //  2. Get to a "free editing" tutorial step
42715       //  3. Make your edits to the walkthrough map
42716       //  4. In your browser dev console run:
42717       //        `id.history().toIntroGraph()`
42718       //  5. This outputs stringified JSON to the browser console
42719       //  6. Copy it to `data/intro_graph.json` and prettify it in your code editor
42720       toIntroGraph: function() {
42721         var nextID = { n: 0, r: 0, w: 0 };
42722         var permIDs = {};
42723         var graph = this.graph();
42724         var baseEntities = {};
42725         Object.values(graph.base().entities).forEach(function(entity) {
42726           var copy2 = copyIntroEntity(entity);
42727           baseEntities[copy2.id] = copy2;
42728         });
42729         Object.keys(graph.entities).forEach(function(id2) {
42730           var entity = graph.entities[id2];
42731           if (entity) {
42732             var copy2 = copyIntroEntity(entity);
42733             baseEntities[copy2.id] = copy2;
42734           } else {
42735             delete baseEntities[id2];
42736           }
42737         });
42738         Object.values(baseEntities).forEach(function(entity) {
42739           if (Array.isArray(entity.nodes)) {
42740             entity.nodes = entity.nodes.map(function(node) {
42741               return permIDs[node] || node;
42742             });
42743           }
42744           if (Array.isArray(entity.members)) {
42745             entity.members = entity.members.map(function(member) {
42746               member.id = permIDs[member.id] || member.id;
42747               return member;
42748             });
42749           }
42750         });
42751         return JSON.stringify({ dataIntroGraph: baseEntities });
42752         function copyIntroEntity(source) {
42753           var copy2 = utilObjectOmit(source, ["type", "user", "v", "version", "visible"]);
42754           if (copy2.tags && !Object.keys(copy2.tags)) {
42755             delete copy2.tags;
42756           }
42757           if (Array.isArray(copy2.loc)) {
42758             copy2.loc[0] = +copy2.loc[0].toFixed(6);
42759             copy2.loc[1] = +copy2.loc[1].toFixed(6);
42760           }
42761           var match = source.id.match(/([nrw])-\d*/);
42762           if (match !== null) {
42763             var nrw = match[1];
42764             var permID;
42765             do {
42766               permID = nrw + ++nextID[nrw];
42767             } while (baseEntities.hasOwnProperty(permID));
42768             copy2.id = permIDs[source.id] = permID;
42769           }
42770           return copy2;
42771         }
42772       },
42773       toJSON: function() {
42774         if (!this.hasChanges()) return;
42775         var allEntities = {};
42776         var baseEntities = {};
42777         var base = _stack[0];
42778         var s2 = _stack.map(function(i3) {
42779           var modified = [];
42780           var deleted = [];
42781           Object.keys(i3.graph.entities).forEach(function(id2) {
42782             var entity = i3.graph.entities[id2];
42783             if (entity) {
42784               var key = osmEntity.key(entity);
42785               allEntities[key] = entity;
42786               modified.push(key);
42787             } else {
42788               deleted.push(id2);
42789             }
42790             if (id2 in base.graph.entities) {
42791               baseEntities[id2] = base.graph.entities[id2];
42792             }
42793             if (entity && entity.nodes) {
42794               entity.nodes.forEach(function(nodeID) {
42795                 if (nodeID in base.graph.entities) {
42796                   baseEntities[nodeID] = base.graph.entities[nodeID];
42797                 }
42798               });
42799             }
42800             var baseParents = base.graph._parentWays[id2];
42801             if (baseParents) {
42802               baseParents.forEach(function(parentID) {
42803                 if (parentID in base.graph.entities) {
42804                   baseEntities[parentID] = base.graph.entities[parentID];
42805                 }
42806               });
42807             }
42808           });
42809           var x2 = {};
42810           if (modified.length) x2.modified = modified;
42811           if (deleted.length) x2.deleted = deleted;
42812           if (i3.imageryUsed) x2.imageryUsed = i3.imageryUsed;
42813           if (i3.photoOverlaysUsed) x2.photoOverlaysUsed = i3.photoOverlaysUsed;
42814           if (i3.annotation) x2.annotation = i3.annotation;
42815           if (i3.transform) x2.transform = i3.transform;
42816           if (i3.selectedIDs) x2.selectedIDs = i3.selectedIDs;
42817           return x2;
42818         });
42819         return JSON.stringify({
42820           version: 3,
42821           entities: Object.values(allEntities),
42822           baseEntities: Object.values(baseEntities),
42823           stack: s2,
42824           nextIDs: osmEntity.id.next,
42825           index: _index,
42826           // note the time the changes were saved
42827           timestamp: (/* @__PURE__ */ new Date()).getTime()
42828         });
42829       },
42830       fromJSON: function(json, loadChildNodes) {
42831         var h2 = JSON.parse(json);
42832         var loadComplete = true;
42833         osmEntity.id.next = h2.nextIDs;
42834         _index = h2.index;
42835         if (h2.version === 2 || h2.version === 3) {
42836           var allEntities = {};
42837           h2.entities.forEach(function(entity) {
42838             allEntities[osmEntity.key(entity)] = osmEntity(entity);
42839           });
42840           if (h2.version === 3) {
42841             var baseEntities = h2.baseEntities.map(function(d2) {
42842               return osmEntity(d2);
42843             });
42844             var stack = _stack.map(function(state) {
42845               return state.graph;
42846             });
42847             _stack[0].graph.rebase(baseEntities, stack, true);
42848             _tree.rebase(baseEntities, true);
42849             if (loadChildNodes) {
42850               var osm = context.connection();
42851               var baseWays = baseEntities.filter(function(e3) {
42852                 return e3.type === "way";
42853               });
42854               var nodeIDs = baseWays.reduce(function(acc, way) {
42855                 return utilArrayUnion(acc, way.nodes);
42856               }, []);
42857               var missing = nodeIDs.filter(function(n3) {
42858                 return !_stack[0].graph.hasEntity(n3);
42859               });
42860               if (missing.length && osm) {
42861                 loadComplete = false;
42862                 context.map().redrawEnable(false);
42863                 var loading = uiLoading(context).blocking(true);
42864                 context.container().call(loading);
42865                 var childNodesLoaded = function(err, result) {
42866                   if (!err) {
42867                     var visibleGroups = utilArrayGroupBy(result.data, "visible");
42868                     var visibles = visibleGroups.true || [];
42869                     var invisibles = visibleGroups.false || [];
42870                     if (visibles.length) {
42871                       var visibleIDs = visibles.map(function(entity) {
42872                         return entity.id;
42873                       });
42874                       var stack2 = _stack.map(function(state) {
42875                         return state.graph;
42876                       });
42877                       missing = utilArrayDifference(missing, visibleIDs);
42878                       _stack[0].graph.rebase(visibles, stack2, true);
42879                       _tree.rebase(visibles, true);
42880                     }
42881                     invisibles.forEach(function(entity) {
42882                       osm.loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded);
42883                     });
42884                   }
42885                   if (err || !missing.length) {
42886                     loading.close();
42887                     context.map().redrawEnable(true);
42888                     dispatch14.call("change");
42889                     dispatch14.call("restore", this);
42890                   }
42891                 };
42892                 osm.loadMultiple(missing, childNodesLoaded);
42893               }
42894             }
42895           }
42896           _stack = h2.stack.map(function(d2) {
42897             var entities = {}, entity;
42898             if (d2.modified) {
42899               d2.modified.forEach(function(key) {
42900                 entity = allEntities[key];
42901                 entities[entity.id] = entity;
42902               });
42903             }
42904             if (d2.deleted) {
42905               d2.deleted.forEach(function(id2) {
42906                 entities[id2] = void 0;
42907               });
42908             }
42909             return {
42910               graph: coreGraph(_stack[0].graph).load(entities),
42911               annotation: d2.annotation,
42912               imageryUsed: d2.imageryUsed,
42913               photoOverlaysUsed: d2.photoOverlaysUsed,
42914               transform: d2.transform,
42915               selectedIDs: d2.selectedIDs
42916             };
42917           });
42918         } else {
42919           _stack = h2.stack.map(function(d2) {
42920             var entities = {};
42921             for (var i3 in d2.entities) {
42922               var entity = d2.entities[i3];
42923               entities[i3] = entity === "undefined" ? void 0 : osmEntity(entity);
42924             }
42925             d2.graph = coreGraph(_stack[0].graph).load(entities);
42926             return d2;
42927           });
42928         }
42929         var transform2 = _stack[_index].transform;
42930         if (transform2) {
42931           context.map().transformEase(transform2, 0);
42932         }
42933         if (loadComplete) {
42934           dispatch14.call("change");
42935           dispatch14.call("restore", this);
42936         }
42937         return history;
42938       },
42939       lock: function() {
42940         return lock.lock();
42941       },
42942       unlock: function() {
42943         lock.unlock();
42944       },
42945       save: function() {
42946         if (lock.locked() && // don't overwrite existing, unresolved changes
42947         !_hasUnresolvedRestorableChanges) {
42948           const success = corePreferences(getKey("saved_history"), history.toJSON() || null);
42949           if (!success) dispatch14.call("storage_error");
42950         }
42951         return history;
42952       },
42953       // delete the history version saved in localStorage
42954       clearSaved: function() {
42955         context.debouncedSave.cancel();
42956         if (lock.locked()) {
42957           _hasUnresolvedRestorableChanges = false;
42958           corePreferences(getKey("saved_history"), null);
42959           corePreferences("comment", null);
42960           corePreferences("hashtags", null);
42961           corePreferences("source", null);
42962         }
42963         return history;
42964       },
42965       savedHistoryJSON: function() {
42966         return corePreferences(getKey("saved_history"));
42967       },
42968       hasRestorableChanges: function() {
42969         return _hasUnresolvedRestorableChanges;
42970       },
42971       // load history from a version stored in localStorage
42972       restore: function() {
42973         if (lock.locked()) {
42974           _hasUnresolvedRestorableChanges = false;
42975           var json = this.savedHistoryJSON();
42976           if (json) history.fromJSON(json, true);
42977         }
42978       },
42979       _getKey: getKey
42980     };
42981     history.reset();
42982     return utilRebind(history, dispatch14, "on");
42983   }
42984
42985   // modules/validations/index.js
42986   var validations_exports = {};
42987   __export(validations_exports, {
42988     validationAlmostJunction: () => validationAlmostJunction,
42989     validationCloseNodes: () => validationCloseNodes,
42990     validationCrossingWays: () => validationCrossingWays,
42991     validationDisconnectedWay: () => validationDisconnectedWay,
42992     validationFormatting: () => validationFormatting,
42993     validationHelpRequest: () => validationHelpRequest,
42994     validationImpossibleOneway: () => validationImpossibleOneway,
42995     validationIncompatibleSource: () => validationIncompatibleSource,
42996     validationMaprules: () => validationMaprules,
42997     validationMismatchedGeometry: () => validationMismatchedGeometry,
42998     validationMissingRole: () => validationMissingRole,
42999     validationMissingTag: () => validationMissingTag,
43000     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
43001     validationOsmApiLimits: () => validationOsmApiLimits,
43002     validationOutdatedTags: () => validationOutdatedTags,
43003     validationPrivateData: () => validationPrivateData,
43004     validationSuspiciousName: () => validationSuspiciousName,
43005     validationUnsquareWay: () => validationUnsquareWay
43006   });
43007
43008   // modules/util/utilDisplayLabel.js
43009   function utilDisplayLabel(entity, graphOrGeometry, verbose) {
43010     var result;
43011     var displayName = utilDisplayName(entity);
43012     var preset = typeof graphOrGeometry === "string" ? _mainPresetIndex.matchTags(entity.tags, graphOrGeometry) : _mainPresetIndex.match(entity, graphOrGeometry);
43013     var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
43014     if (verbose) {
43015       result = [presetName, displayName].filter(Boolean).join(" ");
43016     } else {
43017       result = displayName || presetName;
43018     }
43019     return result || utilDisplayType(entity.id);
43020   }
43021
43022   // modules/validations/almost_junction.js
43023   function validationAlmostJunction(context) {
43024     const type2 = "almost_junction";
43025     const EXTEND_TH_METERS = 5;
43026     const WELD_TH_METERS = 0.75;
43027     const CLOSE_NODE_TH = EXTEND_TH_METERS - WELD_TH_METERS;
43028     const SIG_ANGLE_TH = Math.atan(WELD_TH_METERS / EXTEND_TH_METERS);
43029     function isHighway(entity) {
43030       return entity.type === "way" && osmRoutableHighwayTagValues[entity.tags.highway];
43031     }
43032     function isTaggedAsNotContinuing(node) {
43033       return node.tags.noexit === "yes" || node.tags.amenity === "parking_entrance" || node.tags.entrance && node.tags.entrance !== "no";
43034     }
43035     const validation = function checkAlmostJunction(entity, graph) {
43036       if (!isHighway(entity)) return [];
43037       if (entity.isDegenerate()) return [];
43038       const tree = context.history().tree();
43039       const extendableNodeInfos = findConnectableEndNodesByExtension(entity);
43040       let issues = [];
43041       extendableNodeInfos.forEach((extendableNodeInfo) => {
43042         issues.push(new validationIssue({
43043           type: type2,
43044           subtype: "highway-highway",
43045           severity: "warning",
43046           message: function(context2) {
43047             const entity1 = context2.hasEntity(this.entityIds[0]);
43048             if (this.entityIds[0] === this.entityIds[2]) {
43049               return entity1 ? _t.append("issues.almost_junction.self.message", {
43050                 feature: utilDisplayLabel(entity1, context2.graph())
43051               }) : "";
43052             } else {
43053               const entity2 = context2.hasEntity(this.entityIds[2]);
43054               return entity1 && entity2 ? _t.append("issues.almost_junction.message", {
43055                 feature: utilDisplayLabel(entity1, context2.graph()),
43056                 feature2: utilDisplayLabel(entity2, context2.graph())
43057               }) : "";
43058             }
43059           },
43060           reference: showReference,
43061           entityIds: [
43062             entity.id,
43063             extendableNodeInfo.node.id,
43064             extendableNodeInfo.wid
43065           ],
43066           loc: extendableNodeInfo.node.loc,
43067           hash: JSON.stringify(extendableNodeInfo.node.loc),
43068           data: {
43069             midId: extendableNodeInfo.mid.id,
43070             edge: extendableNodeInfo.edge,
43071             cross_loc: extendableNodeInfo.cross_loc
43072           },
43073           dynamicFixes: makeFixes
43074         }));
43075       });
43076       return issues;
43077       function makeFixes(context2) {
43078         let fixes = [new validationIssueFix({
43079           icon: "iD-icon-abutment",
43080           title: _t.append("issues.fix.connect_features.title"),
43081           onClick: function(context3) {
43082             const annotation = _t("issues.fix.connect_almost_junction.annotation");
43083             const [, endNodeId, crossWayId] = this.issue.entityIds;
43084             const midNode = context3.entity(this.issue.data.midId);
43085             const endNode = context3.entity(endNodeId);
43086             const crossWay = context3.entity(crossWayId);
43087             const nearEndNodes = findNearbyEndNodes(endNode, crossWay);
43088             if (nearEndNodes.length > 0) {
43089               const collinear = findSmallJoinAngle(midNode, endNode, nearEndNodes);
43090               if (collinear) {
43091                 context3.perform(
43092                   actionMergeNodes([collinear.id, endNode.id], collinear.loc),
43093                   annotation
43094                 );
43095                 return;
43096               }
43097             }
43098             const targetEdge = this.issue.data.edge;
43099             const crossLoc = this.issue.data.cross_loc;
43100             const edgeNodes = [context3.entity(targetEdge[0]), context3.entity(targetEdge[1])];
43101             const closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
43102             if (closestNodeInfo.distance < WELD_TH_METERS) {
43103               context3.perform(
43104                 actionMergeNodes([closestNodeInfo.node.id, endNode.id], closestNodeInfo.node.loc),
43105                 annotation
43106               );
43107             } else {
43108               context3.perform(
43109                 actionAddMidpoint({ loc: crossLoc, edge: targetEdge }, endNode),
43110                 annotation
43111               );
43112             }
43113           }
43114         })];
43115         const node = context2.hasEntity(this.entityIds[1]);
43116         if (node && !node.hasInterestingTags()) {
43117           fixes.push(new validationIssueFix({
43118             icon: "maki-barrier",
43119             title: _t.append("issues.fix.tag_as_disconnected.title"),
43120             onClick: function(context3) {
43121               const nodeID = this.issue.entityIds[1];
43122               const tags = Object.assign({}, context3.entity(nodeID).tags);
43123               tags.noexit = "yes";
43124               context3.perform(
43125                 actionChangeTags(nodeID, tags),
43126                 _t("issues.fix.tag_as_disconnected.annotation")
43127               );
43128             }
43129           }));
43130         }
43131         return fixes;
43132       }
43133       function showReference(selection2) {
43134         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.almost_junction.highway-highway.reference"));
43135       }
43136       function isExtendableCandidate(node, way) {
43137         const osm = services.osm;
43138         if (osm && !osm.isDataLoaded(node.loc)) {
43139           return false;
43140         }
43141         if (isTaggedAsNotContinuing(node) || graph.parentWays(node).length !== 1) {
43142           return false;
43143         }
43144         let occurrences = 0;
43145         for (const index in way.nodes) {
43146           if (way.nodes[index] === node.id) {
43147             occurrences += 1;
43148             if (occurrences > 1) {
43149               return false;
43150             }
43151           }
43152         }
43153         return true;
43154       }
43155       function findConnectableEndNodesByExtension(way) {
43156         let results = [];
43157         if (way.isClosed()) return results;
43158         let testNodes;
43159         const indices = [0, way.nodes.length - 1];
43160         indices.forEach((nodeIndex) => {
43161           const nodeID = way.nodes[nodeIndex];
43162           const node = graph.entity(nodeID);
43163           if (!isExtendableCandidate(node, way)) return;
43164           const connectionInfo = canConnectByExtend(way, nodeIndex);
43165           if (!connectionInfo) return;
43166           testNodes = graph.childNodes(way).slice();
43167           testNodes[nodeIndex] = testNodes[nodeIndex].move(connectionInfo.cross_loc);
43168           if (geoHasSelfIntersections(testNodes, nodeID)) return;
43169           results.push(connectionInfo);
43170         });
43171         return results;
43172       }
43173       function findNearbyEndNodes(node, way) {
43174         return [
43175           way.nodes[0],
43176           way.nodes[way.nodes.length - 1]
43177         ].map((d2) => graph.entity(d2)).filter((d2) => {
43178           return d2.id !== node.id && geoSphericalDistance(node.loc, d2.loc) <= CLOSE_NODE_TH;
43179         });
43180       }
43181       function findSmallJoinAngle(midNode, tipNode, endNodes) {
43182         let joinTo;
43183         let minAngle = Infinity;
43184         endNodes.forEach((endNode) => {
43185           const a1 = geoAngle(midNode, tipNode, context.projection) + Math.PI;
43186           const a2 = geoAngle(midNode, endNode, context.projection) + Math.PI;
43187           const diff = Math.max(a1, a2) - Math.min(a1, a2);
43188           if (diff < minAngle) {
43189             joinTo = endNode;
43190             minAngle = diff;
43191           }
43192         });
43193         if (minAngle <= SIG_ANGLE_TH) return joinTo;
43194         return null;
43195       }
43196       function hasTag(tags, key) {
43197         return tags[key] !== void 0 && tags[key] !== "no";
43198       }
43199       function canConnectWays(way, way2) {
43200         if (way.id === way2.id) return true;
43201         if ((hasTag(way.tags, "bridge") || hasTag(way2.tags, "bridge")) && !(hasTag(way.tags, "bridge") && hasTag(way2.tags, "bridge"))) return false;
43202         if ((hasTag(way.tags, "tunnel") || hasTag(way2.tags, "tunnel")) && !(hasTag(way.tags, "tunnel") && hasTag(way2.tags, "tunnel"))) return false;
43203         const layer1 = way.tags.layer || "0", layer2 = way2.tags.layer || "0";
43204         if (layer1 !== layer2) return false;
43205         const level1 = way.tags.level || "0", level2 = way2.tags.level || "0";
43206         if (level1 !== level2) return false;
43207         return true;
43208       }
43209       function canConnectByExtend(way, endNodeIdx) {
43210         const tipNid = way.nodes[endNodeIdx];
43211         const midNid = endNodeIdx === 0 ? way.nodes[1] : way.nodes[way.nodes.length - 2];
43212         const tipNode = graph.entity(tipNid);
43213         const midNode = graph.entity(midNid);
43214         const lon = tipNode.loc[0];
43215         const lat = tipNode.loc[1];
43216         const lon_range = geoMetersToLon(EXTEND_TH_METERS, lat) / 2;
43217         const lat_range = geoMetersToLat(EXTEND_TH_METERS) / 2;
43218         const queryExtent = geoExtent([
43219           [lon - lon_range, lat - lat_range],
43220           [lon + lon_range, lat + lat_range]
43221         ]);
43222         const edgeLen = geoSphericalDistance(midNode.loc, tipNode.loc);
43223         const t2 = EXTEND_TH_METERS / edgeLen + 1;
43224         const extTipLoc = geoVecInterp(midNode.loc, tipNode.loc, t2);
43225         const segmentInfos = tree.waySegments(queryExtent, graph);
43226         for (let i3 = 0; i3 < segmentInfos.length; i3++) {
43227           let segmentInfo = segmentInfos[i3];
43228           let way2 = graph.entity(segmentInfo.wayId);
43229           if (!isHighway(way2)) continue;
43230           if (!canConnectWays(way, way2)) continue;
43231           let nAid = segmentInfo.nodes[0], nBid = segmentInfo.nodes[1];
43232           if (nAid === tipNid || nBid === tipNid) continue;
43233           let nA = graph.entity(nAid), nB = graph.entity(nBid);
43234           let crossLoc = geoLineIntersection([tipNode.loc, extTipLoc], [nA.loc, nB.loc]);
43235           if (crossLoc) {
43236             return {
43237               mid: midNode,
43238               node: tipNode,
43239               wid: way2.id,
43240               edge: [nA.id, nB.id],
43241               cross_loc: crossLoc
43242             };
43243           }
43244         }
43245         return null;
43246       }
43247     };
43248     validation.type = type2;
43249     return validation;
43250   }
43251
43252   // modules/validations/close_nodes.js
43253   function validationCloseNodes(context) {
43254     var type2 = "close_nodes";
43255     var pointThresholdMeters = 0.2;
43256     var validation = function(entity, graph) {
43257       if (entity.type === "node") {
43258         return getIssuesForNode(entity);
43259       } else if (entity.type === "way") {
43260         return getIssuesForWay(entity);
43261       }
43262       return [];
43263       function getIssuesForNode(node) {
43264         var parentWays = graph.parentWays(node);
43265         if (parentWays.length) {
43266           return getIssuesForVertex(node, parentWays);
43267         } else {
43268           return getIssuesForDetachedPoint(node);
43269         }
43270       }
43271       function wayTypeFor(way) {
43272         if (way.tags.boundary && way.tags.boundary !== "no") return "boundary";
43273         if (way.tags.indoor && way.tags.indoor !== "no") return "indoor";
43274         if (way.tags.building && way.tags.building !== "no" || way.tags["building:part"] && way.tags["building:part"] !== "no") return "building";
43275         if (osmPathHighwayTagValues[way.tags.highway]) return "path";
43276         var parentRelations = graph.parentRelations(way);
43277         for (var i3 in parentRelations) {
43278           var relation = parentRelations[i3];
43279           if (relation.tags.type === "boundary") return "boundary";
43280           if (relation.isMultipolygon()) {
43281             if (relation.tags.indoor && relation.tags.indoor !== "no") return "indoor";
43282             if (relation.tags.building && relation.tags.building !== "no" || relation.tags["building:part"] && relation.tags["building:part"] !== "no") return "building";
43283           }
43284         }
43285         return "other";
43286       }
43287       function shouldCheckWay(way) {
43288         if (way.nodes.length <= 2 || way.isClosed() && way.nodes.length <= 4) return false;
43289         var bbox2 = way.extent(graph).bbox();
43290         var hypotenuseMeters = geoSphericalDistance([bbox2.minX, bbox2.minY], [bbox2.maxX, bbox2.maxY]);
43291         if (hypotenuseMeters < 1.5) return false;
43292         return true;
43293       }
43294       function getIssuesForWay(way) {
43295         if (!shouldCheckWay(way)) return [];
43296         var issues = [], nodes = graph.childNodes(way);
43297         for (var i3 = 0; i3 < nodes.length - 1; i3++) {
43298           var node1 = nodes[i3];
43299           var node2 = nodes[i3 + 1];
43300           var issue = getWayIssueIfAny(node1, node2, way);
43301           if (issue) issues.push(issue);
43302         }
43303         return issues;
43304       }
43305       function getIssuesForVertex(node, parentWays) {
43306         var issues = [];
43307         function checkForCloseness(node1, node2, way) {
43308           var issue = getWayIssueIfAny(node1, node2, way);
43309           if (issue) issues.push(issue);
43310         }
43311         for (var i3 = 0; i3 < parentWays.length; i3++) {
43312           var parentWay = parentWays[i3];
43313           if (!shouldCheckWay(parentWay)) continue;
43314           var lastIndex = parentWay.nodes.length - 1;
43315           for (var j2 = 0; j2 < parentWay.nodes.length; j2++) {
43316             if (j2 !== 0) {
43317               if (parentWay.nodes[j2 - 1] === node.id) {
43318                 checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay);
43319               }
43320             }
43321             if (j2 !== lastIndex) {
43322               if (parentWay.nodes[j2 + 1] === node.id) {
43323                 checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay);
43324               }
43325             }
43326           }
43327         }
43328         return issues;
43329       }
43330       function thresholdMetersForWay(way) {
43331         if (!shouldCheckWay(way)) return 0;
43332         var wayType = wayTypeFor(way);
43333         if (wayType === "boundary") return 0;
43334         if (wayType === "indoor") return 0.01;
43335         if (wayType === "building") return 0.05;
43336         if (wayType === "path") return 0.1;
43337         return 0.2;
43338       }
43339       function getIssuesForDetachedPoint(node) {
43340         var issues = [];
43341         var lon = node.loc[0];
43342         var lat = node.loc[1];
43343         var lon_range = geoMetersToLon(pointThresholdMeters, lat) / 2;
43344         var lat_range = geoMetersToLat(pointThresholdMeters) / 2;
43345         var queryExtent = geoExtent([
43346           [lon - lon_range, lat - lat_range],
43347           [lon + lon_range, lat + lat_range]
43348         ]);
43349         var intersected = context.history().tree().intersects(queryExtent, graph);
43350         for (var j2 = 0; j2 < intersected.length; j2++) {
43351           var nearby = intersected[j2];
43352           if (nearby.id === node.id) continue;
43353           if (nearby.type !== "node" || nearby.geometry(graph) !== "point") continue;
43354           if (nearby.loc === node.loc || geoSphericalDistance(node.loc, nearby.loc) < pointThresholdMeters) {
43355             if ("memorial:type" in node.tags && "memorial:type" in nearby.tags && node.tags["memorial:type"] === "stolperstein" && nearby.tags["memorial:type"] === "stolperstein") continue;
43356             if ("memorial" in node.tags && "memorial" in nearby.tags && node.tags.memorial === "stolperstein" && nearby.tags.memorial === "stolperstein") continue;
43357             var zAxisKeys = { layer: true, level: true, "addr:housenumber": true, "addr:unit": true };
43358             var zAxisDifferentiates = false;
43359             for (var key in zAxisKeys) {
43360               var nodeValue = node.tags[key] || "0";
43361               var nearbyValue = nearby.tags[key] || "0";
43362               if (nodeValue !== nearbyValue) {
43363                 zAxisDifferentiates = true;
43364                 break;
43365               }
43366             }
43367             if (zAxisDifferentiates) continue;
43368             issues.push(new validationIssue({
43369               type: type2,
43370               subtype: "detached",
43371               severity: "warning",
43372               message: function(context2) {
43373                 var entity2 = context2.hasEntity(this.entityIds[0]), entity22 = context2.hasEntity(this.entityIds[1]);
43374                 return entity2 && entity22 ? _t.append("issues.close_nodes.detached.message", {
43375                   feature: utilDisplayLabel(entity2, context2.graph()),
43376                   feature2: utilDisplayLabel(entity22, context2.graph())
43377                 }) : "";
43378               },
43379               reference: showReference,
43380               entityIds: [node.id, nearby.id],
43381               dynamicFixes: function() {
43382                 return [
43383                   new validationIssueFix({
43384                     icon: "iD-operation-disconnect",
43385                     title: _t.append("issues.fix.move_points_apart.title")
43386                   }),
43387                   new validationIssueFix({
43388                     icon: "iD-icon-layers",
43389                     title: _t.append("issues.fix.use_different_layers_or_levels.title")
43390                   })
43391                 ];
43392               }
43393             }));
43394           }
43395         }
43396         return issues;
43397         function showReference(selection2) {
43398           var referenceText = _t("issues.close_nodes.detached.reference");
43399           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
43400         }
43401       }
43402       function getWayIssueIfAny(node1, node2, way) {
43403         if (node1.id === node2.id || node1.hasInterestingTags() && node2.hasInterestingTags()) {
43404           return null;
43405         }
43406         if (node1.loc !== node2.loc) {
43407           var parentWays1 = graph.parentWays(node1);
43408           var parentWays2 = new Set(graph.parentWays(node2));
43409           var sharedWays = parentWays1.filter(function(parentWay) {
43410             return parentWays2.has(parentWay);
43411           });
43412           var thresholds = sharedWays.map(function(parentWay) {
43413             return thresholdMetersForWay(parentWay);
43414           });
43415           var threshold = Math.min(...thresholds);
43416           var distance = geoSphericalDistance(node1.loc, node2.loc);
43417           if (distance > threshold) return null;
43418         }
43419         return new validationIssue({
43420           type: type2,
43421           subtype: "vertices",
43422           severity: "warning",
43423           message: function(context2) {
43424             var entity2 = context2.hasEntity(this.entityIds[0]);
43425             return entity2 ? _t.append("issues.close_nodes.message", { way: utilDisplayLabel(entity2, context2.graph()) }) : "";
43426           },
43427           reference: showReference,
43428           entityIds: [way.id, node1.id, node2.id],
43429           loc: node1.loc,
43430           dynamicFixes: function() {
43431             return [
43432               new validationIssueFix({
43433                 icon: "iD-icon-plus",
43434                 title: _t.append("issues.fix.merge_points.title"),
43435                 onClick: function(context2) {
43436                   var entityIds = this.issue.entityIds;
43437                   var action = actionMergeNodes([entityIds[1], entityIds[2]]);
43438                   context2.perform(action, _t("issues.fix.merge_close_vertices.annotation"));
43439                 }
43440               }),
43441               new validationIssueFix({
43442                 icon: "iD-operation-disconnect",
43443                 title: _t.append("issues.fix.move_points_apart.title")
43444               })
43445             ];
43446           }
43447         });
43448         function showReference(selection2) {
43449           var referenceText = _t("issues.close_nodes.reference");
43450           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
43451         }
43452       }
43453     };
43454     validation.type = type2;
43455     return validation;
43456   }
43457
43458   // modules/validations/crossing_ways.js
43459   var import_lodash3 = __toESM(require_lodash());
43460   function validationCrossingWays(context) {
43461     var type2 = "crossing_ways";
43462     function getFeatureWithFeatureTypeTagsForWay(way, graph) {
43463       if (getFeatureType(way, graph) === null) {
43464         var parentRels = graph.parentRelations(way);
43465         for (var i3 = 0; i3 < parentRels.length; i3++) {
43466           var rel = parentRels[i3];
43467           if (getFeatureType(rel, graph) !== null) {
43468             return rel;
43469           }
43470         }
43471       }
43472       return way;
43473     }
43474     function hasTag(tags, key) {
43475       return tags[key] !== void 0 && tags[key] !== "no";
43476     }
43477     function taggedAsIndoor(tags) {
43478       return hasTag(tags, "indoor") || hasTag(tags, "level") || tags.highway === "corridor";
43479     }
43480     function allowsBridge(featureType) {
43481       return featureType === "highway" || featureType === "railway" || featureType === "waterway" || featureType === "aeroway";
43482     }
43483     function allowsTunnel(featureType) {
43484       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
43485     }
43486     var ignoredBuildings = {
43487       demolished: true,
43488       dismantled: true,
43489       proposed: true,
43490       razed: true
43491     };
43492     function getFeatureType(entity, graph) {
43493       var geometry = entity.geometry(graph);
43494       if (geometry !== "line" && geometry !== "area") return null;
43495       var tags = entity.tags;
43496       if (tags.aeroway in osmRoutableAerowayTags) return "aeroway";
43497       if (hasTag(tags, "building") && !ignoredBuildings[tags.building]) return "building";
43498       if (hasTag(tags, "highway") && osmRoutableHighwayTagValues[tags.highway]) return "highway";
43499       if (geometry !== "line") return null;
43500       if (hasTag(tags, "railway") && osmRailwayTrackTagValues[tags.railway]) return "railway";
43501       if (hasTag(tags, "waterway") && osmFlowingWaterwayTagValues[tags.waterway]) return "waterway";
43502       return null;
43503     }
43504     function isLegitCrossing(tags1, featureType1, tags2, featureType2) {
43505       var level1 = tags1.level || "0";
43506       var level2 = tags2.level || "0";
43507       if (taggedAsIndoor(tags1) && taggedAsIndoor(tags2) && level1 !== level2) {
43508         return true;
43509       }
43510       var layer1 = tags1.layer || "0";
43511       var layer2 = tags2.layer || "0";
43512       if (allowsBridge(featureType1) && allowsBridge(featureType2)) {
43513         if (hasTag(tags1, "bridge") && !hasTag(tags2, "bridge")) return true;
43514         if (!hasTag(tags1, "bridge") && hasTag(tags2, "bridge")) return true;
43515         if (hasTag(tags1, "bridge") && hasTag(tags2, "bridge") && layer1 !== layer2) return true;
43516       } else if (allowsBridge(featureType1) && hasTag(tags1, "bridge")) return true;
43517       else if (allowsBridge(featureType2) && hasTag(tags2, "bridge")) return true;
43518       if (allowsTunnel(featureType1) && allowsTunnel(featureType2)) {
43519         if (hasTag(tags1, "tunnel") && !hasTag(tags2, "tunnel")) return true;
43520         if (!hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel")) return true;
43521         if (hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel") && layer1 !== layer2) return true;
43522       } else if (allowsTunnel(featureType1) && hasTag(tags1, "tunnel")) return true;
43523       else if (allowsTunnel(featureType2) && hasTag(tags2, "tunnel")) return true;
43524       if (featureType1 === "waterway" && featureType2 === "highway" && tags2.man_made === "pier") return true;
43525       if (featureType2 === "waterway" && featureType1 === "highway" && tags1.man_made === "pier") return true;
43526       if (featureType1 === "building" || featureType2 === "building" || taggedAsIndoor(tags1) || taggedAsIndoor(tags2)) {
43527         if (layer1 !== layer2) return true;
43528       }
43529       return false;
43530     }
43531     var highwaysDisallowingFords = {
43532       motorway: true,
43533       motorway_link: true,
43534       trunk: true,
43535       trunk_link: true,
43536       primary: true,
43537       primary_link: true,
43538       secondary: true,
43539       secondary_link: true
43540     };
43541     function tagsForConnectionNodeIfAllowed(entity1, entity2, graph, lessLikelyTags) {
43542       var featureType1 = getFeatureType(entity1, graph);
43543       var featureType2 = getFeatureType(entity2, graph);
43544       var geometry1 = entity1.geometry(graph);
43545       var geometry2 = entity2.geometry(graph);
43546       var bothLines = geometry1 === "line" && geometry2 === "line";
43547       const featureTypes = [featureType1, featureType2].sort().join("-");
43548       if (featureTypes === "aeroway-aeroway") return {};
43549       if (featureTypes === "aeroway-highway") {
43550         const isServiceRoad = entity1.tags.highway === "service" || entity2.tags.highway === "service";
43551         const isPath = entity1.tags.highway in osmPathHighwayTagValues || entity2.tags.highway in osmPathHighwayTagValues;
43552         return isServiceRoad || isPath ? {} : { aeroway: "aircraft_crossing" };
43553       }
43554       if (featureTypes === "aeroway-railway") {
43555         return { aeroway: "aircraft_crossing", railway: "level_crossing" };
43556       }
43557       if (featureTypes === "aeroway-waterway") return null;
43558       if (featureType1 === featureType2) {
43559         if (featureType1 === "highway") {
43560           var entity1IsPath = osmPathHighwayTagValues[entity1.tags.highway];
43561           var entity2IsPath = osmPathHighwayTagValues[entity2.tags.highway];
43562           if ((entity1IsPath || entity2IsPath) && entity1IsPath !== entity2IsPath) {
43563             if (!bothLines) return {};
43564             var roadFeature = entity1IsPath ? entity2 : entity1;
43565             var pathFeature = entity1IsPath ? entity1 : entity2;
43566             if (roadFeature.tags.highway === "track") {
43567               return {};
43568             }
43569             if (!lessLikelyTags && roadFeature.tags.highway === "service" && pathFeature.tags.highway === "footway" && pathFeature.tags.footway === "sidewalk") {
43570               return {};
43571             }
43572             if (["marked", "unmarked", "traffic_signals", "uncontrolled"].indexOf(pathFeature.tags.crossing) !== -1) {
43573               var tags = { highway: "crossing", crossing: pathFeature.tags.crossing };
43574               if ("crossing:markings" in pathFeature.tags) {
43575                 tags["crossing:markings"] = pathFeature.tags["crossing:markings"];
43576               }
43577               return tags;
43578             }
43579             return { highway: "crossing" };
43580           }
43581           return {};
43582         }
43583         if (featureType1 === "waterway") return {};
43584         if (featureType1 === "railway") return {};
43585       } else {
43586         if (featureTypes.indexOf("highway") !== -1) {
43587           if (featureTypes.indexOf("railway") !== -1) {
43588             if (!bothLines) return {};
43589             var isTram = entity1.tags.railway === "tram" || entity2.tags.railway === "tram";
43590             if (osmPathHighwayTagValues[entity1.tags.highway] || osmPathHighwayTagValues[entity2.tags.highway]) {
43591               if (isTram) return { railway: "tram_crossing" };
43592               return { railway: "crossing" };
43593             } else {
43594               if (isTram) return { railway: "tram_level_crossing" };
43595               return { railway: "level_crossing" };
43596             }
43597           }
43598           if (featureTypes.indexOf("waterway") !== -1) {
43599             if (hasTag(entity1.tags, "tunnel") && hasTag(entity2.tags, "tunnel")) return null;
43600             if (hasTag(entity1.tags, "bridge") && hasTag(entity2.tags, "bridge")) return null;
43601             if (highwaysDisallowingFords[entity1.tags.highway] || highwaysDisallowingFords[entity2.tags.highway]) {
43602               return null;
43603             }
43604             return bothLines ? { ford: "yes" } : {};
43605           }
43606         }
43607       }
43608       return null;
43609     }
43610     function findCrossingsByWay(way1, graph, tree) {
43611       var edgeCrossInfos = [];
43612       if (way1.type !== "way") return edgeCrossInfos;
43613       var taggedFeature1 = getFeatureWithFeatureTypeTagsForWay(way1, graph);
43614       var way1FeatureType = getFeatureType(taggedFeature1, graph);
43615       if (way1FeatureType === null) return edgeCrossInfos;
43616       var checkedSingleCrossingWays = {};
43617       var i3, j2;
43618       var extent;
43619       var n1, n22, nA, nB, nAId, nBId;
43620       var segment1, segment2;
43621       var oneOnly;
43622       var segmentInfos, segment2Info, way2, taggedFeature2, way2FeatureType;
43623       var way1Nodes = graph.childNodes(way1);
43624       var comparedWays = {};
43625       for (i3 = 0; i3 < way1Nodes.length - 1; i3++) {
43626         n1 = way1Nodes[i3];
43627         n22 = way1Nodes[i3 + 1];
43628         extent = geoExtent([
43629           [
43630             Math.min(n1.loc[0], n22.loc[0]),
43631             Math.min(n1.loc[1], n22.loc[1])
43632           ],
43633           [
43634             Math.max(n1.loc[0], n22.loc[0]),
43635             Math.max(n1.loc[1], n22.loc[1])
43636           ]
43637         ]);
43638         segmentInfos = tree.waySegments(extent, graph);
43639         for (j2 = 0; j2 < segmentInfos.length; j2++) {
43640           segment2Info = segmentInfos[j2];
43641           if (segment2Info.wayId === way1.id) continue;
43642           if (checkedSingleCrossingWays[segment2Info.wayId]) continue;
43643           comparedWays[segment2Info.wayId] = true;
43644           way2 = graph.hasEntity(segment2Info.wayId);
43645           if (!way2) continue;
43646           taggedFeature2 = getFeatureWithFeatureTypeTagsForWay(way2, graph);
43647           way2FeatureType = getFeatureType(taggedFeature2, graph);
43648           if (way2FeatureType === null || isLegitCrossing(taggedFeature1.tags, way1FeatureType, taggedFeature2.tags, way2FeatureType)) {
43649             continue;
43650           }
43651           oneOnly = way1FeatureType === "building" || way2FeatureType === "building";
43652           nAId = segment2Info.nodes[0];
43653           nBId = segment2Info.nodes[1];
43654           if (nAId === n1.id || nAId === n22.id || nBId === n1.id || nBId === n22.id) {
43655             continue;
43656           }
43657           nA = graph.hasEntity(nAId);
43658           if (!nA) continue;
43659           nB = graph.hasEntity(nBId);
43660           if (!nB) continue;
43661           segment1 = [n1.loc, n22.loc];
43662           segment2 = [nA.loc, nB.loc];
43663           var point = geoLineIntersection(segment1, segment2);
43664           if (point) {
43665             edgeCrossInfos.push({
43666               wayInfos: [
43667                 {
43668                   way: way1,
43669                   featureType: way1FeatureType,
43670                   edge: [n1.id, n22.id]
43671                 },
43672                 {
43673                   way: way2,
43674                   featureType: way2FeatureType,
43675                   edge: [nA.id, nB.id]
43676                 }
43677               ],
43678               crossPoint: point
43679             });
43680             if (oneOnly) {
43681               checkedSingleCrossingWays[way2.id] = true;
43682               break;
43683             }
43684           }
43685         }
43686       }
43687       return edgeCrossInfos;
43688     }
43689     function waysToCheck(entity, graph) {
43690       var featureType = getFeatureType(entity, graph);
43691       if (!featureType) return [];
43692       if (entity.type === "way") {
43693         return [entity];
43694       } else if (entity.type === "relation") {
43695         return entity.members.reduce(function(array2, member) {
43696           if (member.type === "way" && // only look at geometry ways
43697           (!member.role || member.role === "outer" || member.role === "inner")) {
43698             var entity2 = graph.hasEntity(member.id);
43699             if (entity2 && array2.indexOf(entity2) === -1) {
43700               array2.push(entity2);
43701             }
43702           }
43703           return array2;
43704         }, []);
43705       }
43706       return [];
43707     }
43708     var validation = function checkCrossingWays(entity, graph) {
43709       var tree = context.history().tree();
43710       var ways = waysToCheck(entity, graph);
43711       var issues = [];
43712       var wayIndex, crossingIndex, crossings;
43713       for (wayIndex in ways) {
43714         crossings = findCrossingsByWay(ways[wayIndex], graph, tree);
43715         for (crossingIndex in crossings) {
43716           issues.push(createIssue(crossings[crossingIndex], graph));
43717         }
43718       }
43719       return issues;
43720     };
43721     function createIssue(crossing, graph) {
43722       crossing.wayInfos.sort(function(way1Info, way2Info) {
43723         var type1 = way1Info.featureType;
43724         var type22 = way2Info.featureType;
43725         if (type1 === type22) {
43726           return utilDisplayLabel(way1Info.way, graph) > utilDisplayLabel(way2Info.way, graph);
43727         } else if (type1 === "waterway") {
43728           return true;
43729         } else if (type22 === "waterway") {
43730           return false;
43731         }
43732         return type1 < type22;
43733       });
43734       var entities = crossing.wayInfos.map(function(wayInfo) {
43735         return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
43736       });
43737       var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
43738       var featureTypes = [crossing.wayInfos[0].featureType, crossing.wayInfos[1].featureType];
43739       var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph);
43740       var featureType1 = crossing.wayInfos[0].featureType;
43741       var featureType2 = crossing.wayInfos[1].featureType;
43742       var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
43743       var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, "tunnel") && allowsTunnel(featureType2) && hasTag(entities[1].tags, "tunnel");
43744       var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, "bridge") && allowsBridge(featureType2) && hasTag(entities[1].tags, "bridge");
43745       var subtype = [featureType1, featureType2].sort().join("-");
43746       var crossingTypeID = subtype;
43747       if (isCrossingIndoors) {
43748         crossingTypeID = "indoor-indoor";
43749       } else if (isCrossingTunnels) {
43750         crossingTypeID = "tunnel-tunnel";
43751       } else if (isCrossingBridges) {
43752         crossingTypeID = "bridge-bridge";
43753       }
43754       if (connectionTags && (isCrossingIndoors || isCrossingTunnels || isCrossingBridges)) {
43755         crossingTypeID += "_connectable";
43756       }
43757       var uniqueID = crossing.crossPoint[0].toFixed(4) + "," + crossing.crossPoint[1].toFixed(4);
43758       return new validationIssue({
43759         type: type2,
43760         subtype,
43761         severity: "warning",
43762         message: function(context2) {
43763           var graph2 = context2.graph();
43764           var entity1 = graph2.hasEntity(this.entityIds[0]), entity2 = graph2.hasEntity(this.entityIds[1]);
43765           return entity1 && entity2 ? _t.append("issues.crossing_ways.message", {
43766             feature: utilDisplayLabel(entity1, graph2),
43767             feature2: utilDisplayLabel(entity2, graph2)
43768           }) : "";
43769         },
43770         reference: showReference,
43771         entityIds: entities.map(function(entity) {
43772           return entity.id;
43773         }),
43774         data: {
43775           edges,
43776           featureTypes,
43777           connectionTags
43778         },
43779         hash: uniqueID,
43780         loc: crossing.crossPoint,
43781         dynamicFixes: function(context2) {
43782           var mode = context2.mode();
43783           if (!mode || mode.id !== "select" || mode.selectedIDs().length !== 1) return [];
43784           var selectedIndex = this.entityIds[0] === mode.selectedIDs()[0] ? 0 : 1;
43785           var selectedFeatureType = this.data.featureTypes[selectedIndex];
43786           var otherFeatureType = this.data.featureTypes[selectedIndex === 0 ? 1 : 0];
43787           var fixes = [];
43788           if (connectionTags) {
43789             fixes.push(makeConnectWaysFix(this.data.connectionTags));
43790             let lessLikelyConnectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph, true);
43791             if (lessLikelyConnectionTags && !(0, import_lodash3.isEqual)(connectionTags, lessLikelyConnectionTags)) {
43792               fixes.push(makeConnectWaysFix(lessLikelyConnectionTags));
43793             }
43794           }
43795           if (isCrossingIndoors) {
43796             fixes.push(new validationIssueFix({
43797               icon: "iD-icon-layers",
43798               title: _t.append("issues.fix.use_different_levels.title")
43799             }));
43800           } else if (isCrossingTunnels || isCrossingBridges || featureType1 === "building" || featureType2 === "building") {
43801             fixes.push(makeChangeLayerFix("higher"));
43802             fixes.push(makeChangeLayerFix("lower"));
43803           } else if (context2.graph().geometry(this.entityIds[0]) === "line" && context2.graph().geometry(this.entityIds[1]) === "line") {
43804             if (allowsBridge(selectedFeatureType) && selectedFeatureType !== "waterway") {
43805               fixes.push(makeAddBridgeOrTunnelFix("add_a_bridge", "temaki-bridge", "bridge"));
43806             }
43807             var skipTunnelFix = otherFeatureType === "waterway" && selectedFeatureType !== "waterway";
43808             if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) {
43809               if (selectedFeatureType === "waterway") {
43810                 fixes.push(makeAddBridgeOrTunnelFix("add_a_culvert", "temaki-waste", "tunnel"));
43811               } else {
43812                 fixes.push(makeAddBridgeOrTunnelFix("add_a_tunnel", "temaki-tunnel", "tunnel"));
43813               }
43814             }
43815           }
43816           fixes.push(new validationIssueFix({
43817             icon: "iD-operation-move",
43818             title: _t.append("issues.fix.reposition_features.title")
43819           }));
43820           return fixes;
43821         }
43822       });
43823       function showReference(selection2) {
43824         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.crossing_ways." + crossingTypeID + ".reference"));
43825       }
43826     }
43827     function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
43828       return new validationIssueFix({
43829         icon: iconName,
43830         title: _t.append("issues.fix." + fixTitleID + ".title"),
43831         onClick: function(context2) {
43832           var mode = context2.mode();
43833           if (!mode || mode.id !== "select") return;
43834           var selectedIDs = mode.selectedIDs();
43835           if (selectedIDs.length !== 1) return;
43836           var selectedWayID = selectedIDs[0];
43837           if (!context2.hasEntity(selectedWayID)) return;
43838           var resultWayIDs = [selectedWayID];
43839           var edge, crossedEdge, crossedWayID;
43840           if (this.issue.entityIds[0] === selectedWayID) {
43841             edge = this.issue.data.edges[0];
43842             crossedEdge = this.issue.data.edges[1];
43843             crossedWayID = this.issue.entityIds[1];
43844           } else {
43845             edge = this.issue.data.edges[1];
43846             crossedEdge = this.issue.data.edges[0];
43847             crossedWayID = this.issue.entityIds[0];
43848           }
43849           var crossingLoc = this.issue.loc;
43850           var projection2 = context2.projection;
43851           var action = function actionAddStructure(graph) {
43852             var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
43853             var crossedWay = graph.hasEntity(crossedWayID);
43854             var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width);
43855             if (!structLengthMeters) {
43856               structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters();
43857             }
43858             if (structLengthMeters) {
43859               if (getFeatureType(crossedWay, graph) === "railway") {
43860                 structLengthMeters *= 2;
43861               }
43862             } else {
43863               structLengthMeters = 8;
43864             }
43865             var a1 = geoAngle(edgeNodes[0], edgeNodes[1], projection2) + Math.PI;
43866             var a2 = geoAngle(graph.entity(crossedEdge[0]), graph.entity(crossedEdge[1]), projection2) + Math.PI;
43867             var crossingAngle = Math.max(a1, a2) - Math.min(a1, a2);
43868             if (crossingAngle > Math.PI) crossingAngle -= Math.PI;
43869             structLengthMeters = structLengthMeters / 2 / Math.sin(crossingAngle) * 2;
43870             structLengthMeters += 4;
43871             structLengthMeters = Math.min(Math.max(structLengthMeters, 4), 50);
43872             function geomToProj(geoPoint) {
43873               return [
43874                 geoLonToMeters(geoPoint[0], geoPoint[1]),
43875                 geoLatToMeters(geoPoint[1])
43876               ];
43877             }
43878             function projToGeom(projPoint) {
43879               var lat = geoMetersToLat(projPoint[1]);
43880               return [
43881                 geoMetersToLon(projPoint[0], lat),
43882                 lat
43883               ];
43884             }
43885             var projEdgeNode1 = geomToProj(edgeNodes[0].loc);
43886             var projEdgeNode2 = geomToProj(edgeNodes[1].loc);
43887             var projectedAngle = geoVecAngle(projEdgeNode1, projEdgeNode2);
43888             var projectedCrossingLoc = geomToProj(crossingLoc);
43889             var linearToSphericalMetersRatio = geoVecLength(projEdgeNode1, projEdgeNode2) / geoSphericalDistance(edgeNodes[0].loc, edgeNodes[1].loc);
43890             function locSphericalDistanceFromCrossingLoc(angle2, distanceMeters) {
43891               var lengthSphericalMeters = distanceMeters * linearToSphericalMetersRatio;
43892               return projToGeom([
43893                 projectedCrossingLoc[0] + Math.cos(angle2) * lengthSphericalMeters,
43894                 projectedCrossingLoc[1] + Math.sin(angle2) * lengthSphericalMeters
43895               ]);
43896             }
43897             var endpointLocGetter1 = function(lengthMeters) {
43898               return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
43899             };
43900             var endpointLocGetter2 = function(lengthMeters) {
43901               return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
43902             };
43903             var minEdgeLengthMeters = 0.55;
43904             function determineEndpoint(edge2, endNode, locGetter) {
43905               var newNode;
43906               var idealLengthMeters = structLengthMeters / 2;
43907               var crossingToEdgeEndDistance = geoSphericalDistance(crossingLoc, endNode.loc);
43908               if (crossingToEdgeEndDistance - idealLengthMeters > minEdgeLengthMeters) {
43909                 var idealNodeLoc = locGetter(idealLengthMeters);
43910                 newNode = osmNode();
43911                 graph = actionAddMidpoint({ loc: idealNodeLoc, edge: edge2 }, newNode)(graph);
43912               } else {
43913                 var edgeCount = 0;
43914                 endNode.parentIntersectionWays(graph).forEach(function(way) {
43915                   way.nodes.forEach(function(nodeID) {
43916                     if (nodeID === endNode.id) {
43917                       if (endNode.id === way.first() && endNode.id !== way.last() || endNode.id === way.last() && endNode.id !== way.first()) {
43918                         edgeCount += 1;
43919                       } else {
43920                         edgeCount += 2;
43921                       }
43922                     }
43923                   });
43924                 });
43925                 if (edgeCount >= 3) {
43926                   var insetLength = crossingToEdgeEndDistance - minEdgeLengthMeters;
43927                   if (insetLength > minEdgeLengthMeters) {
43928                     var insetNodeLoc = locGetter(insetLength);
43929                     newNode = osmNode();
43930                     graph = actionAddMidpoint({ loc: insetNodeLoc, edge: edge2 }, newNode)(graph);
43931                   }
43932                 }
43933               }
43934               if (!newNode) newNode = endNode;
43935               var splitAction = actionSplit([newNode.id]).limitWays(resultWayIDs);
43936               graph = splitAction(graph);
43937               if (splitAction.getCreatedWayIDs().length) {
43938                 resultWayIDs.push(splitAction.getCreatedWayIDs()[0]);
43939               }
43940               return newNode;
43941             }
43942             var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
43943             var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
43944             var structureWay = resultWayIDs.map(function(id2) {
43945               return graph.entity(id2);
43946             }).find(function(way) {
43947               return way.nodes.indexOf(structEndNode1.id) !== -1 && way.nodes.indexOf(structEndNode2.id) !== -1;
43948             });
43949             var tags = Object.assign({}, structureWay.tags);
43950             if (bridgeOrTunnel === "bridge") {
43951               tags.bridge = "yes";
43952               tags.layer = "1";
43953             } else {
43954               var tunnelValue = "yes";
43955               if (getFeatureType(structureWay, graph) === "waterway") {
43956                 tunnelValue = "culvert";
43957               }
43958               tags.tunnel = tunnelValue;
43959               tags.layer = "-1";
43960             }
43961             graph = actionChangeTags(structureWay.id, tags)(graph);
43962             return graph;
43963           };
43964           context2.perform(action, _t("issues.fix." + fixTitleID + ".annotation"));
43965           context2.enter(modeSelect(context2, resultWayIDs));
43966         }
43967       });
43968     }
43969     function makeConnectWaysFix(connectionTags) {
43970       var fixTitleID = "connect_features";
43971       var fixIcon = "iD-icon-crossing";
43972       if (connectionTags.highway === "crossing") {
43973         fixTitleID = "connect_using_crossing";
43974         fixIcon = "temaki-pedestrian";
43975       }
43976       if (connectionTags.ford) {
43977         fixTitleID = "connect_using_ford";
43978         fixIcon = "roentgen-ford";
43979       }
43980       const fix = new validationIssueFix({
43981         icon: fixIcon,
43982         title: _t.append("issues.fix." + fixTitleID + ".title"),
43983         onClick: function(context2) {
43984           var loc = this.issue.loc;
43985           var edges = this.issue.data.edges;
43986           context2.perform(
43987             function actionConnectCrossingWays(graph) {
43988               var node = osmNode({ loc, tags: connectionTags });
43989               graph = graph.replace(node);
43990               var nodesToMerge = [node.id];
43991               var mergeThresholdInMeters = 0.75;
43992               edges.forEach(function(edge) {
43993                 var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
43994                 var nearby = geoSphericalClosestNode(edgeNodes, loc);
43995                 if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
43996                   nodesToMerge.push(nearby.node.id);
43997                 } else {
43998                   graph = actionAddMidpoint({ loc, edge }, node)(graph);
43999                 }
44000               });
44001               if (nodesToMerge.length > 1) {
44002                 graph = actionMergeNodes(nodesToMerge, loc)(graph);
44003               }
44004               return graph;
44005             },
44006             _t("issues.fix.connect_crossing_features.annotation")
44007           );
44008         }
44009       });
44010       fix._connectionTags = connectionTags;
44011       return fix;
44012     }
44013     function makeChangeLayerFix(higherOrLower) {
44014       return new validationIssueFix({
44015         icon: "iD-icon-" + (higherOrLower === "higher" ? "up" : "down"),
44016         title: _t.append("issues.fix.tag_this_as_" + higherOrLower + ".title"),
44017         onClick: function(context2) {
44018           var mode = context2.mode();
44019           if (!mode || mode.id !== "select") return;
44020           var selectedIDs = mode.selectedIDs();
44021           if (selectedIDs.length !== 1) return;
44022           var selectedID = selectedIDs[0];
44023           if (!this.issue.entityIds.some(function(entityId) {
44024             return entityId === selectedID;
44025           })) return;
44026           var entity = context2.hasEntity(selectedID);
44027           if (!entity) return;
44028           var tags = Object.assign({}, entity.tags);
44029           var layer = tags.layer && Number(tags.layer);
44030           if (layer && !isNaN(layer)) {
44031             if (higherOrLower === "higher") {
44032               layer += 1;
44033             } else {
44034               layer -= 1;
44035             }
44036           } else {
44037             if (higherOrLower === "higher") {
44038               layer = 1;
44039             } else {
44040               layer = -1;
44041             }
44042           }
44043           tags.layer = layer.toString();
44044           context2.perform(
44045             actionChangeTags(entity.id, tags),
44046             _t("operations.change_tags.annotation")
44047           );
44048         }
44049       });
44050     }
44051     validation.type = type2;
44052     return validation;
44053   }
44054
44055   // modules/behavior/draw_way.js
44056   function behaviorDrawWay(context, wayID, mode, startGraph) {
44057     const keybinding = utilKeybinding("drawWay");
44058     var dispatch14 = dispatch_default("rejectedSelfIntersection");
44059     var behavior = behaviorDraw(context);
44060     var _nodeIndex;
44061     var _origWay;
44062     var _wayGeometry;
44063     var _headNodeID;
44064     var _annotation;
44065     var _pointerHasMoved = false;
44066     var _drawNode;
44067     var _didResolveTempEdit = false;
44068     function createDrawNode(loc) {
44069       _drawNode = osmNode({ loc });
44070       context.pauseChangeDispatch();
44071       context.replace(function actionAddDrawNode(graph) {
44072         var way = graph.entity(wayID);
44073         return graph.replace(_drawNode).replace(way.addNode(_drawNode.id, _nodeIndex));
44074       }, _annotation);
44075       context.resumeChangeDispatch();
44076       setActiveElements();
44077     }
44078     function removeDrawNode() {
44079       context.pauseChangeDispatch();
44080       context.replace(
44081         function actionDeleteDrawNode(graph) {
44082           var way = graph.entity(wayID);
44083           return graph.replace(way.removeNode(_drawNode.id)).remove(_drawNode);
44084         },
44085         _annotation
44086       );
44087       _drawNode = void 0;
44088       context.resumeChangeDispatch();
44089     }
44090     function keydown(d3_event) {
44091       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44092         if (context.surface().classed("nope")) {
44093           context.surface().classed("nope-suppressed", true);
44094         }
44095         context.surface().classed("nope", false).classed("nope-disabled", true);
44096       }
44097     }
44098     function keyup(d3_event) {
44099       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44100         if (context.surface().classed("nope-suppressed")) {
44101           context.surface().classed("nope", true);
44102         }
44103         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
44104       }
44105     }
44106     function allowsVertex(d2) {
44107       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
44108     }
44109     function move(d3_event, datum2) {
44110       var loc = context.map().mouseCoordinates();
44111       if (!_drawNode) createDrawNode(loc);
44112       context.surface().classed("nope-disabled", d3_event.altKey);
44113       var targetLoc = datum2 && datum2.properties && datum2.properties.entity && allowsVertex(datum2.properties.entity) && datum2.properties.entity.loc;
44114       var targetNodes = datum2 && datum2.properties && datum2.properties.nodes;
44115       if (targetLoc) {
44116         loc = targetLoc;
44117       } else if (targetNodes) {
44118         var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
44119         if (choice) {
44120           loc = choice.loc;
44121         }
44122       }
44123       context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
44124       _drawNode = context.entity(_drawNode.id);
44125       checkGeometry(
44126         true
44127         /* includeDrawNode */
44128       );
44129     }
44130     function checkGeometry(includeDrawNode) {
44131       var nopeDisabled = context.surface().classed("nope-disabled");
44132       var isInvalid = isInvalidGeometry(includeDrawNode);
44133       if (nopeDisabled) {
44134         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
44135       } else {
44136         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
44137       }
44138     }
44139     function isInvalidGeometry(includeDrawNode) {
44140       var testNode = _drawNode;
44141       var parentWay = context.graph().entity(wayID);
44142       var nodes = context.graph().childNodes(parentWay).slice();
44143       if (includeDrawNode) {
44144         if (parentWay.isClosed()) {
44145           nodes.pop();
44146         }
44147       } else {
44148         if (parentWay.isClosed()) {
44149           if (nodes.length < 3) return false;
44150           if (_drawNode) nodes.splice(-2, 1);
44151           testNode = nodes[nodes.length - 2];
44152         } else {
44153           return false;
44154         }
44155       }
44156       return testNode && geoHasSelfIntersections(nodes, testNode.id);
44157     }
44158     function undone() {
44159       _didResolveTempEdit = true;
44160       context.pauseChangeDispatch();
44161       var nextMode;
44162       if (context.graph() === startGraph) {
44163         nextMode = modeSelect(context, [wayID]);
44164       } else {
44165         context.pop(1);
44166         nextMode = mode;
44167       }
44168       context.perform(actionNoop());
44169       context.pop(1);
44170       context.resumeChangeDispatch();
44171       context.enter(nextMode);
44172     }
44173     function setActiveElements() {
44174       if (!_drawNode) return;
44175       context.surface().selectAll("." + _drawNode.id).classed("active", true);
44176     }
44177     function resetToStartGraph() {
44178       while (context.graph() !== startGraph) {
44179         context.pop();
44180       }
44181     }
44182     var drawWay = function(surface) {
44183       _drawNode = void 0;
44184       _didResolveTempEdit = false;
44185       _origWay = context.entity(wayID);
44186       if (typeof _nodeIndex === "number") {
44187         _headNodeID = _origWay.nodes[_nodeIndex];
44188       } else if (_origWay.isClosed()) {
44189         _headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
44190       } else {
44191         _headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
44192       }
44193       _wayGeometry = _origWay.geometry(context.graph());
44194       _annotation = _t(
44195         (_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ? "operations.start.annotation." : "operations.continue.annotation.") + _wayGeometry
44196       );
44197       _pointerHasMoved = false;
44198       context.pauseChangeDispatch();
44199       context.perform(actionNoop(), _annotation);
44200       context.resumeChangeDispatch();
44201       behavior.hover().initialNodeID(_headNodeID);
44202       behavior.on("move", function() {
44203         _pointerHasMoved = true;
44204         move.apply(this, arguments);
44205       }).on("down", function() {
44206         move.apply(this, arguments);
44207       }).on("downcancel", function() {
44208         if (_drawNode) removeDrawNode();
44209       }).on("click", drawWay.add).on("clickWay", drawWay.addWay).on("clickNode", drawWay.addNode).on("undo", context.undo).on("cancel", drawWay.cancel).on("finish", drawWay.finish);
44210       select_default2(window).on("keydown.drawWay", keydown).on("keyup.drawWay", keyup);
44211       context.map().dblclickZoomEnable(false).on("drawn.draw", setActiveElements);
44212       setActiveElements();
44213       surface.call(behavior);
44214       context.history().on("undone.draw", undone);
44215     };
44216     drawWay.off = function(surface) {
44217       if (!_didResolveTempEdit) {
44218         context.pauseChangeDispatch();
44219         resetToStartGraph();
44220         context.resumeChangeDispatch();
44221       }
44222       _drawNode = void 0;
44223       _nodeIndex = void 0;
44224       context.map().on("drawn.draw", null);
44225       surface.call(behavior.off).selectAll(".active").classed("active", false);
44226       surface.classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false);
44227       select_default2(window).on("keydown.drawWay", null).on("keyup.drawWay", null);
44228       context.history().on("undone.draw", null);
44229     };
44230     function attemptAdd(d2, loc, doAdd) {
44231       if (_drawNode) {
44232         context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
44233         _drawNode = context.entity(_drawNode.id);
44234       } else {
44235         createDrawNode(loc);
44236       }
44237       checkGeometry(
44238         true
44239         /* includeDrawNode */
44240       );
44241       if (d2 && d2.properties && d2.properties.nope || context.surface().classed("nope")) {
44242         if (!_pointerHasMoved) {
44243           removeDrawNode();
44244         }
44245         dispatch14.call("rejectedSelfIntersection", this);
44246         return;
44247       }
44248       context.pauseChangeDispatch();
44249       doAdd();
44250       _didResolveTempEdit = true;
44251       context.resumeChangeDispatch();
44252       context.enter(mode);
44253     }
44254     drawWay.add = function(loc, d2) {
44255       attemptAdd(d2, loc, function() {
44256       });
44257     };
44258     drawWay.addWay = function(loc, edge, d2) {
44259       attemptAdd(d2, loc, function() {
44260         context.replace(
44261           actionAddMidpoint({ loc, edge }, _drawNode),
44262           _annotation
44263         );
44264       });
44265     };
44266     drawWay.addNode = function(node, d2) {
44267       if (node.id === _headNodeID || // or the first node when drawing an area
44268       _origWay.isClosed() && node.id === _origWay.first()) {
44269         drawWay.finish();
44270         return;
44271       }
44272       attemptAdd(d2, node.loc, function() {
44273         context.replace(
44274           function actionReplaceDrawNode(graph) {
44275             graph = graph.replace(graph.entity(wayID).removeNode(_drawNode.id)).remove(_drawNode);
44276             return graph.replace(graph.entity(wayID).addNode(node.id, _nodeIndex));
44277           },
44278           _annotation
44279         );
44280       });
44281     };
44282     function getFeatureType(ways) {
44283       if (ways.every((way) => way.isClosed())) return "area";
44284       if (ways.every((way) => !way.isClosed())) return "line";
44285       return "generic";
44286     }
44287     function followMode() {
44288       if (_didResolveTempEdit) return;
44289       try {
44290         const isDrawingArea = _origWay.nodes[0] === _origWay.nodes.slice(-1)[0];
44291         const [secondLastNodeId, lastNodeId] = _origWay.nodes.slice(isDrawingArea ? -3 : -2);
44292         const historyGraph = context.history().graph();
44293         if (!lastNodeId || !secondLastNodeId || !historyGraph.hasEntity(lastNodeId) || !historyGraph.hasEntity(secondLastNodeId)) {
44294           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.needs_more_initial_nodes"))();
44295           return;
44296         }
44297         const lastNodesParents = historyGraph.parentWays(historyGraph.entity(lastNodeId)).filter((w2) => w2.id !== wayID);
44298         const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID);
44299         const featureType = getFeatureType(lastNodesParents);
44300         if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) {
44301           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))();
44302           return;
44303         }
44304         if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) {
44305           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))();
44306           return;
44307         }
44308         const way = lastNodesParents[0];
44309         const indexOfLast = way.nodes.indexOf(lastNodeId);
44310         const indexOfSecondLast = way.nodes.indexOf(secondLastNodeId);
44311         const isDescendingPastZero = indexOfLast === way.nodes.length - 2 && indexOfSecondLast === 0;
44312         let nextNodeIndex = indexOfLast + (indexOfLast > indexOfSecondLast && !isDescendingPastZero ? 1 : -1);
44313         if (nextNodeIndex === -1) nextNodeIndex = indexOfSecondLast === 1 ? way.nodes.length - 2 : 1;
44314         const nextNode = historyGraph.entity(way.nodes[nextNodeIndex]);
44315         drawWay.addNode(nextNode, {
44316           geometry: { type: "Point", coordinates: nextNode.loc },
44317           id: nextNode.id,
44318           properties: { target: true, entity: nextNode }
44319         });
44320       } catch (e3) {
44321         context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))();
44322       }
44323     }
44324     keybinding.on(_t("operations.follow.key"), followMode);
44325     select_default2(document).call(keybinding);
44326     drawWay.finish = function() {
44327       checkGeometry(
44328         false
44329         /* includeDrawNode */
44330       );
44331       if (context.surface().classed("nope")) {
44332         dispatch14.call("rejectedSelfIntersection", this);
44333         return;
44334       }
44335       context.pauseChangeDispatch();
44336       context.pop(1);
44337       _didResolveTempEdit = true;
44338       context.resumeChangeDispatch();
44339       var way = context.hasEntity(wayID);
44340       if (!way || way.isDegenerate()) {
44341         drawWay.cancel();
44342         return;
44343       }
44344       window.setTimeout(function() {
44345         context.map().dblclickZoomEnable(true);
44346       }, 1e3);
44347       var isNewFeature = !mode.isContinuing;
44348       context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature));
44349     };
44350     drawWay.cancel = function() {
44351       context.pauseChangeDispatch();
44352       resetToStartGraph();
44353       context.resumeChangeDispatch();
44354       window.setTimeout(function() {
44355         context.map().dblclickZoomEnable(true);
44356       }, 1e3);
44357       context.surface().classed("nope", false).classed("nope-disabled", false).classed("nope-suppressed", false);
44358       context.enter(modeBrowse(context));
44359     };
44360     drawWay.nodeIndex = function(val) {
44361       if (!arguments.length) return _nodeIndex;
44362       _nodeIndex = val;
44363       return drawWay;
44364     };
44365     drawWay.activeID = function() {
44366       if (!arguments.length) return _drawNode && _drawNode.id;
44367       return drawWay;
44368     };
44369     return utilRebind(drawWay, dispatch14, "on");
44370   }
44371
44372   // modules/modes/draw_line.js
44373   function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
44374     var mode = {
44375       button,
44376       id: "draw-line"
44377     };
44378     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawLine", function() {
44379       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.lines"))();
44380     });
44381     mode.wayID = wayID;
44382     mode.isContinuing = continuing;
44383     mode.enter = function() {
44384       behavior.nodeIndex(affix === "prefix" ? 0 : void 0);
44385       context.install(behavior);
44386     };
44387     mode.exit = function() {
44388       context.uninstall(behavior);
44389     };
44390     mode.selectedIDs = function() {
44391       return [wayID];
44392     };
44393     mode.activeID = function() {
44394       return behavior && behavior.activeID() || [];
44395     };
44396     return mode;
44397   }
44398
44399   // modules/validations/disconnected_way.js
44400   function validationDisconnectedWay() {
44401     var type2 = "disconnected_way";
44402     function isTaggedAsHighway(entity) {
44403       return osmRoutableHighwayTagValues[entity.tags.highway];
44404     }
44405     var validation = function checkDisconnectedWay(entity, graph) {
44406       var routingIslandWays = routingIslandForEntity(entity);
44407       if (!routingIslandWays) return [];
44408       return [new validationIssue({
44409         type: type2,
44410         subtype: "highway",
44411         severity: "warning",
44412         message: function(context) {
44413           var entity2 = this.entityIds.length && context.hasEntity(this.entityIds[0]);
44414           var label = entity2 && utilDisplayLabel(entity2, context.graph());
44415           return _t.append("issues.disconnected_way.routable.message", { count: this.entityIds.length, highway: label });
44416         },
44417         reference: showReference,
44418         entityIds: Array.from(routingIslandWays).map(function(way) {
44419           return way.id;
44420         }),
44421         dynamicFixes: makeFixes
44422       })];
44423       function makeFixes(context) {
44424         var fixes = [];
44425         var singleEntity = this.entityIds.length === 1 && context.hasEntity(this.entityIds[0]);
44426         if (singleEntity) {
44427           if (singleEntity.type === "way" && !singleEntity.isClosed()) {
44428             var textDirection = _mainLocalizer.textDirection();
44429             var startFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.first(), "start");
44430             if (startFix) fixes.push(startFix);
44431             var endFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.last(), "end");
44432             if (endFix) fixes.push(endFix);
44433           }
44434           if (!fixes.length) {
44435             fixes.push(new validationIssueFix({
44436               title: _t.append("issues.fix.connect_feature.title")
44437             }));
44438           }
44439           fixes.push(new validationIssueFix({
44440             icon: "iD-operation-delete",
44441             title: _t.append("issues.fix.delete_feature.title"),
44442             entityIds: [singleEntity.id],
44443             onClick: function(context2) {
44444               var id2 = this.issue.entityIds[0];
44445               var operation2 = operationDelete(context2, [id2]);
44446               if (!operation2.disabled()) {
44447                 operation2();
44448               }
44449             }
44450           }));
44451         } else {
44452           fixes.push(new validationIssueFix({
44453             title: _t.append("issues.fix.connect_features.title")
44454           }));
44455         }
44456         return fixes;
44457       }
44458       function showReference(selection2) {
44459         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.disconnected_way.routable.reference"));
44460       }
44461       function routingIslandForEntity(entity2) {
44462         var routingIsland = /* @__PURE__ */ new Set();
44463         var waysToCheck = [];
44464         function queueParentWays(node) {
44465           graph.parentWays(node).forEach(function(parentWay) {
44466             if (!routingIsland.has(parentWay) && // only check each feature once
44467             isRoutableWay(parentWay, false)) {
44468               routingIsland.add(parentWay);
44469               waysToCheck.push(parentWay);
44470             }
44471           });
44472         }
44473         if (entity2.type === "way" && isRoutableWay(entity2, true)) {
44474           routingIsland.add(entity2);
44475           waysToCheck.push(entity2);
44476         } else if (entity2.type === "node" && isRoutableNode(entity2)) {
44477           routingIsland.add(entity2);
44478           queueParentWays(entity2);
44479         } else {
44480           return null;
44481         }
44482         while (waysToCheck.length) {
44483           var wayToCheck = waysToCheck.pop();
44484           var childNodes = graph.childNodes(wayToCheck);
44485           for (var i3 in childNodes) {
44486             var vertex = childNodes[i3];
44487             if (isConnectedVertex(vertex)) {
44488               return null;
44489             }
44490             if (isRoutableNode(vertex)) {
44491               routingIsland.add(vertex);
44492             }
44493             queueParentWays(vertex);
44494           }
44495         }
44496         return routingIsland;
44497       }
44498       function isConnectedVertex(vertex) {
44499         var osm = services.osm;
44500         if (osm && !osm.isDataLoaded(vertex.loc)) return true;
44501         if (vertex.tags.entrance && vertex.tags.entrance !== "no") return true;
44502         if (vertex.tags.amenity === "parking_entrance") return true;
44503         return false;
44504       }
44505       function isRoutableNode(node) {
44506         if (node.tags.highway === "elevator") return true;
44507         return false;
44508       }
44509       function isRoutableWay(way, ignoreInnerWays) {
44510         if (isTaggedAsHighway(way) || way.tags.route === "ferry") return true;
44511         return graph.parentRelations(way).some(function(parentRelation) {
44512           if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry") return true;
44513           if (parentRelation.isMultipolygon() && isTaggedAsHighway(parentRelation) && (!ignoreInnerWays || parentRelation.memberById(way.id).role !== "inner")) return true;
44514           return false;
44515         });
44516       }
44517       function makeContinueDrawingFixIfAllowed(textDirection, vertexID, whichEnd) {
44518         var vertex = graph.hasEntity(vertexID);
44519         if (!vertex || vertex.tags.noexit === "yes") return null;
44520         var useLeftContinue = whichEnd === "start" && textDirection === "ltr" || whichEnd === "end" && textDirection === "rtl";
44521         return new validationIssueFix({
44522           icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
44523           title: _t.append("issues.fix.continue_from_" + whichEnd + ".title"),
44524           entityIds: [vertexID],
44525           onClick: function(context) {
44526             var wayId = this.issue.entityIds[0];
44527             var way = context.hasEntity(wayId);
44528             var vertexId = this.entityIds[0];
44529             var vertex2 = context.hasEntity(vertexId);
44530             if (!way || !vertex2) return;
44531             var map2 = context.map();
44532             if (!context.editable() || !map2.trimmedExtent().contains(vertex2.loc)) {
44533               map2.zoomToEase(vertex2);
44534             }
44535             context.enter(
44536               modeDrawLine(context, wayId, context.graph(), "line", way.affix(vertexId), true)
44537             );
44538           }
44539         });
44540       }
44541     };
44542     validation.type = type2;
44543     return validation;
44544   }
44545
44546   // modules/validations/invalid_format.js
44547   function validationFormatting() {
44548     var type2 = "invalid_format";
44549     var validation = function(entity) {
44550       var issues = [];
44551       function isValidEmail(email) {
44552         var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
44553         return !email || valid_email.test(email);
44554       }
44555       function showReferenceEmail(selection2) {
44556         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.invalid_format.email.reference"));
44557       }
44558       if (entity.tags.email) {
44559         var emails = entity.tags.email.split(";").map(function(s2) {
44560           return s2.trim();
44561         }).filter(function(x2) {
44562           return !isValidEmail(x2);
44563         });
44564         if (emails.length) {
44565           issues.push(new validationIssue({
44566             type: type2,
44567             subtype: "email",
44568             severity: "warning",
44569             message: function(context) {
44570               var entity2 = context.hasEntity(this.entityIds[0]);
44571               return entity2 ? _t.append(
44572                 "issues.invalid_format.email.message" + this.data,
44573                 { feature: utilDisplayLabel(entity2, context.graph()), email: emails.join(", ") }
44574               ) : "";
44575             },
44576             reference: showReferenceEmail,
44577             entityIds: [entity.id],
44578             hash: emails.join(),
44579             data: emails.length > 1 ? "_multi" : ""
44580           }));
44581         }
44582       }
44583       return issues;
44584     };
44585     validation.type = type2;
44586     return validation;
44587   }
44588
44589   // modules/validations/help_request.js
44590   function validationHelpRequest(context) {
44591     var type2 = "help_request";
44592     var validation = function checkFixmeTag(entity) {
44593       if (!entity.tags.fixme) return [];
44594       if (entity.version === void 0) return [];
44595       if (entity.v !== void 0) {
44596         var baseEntity = context.history().base().hasEntity(entity.id);
44597         if (!baseEntity || !baseEntity.tags.fixme) return [];
44598       }
44599       return [new validationIssue({
44600         type: type2,
44601         subtype: "fixme_tag",
44602         severity: "warning",
44603         message: function(context2) {
44604           var entity2 = context2.hasEntity(this.entityIds[0]);
44605           return entity2 ? _t.append("issues.fixme_tag.message", {
44606             feature: utilDisplayLabel(
44607               entity2,
44608               context2.graph(),
44609               true
44610               /* verbose */
44611             )
44612           }) : "";
44613         },
44614         dynamicFixes: function() {
44615           return [
44616             new validationIssueFix({
44617               title: _t.append("issues.fix.address_the_concern.title")
44618             })
44619           ];
44620         },
44621         reference: showReference,
44622         entityIds: [entity.id]
44623       })];
44624       function showReference(selection2) {
44625         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.fixme_tag.reference"));
44626       }
44627     };
44628     validation.type = type2;
44629     return validation;
44630   }
44631
44632   // modules/validations/impossible_oneway.js
44633   function validationImpossibleOneway() {
44634     var type2 = "impossible_oneway";
44635     var validation = function checkImpossibleOneway(entity, graph) {
44636       if (entity.type !== "way" || entity.geometry(graph) !== "line") return [];
44637       if (entity.isClosed()) return [];
44638       if (!typeForWay(entity)) return [];
44639       if (!entity.isOneWay()) return [];
44640       var firstIssues = issuesForNode(entity, entity.first());
44641       var lastIssues = issuesForNode(entity, entity.last());
44642       return firstIssues.concat(lastIssues);
44643       function typeForWay(way) {
44644         if (way.geometry(graph) !== "line") return null;
44645         if (osmRoutableHighwayTagValues[way.tags.highway]) return "highway";
44646         if (osmFlowingWaterwayTagValues[way.tags.waterway]) return "waterway";
44647         return null;
44648       }
44649       function nodeOccursMoreThanOnce(way, nodeID) {
44650         var occurrences = 0;
44651         for (var index in way.nodes) {
44652           if (way.nodes[index] === nodeID) {
44653             occurrences += 1;
44654             if (occurrences > 1) return true;
44655           }
44656         }
44657         return false;
44658       }
44659       function isConnectedViaOtherTypes(way, node) {
44660         var wayType = typeForWay(way);
44661         if (wayType === "highway") {
44662           if (node.tags.entrance && node.tags.entrance !== "no") return true;
44663           if (node.tags.amenity === "parking_entrance") return true;
44664         } else if (wayType === "waterway") {
44665           if (node.id === way.first()) {
44666             if (node.tags.natural === "spring") return true;
44667           } else {
44668             if (node.tags.manhole === "drain") return true;
44669           }
44670         }
44671         return graph.parentWays(node).some(function(parentWay) {
44672           if (parentWay.id === way.id) return false;
44673           if (wayType === "highway") {
44674             if (parentWay.geometry(graph) === "area" && osmRoutableHighwayTagValues[parentWay.tags.highway]) return true;
44675             if (parentWay.tags.route === "ferry") return true;
44676             return graph.parentRelations(parentWay).some(function(parentRelation) {
44677               if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry") return true;
44678               return parentRelation.isMultipolygon() && osmRoutableHighwayTagValues[parentRelation.tags.highway];
44679             });
44680           } else if (wayType === "waterway") {
44681             if (parentWay.tags.natural === "water" || parentWay.tags.natural === "coastline") return true;
44682           }
44683           return false;
44684         });
44685       }
44686       function issuesForNode(way, nodeID) {
44687         var isFirst = nodeID === way.first();
44688         var wayType = typeForWay(way);
44689         if (nodeOccursMoreThanOnce(way, nodeID)) return [];
44690         var osm = services.osm;
44691         if (!osm) return [];
44692         var node = graph.hasEntity(nodeID);
44693         if (!node || !osm.isDataLoaded(node.loc)) return [];
44694         if (isConnectedViaOtherTypes(way, node)) return [];
44695         var attachedWaysOfSameType = graph.parentWays(node).filter(function(parentWay) {
44696           if (parentWay.id === way.id) return false;
44697           return typeForWay(parentWay) === wayType;
44698         });
44699         if (wayType === "waterway" && attachedWaysOfSameType.length === 0) return [];
44700         var attachedOneways = attachedWaysOfSameType.filter(function(attachedWay) {
44701           return attachedWay.isOneWay();
44702         });
44703         if (attachedOneways.length < attachedWaysOfSameType.length) return [];
44704         if (attachedOneways.length) {
44705           var connectedEndpointsOkay = attachedOneways.some(function(attachedOneway) {
44706             if ((isFirst ? attachedOneway.first() : attachedOneway.last()) !== nodeID) return true;
44707             if (nodeOccursMoreThanOnce(attachedOneway, nodeID)) return true;
44708             return false;
44709           });
44710           if (connectedEndpointsOkay) return [];
44711         }
44712         var placement = isFirst ? "start" : "end", messageID = wayType + ".", referenceID = wayType + ".";
44713         if (wayType === "waterway") {
44714           messageID += "connected." + placement;
44715           referenceID += "connected";
44716         } else {
44717           messageID += placement;
44718           referenceID += placement;
44719         }
44720         return [new validationIssue({
44721           type: type2,
44722           subtype: wayType,
44723           severity: "warning",
44724           message: function(context) {
44725             var entity2 = context.hasEntity(this.entityIds[0]);
44726             return entity2 ? _t.append("issues.impossible_oneway." + messageID + ".message", {
44727               feature: utilDisplayLabel(entity2, context.graph())
44728             }) : "";
44729           },
44730           reference: getReference(referenceID),
44731           entityIds: [way.id, node.id],
44732           dynamicFixes: function() {
44733             var fixes = [];
44734             if (attachedOneways.length) {
44735               fixes.push(new validationIssueFix({
44736                 icon: "iD-operation-reverse",
44737                 title: _t.append("issues.fix.reverse_feature.title"),
44738                 entityIds: [way.id],
44739                 onClick: function(context) {
44740                   var id2 = this.issue.entityIds[0];
44741                   context.perform(actionReverse(id2), _t("operations.reverse.annotation.line", { n: 1 }));
44742                 }
44743               }));
44744             }
44745             if (node.tags.noexit !== "yes") {
44746               var textDirection = _mainLocalizer.textDirection();
44747               var useLeftContinue = isFirst && textDirection === "ltr" || !isFirst && textDirection === "rtl";
44748               fixes.push(new validationIssueFix({
44749                 icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
44750                 title: _t.append("issues.fix.continue_from_" + (isFirst ? "start" : "end") + ".title"),
44751                 onClick: function(context) {
44752                   var entityID = this.issue.entityIds[0];
44753                   var vertexID = this.issue.entityIds[1];
44754                   var way2 = context.entity(entityID);
44755                   var vertex = context.entity(vertexID);
44756                   continueDrawing(way2, vertex, context);
44757                 }
44758               }));
44759             }
44760             return fixes;
44761           },
44762           loc: node.loc
44763         })];
44764         function getReference(referenceID2) {
44765           return function showReference(selection2) {
44766             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.impossible_oneway." + referenceID2 + ".reference"));
44767           };
44768         }
44769       }
44770     };
44771     function continueDrawing(way, vertex, context) {
44772       var map2 = context.map();
44773       if (!context.editable() || !map2.trimmedExtent().contains(vertex.loc)) {
44774         map2.zoomToEase(vertex);
44775       }
44776       context.enter(
44777         modeDrawLine(context, way.id, context.graph(), "line", way.affix(vertex.id), true)
44778       );
44779     }
44780     validation.type = type2;
44781     return validation;
44782   }
44783
44784   // modules/validations/incompatible_source.js
44785   function validationIncompatibleSource() {
44786     const type2 = "incompatible_source";
44787     const incompatibleRules = [
44788       {
44789         id: "amap",
44790         regex: /(^amap$|^amap\.com|autonavi|mapabc|高德)/i
44791       },
44792       {
44793         id: "baidu",
44794         regex: /(baidu|mapbar|百度)/i
44795       },
44796       {
44797         id: "google",
44798         regex: /google/i,
44799         exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))|(esri\/Google_Africa_Buildings)/i
44800       }
44801     ];
44802     const validation = function checkIncompatibleSource(entity) {
44803       const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(";");
44804       if (!entitySources) return [];
44805       const entityID = entity.id;
44806       return entitySources.map((source) => {
44807         const matchRule = incompatibleRules.find((rule) => {
44808           if (!rule.regex.test(source)) return false;
44809           if (rule.exceptRegex && rule.exceptRegex.test(source)) return false;
44810           return true;
44811         });
44812         if (!matchRule) return null;
44813         return new validationIssue({
44814           type: type2,
44815           severity: "warning",
44816           message: (context) => {
44817             const entity2 = context.hasEntity(entityID);
44818             return entity2 ? _t.append("issues.incompatible_source.feature.message", {
44819               feature: utilDisplayLabel(
44820                 entity2,
44821                 context.graph(),
44822                 true
44823                 /* verbose */
44824               ),
44825               value: source
44826             }) : "";
44827           },
44828           reference: getReference(matchRule.id),
44829           entityIds: [entityID],
44830           hash: source,
44831           dynamicFixes: () => {
44832             return [
44833               new validationIssueFix({ title: _t.append("issues.fix.remove_proprietary_data.title") })
44834             ];
44835           }
44836         });
44837       }).filter(Boolean);
44838       function getReference(id2) {
44839         return function showReference(selection2) {
44840           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2)));
44841         };
44842       }
44843     };
44844     validation.type = type2;
44845     return validation;
44846   }
44847
44848   // modules/validations/maprules.js
44849   function validationMaprules() {
44850     var type2 = "maprules";
44851     var validation = function checkMaprules(entity, graph) {
44852       if (!services.maprules) return [];
44853       var rules = services.maprules.validationRules();
44854       var issues = [];
44855       for (var i3 = 0; i3 < rules.length; i3++) {
44856         var rule = rules[i3];
44857         rule.findIssues(entity, graph, issues);
44858       }
44859       return issues;
44860     };
44861     validation.type = type2;
44862     return validation;
44863   }
44864
44865   // modules/validations/mismatched_geometry.js
44866   var import_fast_deep_equal4 = __toESM(require_fast_deep_equal());
44867   function validationMismatchedGeometry() {
44868     var type2 = "mismatched_geometry";
44869     function tagSuggestingLineIsArea(entity) {
44870       if (entity.type !== "way" || entity.isClosed()) return null;
44871       var tagSuggestingArea = entity.tagSuggestingArea();
44872       if (!tagSuggestingArea) {
44873         return null;
44874       }
44875       var asLine = _mainPresetIndex.matchTags(tagSuggestingArea, "line");
44876       var asArea = _mainPresetIndex.matchTags(tagSuggestingArea, "area");
44877       if (asLine && asArea && (0, import_fast_deep_equal4.default)(asLine.tags, asArea.tags)) {
44878         return null;
44879       }
44880       if (asLine.isFallback() && asArea.isFallback() && !(0, import_fast_deep_equal4.default)(tagSuggestingArea, { area: "yes" })) {
44881         return null;
44882       }
44883       return tagSuggestingArea;
44884     }
44885     function makeConnectEndpointsFixOnClick(way, graph) {
44886       if (way.nodes.length < 3) return null;
44887       var nodes = graph.childNodes(way), testNodes;
44888       var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length - 1].loc);
44889       if (firstToLastDistanceMeters < 0.75) {
44890         testNodes = nodes.slice();
44891         testNodes.pop();
44892         testNodes.push(testNodes[0]);
44893         if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
44894           return function(context) {
44895             var way2 = context.entity(this.issue.entityIds[0]);
44896             context.perform(
44897               actionMergeNodes([way2.nodes[0], way2.nodes[way2.nodes.length - 1]], nodes[0].loc),
44898               _t("issues.fix.connect_endpoints.annotation")
44899             );
44900           };
44901         }
44902       }
44903       testNodes = nodes.slice();
44904       testNodes.push(testNodes[0]);
44905       if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
44906         return function(context) {
44907           var wayId = this.issue.entityIds[0];
44908           var way2 = context.entity(wayId);
44909           var nodeId = way2.nodes[0];
44910           var index = way2.nodes.length;
44911           context.perform(
44912             actionAddVertex(wayId, nodeId, index),
44913             _t("issues.fix.connect_endpoints.annotation")
44914           );
44915         };
44916       }
44917     }
44918     function lineTaggedAsAreaIssue(entity) {
44919       var tagSuggestingArea = tagSuggestingLineIsArea(entity);
44920       if (!tagSuggestingArea) return null;
44921       var validAsLine = false;
44922       var presetAsLine = _mainPresetIndex.matchTags(entity.tags, "line");
44923       if (presetAsLine) {
44924         validAsLine = true;
44925         var key = Object.keys(tagSuggestingArea)[0];
44926         if (presetAsLine.tags[key] && presetAsLine.tags[key] === "*") {
44927           validAsLine = false;
44928         }
44929         if (Object.keys(presetAsLine.tags).length === 0) {
44930           validAsLine = false;
44931         }
44932       }
44933       return new validationIssue({
44934         type: type2,
44935         subtype: "area_as_line",
44936         severity: "warning",
44937         message: function(context) {
44938           var entity2 = context.hasEntity(this.entityIds[0]);
44939           return entity2 ? _t.append("issues.tag_suggests_area.message", {
44940             feature: utilDisplayLabel(
44941               entity2,
44942               "area",
44943               true
44944               /* verbose */
44945             ),
44946             tag: utilTagText({ tags: tagSuggestingArea })
44947           }) : "";
44948         },
44949         reference: showReference,
44950         entityIds: [entity.id],
44951         hash: JSON.stringify(tagSuggestingArea),
44952         dynamicFixes: function(context) {
44953           var fixes = [];
44954           var entity2 = context.entity(this.entityIds[0]);
44955           var connectEndsOnClick = makeConnectEndpointsFixOnClick(entity2, context.graph());
44956           if (!validAsLine) {
44957             fixes.push(new validationIssueFix({
44958               title: _t.append("issues.fix.connect_endpoints.title"),
44959               onClick: connectEndsOnClick
44960             }));
44961           }
44962           fixes.push(new validationIssueFix({
44963             icon: "iD-operation-delete",
44964             title: _t.append("issues.fix.remove_tag.title"),
44965             onClick: function(context2) {
44966               var entityId = this.issue.entityIds[0];
44967               var entity3 = context2.entity(entityId);
44968               var tags = Object.assign({}, entity3.tags);
44969               for (var key2 in tagSuggestingArea) {
44970                 delete tags[key2];
44971               }
44972               context2.perform(
44973                 actionChangeTags(entityId, tags),
44974                 _t("issues.fix.remove_tag.annotation")
44975               );
44976             }
44977           }));
44978           return fixes;
44979         }
44980       });
44981       function showReference(selection2) {
44982         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.tag_suggests_area.reference"));
44983       }
44984     }
44985     function vertexPointIssue(entity, graph) {
44986       if (entity.type !== "node") return null;
44987       if (Object.keys(entity.tags).length === 0) return null;
44988       if (entity.isOnAddressLine(graph)) return null;
44989       var geometry = entity.geometry(graph);
44990       var allowedGeometries = osmNodeGeometriesForTags(entity.tags);
44991       if (geometry === "point" && !allowedGeometries.point && allowedGeometries.vertex) {
44992         return new validationIssue({
44993           type: type2,
44994           subtype: "vertex_as_point",
44995           severity: "warning",
44996           message: function(context) {
44997             var entity2 = context.hasEntity(this.entityIds[0]);
44998             return entity2 ? _t.append("issues.vertex_as_point.message", {
44999               feature: utilDisplayLabel(
45000                 entity2,
45001                 "vertex",
45002                 true
45003                 /* verbose */
45004               )
45005             }) : "";
45006           },
45007           reference: function showReference(selection2) {
45008             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.vertex_as_point.reference"));
45009           },
45010           entityIds: [entity.id]
45011         });
45012       } else if (geometry === "vertex" && !allowedGeometries.vertex && allowedGeometries.point) {
45013         return new validationIssue({
45014           type: type2,
45015           subtype: "point_as_vertex",
45016           severity: "warning",
45017           message: function(context) {
45018             var entity2 = context.hasEntity(this.entityIds[0]);
45019             return entity2 ? _t.append("issues.point_as_vertex.message", {
45020               feature: utilDisplayLabel(
45021                 entity2,
45022                 "point",
45023                 true
45024                 /* verbose */
45025               )
45026             }) : "";
45027           },
45028           reference: function showReference(selection2) {
45029             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.point_as_vertex.reference"));
45030           },
45031           entityIds: [entity.id],
45032           dynamicFixes: extractPointDynamicFixes
45033         });
45034       }
45035       return null;
45036     }
45037     function otherMismatchIssue(entity, graph) {
45038       if (!entity.hasInterestingTags()) return null;
45039       if (entity.type !== "node" && entity.type !== "way") return null;
45040       if (entity.type === "node" && entity.isOnAddressLine(graph)) return null;
45041       var sourceGeom = entity.geometry(graph);
45042       var targetGeoms = entity.type === "way" ? ["point", "vertex"] : ["line", "area"];
45043       if (sourceGeom === "area") targetGeoms.unshift("line");
45044       var asSource = _mainPresetIndex.match(entity, graph);
45045       var targetGeom = targetGeoms.find((nodeGeom) => {
45046         const asTarget = _mainPresetIndex.matchTags(
45047           entity.tags,
45048           nodeGeom,
45049           entity.extent(graph).center()
45050         );
45051         if (!asSource || !asTarget || asSource === asTarget || // sometimes there are two presets with the same tags for different geometries
45052         (0, import_fast_deep_equal4.default)(asSource.tags, asTarget.tags)) return false;
45053         if (asTarget.isFallback()) return false;
45054         var primaryKey = Object.keys(asTarget.tags)[0];
45055         if (primaryKey === "building") return false;
45056         if (asTarget.tags[primaryKey] === "*") return false;
45057         return asSource.isFallback() || asSource.tags[primaryKey] === "*";
45058       });
45059       if (!targetGeom) return null;
45060       var subtype = targetGeom + "_as_" + sourceGeom;
45061       if (targetGeom === "vertex") targetGeom = "point";
45062       if (sourceGeom === "vertex") sourceGeom = "point";
45063       var referenceId = targetGeom + "_as_" + sourceGeom;
45064       var dynamicFixes;
45065       if (targetGeom === "point") {
45066         dynamicFixes = extractPointDynamicFixes;
45067       } else if (sourceGeom === "area" && targetGeom === "line") {
45068         dynamicFixes = lineToAreaDynamicFixes;
45069       }
45070       return new validationIssue({
45071         type: type2,
45072         subtype,
45073         severity: "warning",
45074         message: function(context) {
45075           var entity2 = context.hasEntity(this.entityIds[0]);
45076           return entity2 ? _t.append("issues." + referenceId + ".message", {
45077             feature: utilDisplayLabel(
45078               entity2,
45079               targetGeom,
45080               true
45081               /* verbose */
45082             )
45083           }) : "";
45084         },
45085         reference: function showReference(selection2) {
45086           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.mismatched_geometry.reference"));
45087         },
45088         entityIds: [entity.id],
45089         dynamicFixes
45090       });
45091     }
45092     function lineToAreaDynamicFixes(context) {
45093       var convertOnClick;
45094       var entityId = this.entityIds[0];
45095       var entity = context.entity(entityId);
45096       var tags = Object.assign({}, entity.tags);
45097       delete tags.area;
45098       if (!osmTagSuggestingArea(tags)) {
45099         convertOnClick = function(context2) {
45100           var entityId2 = this.issue.entityIds[0];
45101           var entity2 = context2.entity(entityId2);
45102           var tags2 = Object.assign({}, entity2.tags);
45103           if (tags2.area) {
45104             delete tags2.area;
45105           }
45106           context2.perform(
45107             actionChangeTags(entityId2, tags2),
45108             _t("issues.fix.convert_to_line.annotation")
45109           );
45110         };
45111       }
45112       return [
45113         new validationIssueFix({
45114           icon: "iD-icon-line",
45115           title: _t.append("issues.fix.convert_to_line.title"),
45116           onClick: convertOnClick
45117         })
45118       ];
45119     }
45120     function extractPointDynamicFixes(context) {
45121       var entityId = this.entityIds[0];
45122       var extractOnClick = null;
45123       if (!context.hasHiddenConnections(entityId)) {
45124         extractOnClick = function(context2) {
45125           var entityId2 = this.issue.entityIds[0];
45126           var action = actionExtract(entityId2, context2.projection);
45127           context2.perform(
45128             action,
45129             _t("operations.extract.annotation", { n: 1 })
45130           );
45131           context2.enter(modeSelect(context2, [action.getExtractedNodeID()]));
45132         };
45133       }
45134       return [
45135         new validationIssueFix({
45136           icon: "iD-operation-extract",
45137           title: _t.append("issues.fix.extract_point.title"),
45138           onClick: extractOnClick
45139         })
45140       ];
45141     }
45142     function unclosedMultipolygonPartIssues(entity, graph) {
45143       if (entity.type !== "relation" || !entity.isMultipolygon() || entity.isDegenerate() || // cannot determine issues for incompletely-downloaded relations
45144       !entity.isComplete(graph)) return [];
45145       var sequences = osmJoinWays(entity.members, graph);
45146       var issues = [];
45147       for (var i3 in sequences) {
45148         var sequence = sequences[i3];
45149         if (!sequence.nodes) continue;
45150         var firstNode = sequence.nodes[0];
45151         var lastNode = sequence.nodes[sequence.nodes.length - 1];
45152         if (firstNode === lastNode) continue;
45153         var issue = new validationIssue({
45154           type: type2,
45155           subtype: "unclosed_multipolygon_part",
45156           severity: "warning",
45157           message: function(context) {
45158             var entity2 = context.hasEntity(this.entityIds[0]);
45159             return entity2 ? _t.append("issues.unclosed_multipolygon_part.message", {
45160               feature: utilDisplayLabel(
45161                 entity2,
45162                 context.graph(),
45163                 true
45164                 /* verbose */
45165               )
45166             }) : "";
45167           },
45168           reference: showReference,
45169           loc: sequence.nodes[0].loc,
45170           entityIds: [entity.id],
45171           hash: sequence.map(function(way) {
45172             return way.id;
45173           }).join()
45174         });
45175         issues.push(issue);
45176       }
45177       return issues;
45178       function showReference(selection2) {
45179         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unclosed_multipolygon_part.reference"));
45180       }
45181     }
45182     var validation = function checkMismatchedGeometry(entity, graph) {
45183       var vertexPoint = vertexPointIssue(entity, graph);
45184       if (vertexPoint) return [vertexPoint];
45185       var lineAsArea = lineTaggedAsAreaIssue(entity);
45186       if (lineAsArea) return [lineAsArea];
45187       var mismatch = otherMismatchIssue(entity, graph);
45188       if (mismatch) return [mismatch];
45189       return unclosedMultipolygonPartIssues(entity, graph);
45190     };
45191     validation.type = type2;
45192     return validation;
45193   }
45194
45195   // modules/validations/missing_role.js
45196   function validationMissingRole() {
45197     var type2 = "missing_role";
45198     var validation = function checkMissingRole(entity, graph) {
45199       var issues = [];
45200       if (entity.type === "way") {
45201         graph.parentRelations(entity).forEach(function(relation) {
45202           if (!relation.isMultipolygon()) return;
45203           var member = relation.memberById(entity.id);
45204           if (member && isMissingRole(member)) {
45205             issues.push(makeIssue(entity, relation, member));
45206           }
45207         });
45208       } else if (entity.type === "relation" && entity.isMultipolygon()) {
45209         entity.indexedMembers().forEach(function(member) {
45210           var way = graph.hasEntity(member.id);
45211           if (way && isMissingRole(member)) {
45212             issues.push(makeIssue(way, entity, member));
45213           }
45214         });
45215       }
45216       return issues;
45217     };
45218     function isMissingRole(member) {
45219       return !member.role || !member.role.trim().length;
45220     }
45221     function makeIssue(way, relation, member) {
45222       return new validationIssue({
45223         type: type2,
45224         severity: "warning",
45225         message: function(context) {
45226           var member2 = context.hasEntity(this.entityIds[1]), relation2 = context.hasEntity(this.entityIds[0]);
45227           return member2 && relation2 ? _t.append("issues.missing_role.message", {
45228             member: utilDisplayLabel(member2, context.graph()),
45229             relation: utilDisplayLabel(relation2, context.graph())
45230           }) : "";
45231         },
45232         reference: showReference,
45233         entityIds: [relation.id, way.id],
45234         data: {
45235           member
45236         },
45237         hash: member.index.toString(),
45238         dynamicFixes: function() {
45239           return [
45240             makeAddRoleFix("inner"),
45241             makeAddRoleFix("outer"),
45242             new validationIssueFix({
45243               icon: "iD-operation-delete",
45244               title: _t.append("issues.fix.remove_from_relation.title"),
45245               onClick: function(context) {
45246                 context.perform(
45247                   actionDeleteMember(this.issue.entityIds[0], this.issue.data.member.index),
45248                   _t("operations.delete_member.annotation", {
45249                     n: 1
45250                   })
45251                 );
45252               }
45253             })
45254           ];
45255         }
45256       });
45257       function showReference(selection2) {
45258         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.missing_role.multipolygon.reference"));
45259       }
45260     }
45261     function makeAddRoleFix(role) {
45262       return new validationIssueFix({
45263         title: _t.append("issues.fix.set_as_" + role + ".title"),
45264         onClick: function(context) {
45265           var oldMember = this.issue.data.member;
45266           var member = { id: this.issue.entityIds[1], type: oldMember.type, role };
45267           context.perform(
45268             actionChangeMember(this.issue.entityIds[0], member, oldMember.index),
45269             _t("operations.change_role.annotation", {
45270               n: 1
45271             })
45272           );
45273         }
45274       });
45275     }
45276     validation.type = type2;
45277     return validation;
45278   }
45279
45280   // modules/validations/missing_tag.js
45281   function validationMissingTag(context) {
45282     var type2 = "missing_tag";
45283     function hasDescriptiveTags(entity) {
45284       var onlyAttributeKeys = ["description", "name", "note", "start_date", "oneway"];
45285       var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) {
45286         if (k2 === "area" || !osmIsInterestingTag(k2)) return false;
45287         return !onlyAttributeKeys.some(function(attributeKey) {
45288           return k2 === attributeKey || k2.indexOf(attributeKey + ":") === 0;
45289         });
45290       });
45291       if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") {
45292         return false;
45293       }
45294       return entityDescriptiveKeys.length > 0;
45295     }
45296     function isUnknownRoad(entity) {
45297       return entity.type === "way" && entity.tags.highway === "road";
45298     }
45299     function isUntypedRelation(entity) {
45300       return entity.type === "relation" && !entity.tags.type;
45301     }
45302     var validation = function checkMissingTag(entity, graph) {
45303       var subtype;
45304       var osm = context.connection();
45305       var isUnloadedNode = entity.type === "node" && osm && !osm.isDataLoaded(entity.loc);
45306       if (!isUnloadedNode && // allow untagged nodes that are part of ways
45307       entity.geometry(graph) !== "vertex" && // allow untagged entities that are part of relations
45308       !entity.hasParentRelations(graph)) {
45309         if (Object.keys(entity.tags).length === 0) {
45310           subtype = "any";
45311         } else if (!hasDescriptiveTags(entity)) {
45312           subtype = "descriptive";
45313         } else if (isUntypedRelation(entity)) {
45314           subtype = "relation_type";
45315         }
45316       }
45317       if (!subtype && isUnknownRoad(entity)) {
45318         subtype = "highway_classification";
45319       }
45320       if (!subtype) return [];
45321       var messageID = subtype === "highway_classification" ? "unknown_road" : "missing_tag." + subtype;
45322       var referenceID = subtype === "highway_classification" ? "unknown_road" : "missing_tag";
45323       var canDelete = entity.version === void 0 || entity.v !== void 0;
45324       var severity = canDelete && subtype !== "highway_classification" ? "error" : "warning";
45325       return [new validationIssue({
45326         type: type2,
45327         subtype,
45328         severity,
45329         message: function(context2) {
45330           var entity2 = context2.hasEntity(this.entityIds[0]);
45331           return entity2 ? _t.append("issues." + messageID + ".message", {
45332             feature: utilDisplayLabel(entity2, context2.graph())
45333           }) : "";
45334         },
45335         reference: showReference,
45336         entityIds: [entity.id],
45337         dynamicFixes: function(context2) {
45338           var fixes = [];
45339           var selectFixType = subtype === "highway_classification" ? "select_road_type" : "select_preset";
45340           fixes.push(new validationIssueFix({
45341             icon: "iD-icon-search",
45342             title: _t.append("issues.fix." + selectFixType + ".title"),
45343             onClick: function(context3) {
45344               context3.ui().sidebar.showPresetList();
45345             }
45346           }));
45347           var deleteOnClick;
45348           var id2 = this.entityIds[0];
45349           var operation2 = operationDelete(context2, [id2]);
45350           var disabledReasonID = operation2.disabled();
45351           if (!disabledReasonID) {
45352             deleteOnClick = function(context3) {
45353               var id3 = this.issue.entityIds[0];
45354               var operation3 = operationDelete(context3, [id3]);
45355               if (!operation3.disabled()) {
45356                 operation3();
45357               }
45358             };
45359           }
45360           fixes.push(
45361             new validationIssueFix({
45362               icon: "iD-operation-delete",
45363               title: _t.append("issues.fix.delete_feature.title"),
45364               disabledReason: disabledReasonID ? _t("operations.delete." + disabledReasonID + ".single") : void 0,
45365               onClick: deleteOnClick
45366             })
45367           );
45368           return fixes;
45369         }
45370       })];
45371       function showReference(selection2) {
45372         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues." + referenceID + ".reference"));
45373       }
45374     };
45375     validation.type = type2;
45376     return validation;
45377   }
45378
45379   // modules/validations/mutually_exclusive_tags.js
45380   function validationMutuallyExclusiveTags() {
45381     const type2 = "mutually_exclusive_tags";
45382     const tagKeyPairs = osmMutuallyExclusiveTagPairs;
45383     const validation = function checkMutuallyExclusiveTags(entity) {
45384       let pairsFounds = tagKeyPairs.filter((pair3) => {
45385         return pair3[0] in entity.tags && pair3[1] in entity.tags;
45386       }).filter((pair3) => {
45387         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");
45388       });
45389       Object.keys(entity.tags).forEach((key) => {
45390         let negative_key = "not:" + key;
45391         if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
45392           pairsFounds.push([negative_key, key, "same_value"]);
45393         }
45394         if (key.match(/^name:[a-z]+/)) {
45395           negative_key = "not:name";
45396           if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
45397             pairsFounds.push([negative_key, key, "same_value"]);
45398           }
45399         }
45400       });
45401       let issues = pairsFounds.map((pair3) => {
45402         const subtype = pair3[2] || "default";
45403         return new validationIssue({
45404           type: type2,
45405           subtype,
45406           severity: "warning",
45407           message: function(context) {
45408             let entity2 = context.hasEntity(this.entityIds[0]);
45409             return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), {
45410               feature: utilDisplayLabel(entity2, context.graph()),
45411               tag1: pair3[0],
45412               tag2: pair3[1]
45413             }) : "";
45414           },
45415           reference: (selection2) => showReference(selection2, pair3, subtype),
45416           entityIds: [entity.id],
45417           dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove))
45418         });
45419       });
45420       function createIssueFix(tagToRemove) {
45421         return new validationIssueFix({
45422           icon: "iD-operation-delete",
45423           title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }),
45424           onClick: function(context) {
45425             const entityId = this.issue.entityIds[0];
45426             const entity2 = context.entity(entityId);
45427             let tags = Object.assign({}, entity2.tags);
45428             delete tags[tagToRemove];
45429             context.perform(
45430               actionChangeTags(entityId, tags),
45431               _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove })
45432             );
45433           }
45434         });
45435       }
45436       function showReference(selection2, pair3, subtype) {
45437         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] }));
45438       }
45439       return issues;
45440     };
45441     validation.type = type2;
45442     return validation;
45443   }
45444
45445   // modules/operations/split.js
45446   function operationSplit(context, selectedIDs) {
45447     var _vertexIds = selectedIDs.filter(function(id2) {
45448       return context.graph().geometry(id2) === "vertex";
45449     });
45450     var _selectedWayIds = selectedIDs.filter(function(id2) {
45451       var entity = context.graph().hasEntity(id2);
45452       return entity && entity.type === "way";
45453     });
45454     var _isAvailable = _vertexIds.length > 0 && _vertexIds.length + _selectedWayIds.length === selectedIDs.length;
45455     var _action = actionSplit(_vertexIds);
45456     var _ways = [];
45457     var _geometry = "feature";
45458     var _waysAmount = "single";
45459     var _nodesAmount = _vertexIds.length === 1 ? "single" : "multiple";
45460     if (_isAvailable) {
45461       if (_selectedWayIds.length) _action.limitWays(_selectedWayIds);
45462       _ways = _action.ways(context.graph());
45463       var geometries = {};
45464       _ways.forEach(function(way) {
45465         geometries[way.geometry(context.graph())] = true;
45466       });
45467       if (Object.keys(geometries).length === 1) {
45468         _geometry = Object.keys(geometries)[0];
45469       }
45470       _waysAmount = _ways.length === 1 ? "single" : "multiple";
45471     }
45472     var operation2 = function() {
45473       var difference2 = context.perform(_action, operation2.annotation());
45474       var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) {
45475         return context.entity(id2).type === "way";
45476       }));
45477       context.enter(modeSelect(context, idsToSelect));
45478     };
45479     operation2.relatedEntityIds = function() {
45480       return _selectedWayIds.length ? [] : _ways.map((way) => way.id);
45481     };
45482     operation2.available = function() {
45483       return _isAvailable;
45484     };
45485     operation2.disabled = function() {
45486       var reason = _action.disabled(context.graph());
45487       if (reason) {
45488         return reason;
45489       } else if (selectedIDs.some(context.hasHiddenConnections)) {
45490         return "connected_to_hidden";
45491       }
45492       return false;
45493     };
45494     operation2.tooltip = function() {
45495       var disable = operation2.disabled();
45496       return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node");
45497     };
45498     operation2.annotation = function() {
45499       return _t("operations.split.annotation." + _geometry, { n: _ways.length });
45500     };
45501     operation2.icon = function() {
45502       if (_waysAmount === "multiple") {
45503         return "#iD-operation-split-multiple";
45504       } else {
45505         return "#iD-operation-split";
45506       }
45507     };
45508     operation2.id = "split";
45509     operation2.keys = [_t("operations.split.key")];
45510     operation2.title = _t.append("operations.split.title");
45511     operation2.behavior = behaviorOperation(context).which(operation2);
45512     return operation2;
45513   }
45514
45515   // modules/validations/osm_api_limits.js
45516   function validationOsmApiLimits(context) {
45517     const type2 = "osm_api_limits";
45518     const validation = function checkOsmApiLimits(entity) {
45519       const issues = [];
45520       const osm = context.connection();
45521       if (!osm) return issues;
45522       const maxWayNodes = osm.maxWayNodes();
45523       if (entity.type === "way") {
45524         if (entity.nodes.length > maxWayNodes) {
45525           issues.push(new validationIssue({
45526             type: type2,
45527             subtype: "exceededMaxWayNodes",
45528             severity: "error",
45529             message: function() {
45530               return _t.html("issues.osm_api_limits.max_way_nodes.message");
45531             },
45532             reference: function(selection2) {
45533               selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(_t.html("issues.osm_api_limits.max_way_nodes.reference", { maxWayNodes }));
45534             },
45535             entityIds: [entity.id],
45536             dynamicFixes: splitWayIntoSmallChunks
45537           }));
45538         }
45539       }
45540       return issues;
45541     };
45542     function splitWayIntoSmallChunks() {
45543       const fix = new validationIssueFix({
45544         icon: "iD-operation-split",
45545         title: _t.html("issues.fix.split_way.title"),
45546         entityIds: this.entityIds,
45547         onClick: function(context2) {
45548           const maxWayNodes = context2.connection().maxWayNodes();
45549           const g3 = context2.graph();
45550           const entityId = this.entityIds[0];
45551           const entity = context2.graph().entities[entityId];
45552           const numberOfParts = Math.ceil(entity.nodes.length / maxWayNodes);
45553           let splitVertices;
45554           if (numberOfParts === 2) {
45555             const splitIntersections = entity.nodes.map((nid) => g3.entity(nid)).filter((n3) => g3.parentWays(n3).length > 1).map((n3) => n3.id).filter((nid) => {
45556               const splitIndex = entity.nodes.indexOf(nid);
45557               return splitIndex < maxWayNodes && entity.nodes.length - splitIndex < maxWayNodes;
45558             });
45559             if (splitIntersections.length > 0) {
45560               splitVertices = [
45561                 splitIntersections[Math.floor(splitIntersections.length / 2)]
45562               ];
45563             }
45564           }
45565           if (splitVertices === void 0) {
45566             splitVertices = [...Array(numberOfParts - 1)].map((_2, i3) => entity.nodes[Math.floor(entity.nodes.length * (i3 + 1) / numberOfParts)]);
45567           }
45568           if (entity.isClosed()) {
45569             splitVertices.push(entity.nodes[0]);
45570           }
45571           const operation2 = operationSplit(context2, splitVertices.concat(entityId));
45572           if (!operation2.disabled()) {
45573             operation2();
45574           }
45575         }
45576       });
45577       return [fix];
45578     }
45579     validation.type = type2;
45580     return validation;
45581   }
45582
45583   // modules/validations/outdated_tags.js
45584   function validationOutdatedTags() {
45585     const type2 = "outdated_tags";
45586     let _waitingForDeprecated = true;
45587     let _dataDeprecated;
45588     _mainFileFetcher.get("deprecated").then((d2) => _dataDeprecated = d2).catch(() => {
45589     }).finally(() => _waitingForDeprecated = false);
45590     function oldTagIssues(entity, graph) {
45591       if (!entity.hasInterestingTags()) return [];
45592       let preset = _mainPresetIndex.match(entity, graph);
45593       if (!preset) return [];
45594       const oldTags = Object.assign({}, entity.tags);
45595       if (preset.replacement) {
45596         const newPreset = _mainPresetIndex.item(preset.replacement);
45597         graph = actionChangePreset(
45598           entity.id,
45599           preset,
45600           newPreset,
45601           true
45602           /* skip field defaults */
45603         )(graph);
45604         entity = graph.entity(entity.id);
45605         preset = newPreset;
45606       }
45607       if (_dataDeprecated) {
45608         const deprecatedTags = entity.deprecatedTags(_dataDeprecated);
45609         if (entity.type === "way" && entity.isClosed() && entity.tags.traffic_calming === "island" && !entity.tags.highway) {
45610           deprecatedTags.push({
45611             old: { traffic_calming: "island" },
45612             replace: { "area:highway": "traffic_island" }
45613           });
45614         }
45615         if (deprecatedTags.length) {
45616           deprecatedTags.forEach((tag2) => {
45617             graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph);
45618           });
45619           entity = graph.entity(entity.id);
45620         }
45621       }
45622       let newTags = Object.assign({}, entity.tags);
45623       if (preset.tags !== preset.addTags) {
45624         Object.keys(preset.addTags).forEach((k2) => {
45625           if (!newTags[k2]) {
45626             if (preset.addTags[k2] === "*") {
45627               newTags[k2] = "yes";
45628             } else if (preset.addTags[k2]) {
45629               newTags[k2] = preset.addTags[k2];
45630             }
45631           }
45632         });
45633       }
45634       const deprecationDiff = utilTagDiff(oldTags, newTags);
45635       const nsi = services.nsi;
45636       let waitingForNsi = false;
45637       let nsiResult;
45638       if (nsi) {
45639         waitingForNsi = nsi.status() === "loading";
45640         if (!waitingForNsi) {
45641           const loc = entity.extent(graph).center();
45642           nsiResult = nsi.upgradeTags(oldTags, loc);
45643         }
45644       }
45645       const nsiDiff = nsiResult ? utilTagDiff(oldTags, nsiResult.newTags) : [];
45646       let issues = [];
45647       issues.provisional = _waitingForDeprecated || waitingForNsi;
45648       if (deprecationDiff.length) {
45649         const isOnlyAddingTags = deprecationDiff.every((d2) => d2.type === "+");
45650         const prefix = isOnlyAddingTags ? "incomplete." : "";
45651         issues.push(new validationIssue({
45652           type: type2,
45653           subtype: isOnlyAddingTags ? "incomplete_tags" : "deprecated_tags",
45654           severity: "warning",
45655           message: (context) => {
45656             const currEntity = context.hasEntity(entity.id);
45657             if (!currEntity) return "";
45658             const feature3 = utilDisplayLabel(
45659               currEntity,
45660               context.graph(),
45661               /* verbose */
45662               true
45663             );
45664             return _t.append("issues.outdated_tags.".concat(prefix, "message"), { feature: feature3 });
45665           },
45666           reference: (selection2) => showReference(
45667             selection2,
45668             _t.append("issues.outdated_tags.".concat(prefix, "reference")),
45669             deprecationDiff
45670           ),
45671           entityIds: [entity.id],
45672           hash: utilHashcode(JSON.stringify(deprecationDiff)),
45673           dynamicFixes: () => {
45674             let fixes = [
45675               new validationIssueFix({
45676                 title: _t.append("issues.fix.upgrade_tags.title"),
45677                 onClick: (context) => {
45678                   context.perform((graph2) => doUpgrade(graph2, deprecationDiff), _t("issues.fix.upgrade_tags.annotation"));
45679                 }
45680               })
45681             ];
45682             return fixes;
45683           }
45684         }));
45685       }
45686       if (nsiDiff.length) {
45687         const isOnlyAddingTags = nsiDiff.every((d2) => d2.type === "+");
45688         issues.push(new validationIssue({
45689           type: type2,
45690           subtype: "noncanonical_brand",
45691           severity: "warning",
45692           message: (context) => {
45693             const currEntity = context.hasEntity(entity.id);
45694             if (!currEntity) return "";
45695             const feature3 = utilDisplayLabel(
45696               currEntity,
45697               context.graph(),
45698               /* verbose */
45699               true
45700             );
45701             return isOnlyAddingTags ? _t.append("issues.outdated_tags.noncanonical_brand.message_incomplete", { feature: feature3 }) : _t.append("issues.outdated_tags.noncanonical_brand.message", { feature: feature3 });
45702           },
45703           reference: (selection2) => showReference(
45704             selection2,
45705             _t.append("issues.outdated_tags.noncanonical_brand.reference"),
45706             nsiDiff
45707           ),
45708           entityIds: [entity.id],
45709           hash: utilHashcode(JSON.stringify(nsiDiff)),
45710           dynamicFixes: () => {
45711             let fixes = [
45712               new validationIssueFix({
45713                 title: _t.append("issues.fix.upgrade_tags.title"),
45714                 onClick: (context) => {
45715                   context.perform((graph2) => doUpgrade(graph2, nsiDiff), _t("issues.fix.upgrade_tags.annotation"));
45716                 }
45717               }),
45718               new validationIssueFix({
45719                 title: _t.append("issues.fix.tag_as_not.title", { name: nsiResult.matched.displayName }),
45720                 onClick: (context) => {
45721                   context.perform(addNotTag, _t("issues.fix.tag_as_not.annotation"));
45722                 }
45723               })
45724             ];
45725             return fixes;
45726           }
45727         }));
45728       }
45729       return issues;
45730       function doUpgrade(graph2, diff) {
45731         const currEntity = graph2.hasEntity(entity.id);
45732         if (!currEntity) return graph2;
45733         let newTags2 = Object.assign({}, currEntity.tags);
45734         diff.forEach((diff2) => {
45735           if (diff2.type === "-") {
45736             delete newTags2[diff2.key];
45737           } else if (diff2.type === "+") {
45738             newTags2[diff2.key] = diff2.newVal;
45739           }
45740         });
45741         return actionChangeTags(currEntity.id, newTags2)(graph2);
45742       }
45743       function addNotTag(graph2) {
45744         const currEntity = graph2.hasEntity(entity.id);
45745         if (!currEntity) return graph2;
45746         const item = nsiResult && nsiResult.matched;
45747         if (!item) return graph2;
45748         let newTags2 = Object.assign({}, currEntity.tags);
45749         const wd = item.mainTag;
45750         const notwd = "not:".concat(wd);
45751         const qid = item.tags[wd];
45752         newTags2[notwd] = qid;
45753         if (newTags2[wd] === qid) {
45754           const wp = item.mainTag.replace("wikidata", "wikipedia");
45755           delete newTags2[wd];
45756           delete newTags2[wp];
45757         }
45758         return actionChangeTags(currEntity.id, newTags2)(graph2);
45759       }
45760       function showReference(selection2, reference, tagDiff) {
45761         let enter = selection2.selectAll(".issue-reference").data([0]).enter();
45762         enter.append("div").attr("class", "issue-reference").call(reference);
45763         enter.append("strong").call(_t.append("issues.suggested"));
45764         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => {
45765           let klass = d2.type === "+" ? "add" : "remove";
45766           return "tagDiff-cell tagDiff-cell-".concat(klass);
45767         }).html((d2) => d2.display);
45768       }
45769     }
45770     let validation = oldTagIssues;
45771     validation.type = type2;
45772     return validation;
45773   }
45774
45775   // modules/validations/private_data.js
45776   function validationPrivateData() {
45777     var type2 = "private_data";
45778     var privateBuildingValues = {
45779       detached: true,
45780       farm: true,
45781       house: true,
45782       houseboat: true,
45783       residential: true,
45784       semidetached_house: true,
45785       static_caravan: true
45786     };
45787     var publicKeys = {
45788       amenity: true,
45789       craft: true,
45790       historic: true,
45791       leisure: true,
45792       office: true,
45793       shop: true,
45794       tourism: true
45795     };
45796     var personalTags = {
45797       "contact:email": true,
45798       "contact:fax": true,
45799       "contact:phone": true,
45800       email: true,
45801       fax: true,
45802       phone: true
45803     };
45804     var validation = function checkPrivateData(entity) {
45805       var tags = entity.tags;
45806       if (!tags.building || !privateBuildingValues[tags.building]) return [];
45807       var keepTags = {};
45808       for (var k2 in tags) {
45809         if (publicKeys[k2]) return [];
45810         if (!personalTags[k2]) {
45811           keepTags[k2] = tags[k2];
45812         }
45813       }
45814       var tagDiff = utilTagDiff(tags, keepTags);
45815       if (!tagDiff.length) return [];
45816       var fixID = tagDiff.length === 1 ? "remove_tag" : "remove_tags";
45817       return [new validationIssue({
45818         type: type2,
45819         severity: "warning",
45820         message: showMessage,
45821         reference: showReference,
45822         entityIds: [entity.id],
45823         dynamicFixes: function() {
45824           return [
45825             new validationIssueFix({
45826               icon: "iD-operation-delete",
45827               title: _t.append("issues.fix." + fixID + ".title"),
45828               onClick: function(context) {
45829                 context.perform(doUpgrade, _t("issues.fix.remove_tag.annotation"));
45830               }
45831             })
45832           ];
45833         }
45834       })];
45835       function doUpgrade(graph) {
45836         var currEntity = graph.hasEntity(entity.id);
45837         if (!currEntity) return graph;
45838         var newTags = Object.assign({}, currEntity.tags);
45839         tagDiff.forEach(function(diff) {
45840           if (diff.type === "-") {
45841             delete newTags[diff.key];
45842           } else if (diff.type === "+") {
45843             newTags[diff.key] = diff.newVal;
45844           }
45845         });
45846         return actionChangeTags(currEntity.id, newTags)(graph);
45847       }
45848       function showMessage(context) {
45849         var currEntity = context.hasEntity(this.entityIds[0]);
45850         if (!currEntity) return "";
45851         return _t.append(
45852           "issues.private_data.contact.message",
45853           { feature: utilDisplayLabel(currEntity, context.graph()) }
45854         );
45855       }
45856       function showReference(selection2) {
45857         var enter = selection2.selectAll(".issue-reference").data([0]).enter();
45858         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.private_data.reference"));
45859         enter.append("strong").call(_t.append("issues.suggested"));
45860         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) {
45861           var klass = d2.type === "+" ? "add" : "remove";
45862           return "tagDiff-cell tagDiff-cell-" + klass;
45863         }).html(function(d2) {
45864           return d2.display;
45865         });
45866       }
45867     };
45868     validation.type = type2;
45869     return validation;
45870   }
45871
45872   // modules/validations/suspicious_name.js
45873   function validationSuspiciousName(context) {
45874     const type2 = "suspicious_name";
45875     const keysToTestForGenericValues = [
45876       "aerialway",
45877       "aeroway",
45878       "amenity",
45879       "building",
45880       "craft",
45881       "highway",
45882       "leisure",
45883       "railway",
45884       "man_made",
45885       "office",
45886       "shop",
45887       "tourism",
45888       "waterway"
45889     ];
45890     let _waitingForNsi = false;
45891     function isGenericMatchInNsi(tags) {
45892       const nsi = services.nsi;
45893       if (nsi) {
45894         _waitingForNsi = nsi.status() === "loading";
45895         if (!_waitingForNsi) {
45896           return nsi.isGenericName(tags);
45897         }
45898       }
45899       return false;
45900     }
45901     function nameMatchesRawTag(lowercaseName, tags) {
45902       for (let i3 = 0; i3 < keysToTestForGenericValues.length; i3++) {
45903         let key = keysToTestForGenericValues[i3];
45904         let val = tags[key];
45905         if (val) {
45906           val = val.toLowerCase();
45907           if (key === lowercaseName || val === lowercaseName || key.replace(/\_/g, " ") === lowercaseName || val.replace(/\_/g, " ") === lowercaseName) {
45908             return true;
45909           }
45910         }
45911       }
45912       return false;
45913     }
45914     function nameMatchesPresetName(name, presetName) {
45915       if (!presetName) return false;
45916       return name.toLowerCase() === presetName.toLowerCase();
45917     }
45918     function isGenericName(name, tags, presetName) {
45919       name = name.toLowerCase();
45920       return nameMatchesRawTag(name, tags) || nameMatchesPresetName(name, presetName) || isGenericMatchInNsi(tags);
45921     }
45922     function makeGenericNameIssue(entityId, nameKey, genericName, langCode) {
45923       return new validationIssue({
45924         type: type2,
45925         subtype: "generic_name",
45926         severity: "warning",
45927         message: function(context2) {
45928           let entity = context2.hasEntity(this.entityIds[0]);
45929           if (!entity) return "";
45930           let preset = _mainPresetIndex.match(entity, context2.graph());
45931           let langName = langCode && _mainLocalizer.languageName(langCode);
45932           return _t.append(
45933             "issues.generic_name.message" + (langName ? "_language" : ""),
45934             { feature: preset.name(), name: genericName, language: langName }
45935           );
45936         },
45937         reference: showReference,
45938         entityIds: [entityId],
45939         hash: "".concat(nameKey, "=").concat(genericName),
45940         dynamicFixes: function() {
45941           return [
45942             new validationIssueFix({
45943               icon: "iD-operation-delete",
45944               title: _t.append("issues.fix.remove_the_name.title"),
45945               onClick: function(context2) {
45946                 let entityId2 = this.issue.entityIds[0];
45947                 let entity = context2.entity(entityId2);
45948                 let tags = Object.assign({}, entity.tags);
45949                 delete tags[nameKey];
45950                 context2.perform(
45951                   actionChangeTags(entityId2, tags),
45952                   _t("issues.fix.remove_generic_name.annotation")
45953                 );
45954               }
45955             })
45956           ];
45957         }
45958       });
45959       function showReference(selection2) {
45960         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference"));
45961       }
45962     }
45963     let validation = function checkGenericName(entity) {
45964       const tags = entity.tags;
45965       const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"];
45966       if (hasWikidata) return [];
45967       let issues = [];
45968       const presetName = _mainPresetIndex.match(entity, context.graph()).name();
45969       for (let key in tags) {
45970         const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/);
45971         if (!m2) continue;
45972         const langCode = m2.length >= 2 ? m2[1] : null;
45973         const value = tags[key];
45974         if (isGenericName(value, tags, presetName)) {
45975           issues.provisional = _waitingForNsi;
45976           issues.push(makeGenericNameIssue(entity.id, key, value, langCode));
45977         }
45978       }
45979       return issues;
45980     };
45981     validation.type = type2;
45982     return validation;
45983   }
45984
45985   // modules/validations/unsquare_way.js
45986   function validationUnsquareWay(context) {
45987     var type2 = "unsquare_way";
45988     var DEFAULT_DEG_THRESHOLD = 5;
45989     var epsilon3 = 0.05;
45990     var nodeThreshold = 10;
45991     function isBuilding(entity, graph) {
45992       if (entity.type !== "way" || entity.geometry(graph) !== "area") return false;
45993       return entity.tags.building && entity.tags.building !== "no";
45994     }
45995     var validation = function checkUnsquareWay(entity, graph) {
45996       if (!isBuilding(entity, graph)) return [];
45997       if (entity.tags.nonsquare === "yes") return [];
45998       var isClosed = entity.isClosed();
45999       if (!isClosed) return [];
46000       var nodes = graph.childNodes(entity).slice();
46001       if (nodes.length > nodeThreshold + 1) return [];
46002       var osm = services.osm;
46003       if (!osm || nodes.some(function(node) {
46004         return !osm.isDataLoaded(node.loc);
46005       })) return [];
46006       var hasConnectedSquarableWays = nodes.some(function(node) {
46007         return graph.parentWays(node).some(function(way) {
46008           if (way.id === entity.id) return false;
46009           if (isBuilding(way, graph)) return true;
46010           return graph.parentRelations(way).some(function(parentRelation) {
46011             return parentRelation.isMultipolygon() && parentRelation.tags.building && parentRelation.tags.building !== "no";
46012           });
46013         });
46014       });
46015       if (hasConnectedSquarableWays) return [];
46016       var storedDegreeThreshold = corePreferences("validate-square-degrees");
46017       var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD;
46018       var points = nodes.map(function(node) {
46019         return context.projection(node.loc);
46020       });
46021       if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon3, degreeThreshold, true)) return [];
46022       var autoArgs;
46023       if (!entity.tags.wikidata) {
46024         var autoAction = actionOrthogonalize(entity.id, context.projection, void 0, degreeThreshold);
46025         autoAction.transitionable = false;
46026         autoArgs = [autoAction, _t("operations.orthogonalize.annotation.feature", { n: 1 })];
46027       }
46028       return [new validationIssue({
46029         type: type2,
46030         subtype: "building",
46031         severity: "warning",
46032         message: function(context2) {
46033           var entity2 = context2.hasEntity(this.entityIds[0]);
46034           return entity2 ? _t.append("issues.unsquare_way.message", {
46035             feature: utilDisplayLabel(entity2, context2.graph())
46036           }) : "";
46037         },
46038         reference: showReference,
46039         entityIds: [entity.id],
46040         hash: degreeThreshold,
46041         dynamicFixes: function() {
46042           return [
46043             new validationIssueFix({
46044               icon: "iD-operation-orthogonalize",
46045               title: _t.append("issues.fix.square_feature.title"),
46046               autoArgs,
46047               onClick: function(context2, completionHandler) {
46048                 var entityId = this.issue.entityIds[0];
46049                 context2.perform(
46050                   actionOrthogonalize(entityId, context2.projection, void 0, degreeThreshold),
46051                   _t("operations.orthogonalize.annotation.feature", { n: 1 })
46052                 );
46053                 window.setTimeout(function() {
46054                   completionHandler();
46055                 }, 175);
46056               }
46057             })
46058             /*
46059             new validationIssueFix({
46060                 title: t.append('issues.fix.tag_as_unsquare.title'),
46061                 onClick: function(context) {
46062                     var entityId = this.issue.entityIds[0];
46063                     var entity = context.entity(entityId);
46064                     var tags = Object.assign({}, entity.tags);  // shallow copy
46065                     tags.nonsquare = 'yes';
46066                     context.perform(
46067                         actionChangeTags(entityId, tags),
46068                         t('issues.fix.tag_as_unsquare.annotation')
46069                     );
46070                 }
46071             })
46072             */
46073           ];
46074         }
46075       })];
46076       function showReference(selection2) {
46077         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unsquare_way.buildings.reference"));
46078       }
46079     };
46080     validation.type = type2;
46081     return validation;
46082   }
46083
46084   // modules/core/validator.js
46085   function coreValidator(context) {
46086     let dispatch14 = dispatch_default("validated", "focusedIssue");
46087     const validator = {};
46088     let _rules = {};
46089     let _disabledRules = {};
46090     let _ignoredIssueIDs = /* @__PURE__ */ new Set();
46091     let _resolvedIssueIDs = /* @__PURE__ */ new Set();
46092     let _baseCache = validationCache("base");
46093     let _headCache = validationCache("head");
46094     let _completeDiff = {};
46095     let _headIsCurrent = false;
46096     let _deferredRIC = {};
46097     let _deferredST = /* @__PURE__ */ new Set();
46098     let _headPromise;
46099     const RETRY = 5e3;
46100     const _errorOverrides = parseHashParam(context.initialHashParams.validationError);
46101     const _warningOverrides = parseHashParam(context.initialHashParams.validationWarning);
46102     const _disableOverrides = parseHashParam(context.initialHashParams.validationDisable);
46103     function parseHashParam(param) {
46104       let result = [];
46105       let rules = (param || "").split(",");
46106       rules.forEach((rule) => {
46107         rule = rule.trim();
46108         const parts = rule.split("/", 2);
46109         const type2 = parts[0];
46110         const subtype = parts[1] || "*";
46111         if (!type2 || !subtype) return;
46112         result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) });
46113       });
46114       return result;
46115       function makeRegExp(str) {
46116         const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
46117         return new RegExp("^" + escaped + "$");
46118       }
46119     }
46120     validator.init = () => {
46121       Object.values(validations_exports).forEach((validation) => {
46122         if (typeof validation !== "function") return;
46123         const fn = validation(context);
46124         const key = fn.type;
46125         _rules[key] = fn;
46126       });
46127       let disabledRules = corePreferences("validate-disabledRules");
46128       if (disabledRules) {
46129         disabledRules.split(",").forEach((k2) => _disabledRules[k2] = true);
46130       }
46131     };
46132     function reset(resetIgnored) {
46133       _baseCache.queue = [];
46134       _headCache.queue = [];
46135       Object.keys(_deferredRIC).forEach((key) => {
46136         window.cancelIdleCallback(key);
46137         _deferredRIC[key]();
46138       });
46139       _deferredRIC = {};
46140       _deferredST.forEach(window.clearTimeout);
46141       _deferredST.clear();
46142       if (resetIgnored) _ignoredIssueIDs.clear();
46143       _resolvedIssueIDs.clear();
46144       _baseCache = validationCache("base");
46145       _headCache = validationCache("head");
46146       _completeDiff = {};
46147       _headIsCurrent = false;
46148     }
46149     validator.reset = () => {
46150       reset(true);
46151     };
46152     validator.resetIgnoredIssues = () => {
46153       _ignoredIssueIDs.clear();
46154       dispatch14.call("validated");
46155     };
46156     validator.revalidateUnsquare = () => {
46157       revalidateUnsquare(_headCache);
46158       revalidateUnsquare(_baseCache);
46159       dispatch14.call("validated");
46160     };
46161     function revalidateUnsquare(cache) {
46162       const checkUnsquareWay = _rules.unsquare_way;
46163       if (!cache.graph || typeof checkUnsquareWay !== "function") return;
46164       cache.uncacheIssuesOfType("unsquare_way");
46165       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");
46166       buildings.forEach((entity) => {
46167         const detected = checkUnsquareWay(entity, cache.graph);
46168         if (!detected.length) return;
46169         cache.cacheIssues(detected);
46170       });
46171     }
46172     validator.getIssues = (options2) => {
46173       const opts = Object.assign({ what: "all", where: "all", includeIgnored: false, includeDisabledRules: false }, options2);
46174       const view = context.map().extent();
46175       let seen = /* @__PURE__ */ new Set();
46176       let results = [];
46177       if (_headCache.graph && _headCache.graph !== _baseCache.graph) {
46178         Object.values(_headCache.issuesByIssueID).forEach((issue) => {
46179           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
46180           if (opts.what === "edited" && !userModified) return;
46181           if (!filter2(issue)) return;
46182           seen.add(issue.id);
46183           results.push(issue);
46184         });
46185       }
46186       if (opts.what === "all") {
46187         Object.values(_baseCache.issuesByIssueID).forEach((issue) => {
46188           if (!filter2(issue)) return;
46189           seen.add(issue.id);
46190           results.push(issue);
46191         });
46192       }
46193       return results;
46194       function filter2(issue) {
46195         if (!issue) return false;
46196         if (seen.has(issue.id)) return false;
46197         if (_resolvedIssueIDs.has(issue.id)) return false;
46198         if (opts.includeDisabledRules === "only" && !_disabledRules[issue.type]) return false;
46199         if (!opts.includeDisabledRules && _disabledRules[issue.type]) return false;
46200         if (opts.includeIgnored === "only" && !_ignoredIssueIDs.has(issue.id)) return false;
46201         if (!opts.includeIgnored && _ignoredIssueIDs.has(issue.id)) return false;
46202         if ((issue.entityIds || []).some((id2) => !context.hasEntity(id2))) return false;
46203         if (opts.where === "visible") {
46204           const extent = issue.extent(context.graph());
46205           if (!view.intersects(extent)) return false;
46206         }
46207         return true;
46208       }
46209     };
46210     validator.getResolvedIssues = () => {
46211       return Array.from(_resolvedIssueIDs).map((issueID) => _baseCache.issuesByIssueID[issueID]).filter(Boolean);
46212     };
46213     validator.focusIssue = (issue) => {
46214       const graph = context.graph();
46215       let selectID;
46216       let focusCenter;
46217       const issueExtent = issue.extent(graph);
46218       if (issueExtent) {
46219         focusCenter = issueExtent.center();
46220       }
46221       if (issue.entityIds && issue.entityIds.length) {
46222         selectID = issue.entityIds[0];
46223         if (selectID && selectID.charAt(0) === "r") {
46224           const ids = utilEntityAndDeepMemberIDs([selectID], graph);
46225           let nodeID = ids.find((id2) => id2.charAt(0) === "n" && graph.hasEntity(id2));
46226           if (!nodeID) {
46227             const wayID = ids.find((id2) => id2.charAt(0) === "w" && graph.hasEntity(id2));
46228             if (wayID) {
46229               nodeID = graph.entity(wayID).first();
46230             }
46231           }
46232           if (nodeID) {
46233             focusCenter = graph.entity(nodeID).loc;
46234           }
46235         }
46236       }
46237       if (focusCenter) {
46238         const setZoom = Math.max(context.map().zoom(), 19);
46239         context.map().unobscuredCenterZoomEase(focusCenter, setZoom);
46240       }
46241       if (selectID) {
46242         window.setTimeout(() => {
46243           context.enter(modeSelect(context, [selectID]));
46244           dispatch14.call("focusedIssue", this, issue);
46245         }, 250);
46246       }
46247     };
46248     validator.getIssuesBySeverity = (options2) => {
46249       let groups = utilArrayGroupBy(validator.getIssues(options2), "severity");
46250       groups.error = groups.error || [];
46251       groups.warning = groups.warning || [];
46252       return groups;
46253     };
46254     validator.getSharedEntityIssues = (entityIDs, options2) => {
46255       const orderedIssueTypes = [
46256         // Show some issue types in a particular order:
46257         "missing_tag",
46258         "missing_role",
46259         // - missing data first
46260         "outdated_tags",
46261         "mismatched_geometry",
46262         // - identity issues
46263         "crossing_ways",
46264         "almost_junction",
46265         // - geometry issues where fixing them might solve connectivity issues
46266         "disconnected_way",
46267         "impossible_oneway"
46268         // - finally connectivity issues
46269       ];
46270       const allIssues = validator.getIssues(options2);
46271       const forEntityIDs = new Set(entityIDs);
46272       return allIssues.filter((issue) => (issue.entityIds || []).some((entityID) => forEntityIDs.has(entityID))).sort((issue1, issue2) => {
46273         if (issue1.type === issue2.type) {
46274           return issue1.id < issue2.id ? -1 : 1;
46275         }
46276         const index1 = orderedIssueTypes.indexOf(issue1.type);
46277         const index2 = orderedIssueTypes.indexOf(issue2.type);
46278         if (index1 !== -1 && index2 !== -1) {
46279           return index1 - index2;
46280         } else if (index1 === -1 && index2 === -1) {
46281           return issue1.type < issue2.type ? -1 : 1;
46282         } else {
46283           return index1 !== -1 ? -1 : 1;
46284         }
46285       });
46286     };
46287     validator.getEntityIssues = (entityID, options2) => {
46288       return validator.getSharedEntityIssues([entityID], options2);
46289     };
46290     validator.getRuleKeys = () => {
46291       return Object.keys(_rules);
46292     };
46293     validator.isRuleEnabled = (key) => {
46294       return !_disabledRules[key];
46295     };
46296     validator.toggleRule = (key) => {
46297       if (_disabledRules[key]) {
46298         delete _disabledRules[key];
46299       } else {
46300         _disabledRules[key] = true;
46301       }
46302       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
46303       validator.validate();
46304     };
46305     validator.disableRules = (keys2) => {
46306       _disabledRules = {};
46307       keys2.forEach((k2) => _disabledRules[k2] = true);
46308       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
46309       validator.validate();
46310     };
46311     validator.ignoreIssue = (issueID) => {
46312       _ignoredIssueIDs.add(issueID);
46313     };
46314     validator.validate = () => {
46315       const baseGraph = context.history().base();
46316       if (!_headCache.graph) _headCache.graph = baseGraph;
46317       if (!_baseCache.graph) _baseCache.graph = baseGraph;
46318       const prevGraph = _headCache.graph;
46319       const currGraph = context.graph();
46320       if (currGraph === prevGraph) {
46321         _headIsCurrent = true;
46322         dispatch14.call("validated");
46323         return Promise.resolve();
46324       }
46325       if (_headPromise) {
46326         _headIsCurrent = false;
46327         return _headPromise;
46328       }
46329       _headCache.graph = currGraph;
46330       _completeDiff = context.history().difference().complete();
46331       const incrementalDiff = coreDifference(prevGraph, currGraph);
46332       const diff = Object.keys(incrementalDiff.complete());
46333       const entityIDs = _headCache.withAllRelatedEntities(diff);
46334       if (!entityIDs.size) {
46335         dispatch14.call("validated");
46336         return Promise.resolve();
46337       }
46338       const addConnectedWays = (graph) => diff.filter((entityID) => graph.hasEntity(entityID)).map((entityID) => graph.entity(entityID)).flatMap((entity) => graph.childNodes(entity)).flatMap((vertex) => graph.parentWays(vertex)).forEach((way) => entityIDs.add(way.id));
46339       addConnectedWays(currGraph);
46340       addConnectedWays(prevGraph);
46341       Object.values(__spreadValues(__spreadValues({}, incrementalDiff.created()), incrementalDiff.deleted())).filter((e3) => e3.type === "relation").flatMap((r2) => r2.members).forEach((m2) => entityIDs.add(m2.id));
46342       Object.values(incrementalDiff.modified()).filter((e3) => e3.type === "relation").map((r2) => ({ baseEntity: prevGraph.entity(r2.id), headEntity: r2 })).forEach(({ baseEntity, headEntity }) => {
46343         const bm = baseEntity.members.map((m2) => m2.id);
46344         const hm = headEntity.members.map((m2) => m2.id);
46345         const symDiff = utilArrayDifference(utilArrayUnion(bm, hm), utilArrayIntersection(bm, hm));
46346         symDiff.forEach((id2) => entityIDs.add(id2));
46347       });
46348       _headPromise = validateEntitiesAsync(entityIDs, _headCache).then(() => updateResolvedIssues(entityIDs)).then(() => dispatch14.call("validated")).catch(() => {
46349       }).then(() => {
46350         _headPromise = null;
46351         if (!_headIsCurrent) {
46352           validator.validate();
46353         }
46354       });
46355       return _headPromise;
46356     };
46357     context.history().on("restore.validator", validator.validate).on("undone.validator", validator.validate).on("redone.validator", validator.validate).on("reset.validator", () => {
46358       reset(false);
46359       validator.validate();
46360     });
46361     context.on("exit.validator", validator.validate);
46362     context.history().on("merge.validator", (entities) => {
46363       if (!entities) return;
46364       const baseGraph = context.history().base();
46365       if (!_headCache.graph) _headCache.graph = baseGraph;
46366       if (!_baseCache.graph) _baseCache.graph = baseGraph;
46367       let entityIDs = entities.map((entity) => entity.id);
46368       entityIDs = _baseCache.withAllRelatedEntities(entityIDs);
46369       validateEntitiesAsync(entityIDs, _baseCache);
46370     });
46371     function validateEntity(entity, graph) {
46372       let result = { issues: [], provisional: false };
46373       Object.keys(_rules).forEach(runValidation);
46374       return result;
46375       function runValidation(key) {
46376         const fn = _rules[key];
46377         if (typeof fn !== "function") {
46378           console.error("no such validation rule = " + key);
46379           return;
46380         }
46381         let detected = fn(entity, graph);
46382         if (detected.provisional) {
46383           result.provisional = true;
46384         }
46385         detected = detected.filter(applySeverityOverrides);
46386         result.issues = result.issues.concat(detected);
46387         function applySeverityOverrides(issue) {
46388           const type2 = issue.type;
46389           const subtype = issue.subtype || "";
46390           let i3;
46391           for (i3 = 0; i3 < _errorOverrides.length; i3++) {
46392             if (_errorOverrides[i3].type.test(type2) && _errorOverrides[i3].subtype.test(subtype)) {
46393               issue.severity = "error";
46394               return true;
46395             }
46396           }
46397           for (i3 = 0; i3 < _warningOverrides.length; i3++) {
46398             if (_warningOverrides[i3].type.test(type2) && _warningOverrides[i3].subtype.test(subtype)) {
46399               issue.severity = "warning";
46400               return true;
46401             }
46402           }
46403           for (i3 = 0; i3 < _disableOverrides.length; i3++) {
46404             if (_disableOverrides[i3].type.test(type2) && _disableOverrides[i3].subtype.test(subtype)) {
46405               return false;
46406             }
46407           }
46408           return true;
46409         }
46410       }
46411     }
46412     function updateResolvedIssues(entityIDs) {
46413       entityIDs.forEach((entityID) => {
46414         const baseIssues = _baseCache.issuesByEntityID[entityID];
46415         if (!baseIssues) return;
46416         baseIssues.forEach((issueID) => {
46417           const issue = _baseCache.issuesByIssueID[issueID];
46418           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
46419           if (userModified && !_headCache.issuesByIssueID[issueID]) {
46420             _resolvedIssueIDs.add(issueID);
46421           } else {
46422             _resolvedIssueIDs.delete(issueID);
46423           }
46424         });
46425       });
46426     }
46427     function validateEntitiesAsync(entityIDs, cache) {
46428       const jobs = Array.from(entityIDs).map((entityID) => {
46429         if (cache.queuedEntityIDs.has(entityID)) return null;
46430         cache.queuedEntityIDs.add(entityID);
46431         cache.uncacheEntityID(entityID);
46432         return () => {
46433           cache.queuedEntityIDs.delete(entityID);
46434           const graph = cache.graph;
46435           if (!graph) return;
46436           const entity = graph.hasEntity(entityID);
46437           if (!entity) return;
46438           const result = validateEntity(entity, graph);
46439           if (result.provisional) {
46440             cache.provisionalEntityIDs.add(entityID);
46441           }
46442           cache.cacheIssues(result.issues);
46443         };
46444       }).filter(Boolean);
46445       cache.queue = cache.queue.concat(utilArrayChunk(jobs, 100));
46446       if (cache.queuePromise) return cache.queuePromise;
46447       cache.queuePromise = processQueue(cache).then(() => revalidateProvisionalEntities(cache)).catch(() => {
46448       }).finally(() => cache.queuePromise = null);
46449       return cache.queuePromise;
46450     }
46451     function revalidateProvisionalEntities(cache) {
46452       if (!cache.provisionalEntityIDs.size) return;
46453       const handle = window.setTimeout(() => {
46454         _deferredST.delete(handle);
46455         if (!cache.provisionalEntityIDs.size) return;
46456         validateEntitiesAsync(Array.from(cache.provisionalEntityIDs), cache);
46457       }, RETRY);
46458       _deferredST.add(handle);
46459     }
46460     function processQueue(cache) {
46461       if (!cache.queue.length) return Promise.resolve();
46462       const chunk = cache.queue.pop();
46463       return new Promise((resolvePromise, rejectPromise) => {
46464         const handle = window.requestIdleCallback(() => {
46465           delete _deferredRIC[handle];
46466           chunk.forEach((job) => job());
46467           resolvePromise();
46468         });
46469         _deferredRIC[handle] = rejectPromise;
46470       }).then(() => {
46471         if (cache.queue.length % 25 === 0) dispatch14.call("validated");
46472       }).then(() => processQueue(cache));
46473     }
46474     return utilRebind(validator, dispatch14, "on");
46475   }
46476   function validationCache(which) {
46477     let cache = {
46478       which,
46479       graph: null,
46480       queue: [],
46481       queuePromise: null,
46482       queuedEntityIDs: /* @__PURE__ */ new Set(),
46483       provisionalEntityIDs: /* @__PURE__ */ new Set(),
46484       issuesByIssueID: {},
46485       // issue.id -> issue
46486       issuesByEntityID: {}
46487       // entity.id -> Set(issue.id)
46488     };
46489     cache.cacheIssue = (issue) => {
46490       (issue.entityIds || []).forEach((entityID) => {
46491         if (!cache.issuesByEntityID[entityID]) {
46492           cache.issuesByEntityID[entityID] = /* @__PURE__ */ new Set();
46493         }
46494         cache.issuesByEntityID[entityID].add(issue.id);
46495       });
46496       cache.issuesByIssueID[issue.id] = issue;
46497     };
46498     cache.uncacheIssue = (issue) => {
46499       (issue.entityIds || []).forEach((entityID) => {
46500         if (cache.issuesByEntityID[entityID]) {
46501           cache.issuesByEntityID[entityID].delete(issue.id);
46502         }
46503       });
46504       delete cache.issuesByIssueID[issue.id];
46505     };
46506     cache.cacheIssues = (issues) => {
46507       issues.forEach(cache.cacheIssue);
46508     };
46509     cache.uncacheIssues = (issues) => {
46510       issues.forEach(cache.uncacheIssue);
46511     };
46512     cache.uncacheIssuesOfType = (type2) => {
46513       const issuesOfType = Object.values(cache.issuesByIssueID).filter((issue) => issue.type === type2);
46514       cache.uncacheIssues(issuesOfType);
46515     };
46516     cache.uncacheEntityID = (entityID) => {
46517       const entityIssueIDs = cache.issuesByEntityID[entityID];
46518       if (entityIssueIDs) {
46519         entityIssueIDs.forEach((issueID) => {
46520           const issue = cache.issuesByIssueID[issueID];
46521           if (issue) {
46522             cache.uncacheIssue(issue);
46523           } else {
46524             delete cache.issuesByIssueID[issueID];
46525           }
46526         });
46527       }
46528       delete cache.issuesByEntityID[entityID];
46529       cache.provisionalEntityIDs.delete(entityID);
46530     };
46531     cache.withAllRelatedEntities = (entityIDs) => {
46532       let result = /* @__PURE__ */ new Set();
46533       (entityIDs || []).forEach((entityID) => {
46534         result.add(entityID);
46535         const entityIssueIDs = cache.issuesByEntityID[entityID];
46536         if (entityIssueIDs) {
46537           entityIssueIDs.forEach((issueID) => {
46538             const issue = cache.issuesByIssueID[issueID];
46539             if (issue) {
46540               (issue.entityIds || []).forEach((relatedID) => result.add(relatedID));
46541             } else {
46542               delete cache.issuesByIssueID[issueID];
46543             }
46544           });
46545         }
46546       });
46547       return result;
46548     };
46549     return cache;
46550   }
46551
46552   // modules/core/uploader.js
46553   function coreUploader(context) {
46554     var dispatch14 = dispatch_default(
46555       // Start and end events are dispatched exactly once each per legitimate outside call to `save`
46556       "saveStarted",
46557       // dispatched as soon as a call to `save` has been deemed legitimate
46558       "saveEnded",
46559       // dispatched after the result event has been dispatched
46560       "willAttemptUpload",
46561       // dispatched before the actual upload call occurs, if it will
46562       "progressChanged",
46563       // Each save results in one of these outcomes:
46564       "resultNoChanges",
46565       // upload wasn't attempted since there were no edits
46566       "resultErrors",
46567       // upload failed due to errors
46568       "resultConflicts",
46569       // upload failed due to data conflicts
46570       "resultSuccess"
46571       // upload completed without errors
46572     );
46573     var _isSaving = false;
46574     let _anyConflictsAutomaticallyResolved = false;
46575     var _conflicts = [];
46576     var _errors = [];
46577     var _origChanges;
46578     var _discardTags = {};
46579     _mainFileFetcher.get("discarded").then(function(d2) {
46580       _discardTags = d2;
46581     }).catch(function() {
46582     });
46583     const uploader = {};
46584     uploader.isSaving = function() {
46585       return _isSaving;
46586     };
46587     uploader.save = function(changeset, tryAgain, checkConflicts) {
46588       if (_isSaving && !tryAgain) {
46589         return;
46590       }
46591       var osm = context.connection();
46592       if (!osm) return;
46593       if (!osm.authenticated()) {
46594         osm.authenticate(function(err) {
46595           if (!err) {
46596             uploader.save(changeset, tryAgain, checkConflicts);
46597           }
46598         });
46599         return;
46600       }
46601       if (!_isSaving) {
46602         _isSaving = true;
46603         dispatch14.call("saveStarted", this);
46604       }
46605       var history = context.history();
46606       _anyConflictsAutomaticallyResolved = false;
46607       _conflicts = [];
46608       _errors = [];
46609       _origChanges = history.changes(actionDiscardTags(history.difference(), _discardTags));
46610       if (!tryAgain) {
46611         history.perform(actionNoop());
46612       }
46613       if (!checkConflicts) {
46614         upload(changeset);
46615       } else {
46616         performFullConflictCheck(changeset);
46617       }
46618     };
46619     function performFullConflictCheck(changeset) {
46620       var osm = context.connection();
46621       if (!osm) return;
46622       var history = context.history();
46623       var localGraph = context.graph();
46624       var remoteGraph = coreGraph(history.base(), true);
46625       var summary = history.difference().summary();
46626       var _toCheck = [];
46627       for (var i3 = 0; i3 < summary.length; i3++) {
46628         var item = summary[i3];
46629         if (item.changeType === "modified") {
46630           _toCheck.push(item.entity.id);
46631         }
46632       }
46633       var _toLoad = withChildNodes(_toCheck, localGraph);
46634       var _loaded = {};
46635       var _toLoadCount = 0;
46636       var _toLoadTotal = _toLoad.length;
46637       if (_toCheck.length) {
46638         dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
46639         _toLoad.forEach(function(id2) {
46640           _loaded[id2] = false;
46641         });
46642         osm.loadMultiple(_toLoad, loaded);
46643       } else {
46644         upload(changeset);
46645       }
46646       return;
46647       function withChildNodes(ids, graph) {
46648         var s2 = new Set(ids);
46649         ids.forEach(function(id2) {
46650           var entity = graph.entity(id2);
46651           if (entity.type !== "way") return;
46652           graph.childNodes(entity).forEach(function(child) {
46653             if (child.version !== void 0) {
46654               s2.add(child.id);
46655             }
46656           });
46657         });
46658         return Array.from(s2);
46659       }
46660       function loaded(err, result) {
46661         if (_errors.length) return;
46662         if (err) {
46663           _errors.push({
46664             msg: err.message || err.responseText,
46665             details: [_t("save.status_code", { code: err.status })]
46666           });
46667           didResultInErrors();
46668         } else {
46669           var loadMore = [];
46670           result.data.forEach(function(entity) {
46671             remoteGraph.replace(entity);
46672             _loaded[entity.id] = true;
46673             _toLoad = _toLoad.filter(function(val) {
46674               return val !== entity.id;
46675             });
46676             if (!entity.visible) return;
46677             var i4, id2;
46678             if (entity.type === "way") {
46679               for (i4 = 0; i4 < entity.nodes.length; i4++) {
46680                 id2 = entity.nodes[i4];
46681                 if (_loaded[id2] === void 0) {
46682                   _loaded[id2] = false;
46683                   loadMore.push(id2);
46684                 }
46685               }
46686             } else if (entity.type === "relation" && entity.isMultipolygon()) {
46687               for (i4 = 0; i4 < entity.members.length; i4++) {
46688                 id2 = entity.members[i4].id;
46689                 if (_loaded[id2] === void 0) {
46690                   _loaded[id2] = false;
46691                   loadMore.push(id2);
46692                 }
46693               }
46694             }
46695           });
46696           _toLoadCount += result.data.length;
46697           _toLoadTotal += loadMore.length;
46698           dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
46699           if (loadMore.length) {
46700             _toLoad.push.apply(_toLoad, loadMore);
46701             osm.loadMultiple(loadMore, loaded);
46702           }
46703           if (!_toLoad.length) {
46704             detectConflicts();
46705             upload(changeset);
46706           }
46707         }
46708       }
46709       function detectConflicts() {
46710         function choice(id2, text, action) {
46711           return {
46712             id: id2,
46713             text,
46714             action: function() {
46715               history.replace(action);
46716             }
46717           };
46718         }
46719         function formatUser(d2) {
46720           return '<a href="' + osm.userURL(d2) + '" target="_blank">' + escape_default(d2) + "</a>";
46721         }
46722         function entityName(entity) {
46723           return utilDisplayName(entity) || utilDisplayType(entity.id) + " " + entity.id;
46724         }
46725         function sameVersions(local, remote) {
46726           if (local.version !== remote.version) return false;
46727           if (local.type === "way") {
46728             var children2 = utilArrayUnion(local.nodes, remote.nodes);
46729             for (var i4 = 0; i4 < children2.length; i4++) {
46730               var a2 = localGraph.hasEntity(children2[i4]);
46731               var b2 = remoteGraph.hasEntity(children2[i4]);
46732               if (a2 && b2 && a2.version !== b2.version) return false;
46733             }
46734           }
46735           return true;
46736         }
46737         _toCheck.forEach(function(id2) {
46738           var local = localGraph.entity(id2);
46739           var remote = remoteGraph.entity(id2);
46740           if (sameVersions(local, remote)) return;
46741           var merge3 = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags, formatUser);
46742           history.replace(merge3);
46743           var mergeConflicts = merge3.conflicts();
46744           if (!mergeConflicts.length) {
46745             _anyConflictsAutomaticallyResolved = true;
46746             return;
46747           }
46748           var forceLocal = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_local");
46749           var forceRemote = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_remote");
46750           var keepMine = _t("save.conflict." + (remote.visible ? "keep_local" : "restore"));
46751           var keepTheirs = _t("save.conflict." + (remote.visible ? "keep_remote" : "delete"));
46752           _conflicts.push({
46753             id: id2,
46754             name: entityName(local),
46755             details: mergeConflicts,
46756             chosen: 1,
46757             choices: [
46758               choice(id2, keepMine, forceLocal),
46759               choice(id2, keepTheirs, forceRemote)
46760             ]
46761           });
46762         });
46763       }
46764     }
46765     async function upload(changeset) {
46766       var osm = context.connection();
46767       if (!osm) {
46768         _errors.push({ msg: "No OSM Service" });
46769       }
46770       if (_conflicts.length) {
46771         didResultInConflicts(changeset);
46772       } else if (_errors.length) {
46773         didResultInErrors();
46774       } else {
46775         if (_anyConflictsAutomaticallyResolved) {
46776           changeset.tags.merge_conflict_resolved = "automatically";
46777           await osm.updateChangesetTags(changeset);
46778         }
46779         var history = context.history();
46780         var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
46781         if (changes.modified.length || changes.created.length || changes.deleted.length) {
46782           dispatch14.call("willAttemptUpload", this);
46783           osm.putChangeset(changeset, changes, uploadCallback);
46784         } else {
46785           didResultInNoChanges();
46786         }
46787       }
46788     }
46789     function uploadCallback(err, changeset) {
46790       if (err) {
46791         if (err.status === 409) {
46792           uploader.save(changeset, true, true);
46793         } else {
46794           _errors.push({
46795             msg: err.message || err.responseText,
46796             details: [_t("save.status_code", { code: err.status })]
46797           });
46798           didResultInErrors();
46799         }
46800       } else {
46801         didResultInSuccess(changeset);
46802       }
46803     }
46804     function didResultInNoChanges() {
46805       dispatch14.call("resultNoChanges", this);
46806       endSave();
46807       context.flush();
46808     }
46809     function didResultInErrors() {
46810       context.history().pop();
46811       dispatch14.call("resultErrors", this, _errors);
46812       endSave();
46813     }
46814     function didResultInConflicts(changeset) {
46815       changeset.tags.merge_conflict_resolved = "manually";
46816       context.connection().updateChangesetTags(changeset);
46817       _conflicts.sort(function(a2, b2) {
46818         return b2.id.localeCompare(a2.id);
46819       });
46820       dispatch14.call("resultConflicts", this, changeset, _conflicts, _origChanges);
46821       endSave();
46822     }
46823     function didResultInSuccess(changeset) {
46824       context.history().clearSaved();
46825       dispatch14.call("resultSuccess", this, changeset);
46826       window.setTimeout(function() {
46827         endSave();
46828         context.flush();
46829       }, 2500);
46830     }
46831     function endSave() {
46832       _isSaving = false;
46833       dispatch14.call("saveEnded", this);
46834     }
46835     uploader.cancelConflictResolution = function() {
46836       context.history().pop();
46837     };
46838     uploader.processResolvedConflicts = function(changeset) {
46839       var history = context.history();
46840       for (var i3 = 0; i3 < _conflicts.length; i3++) {
46841         if (_conflicts[i3].chosen === 1) {
46842           var entity = context.hasEntity(_conflicts[i3].id);
46843           if (entity && entity.type === "way") {
46844             var children2 = utilArrayUniq(entity.nodes);
46845             for (var j2 = 0; j2 < children2.length; j2++) {
46846               history.replace(actionRevert(children2[j2]));
46847             }
46848           }
46849           history.replace(actionRevert(_conflicts[i3].id));
46850         }
46851       }
46852       uploader.save(changeset, true, false);
46853     };
46854     uploader.reset = function() {
46855     };
46856     return utilRebind(uploader, dispatch14, "on");
46857   }
46858
46859   // modules/modes/draw_area.js
46860   function modeDrawArea(context, wayID, startGraph, button) {
46861     var mode = {
46862       button,
46863       id: "draw-area"
46864     };
46865     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
46866       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
46867     });
46868     mode.wayID = wayID;
46869     mode.enter = function() {
46870       context.install(behavior);
46871     };
46872     mode.exit = function() {
46873       context.uninstall(behavior);
46874     };
46875     mode.selectedIDs = function() {
46876       return [wayID];
46877     };
46878     mode.activeID = function() {
46879       return behavior && behavior.activeID() || [];
46880     };
46881     return mode;
46882   }
46883
46884   // modules/modes/add_area.js
46885   function modeAddArea(context, mode) {
46886     mode.id = "add-area";
46887     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
46888     function defaultTags(loc) {
46889       var defaultTags2 = { area: "yes" };
46890       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
46891       return defaultTags2;
46892     }
46893     function actionClose(wayId) {
46894       return function(graph) {
46895         return graph.replace(graph.entity(wayId).close());
46896       };
46897     }
46898     function start2(loc) {
46899       var startGraph = context.graph();
46900       var node = osmNode({ loc });
46901       var way = osmWay({ tags: defaultTags(loc) });
46902       context.perform(
46903         actionAddEntity(node),
46904         actionAddEntity(way),
46905         actionAddVertex(way.id, node.id),
46906         actionClose(way.id)
46907       );
46908       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46909     }
46910     function startFromWay(loc, edge) {
46911       var startGraph = context.graph();
46912       var node = osmNode({ loc });
46913       var way = osmWay({ tags: defaultTags(loc) });
46914       context.perform(
46915         actionAddEntity(node),
46916         actionAddEntity(way),
46917         actionAddVertex(way.id, node.id),
46918         actionClose(way.id),
46919         actionAddMidpoint({ loc, edge }, node)
46920       );
46921       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46922     }
46923     function startFromNode(node) {
46924       var startGraph = context.graph();
46925       var way = osmWay({ tags: defaultTags(node.loc) });
46926       context.perform(
46927         actionAddEntity(way),
46928         actionAddVertex(way.id, node.id),
46929         actionClose(way.id)
46930       );
46931       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46932     }
46933     mode.enter = function() {
46934       context.install(behavior);
46935     };
46936     mode.exit = function() {
46937       context.uninstall(behavior);
46938     };
46939     return mode;
46940   }
46941
46942   // modules/modes/add_line.js
46943   function modeAddLine(context, mode) {
46944     mode.id = "add-line";
46945     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
46946     function defaultTags(loc) {
46947       var defaultTags2 = {};
46948       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
46949       return defaultTags2;
46950     }
46951     function start2(loc) {
46952       var startGraph = context.graph();
46953       var node = osmNode({ loc });
46954       var way = osmWay({ tags: defaultTags(loc) });
46955       context.perform(
46956         actionAddEntity(node),
46957         actionAddEntity(way),
46958         actionAddVertex(way.id, node.id)
46959       );
46960       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46961     }
46962     function startFromWay(loc, edge) {
46963       var startGraph = context.graph();
46964       var node = osmNode({ loc });
46965       var way = osmWay({ tags: defaultTags(loc) });
46966       context.perform(
46967         actionAddEntity(node),
46968         actionAddEntity(way),
46969         actionAddVertex(way.id, node.id),
46970         actionAddMidpoint({ loc, edge }, node)
46971       );
46972       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46973     }
46974     function startFromNode(node) {
46975       var startGraph = context.graph();
46976       var way = osmWay({ tags: defaultTags(node.loc) });
46977       context.perform(
46978         actionAddEntity(way),
46979         actionAddVertex(way.id, node.id)
46980       );
46981       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46982     }
46983     mode.enter = function() {
46984       context.install(behavior);
46985     };
46986     mode.exit = function() {
46987       context.uninstall(behavior);
46988     };
46989     return mode;
46990   }
46991
46992   // modules/modes/add_point.js
46993   function modeAddPoint(context, mode) {
46994     mode.id = "add-point";
46995     var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
46996     function defaultTags(loc) {
46997       var defaultTags2 = {};
46998       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
46999       return defaultTags2;
47000     }
47001     function add(loc) {
47002       var node = osmNode({ loc, tags: defaultTags(loc) });
47003       context.perform(
47004         actionAddEntity(node),
47005         _t("operations.add.annotation.point")
47006       );
47007       enterSelectMode(node);
47008     }
47009     function addWay(loc, edge) {
47010       var node = osmNode({ tags: defaultTags(loc) });
47011       context.perform(
47012         actionAddMidpoint({ loc, edge }, node),
47013         _t("operations.add.annotation.vertex")
47014       );
47015       enterSelectMode(node);
47016     }
47017     function enterSelectMode(node) {
47018       context.enter(
47019         modeSelect(context, [node.id]).newFeature(true)
47020       );
47021     }
47022     function addNode(node) {
47023       const _defaultTags = defaultTags(node.loc);
47024       if (Object.keys(_defaultTags).length === 0) {
47025         enterSelectMode(node);
47026         return;
47027       }
47028       var tags = Object.assign({}, node.tags);
47029       for (var key in _defaultTags) {
47030         tags[key] = _defaultTags[key];
47031       }
47032       context.perform(
47033         actionChangeTags(node.id, tags),
47034         _t("operations.add.annotation.point")
47035       );
47036       enterSelectMode(node);
47037     }
47038     function cancel() {
47039       context.enter(modeBrowse(context));
47040     }
47041     mode.enter = function() {
47042       context.install(behavior);
47043     };
47044     mode.exit = function() {
47045       context.uninstall(behavior);
47046     };
47047     return mode;
47048   }
47049
47050   // modules/ui/note_comments.js
47051   function uiNoteComments() {
47052     var _note;
47053     function noteComments(selection2) {
47054       if (_note.isNew()) return;
47055       var comments = selection2.selectAll(".comments-container").data([0]);
47056       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
47057       var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
47058       commentEnter.append("div").attr("class", function(d2) {
47059         return "comment-avatar user-" + d2.uid;
47060       }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
47061       var mainEnter = commentEnter.append("div").attr("class", "comment-main");
47062       var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
47063       metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
47064         var selection3 = select_default2(this);
47065         var osm = services.osm;
47066         if (osm && d2.user) {
47067           selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
47068         }
47069         if (d2.user) {
47070           selection3.text(d2.user);
47071         } else {
47072           selection3.call(_t.append("note.anonymous"));
47073         }
47074       });
47075       metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
47076         return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
47077       });
47078       mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
47079         return d2.html;
47080       }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
47081       comments.call(replaceAvatars);
47082     }
47083     function replaceAvatars(selection2) {
47084       var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
47085       var osm = services.osm;
47086       if (showThirdPartyIcons !== "true" || !osm) return;
47087       var uids = {};
47088       _note.comments.forEach(function(d2) {
47089         if (d2.uid) uids[d2.uid] = true;
47090       });
47091       Object.keys(uids).forEach(function(uid) {
47092         osm.loadUser(uid, function(err, user) {
47093           if (!user || !user.image_url) return;
47094           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);
47095         });
47096       });
47097     }
47098     function localeDateString2(s2) {
47099       if (!s2) return null;
47100       var options2 = { day: "numeric", month: "short", year: "numeric" };
47101       s2 = s2.replace(/-/g, "/");
47102       var d2 = new Date(s2);
47103       if (isNaN(d2.getTime())) return null;
47104       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
47105     }
47106     noteComments.note = function(val) {
47107       if (!arguments.length) return _note;
47108       _note = val;
47109       return noteComments;
47110     };
47111     return noteComments;
47112   }
47113
47114   // modules/ui/note_header.js
47115   function uiNoteHeader() {
47116     var _note;
47117     function noteHeader(selection2) {
47118       var header = selection2.selectAll(".note-header").data(
47119         _note ? [_note] : [],
47120         function(d2) {
47121           return d2.status + d2.id;
47122         }
47123       );
47124       header.exit().remove();
47125       var headerEnter = header.enter().append("div").attr("class", "note-header");
47126       var iconEnter = headerEnter.append("div").attr("class", function(d2) {
47127         return "note-header-icon " + d2.status;
47128       }).classed("new", function(d2) {
47129         return d2.id < 0;
47130       });
47131       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
47132       iconEnter.each(function(d2) {
47133         var statusIcon;
47134         if (d2.id < 0) {
47135           statusIcon = "#iD-icon-plus";
47136         } else if (d2.status === "open") {
47137           statusIcon = "#iD-icon-close";
47138         } else {
47139           statusIcon = "#iD-icon-apply";
47140         }
47141         iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
47142       });
47143       headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
47144         if (_note.isNew()) {
47145           return _t.html("note.new");
47146         }
47147         return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
47148       });
47149     }
47150     noteHeader.note = function(val) {
47151       if (!arguments.length) return _note;
47152       _note = val;
47153       return noteHeader;
47154     };
47155     return noteHeader;
47156   }
47157
47158   // modules/ui/note_report.js
47159   function uiNoteReport() {
47160     var _note;
47161     function noteReport(selection2) {
47162       var url;
47163       if (services.osm && _note instanceof osmNote && !_note.isNew()) {
47164         url = services.osm.noteReportURL(_note);
47165       }
47166       var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
47167       link3.exit().remove();
47168       var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
47169         return d2;
47170       }).call(svgIcon("#iD-icon-out-link", "inline"));
47171       linkEnter.append("span").call(_t.append("note.report"));
47172     }
47173     noteReport.note = function(val) {
47174       if (!arguments.length) return _note;
47175       _note = val;
47176       return noteReport;
47177     };
47178     return noteReport;
47179   }
47180
47181   // modules/ui/view_on_osm.js
47182   function uiViewOnOSM(context) {
47183     var _what;
47184     function viewOnOSM(selection2) {
47185       var url;
47186       if (_what instanceof osmEntity) {
47187         url = context.connection().entityURL(_what);
47188       } else if (_what instanceof osmNote) {
47189         url = context.connection().noteURL(_what);
47190       }
47191       var data = !_what || _what.isNew() ? [] : [_what];
47192       var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
47193         return d2.id;
47194       });
47195       link3.exit().remove();
47196       var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
47197       linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
47198     }
47199     viewOnOSM.what = function(_2) {
47200       if (!arguments.length) return _what;
47201       _what = _2;
47202       return viewOnOSM;
47203     };
47204     return viewOnOSM;
47205   }
47206
47207   // modules/ui/note_editor.js
47208   function uiNoteEditor(context) {
47209     var dispatch14 = dispatch_default("change");
47210     var noteComments = uiNoteComments(context);
47211     var noteHeader = uiNoteHeader();
47212     var _note;
47213     var _newNote;
47214     function noteEditor(selection2) {
47215       var header = selection2.selectAll(".header").data([0]);
47216       var headerEnter = header.enter().append("div").attr("class", "header fillL");
47217       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
47218         context.enter(modeBrowse(context));
47219       }).call(svgIcon("#iD-icon-close"));
47220       headerEnter.append("h2").call(_t.append("note.title"));
47221       var body = selection2.selectAll(".body").data([0]);
47222       body = body.enter().append("div").attr("class", "body").merge(body);
47223       var editor = body.selectAll(".note-editor").data([0]);
47224       editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
47225       var footer = selection2.selectAll(".footer").data([0]);
47226       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
47227       var osm = services.osm;
47228       if (osm) {
47229         osm.on("change.note-save", function() {
47230           selection2.call(noteEditor);
47231         });
47232       }
47233     }
47234     function noteSaveSection(selection2) {
47235       var isSelected = _note && _note.id === context.selectedNoteID();
47236       var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
47237         return d2.status + d2.id;
47238       });
47239       noteSave.exit().remove();
47240       var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
47241       noteSaveEnter.append("h4").attr("class", ".note-save-header").text("").each(function() {
47242         if (_note.isNew()) {
47243           _t.append("note.newDescription")(select_default2(this));
47244         } else {
47245           _t.append("note.newComment")(select_default2(this));
47246         }
47247       });
47248       var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
47249         return d2.newComment;
47250       }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
47251       if (!commentTextarea.empty() && _newNote) {
47252         commentTextarea.node().focus();
47253       }
47254       noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
47255       function keydown(d3_event) {
47256         if (!(d3_event.keyCode === 13 && // ↩ Return
47257         d3_event.metaKey)) return;
47258         var osm = services.osm;
47259         if (!osm) return;
47260         var hasAuth = osm.authenticated();
47261         if (!hasAuth) return;
47262         if (!_note.newComment) return;
47263         d3_event.preventDefault();
47264         select_default2(this).on("keydown.note-input", null);
47265         window.setTimeout(function() {
47266           if (_note.isNew()) {
47267             noteSave.selectAll(".save-button").node().focus();
47268             clickSave(_note);
47269           } else {
47270             noteSave.selectAll(".comment-button").node().focus();
47271             clickComment(_note);
47272           }
47273         }, 10);
47274       }
47275       function changeInput() {
47276         var input = select_default2(this);
47277         var val = input.property("value").trim() || void 0;
47278         _note = _note.update({ newComment: val });
47279         var osm = services.osm;
47280         if (osm) {
47281           osm.replaceNote(_note);
47282         }
47283         noteSave.call(noteSaveButtons);
47284       }
47285     }
47286     function userDetails(selection2) {
47287       var detailSection = selection2.selectAll(".detail-section").data([0]);
47288       detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
47289       var osm = services.osm;
47290       if (!osm) return;
47291       var hasAuth = osm.authenticated();
47292       var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
47293       authWarning.exit().transition().duration(200).style("opacity", 0).remove();
47294       var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
47295       authEnter.call(svgIcon("#iD-icon-alert", "inline"));
47296       authEnter.append("span").call(_t.append("note.login"));
47297       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) {
47298         d3_event.preventDefault();
47299         osm.authenticate();
47300       });
47301       authEnter.transition().duration(200).style("opacity", 1);
47302       var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
47303       prose.exit().remove();
47304       prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
47305       osm.userDetails(function(err, user) {
47306         if (err) return;
47307         var userLink = select_default2(document.createElement("div"));
47308         if (user.image_url) {
47309           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
47310         }
47311         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
47312         prose.html(_t.html("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
47313       });
47314     }
47315     function noteSaveButtons(selection2) {
47316       var osm = services.osm;
47317       var hasAuth = osm && osm.authenticated();
47318       var isSelected = _note && _note.id === context.selectedNoteID();
47319       var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
47320         return d2.status + d2.id;
47321       });
47322       buttonSection.exit().remove();
47323       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
47324       if (_note.isNew()) {
47325         buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
47326         buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
47327       } else {
47328         buttonEnter.append("button").attr("class", "button status-button action");
47329         buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
47330       }
47331       buttonSection = buttonSection.merge(buttonEnter);
47332       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
47333       buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
47334       buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).each(function(d2) {
47335         var action = d2.status === "open" ? "close" : "open";
47336         var andComment = d2.newComment ? "_comment" : "";
47337         _t.addOrUpdate("note." + action + andComment)(select_default2(this));
47338       }).on("click.status", clickStatus);
47339       buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
47340       function isSaveDisabled(d2) {
47341         return hasAuth && d2.status === "open" && d2.newComment ? null : true;
47342       }
47343     }
47344     function clickCancel(d3_event, d2) {
47345       this.blur();
47346       var osm = services.osm;
47347       if (osm) {
47348         osm.removeNote(d2);
47349       }
47350       context.enter(modeBrowse(context));
47351       dispatch14.call("change");
47352     }
47353     function clickSave(d3_event, d2) {
47354       this.blur();
47355       var osm = services.osm;
47356       if (osm) {
47357         osm.postNoteCreate(d2, function(err, note) {
47358           dispatch14.call("change", note);
47359         });
47360       }
47361     }
47362     function clickStatus(d3_event, d2) {
47363       this.blur();
47364       var osm = services.osm;
47365       if (osm) {
47366         var setStatus = d2.status === "open" ? "closed" : "open";
47367         osm.postNoteUpdate(d2, setStatus, function(err, note) {
47368           dispatch14.call("change", note);
47369         });
47370       }
47371     }
47372     function clickComment(d3_event, d2) {
47373       this.blur();
47374       var osm = services.osm;
47375       if (osm) {
47376         osm.postNoteUpdate(d2, d2.status, function(err, note) {
47377           dispatch14.call("change", note);
47378         });
47379       }
47380     }
47381     noteEditor.note = function(val) {
47382       if (!arguments.length) return _note;
47383       _note = val;
47384       return noteEditor;
47385     };
47386     noteEditor.newNote = function(val) {
47387       if (!arguments.length) return _newNote;
47388       _newNote = val;
47389       return noteEditor;
47390     };
47391     return utilRebind(noteEditor, dispatch14, "on");
47392   }
47393
47394   // modules/modes/select_note.js
47395   function modeSelectNote(context, selectedNoteID) {
47396     var mode = {
47397       id: "select-note",
47398       button: "browse"
47399     };
47400     var _keybinding = utilKeybinding("select-note");
47401     var _noteEditor = uiNoteEditor(context).on("change", function() {
47402       context.map().pan([0, 0]);
47403       var note = checkSelectedID();
47404       if (!note) return;
47405       context.ui().sidebar.show(_noteEditor.note(note));
47406     });
47407     var _behaviors = [
47408       behaviorBreathe(context),
47409       behaviorHover(context),
47410       behaviorSelect(context),
47411       behaviorLasso(context),
47412       modeDragNode(context).behavior,
47413       modeDragNote(context).behavior
47414     ];
47415     var _newFeature = false;
47416     function checkSelectedID() {
47417       if (!services.osm) return;
47418       var note = services.osm.getNote(selectedNoteID);
47419       if (!note) {
47420         context.enter(modeBrowse(context));
47421       }
47422       return note;
47423     }
47424     function selectNote(d3_event, drawn) {
47425       if (!checkSelectedID()) return;
47426       var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
47427       if (selection2.empty()) {
47428         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
47429         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
47430           context.enter(modeBrowse(context));
47431         }
47432       } else {
47433         selection2.classed("selected", true);
47434         context.selectedNoteID(selectedNoteID);
47435       }
47436     }
47437     function esc() {
47438       if (context.container().select(".combobox").size()) return;
47439       context.enter(modeBrowse(context));
47440     }
47441     mode.zoomToSelected = function() {
47442       if (!services.osm) return;
47443       var note = services.osm.getNote(selectedNoteID);
47444       if (note) {
47445         context.map().centerZoomEase(note.loc, 20);
47446       }
47447     };
47448     mode.newFeature = function(val) {
47449       if (!arguments.length) return _newFeature;
47450       _newFeature = val;
47451       return mode;
47452     };
47453     mode.enter = function() {
47454       var note = checkSelectedID();
47455       if (!note) return;
47456       _behaviors.forEach(context.install);
47457       _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
47458       select_default2(document).call(_keybinding);
47459       selectNote();
47460       var sidebar = context.ui().sidebar;
47461       sidebar.show(_noteEditor.note(note).newNote(_newFeature));
47462       sidebar.expand(sidebar.intersects(note.extent()));
47463       context.map().on("drawn.select", selectNote);
47464     };
47465     mode.exit = function() {
47466       _behaviors.forEach(context.uninstall);
47467       select_default2(document).call(_keybinding.unbind);
47468       context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
47469       context.map().on("drawn.select", null);
47470       context.ui().sidebar.hide();
47471       context.selectedNoteID(null);
47472     };
47473     return mode;
47474   }
47475
47476   // modules/modes/add_note.js
47477   function modeAddNote(context) {
47478     var mode = {
47479       id: "add-note",
47480       button: "note",
47481       description: _t.append("modes.add_note.description"),
47482       key: _t("modes.add_note.key")
47483     };
47484     var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
47485     function add(loc) {
47486       var osm = services.osm;
47487       if (!osm) return;
47488       var note = osmNote({ loc, status: "open", comments: [] });
47489       osm.replaceNote(note);
47490       context.map().pan([0, 0]);
47491       context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
47492     }
47493     function cancel() {
47494       context.enter(modeBrowse(context));
47495     }
47496     mode.enter = function() {
47497       context.install(behavior);
47498     };
47499     mode.exit = function() {
47500       context.uninstall(behavior);
47501     };
47502     return mode;
47503   }
47504
47505   // modules/util/jxon.js
47506   var JXON = new function() {
47507     var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i;
47508     function parseText(sValue) {
47509       if (rIsNull.test(sValue)) {
47510         return null;
47511       }
47512       if (rIsBool.test(sValue)) {
47513         return sValue.toLowerCase() === "true";
47514       }
47515       if (isFinite(sValue)) {
47516         return parseFloat(sValue);
47517       }
47518       if (isFinite(Date.parse(sValue))) {
47519         return new Date(sValue);
47520       }
47521       return sValue;
47522     }
47523     function EmptyTree() {
47524     }
47525     EmptyTree.prototype.toString = function() {
47526       return "null";
47527     };
47528     EmptyTree.prototype.valueOf = function() {
47529       return null;
47530     };
47531     function objectify(vValue) {
47532       return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
47533     }
47534     function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
47535       var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2);
47536       var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : (
47537         /* put here the default value for empty nodes: */
47538         true
47539       );
47540       if (bChildren) {
47541         for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
47542           oNode = oParentNode.childNodes.item(nItem);
47543           if (oNode.nodeType === 4) {
47544             sCollectedTxt += oNode.nodeValue;
47545           } else if (oNode.nodeType === 3) {
47546             sCollectedTxt += oNode.nodeValue.trim();
47547           } else if (oNode.nodeType === 1 && !oNode.prefix) {
47548             aCache.push(oNode);
47549           }
47550         }
47551       }
47552       var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt);
47553       if (!bHighVerb && (bChildren || bAttributes)) {
47554         vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
47555       }
47556       for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
47557         sProp = aCache[nElId].nodeName.toLowerCase();
47558         vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
47559         if (vResult.hasOwnProperty(sProp)) {
47560           if (vResult[sProp].constructor !== Array) {
47561             vResult[sProp] = [vResult[sProp]];
47562           }
47563           vResult[sProp].push(vContent);
47564         } else {
47565           vResult[sProp] = vContent;
47566           nLength++;
47567         }
47568       }
47569       if (bAttributes) {
47570         var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult;
47571         for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
47572           oAttrib = oParentNode.attributes.item(nAttrib);
47573           oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim());
47574         }
47575         if (bNesteAttr) {
47576           if (bFreeze) {
47577             Object.freeze(oAttrParent);
47578           }
47579           vResult[sAttributesProp] = oAttrParent;
47580           nLength -= nAttrLen - 1;
47581         }
47582       }
47583       if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
47584         vResult[sValueProp] = vBuiltVal;
47585       } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
47586         vResult = vBuiltVal;
47587       }
47588       if (bFreeze && (bHighVerb || nLength > 0)) {
47589         Object.freeze(vResult);
47590       }
47591       aCache.length = nLevelStart;
47592       return vResult;
47593     }
47594     function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
47595       var vValue, oChild;
47596       if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) {
47597         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString()));
47598       } else if (oParentObj.constructor === Date) {
47599         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString()));
47600       }
47601       for (var sName in oParentObj) {
47602         vValue = oParentObj[sName];
47603         if (isFinite(sName) || vValue instanceof Function) {
47604           continue;
47605         }
47606         if (sName === sValueProp) {
47607           if (vValue !== null && vValue !== true) {
47608             oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue)));
47609           }
47610         } else if (sName === sAttributesProp) {
47611           for (var sAttrib in vValue) {
47612             oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
47613           }
47614         } else if (sName.charAt(0) === sAttrPref) {
47615           oParentEl.setAttribute(sName.slice(1), vValue);
47616         } else if (vValue.constructor === Array) {
47617           for (var nItem = 0; nItem < vValue.length; nItem++) {
47618             oChild = oXMLDoc.createElement(sName);
47619             loadObjTree(oXMLDoc, oChild, vValue[nItem]);
47620             oParentEl.appendChild(oChild);
47621           }
47622         } else {
47623           oChild = oXMLDoc.createElement(sName);
47624           if (vValue instanceof Object) {
47625             loadObjTree(oXMLDoc, oChild, vValue);
47626           } else if (vValue !== null && vValue !== true) {
47627             oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
47628           }
47629           oParentEl.appendChild(oChild);
47630         }
47631       }
47632     }
47633     this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) {
47634       var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : (
47635         /* put here the default verbosity level: */
47636         1
47637       );
47638       return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
47639     };
47640     this.unbuild = function(oObjTree) {
47641       var oNewDoc = document.implementation.createDocument("", "", null);
47642       loadObjTree(oNewDoc, oNewDoc, oObjTree);
47643       return oNewDoc;
47644     };
47645     this.stringify = function(oObjTree) {
47646       return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree));
47647     };
47648   }();
47649
47650   // modules/ui/conflicts.js
47651   function uiConflicts(context) {
47652     var dispatch14 = dispatch_default("cancel", "save");
47653     var keybinding = utilKeybinding("conflicts");
47654     var _origChanges;
47655     var _conflictList;
47656     var _shownConflictIndex;
47657     function keybindingOn() {
47658       select_default2(document).call(keybinding.on("\u238B", cancel, true));
47659     }
47660     function keybindingOff() {
47661       select_default2(document).call(keybinding.unbind);
47662     }
47663     function tryAgain() {
47664       keybindingOff();
47665       dispatch14.call("save");
47666     }
47667     function cancel() {
47668       keybindingOff();
47669       dispatch14.call("cancel");
47670     }
47671     function conflicts(selection2) {
47672       keybindingOn();
47673       var headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
47674       headerEnter.append("button").attr("class", "fr").attr("title", _t("icons.close")).on("click", cancel).call(svgIcon("#iD-icon-close"));
47675       headerEnter.append("h2").call(_t.append("save.conflict.header"));
47676       var bodyEnter = selection2.selectAll(".body").data([0]).enter().append("div").attr("class", "body fillL");
47677       var conflictsHelpEnter = bodyEnter.append("div").attr("class", "conflicts-help").call(_t.append("save.conflict.help"));
47678       var changeset = new osmChangeset();
47679       delete changeset.id;
47680       var data = JXON.stringify(changeset.osmChangeJXON(_origChanges));
47681       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
47682       var fileName = "changes.osc";
47683       var linkEnter = conflictsHelpEnter.selectAll(".download-changes").append("a").attr("class", "download-changes");
47684       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
47685       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("save.conflict.download_changes"));
47686       bodyEnter.append("div").attr("class", "conflict-container fillL3").call(showConflict, 0);
47687       bodyEnter.append("div").attr("class", "conflicts-done").attr("opacity", 0).style("display", "none").call(_t.append("save.conflict.done"));
47688       var buttonsEnter = bodyEnter.append("div").attr("class", "buttons col12 joined conflicts-buttons");
47689       buttonsEnter.append("button").attr("disabled", _conflictList.length > 1).attr("class", "action conflicts-button col6").call(_t.append("save.title")).on("click.try_again", tryAgain);
47690       buttonsEnter.append("button").attr("class", "secondary-action conflicts-button col6").call(_t.append("confirm.cancel")).on("click.cancel", cancel);
47691     }
47692     function showConflict(selection2, index) {
47693       index = utilWrap(index, _conflictList.length);
47694       _shownConflictIndex = index;
47695       var parent = select_default2(selection2.node().parentNode);
47696       if (index === _conflictList.length - 1) {
47697         window.setTimeout(function() {
47698           parent.select(".conflicts-button").attr("disabled", null);
47699           parent.select(".conflicts-done").transition().attr("opacity", 1).style("display", "block");
47700         }, 250);
47701       }
47702       var conflict = selection2.selectAll(".conflict").data([_conflictList[index]]);
47703       conflict.exit().remove();
47704       var conflictEnter = conflict.enter().append("div").attr("class", "conflict");
47705       conflictEnter.append("h4").attr("class", "conflict-count").call(_t.append("save.conflict.count", { num: index + 1, total: _conflictList.length }));
47706       conflictEnter.append("a").attr("class", "conflict-description").attr("href", "#").text(function(d2) {
47707         return d2.name;
47708       }).on("click", function(d3_event, d2) {
47709         d3_event.preventDefault();
47710         zoomToEntity(d2.id);
47711       });
47712       var details = conflictEnter.append("div").attr("class", "conflict-detail-container");
47713       details.append("ul").attr("class", "conflict-detail-list").selectAll("li").data(function(d2) {
47714         return d2.details || [];
47715       }).enter().append("li").attr("class", "conflict-detail-item").html(function(d2) {
47716         return d2;
47717       });
47718       details.append("div").attr("class", "conflict-choices").call(addChoices);
47719       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) {
47720         return i3 === 0 && index === 0 || i3 === 1 && index === _conflictList.length - 1 || null;
47721       }).on("click", function(d3_event, d2) {
47722         d3_event.preventDefault();
47723         var container = parent.selectAll(".conflict-container");
47724         var sign2 = d2 === "previous" ? -1 : 1;
47725         container.selectAll(".conflict").remove();
47726         container.call(showConflict, index + sign2);
47727       }).each(function(d2) {
47728         _t.append("save.conflict." + d2)(select_default2(this));
47729       });
47730     }
47731     function addChoices(selection2) {
47732       var choices = selection2.append("ul").attr("class", "layer-list").selectAll("li").data(function(d2) {
47733         return d2.choices || [];
47734       });
47735       var choicesEnter = choices.enter().append("li").attr("class", "layer");
47736       var labelEnter = choicesEnter.append("label");
47737       labelEnter.append("input").attr("type", "radio").attr("name", function(d2) {
47738         return d2.id;
47739       }).on("change", function(d3_event, d2) {
47740         var ul = this.parentNode.parentNode.parentNode;
47741         ul.__data__.chosen = d2.id;
47742         choose(d3_event, ul, d2);
47743       });
47744       labelEnter.append("span").text(function(d2) {
47745         return d2.text;
47746       });
47747       choicesEnter.merge(choices).each(function(d2) {
47748         var ul = this.parentNode;
47749         if (ul.__data__.chosen === d2.id) {
47750           choose(null, ul, d2);
47751         }
47752       });
47753     }
47754     function choose(d3_event, ul, datum2) {
47755       if (d3_event) d3_event.preventDefault();
47756       select_default2(ul).selectAll("li").classed("active", function(d2) {
47757         return d2 === datum2;
47758       }).selectAll("input").property("checked", function(d2) {
47759         return d2 === datum2;
47760       });
47761       var extent = geoExtent();
47762       var entity;
47763       entity = context.graph().hasEntity(datum2.id);
47764       if (entity) extent._extend(entity.extent(context.graph()));
47765       datum2.action();
47766       entity = context.graph().hasEntity(datum2.id);
47767       if (entity) extent._extend(entity.extent(context.graph()));
47768       zoomToEntity(datum2.id, extent);
47769     }
47770     function zoomToEntity(id2, extent) {
47771       context.surface().selectAll(".hover").classed("hover", false);
47772       var entity = context.graph().hasEntity(id2);
47773       if (entity) {
47774         if (extent) {
47775           context.map().trimmedExtent(extent);
47776         } else {
47777           context.map().zoomToEase(entity);
47778         }
47779         context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
47780       }
47781     }
47782     conflicts.conflictList = function(_2) {
47783       if (!arguments.length) return _conflictList;
47784       _conflictList = _2;
47785       return conflicts;
47786     };
47787     conflicts.origChanges = function(_2) {
47788       if (!arguments.length) return _origChanges;
47789       _origChanges = _2;
47790       return conflicts;
47791     };
47792     conflicts.shownEntityIds = function() {
47793       if (_conflictList && typeof _shownConflictIndex === "number") {
47794         return [_conflictList[_shownConflictIndex].id];
47795       }
47796       return [];
47797     };
47798     return utilRebind(conflicts, dispatch14, "on");
47799   }
47800
47801   // modules/ui/confirm.js
47802   function uiConfirm(selection2) {
47803     var modalSelection = uiModal(selection2);
47804     modalSelection.select(".modal").classed("modal-alert", true);
47805     var section = modalSelection.select(".content");
47806     section.append("div").attr("class", "modal-section header");
47807     section.append("div").attr("class", "modal-section message-text");
47808     var buttons = section.append("div").attr("class", "modal-section buttons cf");
47809     modalSelection.okButton = function() {
47810       buttons.append("button").attr("class", "button ok-button action").on("click.confirm", function() {
47811         modalSelection.remove();
47812       }).call(_t.append("confirm.okay")).node().focus();
47813       return modalSelection;
47814     };
47815     return modalSelection;
47816   }
47817
47818   // modules/ui/commit.js
47819   var import_fast_deep_equal10 = __toESM(require_fast_deep_equal());
47820
47821   // modules/ui/popover.js
47822   var _popoverID = 0;
47823   function uiPopover(klass) {
47824     var _id = _popoverID++;
47825     var _anchorSelection = select_default2(null);
47826     var popover = function(selection2) {
47827       _anchorSelection = selection2;
47828       selection2.each(setup);
47829     };
47830     var _animation = utilFunctor(false);
47831     var _placement = utilFunctor("top");
47832     var _alignment = utilFunctor("center");
47833     var _scrollContainer = utilFunctor(select_default2(null));
47834     var _content;
47835     var _displayType = utilFunctor("");
47836     var _hasArrow = utilFunctor(true);
47837     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
47838     popover.displayType = function(val) {
47839       if (arguments.length) {
47840         _displayType = utilFunctor(val);
47841         return popover;
47842       } else {
47843         return _displayType;
47844       }
47845     };
47846     popover.hasArrow = function(val) {
47847       if (arguments.length) {
47848         _hasArrow = utilFunctor(val);
47849         return popover;
47850       } else {
47851         return _hasArrow;
47852       }
47853     };
47854     popover.placement = function(val) {
47855       if (arguments.length) {
47856         _placement = utilFunctor(val);
47857         return popover;
47858       } else {
47859         return _placement;
47860       }
47861     };
47862     popover.alignment = function(val) {
47863       if (arguments.length) {
47864         _alignment = utilFunctor(val);
47865         return popover;
47866       } else {
47867         return _alignment;
47868       }
47869     };
47870     popover.scrollContainer = function(val) {
47871       if (arguments.length) {
47872         _scrollContainer = utilFunctor(val);
47873         return popover;
47874       } else {
47875         return _scrollContainer;
47876       }
47877     };
47878     popover.content = function(val) {
47879       if (arguments.length) {
47880         _content = val;
47881         return popover;
47882       } else {
47883         return _content;
47884       }
47885     };
47886     popover.isShown = function() {
47887       var popoverSelection = _anchorSelection.select(".popover-" + _id);
47888       return !popoverSelection.empty() && popoverSelection.classed("in");
47889     };
47890     popover.show = function() {
47891       _anchorSelection.each(show);
47892     };
47893     popover.updateContent = function() {
47894       _anchorSelection.each(updateContent);
47895     };
47896     popover.hide = function() {
47897       _anchorSelection.each(hide);
47898     };
47899     popover.toggle = function() {
47900       _anchorSelection.each(toggle);
47901     };
47902     popover.destroy = function(selection2, selector) {
47903       selector = selector || ".popover-" + _id;
47904       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() {
47905         return this.getAttribute("data-original-title") || this.getAttribute("title");
47906       }).attr("data-original-title", null).selectAll(selector).remove();
47907     };
47908     popover.destroyAny = function(selection2) {
47909       selection2.call(popover.destroy, ".popover");
47910     };
47911     function setup() {
47912       var anchor = select_default2(this);
47913       var animate = _animation.apply(this, arguments);
47914       var popoverSelection = anchor.selectAll(".popover-" + _id).data([0]);
47915       var enter = popoverSelection.enter().append("div").attr("class", "popover popover-" + _id + " " + (klass ? klass : "")).classed("arrowed", _hasArrow.apply(this, arguments));
47916       enter.append("div").attr("class", "popover-arrow");
47917       enter.append("div").attr("class", "popover-inner");
47918       popoverSelection = enter.merge(popoverSelection);
47919       if (animate) {
47920         popoverSelection.classed("fade", true);
47921       }
47922       var display = _displayType.apply(this, arguments);
47923       if (display === "hover") {
47924         var _lastNonMouseEnterTime;
47925         anchor.on(_pointerPrefix + "enter.popover", function(d3_event) {
47926           if (d3_event.pointerType) {
47927             if (d3_event.pointerType !== "mouse") {
47928               _lastNonMouseEnterTime = d3_event.timeStamp;
47929               return;
47930             } else if (_lastNonMouseEnterTime && d3_event.timeStamp - _lastNonMouseEnterTime < 1500) {
47931               return;
47932             }
47933           }
47934           if (d3_event.buttons !== 0) return;
47935           show.apply(this, arguments);
47936         }).on(_pointerPrefix + "leave.popover", function() {
47937           hide.apply(this, arguments);
47938         }).on("focus.popover", function() {
47939           show.apply(this, arguments);
47940         }).on("blur.popover", function() {
47941           hide.apply(this, arguments);
47942         });
47943       } else if (display === "clickFocus") {
47944         anchor.on(_pointerPrefix + "down.popover", function(d3_event) {
47945           d3_event.preventDefault();
47946           d3_event.stopPropagation();
47947         }).on(_pointerPrefix + "up.popover", function(d3_event) {
47948           d3_event.preventDefault();
47949           d3_event.stopPropagation();
47950         }).on("click.popover", toggle);
47951         popoverSelection.attr("tabindex", 0).on("blur.popover", function() {
47952           anchor.each(function() {
47953             hide.apply(this, arguments);
47954           });
47955         });
47956       }
47957     }
47958     function show() {
47959       var anchor = select_default2(this);
47960       var popoverSelection = anchor.selectAll(".popover-" + _id);
47961       if (popoverSelection.empty()) {
47962         anchor.call(popover.destroy);
47963         anchor.each(setup);
47964         popoverSelection = anchor.selectAll(".popover-" + _id);
47965       }
47966       popoverSelection.classed("in", true);
47967       var displayType = _displayType.apply(this, arguments);
47968       if (displayType === "clickFocus") {
47969         anchor.classed("active", true);
47970         popoverSelection.node().focus();
47971       }
47972       anchor.each(updateContent);
47973     }
47974     function updateContent() {
47975       var anchor = select_default2(this);
47976       if (_content) {
47977         anchor.selectAll(".popover-" + _id + " > .popover-inner").call(_content.apply(this, arguments));
47978       }
47979       updatePosition.apply(this, arguments);
47980       updatePosition.apply(this, arguments);
47981       updatePosition.apply(this, arguments);
47982     }
47983     function updatePosition() {
47984       var anchor = select_default2(this);
47985       var popoverSelection = anchor.selectAll(".popover-" + _id);
47986       var scrollContainer = _scrollContainer && _scrollContainer.apply(this, arguments);
47987       var scrollNode = scrollContainer && !scrollContainer.empty() && scrollContainer.node();
47988       var scrollLeft = scrollNode ? scrollNode.scrollLeft : 0;
47989       var scrollTop = scrollNode ? scrollNode.scrollTop : 0;
47990       var placement = _placement.apply(this, arguments);
47991       popoverSelection.classed("left", false).classed("right", false).classed("top", false).classed("bottom", false).classed(placement, true);
47992       var alignment = _alignment.apply(this, arguments);
47993       var alignFactor = 0.5;
47994       if (alignment === "leading") {
47995         alignFactor = 0;
47996       } else if (alignment === "trailing") {
47997         alignFactor = 1;
47998       }
47999       var anchorFrame = getFrame(anchor.node());
48000       var popoverFrame = getFrame(popoverSelection.node());
48001       var position;
48002       switch (placement) {
48003         case "top":
48004           position = {
48005             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
48006             y: anchorFrame.y - popoverFrame.h
48007           };
48008           break;
48009         case "bottom":
48010           position = {
48011             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
48012             y: anchorFrame.y + anchorFrame.h
48013           };
48014           break;
48015         case "left":
48016           position = {
48017             x: anchorFrame.x - popoverFrame.w,
48018             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
48019           };
48020           break;
48021         case "right":
48022           position = {
48023             x: anchorFrame.x + anchorFrame.w,
48024             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
48025           };
48026           break;
48027       }
48028       if (position) {
48029         if (scrollNode && (placement === "top" || placement === "bottom")) {
48030           var initialPosX = position.x;
48031           if (position.x + popoverFrame.w > scrollNode.offsetWidth - 10) {
48032             position.x = scrollNode.offsetWidth - 10 - popoverFrame.w;
48033           } else if (position.x < 10) {
48034             position.x = 10;
48035           }
48036           var arrow = anchor.selectAll(".popover-" + _id + " > .popover-arrow");
48037           var arrowPosX = Math.min(Math.max(popoverFrame.w / 2 - (position.x - initialPosX), 10), popoverFrame.w - 10);
48038           arrow.style("left", ~~arrowPosX + "px");
48039         }
48040         popoverSelection.style("left", ~~position.x + "px").style("top", ~~position.y + "px");
48041       } else {
48042         popoverSelection.style("left", null).style("top", null);
48043       }
48044       function getFrame(node) {
48045         var positionStyle = select_default2(node).style("position");
48046         if (positionStyle === "absolute" || positionStyle === "static") {
48047           return {
48048             x: node.offsetLeft - scrollLeft,
48049             y: node.offsetTop - scrollTop,
48050             w: node.offsetWidth,
48051             h: node.offsetHeight
48052           };
48053         } else {
48054           return {
48055             x: 0,
48056             y: 0,
48057             w: node.offsetWidth,
48058             h: node.offsetHeight
48059           };
48060         }
48061       }
48062     }
48063     function hide() {
48064       var anchor = select_default2(this);
48065       if (_displayType.apply(this, arguments) === "clickFocus") {
48066         anchor.classed("active", false);
48067       }
48068       anchor.selectAll(".popover-" + _id).classed("in", false);
48069     }
48070     function toggle() {
48071       if (select_default2(this).select(".popover-" + _id).classed("in")) {
48072         hide.apply(this, arguments);
48073       } else {
48074         show.apply(this, arguments);
48075       }
48076     }
48077     return popover;
48078   }
48079
48080   // modules/ui/tooltip.js
48081   function uiTooltip(klass) {
48082     var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover");
48083     var _title = function() {
48084       var title = this.getAttribute("data-original-title");
48085       if (title) {
48086         return title;
48087       } else {
48088         title = this.getAttribute("title");
48089         this.removeAttribute("title");
48090         this.setAttribute("data-original-title", title);
48091       }
48092       return title;
48093     };
48094     var _heading = utilFunctor(null);
48095     var _keys = utilFunctor(null);
48096     tooltip.title = function(val) {
48097       if (!arguments.length) return _title;
48098       _title = utilFunctor(val);
48099       return tooltip;
48100     };
48101     tooltip.heading = function(val) {
48102       if (!arguments.length) return _heading;
48103       _heading = utilFunctor(val);
48104       return tooltip;
48105     };
48106     tooltip.keys = function(val) {
48107       if (!arguments.length) return _keys;
48108       _keys = utilFunctor(val);
48109       return tooltip;
48110     };
48111     tooltip.content(function() {
48112       var heading2 = _heading.apply(this, arguments);
48113       var text = _title.apply(this, arguments);
48114       var keys2 = _keys.apply(this, arguments);
48115       var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2);
48116       var textCallback = typeof text === "function" ? text : (s2) => s2.text(text);
48117       return function(selection2) {
48118         var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []);
48119         headingSelect.exit().remove();
48120         headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback);
48121         var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []);
48122         textSelect.exit().remove();
48123         textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback);
48124         var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []);
48125         keyhintWrap.exit().remove();
48126         var keyhintWrapEnter = keyhintWrap.enter().append("div").attr("class", "keyhint-wrap");
48127         keyhintWrapEnter.append("span").call(_t.append("tooltip_keyhint"));
48128         keyhintWrap = keyhintWrapEnter.merge(keyhintWrap);
48129         keyhintWrap.selectAll("kbd.shortcut").data(keys2 && keys2.length ? keys2 : []).enter().append("kbd").attr("class", "shortcut").text(function(d2) {
48130           return d2;
48131         });
48132       };
48133     });
48134     return tooltip;
48135   }
48136
48137   // modules/ui/combobox.js
48138   var _comboHideTimerID;
48139   function uiCombobox(context, klass) {
48140     var dispatch14 = dispatch_default("accept", "cancel", "update");
48141     var container = context.container();
48142     var _suggestions = [];
48143     var _data = [];
48144     var _fetched = {};
48145     var _selected = null;
48146     var _canAutocomplete = true;
48147     var _caseSensitive = false;
48148     var _cancelFetch = false;
48149     var _minItems = 2;
48150     var _tDown = 0;
48151     var _mouseEnterHandler, _mouseLeaveHandler;
48152     var _fetcher = function(val, cb) {
48153       cb(_data.filter(function(d2) {
48154         var terms = d2.terms || [];
48155         terms.push(d2.value);
48156         if (d2.key) {
48157           terms.push(d2.key);
48158         }
48159         return terms.some(function(term) {
48160           return term.toString().toLowerCase().indexOf(val.toLowerCase()) !== -1;
48161         });
48162       }));
48163     };
48164     var combobox = function(input, attachTo) {
48165       if (!input || input.empty()) return;
48166       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() {
48167         var parent = this.parentNode;
48168         var sibling = this.nextSibling;
48169         select_default2(parent).selectAll(".combobox-caret").filter(function(d2) {
48170           return d2 === input.node();
48171         }).data([input.node()]).enter().insert("div", function() {
48172           return sibling;
48173         }).attr("class", "combobox-caret").on("mousedown.combo-caret", function(d3_event) {
48174           d3_event.preventDefault();
48175           input.node().focus();
48176           mousedown(d3_event);
48177         }).on("mouseup.combo-caret", function(d3_event) {
48178           d3_event.preventDefault();
48179           mouseup(d3_event);
48180         });
48181       });
48182       function mousedown(d3_event) {
48183         if (d3_event.button !== 0) return;
48184         if (input.classed("disabled")) return;
48185         _tDown = +/* @__PURE__ */ new Date();
48186         var start2 = input.property("selectionStart");
48187         var end = input.property("selectionEnd");
48188         if (start2 !== end) {
48189           var val = utilGetSetValue(input);
48190           input.node().setSelectionRange(val.length, val.length);
48191           return;
48192         }
48193         input.on("mouseup.combo-input", mouseup);
48194       }
48195       function mouseup(d3_event) {
48196         input.on("mouseup.combo-input", null);
48197         if (d3_event.button !== 0) return;
48198         if (input.classed("disabled")) return;
48199         if (input.node() !== document.activeElement) return;
48200         var start2 = input.property("selectionStart");
48201         var end = input.property("selectionEnd");
48202         if (start2 !== end) return;
48203         var combo = container.selectAll(".combobox");
48204         if (combo.empty() || combo.datum() !== input.node()) {
48205           var tOrig = _tDown;
48206           window.setTimeout(function() {
48207             if (tOrig !== _tDown) return;
48208             fetchComboData("", function() {
48209               show();
48210               render();
48211             });
48212           }, 250);
48213         } else {
48214           hide();
48215         }
48216       }
48217       function focus() {
48218         fetchComboData("");
48219       }
48220       function blur() {
48221         _comboHideTimerID = window.setTimeout(hide, 75);
48222       }
48223       function show() {
48224         hide();
48225         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) {
48226           d3_event.preventDefault();
48227         });
48228         container.on("scroll.combo-scroll", render, true);
48229       }
48230       function hide() {
48231         _hide(container);
48232       }
48233       function keydown(d3_event) {
48234         var shown = !container.selectAll(".combobox").empty();
48235         var tagName = input.node() ? input.node().tagName.toLowerCase() : "";
48236         switch (d3_event.keyCode) {
48237           case 8:
48238           // ⌫ Backspace
48239           case 46:
48240             d3_event.stopPropagation();
48241             _selected = null;
48242             render();
48243             input.on("input.combo-input", function() {
48244               var start2 = input.property("selectionStart");
48245               input.node().setSelectionRange(start2, start2);
48246               input.on("input.combo-input", change);
48247               change(false);
48248             });
48249             break;
48250           case 9:
48251             accept(d3_event);
48252             break;
48253           case 13:
48254             d3_event.preventDefault();
48255             d3_event.stopPropagation();
48256             accept(d3_event);
48257             break;
48258           case 38:
48259             if (tagName === "textarea" && !shown) return;
48260             d3_event.preventDefault();
48261             if (tagName === "input" && !shown) {
48262               show();
48263             }
48264             nav(-1);
48265             break;
48266           case 40:
48267             if (tagName === "textarea" && !shown) return;
48268             d3_event.preventDefault();
48269             if (tagName === "input" && !shown) {
48270               show();
48271             }
48272             nav(1);
48273             break;
48274         }
48275       }
48276       function keyup(d3_event) {
48277         switch (d3_event.keyCode) {
48278           case 27:
48279             cancel();
48280             break;
48281         }
48282       }
48283       function change(doAutoComplete) {
48284         if (doAutoComplete === void 0) doAutoComplete = true;
48285         fetchComboData(value(), function(skipAutosuggest) {
48286           _selected = null;
48287           var val = input.property("value");
48288           if (_suggestions.length) {
48289             if (doAutoComplete && !skipAutosuggest && input.property("selectionEnd") === val.length) {
48290               _selected = tryAutocomplete();
48291             }
48292             if (!_selected) {
48293               _selected = val;
48294             }
48295           }
48296           if (val.length) {
48297             var combo = container.selectAll(".combobox");
48298             if (combo.empty()) {
48299               show();
48300             }
48301           } else {
48302             hide();
48303           }
48304           render();
48305         });
48306       }
48307       function nav(dir) {
48308         if (_suggestions.length) {
48309           var index = -1;
48310           for (var i3 = 0; i3 < _suggestions.length; i3++) {
48311             if (_selected && _suggestions[i3].value === _selected) {
48312               index = i3;
48313               break;
48314             }
48315           }
48316           index = Math.max(Math.min(index + dir, _suggestions.length - 1), 0);
48317           _selected = _suggestions[index].value;
48318           utilGetSetValue(input, _selected);
48319           dispatch14.call("update");
48320         }
48321         render();
48322         ensureVisible();
48323       }
48324       function ensureVisible() {
48325         var _a4;
48326         var combo = container.selectAll(".combobox");
48327         if (combo.empty()) return;
48328         var containerRect = container.node().getBoundingClientRect();
48329         var comboRect = combo.node().getBoundingClientRect();
48330         if (comboRect.bottom > containerRect.bottom) {
48331           var node = attachTo ? attachTo.node() : input.node();
48332           node.scrollIntoView({ behavior: "instant", block: "center" });
48333           render();
48334         }
48335         var selected = combo.selectAll(".combobox-option.selected").node();
48336         if (selected) {
48337           (_a4 = selected.scrollIntoView) == null ? void 0 : _a4.call(selected, { behavior: "smooth", block: "nearest" });
48338         }
48339       }
48340       function value() {
48341         var value2 = input.property("value");
48342         var start2 = input.property("selectionStart");
48343         var end = input.property("selectionEnd");
48344         if (start2 && end) {
48345           value2 = value2.substring(0, start2);
48346         }
48347         return value2;
48348       }
48349       function fetchComboData(v2, cb) {
48350         _cancelFetch = false;
48351         _fetcher.call(input, v2, function(results, skipAutosuggest) {
48352           if (_cancelFetch) return;
48353           _suggestions = results;
48354           results.forEach(function(d2) {
48355             _fetched[d2.value] = d2;
48356           });
48357           if (cb) {
48358             cb(skipAutosuggest);
48359           }
48360         });
48361       }
48362       function tryAutocomplete() {
48363         if (!_canAutocomplete) return;
48364         var val = _caseSensitive ? value() : value().toLowerCase();
48365         if (!val) return;
48366         if (isFinite(val)) return;
48367         const suggestionValues = [];
48368         _suggestions.forEach((s2) => {
48369           suggestionValues.push(s2.value);
48370           if (s2.key && s2.key !== s2.value) {
48371             suggestionValues.push(s2.key);
48372           }
48373         });
48374         var bestIndex = -1;
48375         for (var i3 = 0; i3 < suggestionValues.length; i3++) {
48376           var suggestion = suggestionValues[i3];
48377           var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase();
48378           if (compare2 === val) {
48379             bestIndex = i3;
48380             break;
48381           } else if (bestIndex === -1 && compare2.indexOf(val) === 0) {
48382             bestIndex = i3;
48383           }
48384         }
48385         if (bestIndex !== -1) {
48386           var bestVal = suggestionValues[bestIndex];
48387           input.property("value", bestVal);
48388           input.node().setSelectionRange(val.length, bestVal.length);
48389           dispatch14.call("update");
48390           return bestVal;
48391         }
48392       }
48393       function render() {
48394         if (_suggestions.length < _minItems || document.activeElement !== input.node()) {
48395           hide();
48396           return;
48397         }
48398         var shown = !container.selectAll(".combobox").empty();
48399         if (!shown) return;
48400         var combo = container.selectAll(".combobox");
48401         var options2 = combo.selectAll(".combobox-option").data(_suggestions, function(d2) {
48402           return d2.value;
48403         });
48404         options2.exit().remove();
48405         options2.enter().append("a").attr("class", function(d2) {
48406           return "combobox-option " + (d2.klass || "");
48407         }).attr("title", function(d2) {
48408           return d2.title;
48409         }).each(function(d2) {
48410           if (d2.display) {
48411             d2.display(select_default2(this));
48412           } else {
48413             select_default2(this).text(d2.value);
48414           }
48415         }).on("mouseenter", _mouseEnterHandler).on("mouseleave", _mouseLeaveHandler).merge(options2).classed("selected", function(d2) {
48416           return d2.value === _selected || d2.key === _selected;
48417         }).on("click.combo-option", accept).order();
48418         var node = attachTo ? attachTo.node() : input.node();
48419         var containerRect = container.node().getBoundingClientRect();
48420         var rect = node.getBoundingClientRect();
48421         combo.style("left", rect.left + 5 - containerRect.left + "px").style("width", rect.width - 10 + "px").style("top", rect.height + rect.top - containerRect.top + "px");
48422       }
48423       function accept(d3_event, d2) {
48424         _cancelFetch = true;
48425         var thiz = input.node();
48426         if (d2) {
48427           utilGetSetValue(input, d2.value);
48428           utilTriggerEvent(input, "change");
48429         }
48430         var val = utilGetSetValue(input);
48431         thiz.setSelectionRange(val.length, val.length);
48432         if (!d2) {
48433           d2 = _fetched[val];
48434         }
48435         dispatch14.call("accept", thiz, d2, val);
48436         hide();
48437       }
48438       function cancel() {
48439         _cancelFetch = true;
48440         var thiz = input.node();
48441         var val = utilGetSetValue(input);
48442         var start2 = input.property("selectionStart");
48443         var end = input.property("selectionEnd");
48444         val = val.slice(0, start2) + val.slice(end);
48445         utilGetSetValue(input, val);
48446         thiz.setSelectionRange(val.length, val.length);
48447         dispatch14.call("cancel", thiz);
48448         hide();
48449       }
48450     };
48451     combobox.canAutocomplete = function(val) {
48452       if (!arguments.length) return _canAutocomplete;
48453       _canAutocomplete = val;
48454       return combobox;
48455     };
48456     combobox.caseSensitive = function(val) {
48457       if (!arguments.length) return _caseSensitive;
48458       _caseSensitive = val;
48459       return combobox;
48460     };
48461     combobox.data = function(val) {
48462       if (!arguments.length) return _data;
48463       _data = val;
48464       return combobox;
48465     };
48466     combobox.fetcher = function(val) {
48467       if (!arguments.length) return _fetcher;
48468       _fetcher = val;
48469       return combobox;
48470     };
48471     combobox.minItems = function(val) {
48472       if (!arguments.length) return _minItems;
48473       _minItems = val;
48474       return combobox;
48475     };
48476     combobox.itemsMouseEnter = function(val) {
48477       if (!arguments.length) return _mouseEnterHandler;
48478       _mouseEnterHandler = val;
48479       return combobox;
48480     };
48481     combobox.itemsMouseLeave = function(val) {
48482       if (!arguments.length) return _mouseLeaveHandler;
48483       _mouseLeaveHandler = val;
48484       return combobox;
48485     };
48486     return utilRebind(combobox, dispatch14, "on");
48487   }
48488   function _hide(container) {
48489     if (_comboHideTimerID) {
48490       window.clearTimeout(_comboHideTimerID);
48491       _comboHideTimerID = void 0;
48492     }
48493     container.selectAll(".combobox").remove();
48494     container.on("scroll.combo-scroll", null);
48495   }
48496   uiCombobox.off = function(input, context) {
48497     _hide(context.container());
48498     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);
48499     context.container().on("scroll.combo-scroll", null);
48500   };
48501
48502   // modules/ui/intro/helper.js
48503   function pointBox(loc, context) {
48504     var rect = context.surfaceRect();
48505     var point = context.curtainProjection(loc);
48506     return {
48507       left: point[0] + rect.left - 40,
48508       top: point[1] + rect.top - 60,
48509       width: 80,
48510       height: 90
48511     };
48512   }
48513   function pad(locOrBox, padding, context) {
48514     var box;
48515     if (locOrBox instanceof Array) {
48516       var rect = context.surfaceRect();
48517       var point = context.curtainProjection(locOrBox);
48518       box = {
48519         left: point[0] + rect.left,
48520         top: point[1] + rect.top
48521       };
48522     } else {
48523       box = locOrBox;
48524     }
48525     return {
48526       left: box.left - padding,
48527       top: box.top - padding,
48528       width: (box.width || 0) + 2 * padding,
48529       height: (box.width || 0) + 2 * padding
48530     };
48531   }
48532   function icon(name, svgklass, useklass) {
48533     return '<svg class="icon ' + (svgklass || "") + '"><use xlink:href="' + name + '"' + (useklass ? ' class="' + useklass + '"' : "") + "></use></svg>";
48534   }
48535   var helpStringReplacements;
48536   function helpHtml(id2, replacements) {
48537     if (!helpStringReplacements) {
48538       helpStringReplacements = {
48539         // insert icons corresponding to various UI elements
48540         point_icon: icon("#iD-icon-point", "inline"),
48541         line_icon: icon("#iD-icon-line", "inline"),
48542         area_icon: icon("#iD-icon-area", "inline"),
48543         note_icon: icon("#iD-icon-note", "inline add-note"),
48544         plus: icon("#iD-icon-plus", "inline"),
48545         minus: icon("#iD-icon-minus", "inline"),
48546         layers_icon: icon("#iD-icon-layers", "inline"),
48547         data_icon: icon("#iD-icon-data", "inline"),
48548         inspect: icon("#iD-icon-inspect", "inline"),
48549         help_icon: icon("#iD-icon-help", "inline"),
48550         undo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo", "inline"),
48551         redo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-undo" : "#iD-icon-redo", "inline"),
48552         save_icon: icon("#iD-icon-save", "inline"),
48553         // operation icons
48554         circularize_icon: icon("#iD-operation-circularize", "inline operation"),
48555         continue_icon: icon("#iD-operation-continue", "inline operation"),
48556         copy_icon: icon("#iD-operation-copy", "inline operation"),
48557         delete_icon: icon("#iD-operation-delete", "inline operation"),
48558         disconnect_icon: icon("#iD-operation-disconnect", "inline operation"),
48559         downgrade_icon: icon("#iD-operation-downgrade", "inline operation"),
48560         extract_icon: icon("#iD-operation-extract", "inline operation"),
48561         merge_icon: icon("#iD-operation-merge", "inline operation"),
48562         move_icon: icon("#iD-operation-move", "inline operation"),
48563         orthogonalize_icon: icon("#iD-operation-orthogonalize", "inline operation"),
48564         paste_icon: icon("#iD-operation-paste", "inline operation"),
48565         reflect_long_icon: icon("#iD-operation-reflect-long", "inline operation"),
48566         reflect_short_icon: icon("#iD-operation-reflect-short", "inline operation"),
48567         reverse_icon: icon("#iD-operation-reverse", "inline operation"),
48568         rotate_icon: icon("#iD-operation-rotate", "inline operation"),
48569         split_icon: icon("#iD-operation-split", "inline operation"),
48570         straighten_icon: icon("#iD-operation-straighten", "inline operation"),
48571         // interaction icons
48572         leftclick: icon("#iD-walkthrough-mouse-left", "inline operation"),
48573         rightclick: icon("#iD-walkthrough-mouse-right", "inline operation"),
48574         mousewheel_icon: icon("#iD-walkthrough-mousewheel", "inline operation"),
48575         tap_icon: icon("#iD-walkthrough-tap", "inline operation"),
48576         doubletap_icon: icon("#iD-walkthrough-doubletap", "inline operation"),
48577         longpress_icon: icon("#iD-walkthrough-longpress", "inline operation"),
48578         touchdrag_icon: icon("#iD-walkthrough-touchdrag", "inline operation"),
48579         pinch_icon: icon("#iD-walkthrough-pinch-apart", "inline operation"),
48580         // insert keys; may be localized and platform-dependent
48581         shift: uiCmd.display("\u21E7"),
48582         alt: uiCmd.display("\u2325"),
48583         return: uiCmd.display("\u21B5"),
48584         esc: _t.html("shortcuts.key.esc"),
48585         space: _t.html("shortcuts.key.space"),
48586         add_note_key: _t.html("modes.add_note.key"),
48587         help_key: _t.html("help.key"),
48588         shortcuts_key: _t.html("shortcuts.toggle.key"),
48589         // reference localized UI labels directly so that they'll always match
48590         save: _t.html("save.title"),
48591         undo: _t.html("undo.title"),
48592         redo: _t.html("redo.title"),
48593         upload: _t.html("commit.save"),
48594         point: _t.html("modes.add_point.title"),
48595         line: _t.html("modes.add_line.title"),
48596         area: _t.html("modes.add_area.title"),
48597         note: _t.html("modes.add_note.label"),
48598         circularize: _t.html("operations.circularize.title"),
48599         continue: _t.html("operations.continue.title"),
48600         copy: _t.html("operations.copy.title"),
48601         delete: _t.html("operations.delete.title"),
48602         disconnect: _t.html("operations.disconnect.title"),
48603         downgrade: _t.html("operations.downgrade.title"),
48604         extract: _t.html("operations.extract.title"),
48605         merge: _t.html("operations.merge.title"),
48606         move: _t.html("operations.move.title"),
48607         orthogonalize: _t.html("operations.orthogonalize.title"),
48608         paste: _t.html("operations.paste.title"),
48609         reflect_long: _t.html("operations.reflect.title.long"),
48610         reflect_short: _t.html("operations.reflect.title.short"),
48611         reverse: _t.html("operations.reverse.title"),
48612         rotate: _t.html("operations.rotate.title"),
48613         split: _t.html("operations.split.title"),
48614         straighten: _t.html("operations.straighten.title"),
48615         map_data: _t.html("map_data.title"),
48616         osm_notes: _t.html("map_data.layers.notes.title"),
48617         fields: _t.html("inspector.fields"),
48618         tags: _t.html("inspector.tags"),
48619         relations: _t.html("inspector.relations"),
48620         new_relation: _t.html("inspector.new_relation"),
48621         turn_restrictions: _t.html("_tagging.presets.fields.restrictions.label"),
48622         background_settings: _t.html("background.description"),
48623         imagery_offset: _t.html("background.fix_misalignment"),
48624         start_the_walkthrough: _t.html("splash.walkthrough"),
48625         help: _t.html("help.title"),
48626         ok: _t.html("intro.ok")
48627       };
48628       for (var key in helpStringReplacements) {
48629         helpStringReplacements[key] = { html: helpStringReplacements[key] };
48630       }
48631     }
48632     var reps;
48633     if (replacements) {
48634       reps = Object.assign(replacements, helpStringReplacements);
48635     } else {
48636       reps = helpStringReplacements;
48637     }
48638     return _t.html(id2, reps).replace(/\`(.*?)\`/g, "<kbd>$1</kbd>");
48639   }
48640   function slugify(text) {
48641     return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
48642   }
48643   var missingStrings = {};
48644   function checkKey(key, text) {
48645     if (_t(key, { default: void 0 }) === void 0) {
48646       if (missingStrings.hasOwnProperty(key)) return;
48647       missingStrings[key] = text;
48648       var missing = key + ": " + text;
48649       if (typeof console !== "undefined") console.log(missing);
48650     }
48651   }
48652   function localize(obj) {
48653     var key;
48654     var name = obj.tags && obj.tags.name;
48655     if (name) {
48656       key = "intro.graph.name." + slugify(name);
48657       obj.tags.name = _t(key, { default: name });
48658       checkKey(key, name);
48659     }
48660     var street = obj.tags && obj.tags["addr:street"];
48661     if (street) {
48662       key = "intro.graph.name." + slugify(street);
48663       obj.tags["addr:street"] = _t(key, { default: street });
48664       checkKey(key, street);
48665       var addrTags = [
48666         "block_number",
48667         "city",
48668         "county",
48669         "district",
48670         "hamlet",
48671         "neighbourhood",
48672         "postcode",
48673         "province",
48674         "quarter",
48675         "state",
48676         "subdistrict",
48677         "suburb"
48678       ];
48679       addrTags.forEach(function(k2) {
48680         var key2 = "intro.graph." + k2;
48681         var tag2 = "addr:" + k2;
48682         var val = obj.tags && obj.tags[tag2];
48683         var str = _t(key2, { default: val });
48684         if (str) {
48685           if (str.match(/^<.*>$/) !== null) {
48686             delete obj.tags[tag2];
48687           } else {
48688             obj.tags[tag2] = str;
48689           }
48690         }
48691       });
48692     }
48693     return obj;
48694   }
48695   function isMostlySquare(points) {
48696     var threshold = 15;
48697     var lowerBound = Math.cos((90 - threshold) * Math.PI / 180);
48698     var upperBound = Math.cos(threshold * Math.PI / 180);
48699     for (var i3 = 0; i3 < points.length; i3++) {
48700       var a2 = points[(i3 - 1 + points.length) % points.length];
48701       var origin = points[i3];
48702       var b2 = points[(i3 + 1) % points.length];
48703       var dotp = geoVecNormalizedDot(a2, b2, origin);
48704       var mag = Math.abs(dotp);
48705       if (mag > lowerBound && mag < upperBound) {
48706         return false;
48707       }
48708     }
48709     return true;
48710   }
48711   function selectMenuItem(context, operation2) {
48712     return context.container().select(".edit-menu .edit-menu-item-" + operation2);
48713   }
48714   function transitionTime(point1, point2) {
48715     var distance = geoSphericalDistance(point1, point2);
48716     if (distance === 0) {
48717       return 0;
48718     } else if (distance < 80) {
48719       return 500;
48720     } else {
48721       return 1e3;
48722     }
48723   }
48724
48725   // modules/ui/field_help.js
48726   function uiFieldHelp(context, fieldName) {
48727     var fieldHelp = {};
48728     var _inspector = select_default2(null);
48729     var _wrap = select_default2(null);
48730     var _body = select_default2(null);
48731     var fieldHelpKeys = {
48732       restrictions: [
48733         ["about", [
48734           "about",
48735           "from_via_to",
48736           "maxdist",
48737           "maxvia"
48738         ]],
48739         ["inspecting", [
48740           "about",
48741           "from_shadow",
48742           "allow_shadow",
48743           "restrict_shadow",
48744           "only_shadow",
48745           "restricted",
48746           "only"
48747         ]],
48748         ["modifying", [
48749           "about",
48750           "indicators",
48751           "allow_turn",
48752           "restrict_turn",
48753           "only_turn"
48754         ]],
48755         ["tips", [
48756           "simple",
48757           "simple_example",
48758           "indirect",
48759           "indirect_example",
48760           "indirect_noedit"
48761         ]]
48762       ]
48763     };
48764     var fieldHelpHeadings = {};
48765     var replacements = {
48766       distField: { html: _t.html("restriction.controls.distance") },
48767       viaField: { html: _t.html("restriction.controls.via") },
48768       fromShadow: { html: icon("#iD-turn-shadow", "inline shadow from") },
48769       allowShadow: { html: icon("#iD-turn-shadow", "inline shadow allow") },
48770       restrictShadow: { html: icon("#iD-turn-shadow", "inline shadow restrict") },
48771       onlyShadow: { html: icon("#iD-turn-shadow", "inline shadow only") },
48772       allowTurn: { html: icon("#iD-turn-yes", "inline turn") },
48773       restrictTurn: { html: icon("#iD-turn-no", "inline turn") },
48774       onlyTurn: { html: icon("#iD-turn-only", "inline turn") }
48775     };
48776     var docs = fieldHelpKeys[fieldName].map(function(key) {
48777       var helpkey = "help.field." + fieldName + "." + key[0];
48778       var text = key[1].reduce(function(all, part) {
48779         var subkey = helpkey + "." + part;
48780         var depth = fieldHelpHeadings[subkey];
48781         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
48782         return all + hhh + _t.html(subkey, replacements) + "\n\n";
48783       }, "");
48784       return {
48785         key: helpkey,
48786         title: _t.html(helpkey + ".title"),
48787         html: marked(text.trim())
48788       };
48789     });
48790     function show() {
48791       updatePosition();
48792       _body.classed("hide", false).style("opacity", "0").transition().duration(200).style("opacity", "1");
48793     }
48794     function hide() {
48795       _body.classed("hide", true).transition().duration(200).style("opacity", "0").on("end", function() {
48796         _body.classed("hide", true);
48797       });
48798     }
48799     function clickHelp(index) {
48800       var d2 = docs[index];
48801       var tkeys = fieldHelpKeys[fieldName][index][1];
48802       _body.selectAll(".field-help-nav-item").classed("active", function(d4, i3) {
48803         return i3 === index;
48804       });
48805       var content = _body.selectAll(".field-help-content").html(d2.html);
48806       content.selectAll("p").attr("class", function(d4, i3) {
48807         return tkeys[i3];
48808       });
48809       if (d2.key === "help.field.restrictions.inspecting") {
48810         content.insert("img", "p.from_shadow").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_inspect.gif"));
48811       } else if (d2.key === "help.field.restrictions.modifying") {
48812         content.insert("img", "p.allow_turn").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_modify.gif"));
48813       }
48814     }
48815     fieldHelp.button = function(selection2) {
48816       if (_body.empty()) return;
48817       var button = selection2.selectAll(".field-help-button").data([0]);
48818       button.enter().append("button").attr("class", "field-help-button").call(svgIcon("#iD-icon-help")).merge(button).on("click", function(d3_event) {
48819         d3_event.stopPropagation();
48820         d3_event.preventDefault();
48821         if (_body.classed("hide")) {
48822           show();
48823         } else {
48824           hide();
48825         }
48826       });
48827     };
48828     function updatePosition() {
48829       var wrap2 = _wrap.node();
48830       var inspector = _inspector.node();
48831       var wRect = wrap2.getBoundingClientRect();
48832       var iRect = inspector.getBoundingClientRect();
48833       _body.style("top", wRect.top + inspector.scrollTop - iRect.top + "px");
48834     }
48835     fieldHelp.body = function(selection2) {
48836       _wrap = selection2.selectAll(".form-field-input-wrap");
48837       if (_wrap.empty()) return;
48838       _inspector = context.container().select(".sidebar .entity-editor-pane .inspector-body");
48839       if (_inspector.empty()) return;
48840       _body = _inspector.selectAll(".field-help-body").data([0]);
48841       var enter = _body.enter().append("div").attr("class", "field-help-body hide");
48842       var titleEnter = enter.append("div").attr("class", "field-help-title cf");
48843       titleEnter.append("h2").attr("class", _mainLocalizer.textDirection() === "rtl" ? "fr" : "fl").call(_t.append("help.field." + fieldName + ".title"));
48844       titleEnter.append("button").attr("class", "fr close").attr("title", _t("icons.close")).on("click", function(d3_event) {
48845         d3_event.stopPropagation();
48846         d3_event.preventDefault();
48847         hide();
48848       }).call(svgIcon("#iD-icon-close"));
48849       var navEnter = enter.append("div").attr("class", "field-help-nav cf");
48850       var titles = docs.map(function(d2) {
48851         return d2.title;
48852       });
48853       navEnter.selectAll(".field-help-nav-item").data(titles).enter().append("div").attr("class", "field-help-nav-item").html(function(d2) {
48854         return d2;
48855       }).on("click", function(d3_event, d2) {
48856         d3_event.stopPropagation();
48857         d3_event.preventDefault();
48858         clickHelp(titles.indexOf(d2));
48859       });
48860       enter.append("div").attr("class", "field-help-content");
48861       _body = _body.merge(enter);
48862       clickHelp(0);
48863     };
48864     return fieldHelp;
48865   }
48866
48867   // modules/ui/fields/check.js
48868   function uiFieldCheck(field, context) {
48869     var dispatch14 = dispatch_default("change");
48870     var options2 = field.options;
48871     var values = [];
48872     var texts = [];
48873     var _tags;
48874     var input = select_default2(null);
48875     var text = select_default2(null);
48876     var label = select_default2(null);
48877     var reverser = select_default2(null);
48878     var _impliedYes;
48879     var _entityIDs = [];
48880     var _value;
48881     var stringsField = field.resolveReference("stringsCrossReference");
48882     if (!options2 && stringsField.options) {
48883       options2 = stringsField.options;
48884     }
48885     if (options2) {
48886       for (var i3 in options2) {
48887         var v2 = options2[i3];
48888         values.push(v2 === "undefined" ? void 0 : v2);
48889         texts.push(stringsField.t.html("options." + v2, { "default": v2 }));
48890       }
48891     } else {
48892       values = [void 0, "yes"];
48893       texts = [_t.html("inspector.unknown"), _t.html("inspector.check.yes")];
48894       if (field.type !== "defaultCheck") {
48895         values.push("no");
48896         texts.push(_t.html("inspector.check.no"));
48897       }
48898     }
48899     function checkImpliedYes() {
48900       _impliedYes = field.id === "oneway_yes";
48901       if (field.id === "oneway") {
48902         var entity = context.entity(_entityIDs[0]);
48903         if (entity.type === "way" && entity.isOneWay()) {
48904           _impliedYes = true;
48905           texts[0] = _t.html("_tagging.presets.fields.oneway_yes.options.undefined");
48906         }
48907       }
48908     }
48909     function reverserHidden() {
48910       if (!context.container().select("div.inspector-hover").empty()) return true;
48911       return !(_value === "yes" || _impliedYes && !_value);
48912     }
48913     function reverserSetText(selection2) {
48914       var entity = _entityIDs.length && context.hasEntity(_entityIDs[0]);
48915       if (reverserHidden() || !entity) return selection2;
48916       var first = entity.first();
48917       var last = entity.isClosed() ? entity.nodes[entity.nodes.length - 2] : entity.last();
48918       var pseudoDirection = first < last;
48919       var icon2 = pseudoDirection ? "#iD-icon-forward" : "#iD-icon-backward";
48920       selection2.selectAll(".reverser-span").html("").call(_t.append("inspector.check.reverser")).call(svgIcon(icon2, "inline"));
48921       return selection2;
48922     }
48923     var check = function(selection2) {
48924       checkImpliedYes();
48925       label = selection2.selectAll(".form-field-input-wrap").data([0]);
48926       var enter = label.enter().append("label").attr("class", "form-field-input-wrap form-field-input-check");
48927       enter.append("input").property("indeterminate", field.type !== "defaultCheck").attr("type", "checkbox").attr("id", field.domId);
48928       enter.append("span").html(texts[0]).attr("class", "value");
48929       if (field.type === "onewayCheck") {
48930         enter.append("button").attr("class", "reverser" + (reverserHidden() ? " hide" : "")).append("span").attr("class", "reverser-span");
48931       }
48932       label = label.merge(enter);
48933       input = label.selectAll("input");
48934       text = label.selectAll("span.value");
48935       input.on("click", function(d3_event) {
48936         d3_event.stopPropagation();
48937         var t2 = {};
48938         if (Array.isArray(_tags[field.key])) {
48939           if (values.indexOf("yes") !== -1) {
48940             t2[field.key] = "yes";
48941           } else {
48942             t2[field.key] = values[0];
48943           }
48944         } else {
48945           t2[field.key] = values[(values.indexOf(_value) + 1) % values.length];
48946         }
48947         if (t2[field.key] === "reversible" || t2[field.key] === "alternating") {
48948           t2[field.key] = values[0];
48949         }
48950         dispatch14.call("change", this, t2);
48951       });
48952       if (field.type === "onewayCheck") {
48953         reverser = label.selectAll(".reverser");
48954         reverser.call(reverserSetText).on("click", function(d3_event) {
48955           d3_event.preventDefault();
48956           d3_event.stopPropagation();
48957           context.perform(
48958             function(graph) {
48959               for (var i4 in _entityIDs) {
48960                 graph = actionReverse(_entityIDs[i4])(graph);
48961               }
48962               return graph;
48963             },
48964             _t("operations.reverse.annotation.line", { n: 1 })
48965           );
48966           context.validator().validate();
48967           select_default2(this).call(reverserSetText);
48968         });
48969       }
48970     };
48971     check.entityIDs = function(val) {
48972       if (!arguments.length) return _entityIDs;
48973       _entityIDs = val;
48974       return check;
48975     };
48976     check.tags = function(tags) {
48977       _tags = tags;
48978       function isChecked(val) {
48979         return val !== "no" && val !== "" && val !== void 0 && val !== null;
48980       }
48981       function textFor(val) {
48982         if (val === "") val = void 0;
48983         var index = values.indexOf(val);
48984         return index !== -1 ? texts[index] : '"' + val + '"';
48985       }
48986       checkImpliedYes();
48987       var isMixed = Array.isArray(tags[field.key]);
48988       _value = !isMixed && tags[field.key] && tags[field.key].toLowerCase();
48989       if (field.type === "onewayCheck" && (_value === "1" || _value === "-1")) {
48990         _value = "yes";
48991       }
48992       input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value));
48993       text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed);
48994       label.classed("set", !!_value);
48995       if (field.type === "onewayCheck") {
48996         reverser.classed("hide", reverserHidden()).call(reverserSetText);
48997       }
48998     };
48999     check.focus = function() {
49000       input.node().focus();
49001     };
49002     return utilRebind(check, dispatch14, "on");
49003   }
49004
49005   // modules/svg/areas.js
49006   var import_fast_deep_equal5 = __toESM(require_fast_deep_equal());
49007
49008   // modules/svg/helpers.js
49009   function svgPassiveVertex(node, graph, activeID) {
49010     if (!activeID) return 1;
49011     if (activeID === node.id) return 0;
49012     var parents = graph.parentWays(node);
49013     var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3;
49014     for (i3 = 0; i3 < parents.length; i3++) {
49015       nodes = parents[i3].nodes;
49016       isClosed = parents[i3].isClosed();
49017       for (j2 = 0; j2 < nodes.length; j2++) {
49018         if (nodes[j2] === node.id) {
49019           ix1 = j2 - 2;
49020           ix2 = j2 - 1;
49021           ix3 = j2 + 1;
49022           ix4 = j2 + 2;
49023           if (isClosed) {
49024             max3 = nodes.length - 1;
49025             if (ix1 < 0) ix1 = max3 + ix1;
49026             if (ix2 < 0) ix2 = max3 + ix2;
49027             if (ix3 > max3) ix3 = ix3 - max3;
49028             if (ix4 > max3) ix4 = ix4 - max3;
49029           }
49030           if (nodes[ix1] === activeID) return 0;
49031           else if (nodes[ix2] === activeID) return 2;
49032           else if (nodes[ix3] === activeID) return 2;
49033           else if (nodes[ix4] === activeID) return 0;
49034           else if (isClosed && nodes.indexOf(activeID) !== -1) return 0;
49035         }
49036       }
49037     }
49038     return 1;
49039   }
49040   function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) {
49041     return function(entity) {
49042       var i3 = 0;
49043       var offset = dt2;
49044       var segments = [];
49045       var clip = identity_default2().clipExtent(projection2.clipExtent()).stream;
49046       var coordinates = graph.childNodes(entity).map(function(n3) {
49047         return n3.loc;
49048       });
49049       var a2, b2;
49050       if (shouldReverse(entity)) {
49051         coordinates.reverse();
49052       }
49053       stream_default({
49054         type: "LineString",
49055         coordinates
49056       }, projection2.stream(clip({
49057         lineStart: function() {
49058         },
49059         lineEnd: function() {
49060           a2 = null;
49061         },
49062         point: function(x2, y2) {
49063           b2 = [x2, y2];
49064           if (a2) {
49065             var span = geoVecLength(a2, b2) - offset;
49066             if (span >= 0) {
49067               var heading2 = geoVecAngle(a2, b2);
49068               var dx = dt2 * Math.cos(heading2);
49069               var dy = dt2 * Math.sin(heading2);
49070               var p2 = [
49071                 a2[0] + offset * Math.cos(heading2),
49072                 a2[1] + offset * Math.sin(heading2)
49073               ];
49074               var coord2 = [a2, p2];
49075               for (span -= dt2; span >= 0; span -= dt2) {
49076                 p2 = geoVecAdd(p2, [dx, dy]);
49077                 coord2.push(p2);
49078               }
49079               coord2.push(b2);
49080               var segment = "";
49081               var j2;
49082               for (j2 = 0; j2 < coord2.length; j2++) {
49083                 segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49084               }
49085               segments.push({ id: entity.id, index: i3++, d: segment });
49086               if (bothDirections(entity)) {
49087                 segment = "";
49088                 for (j2 = coord2.length - 1; j2 >= 0; j2--) {
49089                   segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49090                 }
49091                 segments.push({ id: entity.id, index: i3++, d: segment });
49092               }
49093             }
49094             offset = -span;
49095           }
49096           a2 = b2;
49097         }
49098       })));
49099       return segments;
49100     };
49101   }
49102   function svgPath(projection2, graph, isArea) {
49103     var cache = {};
49104     var padding = isArea ? 65 : 5;
49105     var viewport = projection2.clipExtent();
49106     var paddedExtent = [
49107       [viewport[0][0] - padding, viewport[0][1] - padding],
49108       [viewport[1][0] + padding, viewport[1][1] + padding]
49109     ];
49110     var clip = identity_default2().clipExtent(paddedExtent).stream;
49111     var project = projection2.stream;
49112     var path = path_default().projection({ stream: function(output) {
49113       return project(clip(output));
49114     } });
49115     var svgpath = function(entity) {
49116       if (entity.id in cache) {
49117         return cache[entity.id];
49118       } else {
49119         return cache[entity.id] = path(entity.asGeoJSON(graph));
49120       }
49121     };
49122     svgpath.geojson = function(d2) {
49123       if (d2.__featurehash__ !== void 0) {
49124         if (d2.__featurehash__ in cache) {
49125           return cache[d2.__featurehash__];
49126         } else {
49127           return cache[d2.__featurehash__] = path(d2);
49128         }
49129       } else {
49130         return path(d2);
49131       }
49132     };
49133     return svgpath;
49134   }
49135   function svgPointTransform(projection2) {
49136     var svgpoint = function(entity) {
49137       var pt2 = projection2(entity.loc);
49138       return "translate(" + pt2[0] + "," + pt2[1] + ")";
49139     };
49140     svgpoint.geojson = function(d2) {
49141       return svgpoint(d2.properties.entity);
49142     };
49143     return svgpoint;
49144   }
49145   function svgRelationMemberTags(graph) {
49146     return function(entity) {
49147       var tags = entity.tags;
49148       var shouldCopyMultipolygonTags = !entity.hasInterestingTags();
49149       graph.parentRelations(entity).forEach(function(relation) {
49150         var type2 = relation.tags.type;
49151         if (type2 === "multipolygon" && shouldCopyMultipolygonTags || type2 === "boundary") {
49152           tags = Object.assign({}, relation.tags, tags);
49153         }
49154       });
49155       return tags;
49156     };
49157   }
49158   function svgSegmentWay(way, graph, activeID) {
49159     if (activeID === void 0) {
49160       return graph.transient(way, "waySegments", getWaySegments);
49161     } else {
49162       return getWaySegments();
49163     }
49164     function getWaySegments() {
49165       var isActiveWay = way.nodes.indexOf(activeID) !== -1;
49166       var features = { passive: [], active: [] };
49167       var start2 = {};
49168       var end = {};
49169       var node, type2;
49170       for (var i3 = 0; i3 < way.nodes.length; i3++) {
49171         node = graph.entity(way.nodes[i3]);
49172         type2 = svgPassiveVertex(node, graph, activeID);
49173         end = { node, type: type2 };
49174         if (start2.type !== void 0) {
49175           if (start2.node.id === activeID || end.node.id === activeID) {
49176           } else if (isActiveWay && (start2.type === 2 || end.type === 2)) {
49177             pushActive(start2, end, i3);
49178           } else if (start2.type === 0 && end.type === 0) {
49179             pushActive(start2, end, i3);
49180           } else {
49181             pushPassive(start2, end, i3);
49182           }
49183         }
49184         start2 = end;
49185       }
49186       return features;
49187       function pushActive(start3, end2, index) {
49188         features.active.push({
49189           type: "Feature",
49190           id: way.id + "-" + index + "-nope",
49191           properties: {
49192             nope: true,
49193             target: true,
49194             entity: way,
49195             nodes: [start3.node, end2.node],
49196             index
49197           },
49198           geometry: {
49199             type: "LineString",
49200             coordinates: [start3.node.loc, end2.node.loc]
49201           }
49202         });
49203       }
49204       function pushPassive(start3, end2, index) {
49205         features.passive.push({
49206           type: "Feature",
49207           id: way.id + "-" + index,
49208           properties: {
49209             target: true,
49210             entity: way,
49211             nodes: [start3.node, end2.node],
49212             index
49213           },
49214           geometry: {
49215             type: "LineString",
49216             coordinates: [start3.node.loc, end2.node.loc]
49217           }
49218         });
49219       }
49220     }
49221   }
49222
49223   // modules/svg/tag_classes.js
49224   function svgTagClasses() {
49225     var primaries = [
49226       "building",
49227       "highway",
49228       "railway",
49229       "waterway",
49230       "aeroway",
49231       "aerialway",
49232       "piste:type",
49233       "boundary",
49234       "power",
49235       "amenity",
49236       "natural",
49237       "landuse",
49238       "leisure",
49239       "military",
49240       "place",
49241       "man_made",
49242       "route",
49243       "attraction",
49244       "roller_coaster",
49245       "building:part",
49246       "indoor"
49247     ];
49248     var statuses = Object.keys(osmLifecyclePrefixes);
49249     var secondaries = [
49250       "oneway",
49251       "bridge",
49252       "tunnel",
49253       "embankment",
49254       "cutting",
49255       "barrier",
49256       "surface",
49257       "tracktype",
49258       "footway",
49259       "crossing",
49260       "service",
49261       "sport",
49262       "public_transport",
49263       "location",
49264       "parking",
49265       "golf",
49266       "type",
49267       "leisure",
49268       "man_made",
49269       "indoor",
49270       "construction",
49271       "proposed"
49272     ];
49273     var _tags = function(entity) {
49274       return entity.tags;
49275     };
49276     var tagClasses = function(selection2) {
49277       selection2.each(function tagClassesEach(entity) {
49278         var value = this.className;
49279         if (value.baseVal !== void 0) {
49280           value = value.baseVal;
49281         }
49282         var t2 = _tags(entity);
49283         var computed = tagClasses.getClassesString(t2, value);
49284         if (computed !== value) {
49285           select_default2(this).attr("class", computed);
49286         }
49287       });
49288     };
49289     tagClasses.getClassesString = function(t2, value) {
49290       var primary, status;
49291       var i3, j2, k2, v2;
49292       var overrideGeometry;
49293       if (/\bstroke\b/.test(value)) {
49294         if (!!t2.barrier && t2.barrier !== "no") {
49295           overrideGeometry = "line";
49296         }
49297       }
49298       var classes = value.trim().split(/\s+/).filter(function(klass) {
49299         return klass.length && !/^tag-/.test(klass);
49300       }).map(function(klass) {
49301         return klass === "line" || klass === "area" ? overrideGeometry || klass : klass;
49302       });
49303       for (i3 = 0; i3 < primaries.length; i3++) {
49304         k2 = primaries[i3];
49305         v2 = t2[k2];
49306         if (!v2 || v2 === "no") continue;
49307         if (k2 === "piste:type") {
49308           k2 = "piste";
49309         } else if (k2 === "building:part") {
49310           k2 = "building_part";
49311         }
49312         primary = k2;
49313         if (statuses.indexOf(v2) !== -1) {
49314           status = v2;
49315           classes.push("tag-" + k2);
49316         } else {
49317           classes.push("tag-" + k2);
49318           classes.push("tag-" + k2 + "-" + v2);
49319         }
49320         break;
49321       }
49322       if (!primary) {
49323         for (i3 = 0; i3 < statuses.length; i3++) {
49324           for (j2 = 0; j2 < primaries.length; j2++) {
49325             k2 = statuses[i3] + ":" + primaries[j2];
49326             v2 = t2[k2];
49327             if (!v2 || v2 === "no") continue;
49328             status = statuses[i3];
49329             break;
49330           }
49331         }
49332       }
49333       if (!status) {
49334         for (i3 = 0; i3 < statuses.length; i3++) {
49335           k2 = statuses[i3];
49336           v2 = t2[k2];
49337           if (!v2 || v2 === "no") continue;
49338           if (v2 === "yes") {
49339             status = k2;
49340           } else if (primary && primary === v2) {
49341             status = k2;
49342           } else if (!primary && primaries.indexOf(v2) !== -1) {
49343             status = k2;
49344             primary = v2;
49345             classes.push("tag-" + v2);
49346           }
49347           if (status) break;
49348         }
49349       }
49350       if (status) {
49351         classes.push("tag-status");
49352         classes.push("tag-status-" + status);
49353       }
49354       for (i3 = 0; i3 < secondaries.length; i3++) {
49355         k2 = secondaries[i3];
49356         v2 = t2[k2];
49357         if (!v2 || v2 === "no" || k2 === primary) continue;
49358         classes.push("tag-" + k2);
49359         classes.push("tag-" + k2 + "-" + v2);
49360       }
49361       if (primary === "highway" && !osmPathHighwayTagValues[t2.highway] || primary === "aeroway") {
49362         var surface = t2.highway === "track" ? "unpaved" : "paved";
49363         for (k2 in t2) {
49364           v2 = t2[k2];
49365           if (k2 in osmPavedTags) {
49366             surface = osmPavedTags[k2][v2] ? "paved" : "unpaved";
49367           }
49368           if (k2 in osmSemipavedTags && !!osmSemipavedTags[k2][v2]) {
49369             surface = "semipaved";
49370           }
49371         }
49372         classes.push("tag-" + surface);
49373       }
49374       var qid = t2.wikidata || t2["flag:wikidata"] || t2["brand:wikidata"] || t2["network:wikidata"] || t2["operator:wikidata"];
49375       if (qid) {
49376         classes.push("tag-wikidata");
49377       }
49378       return classes.filter((klass) => /^[-_a-z0-9]+$/.test(klass)).join(" ").trim();
49379     };
49380     tagClasses.tags = function(val) {
49381       if (!arguments.length) return _tags;
49382       _tags = val;
49383       return tagClasses;
49384     };
49385     return tagClasses;
49386   }
49387
49388   // modules/svg/tag_pattern.js
49389   var patterns = {
49390     // tag - pattern name
49391     // -or-
49392     // tag - value - pattern name
49393     // -or-
49394     // tag - value - rules (optional tag-values, pattern name)
49395     // (matches earlier rules first, so fallback should be last entry)
49396     amenity: {
49397       grave_yard: "cemetery",
49398       fountain: "water_standing"
49399     },
49400     landuse: {
49401       cemetery: [
49402         { religion: "christian", pattern: "cemetery_christian" },
49403         { religion: "buddhist", pattern: "cemetery_buddhist" },
49404         { religion: "muslim", pattern: "cemetery_muslim" },
49405         { religion: "jewish", pattern: "cemetery_jewish" },
49406         { pattern: "cemetery" }
49407       ],
49408       construction: "construction",
49409       farmland: "farmland",
49410       farmyard: "farmyard",
49411       forest: [
49412         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
49413         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
49414         { leaf_type: "leafless", pattern: "forest_leafless" },
49415         { pattern: "forest" }
49416         // same as 'leaf_type:mixed'
49417       ],
49418       grave_yard: "cemetery",
49419       grass: "grass",
49420       landfill: "landfill",
49421       meadow: "meadow",
49422       military: "construction",
49423       orchard: "orchard",
49424       quarry: "quarry",
49425       vineyard: "vineyard"
49426     },
49427     leisure: {
49428       horse_riding: "farmyard"
49429     },
49430     natural: {
49431       beach: "beach",
49432       grassland: "grass",
49433       sand: "beach",
49434       scrub: "scrub",
49435       water: [
49436         { water: "pond", pattern: "pond" },
49437         { water: "reservoir", pattern: "water_standing" },
49438         { pattern: "waves" }
49439       ],
49440       wetland: [
49441         { wetland: "marsh", pattern: "wetland_marsh" },
49442         { wetland: "swamp", pattern: "wetland_swamp" },
49443         { wetland: "bog", pattern: "wetland_bog" },
49444         { wetland: "reedbed", pattern: "wetland_reedbed" },
49445         { pattern: "wetland" }
49446       ],
49447       wood: [
49448         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
49449         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
49450         { leaf_type: "leafless", pattern: "forest_leafless" },
49451         { pattern: "forest" }
49452         // same as 'leaf_type:mixed'
49453       ]
49454     },
49455     golf: {
49456       green: "golf_green",
49457       tee: "grass",
49458       fairway: "grass",
49459       rough: "scrub"
49460     },
49461     surface: {
49462       grass: "grass",
49463       sand: "beach"
49464     }
49465   };
49466   function svgTagPattern(tags) {
49467     if (tags.building && tags.building !== "no") {
49468       return null;
49469     }
49470     for (var tag2 in patterns) {
49471       var entityValue = tags[tag2];
49472       if (!entityValue) continue;
49473       if (typeof patterns[tag2] === "string") {
49474         return "pattern-" + patterns[tag2];
49475       } else {
49476         var values = patterns[tag2];
49477         for (var value in values) {
49478           if (entityValue !== value) continue;
49479           var rules = values[value];
49480           if (typeof rules === "string") {
49481             return "pattern-" + rules;
49482           }
49483           for (var ruleKey in rules) {
49484             var rule = rules[ruleKey];
49485             var pass = true;
49486             for (var criterion in rule) {
49487               if (criterion !== "pattern") {
49488                 var v2 = tags[criterion];
49489                 if (!v2 || v2 !== rule[criterion]) {
49490                   pass = false;
49491                   break;
49492                 }
49493               }
49494             }
49495             if (pass) {
49496               return "pattern-" + rule.pattern;
49497             }
49498           }
49499         }
49500       }
49501     }
49502     return null;
49503   }
49504
49505   // modules/svg/areas.js
49506   function svgAreas(projection2, context) {
49507     function getPatternStyle(tags) {
49508       var imageID = svgTagPattern(tags);
49509       if (imageID) {
49510         return 'url("#ideditor-' + imageID + '")';
49511       }
49512       return "";
49513     }
49514     function drawTargets(selection2, graph, entities, filter2) {
49515       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
49516       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
49517       var getPath = svgPath(projection2).geojson;
49518       var activeID = context.activeID();
49519       var base = context.history().base();
49520       var data = { targets: [], nopes: [] };
49521       entities.forEach(function(way) {
49522         var features = svgSegmentWay(way, graph, activeID);
49523         data.targets.push.apply(data.targets, features.passive);
49524         data.nopes.push.apply(data.nopes, features.active);
49525       });
49526       var targetData = data.targets.filter(getPath);
49527       var targets = selection2.selectAll(".area.target-allowed").filter(function(d2) {
49528         return filter2(d2.properties.entity);
49529       }).data(targetData, function key(d2) {
49530         return d2.id;
49531       });
49532       targets.exit().remove();
49533       var segmentWasEdited = function(d2) {
49534         var wayID = d2.properties.entity.id;
49535         if (!base.entities[wayID] || !(0, import_fast_deep_equal5.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
49536           return false;
49537         }
49538         return d2.properties.nodes.some(function(n3) {
49539           return !base.entities[n3.id] || !(0, import_fast_deep_equal5.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
49540         });
49541       };
49542       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
49543         return "way area target target-allowed " + targetClass + d2.id;
49544       }).classed("segment-edited", segmentWasEdited);
49545       var nopeData = data.nopes.filter(getPath);
49546       var nopes = selection2.selectAll(".area.target-nope").filter(function(d2) {
49547         return filter2(d2.properties.entity);
49548       }).data(nopeData, function key(d2) {
49549         return d2.id;
49550       });
49551       nopes.exit().remove();
49552       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
49553         return "way area target target-nope " + nopeClass + d2.id;
49554       }).classed("segment-edited", segmentWasEdited);
49555     }
49556     function drawAreas(selection2, graph, entities, filter2) {
49557       var path = svgPath(projection2, graph, true);
49558       var areas = {};
49559       var base = context.history().base();
49560       for (var i3 = 0; i3 < entities.length; i3++) {
49561         var entity = entities[i3];
49562         if (entity.geometry(graph) !== "area") continue;
49563         if (!areas[entity.id]) {
49564           areas[entity.id] = {
49565             entity,
49566             area: Math.abs(entity.area(graph))
49567           };
49568         }
49569       }
49570       var fills = Object.values(areas).filter(function hasPath(a2) {
49571         return path(a2.entity);
49572       });
49573       fills.sort(function areaSort(a2, b2) {
49574         return b2.area - a2.area;
49575       });
49576       fills = fills.map(function(a2) {
49577         return a2.entity;
49578       });
49579       var strokes = fills.filter(function(area) {
49580         return area.type === "way";
49581       });
49582       var data = {
49583         clip: fills,
49584         shadow: strokes,
49585         stroke: strokes,
49586         fill: fills
49587       };
49588       var clipPaths = context.surface().selectAll("defs").selectAll(".clipPath-osm").filter(filter2).data(data.clip, osmEntity.key);
49589       clipPaths.exit().remove();
49590       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-osm").attr("id", function(entity2) {
49591         return "ideditor-" + entity2.id + "-clippath";
49592       });
49593       clipPathsEnter.append("path");
49594       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", path);
49595       var drawLayer = selection2.selectAll(".layer-osm.areas");
49596       var touchLayer = selection2.selectAll(".layer-touch.areas");
49597       var areagroup = drawLayer.selectAll("g.areagroup").data(["fill", "shadow", "stroke"]);
49598       areagroup = areagroup.enter().append("g").attr("class", function(d2) {
49599         return "areagroup area-" + d2;
49600       }).merge(areagroup);
49601       var paths = areagroup.selectAll("path").filter(filter2).data(function(layer) {
49602         return data[layer];
49603       }, osmEntity.key);
49604       paths.exit().remove();
49605       var fillpaths = selection2.selectAll(".area-fill path.area").nodes();
49606       var bisect = bisector(function(node) {
49607         return -node.__data__.area(graph);
49608       }).left;
49609       function sortedByArea(entity2) {
49610         if (this._parent.__data__ === "fill") {
49611           return fillpaths[bisect(fillpaths, -entity2.area(graph))];
49612         }
49613       }
49614       paths = paths.enter().insert("path", sortedByArea).merge(paths).each(function(entity2) {
49615         var layer = this.parentNode.__data__;
49616         this.setAttribute("class", entity2.type + " area " + layer + " " + entity2.id);
49617         if (layer === "fill") {
49618           this.setAttribute("clip-path", "url(#ideditor-" + entity2.id + "-clippath)");
49619           this.style.fill = this.style.stroke = getPatternStyle(entity2.tags);
49620         }
49621       }).classed("added", function(d2) {
49622         return !base.entities[d2.id];
49623       }).classed("geometry-edited", function(d2) {
49624         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);
49625       }).classed("retagged", function(d2) {
49626         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);
49627       }).call(svgTagClasses()).attr("d", path);
49628       touchLayer.call(drawTargets, graph, data.stroke, filter2);
49629     }
49630     return drawAreas;
49631   }
49632
49633   // modules/svg/data.js
49634   var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify());
49635
49636   // node_modules/@tmcw/togeojson/dist/togeojson.es.mjs
49637   function $(element, tagName) {
49638     return Array.from(element.getElementsByTagName(tagName));
49639   }
49640   function normalizeId(id2) {
49641     return id2[0] === "#" ? id2 : "#".concat(id2);
49642   }
49643   function $ns(element, tagName, ns) {
49644     return Array.from(element.getElementsByTagNameNS(ns, tagName));
49645   }
49646   function nodeVal(node) {
49647     node == null ? void 0 : node.normalize();
49648     return (node == null ? void 0 : node.textContent) || "";
49649   }
49650   function get1(node, tagName, callback) {
49651     const n3 = node.getElementsByTagName(tagName);
49652     const result = n3.length ? n3[0] : null;
49653     if (result && callback)
49654       callback(result);
49655     return result;
49656   }
49657   function get3(node, tagName, callback) {
49658     const properties = {};
49659     if (!node)
49660       return properties;
49661     const n3 = node.getElementsByTagName(tagName);
49662     const result = n3.length ? n3[0] : null;
49663     if (result && callback) {
49664       return callback(result, properties);
49665     }
49666     return properties;
49667   }
49668   function val1(node, tagName, callback) {
49669     const val = nodeVal(get1(node, tagName));
49670     if (val && callback)
49671       return callback(val) || {};
49672     return {};
49673   }
49674   function $num(node, tagName, callback) {
49675     const val = Number.parseFloat(nodeVal(get1(node, tagName)));
49676     if (Number.isNaN(val))
49677       return void 0;
49678     if (val && callback)
49679       return callback(val) || {};
49680     return {};
49681   }
49682   function num1(node, tagName, callback) {
49683     const val = Number.parseFloat(nodeVal(get1(node, tagName)));
49684     if (Number.isNaN(val))
49685       return void 0;
49686     if (callback)
49687       callback(val);
49688     return val;
49689   }
49690   function getMulti(node, propertyNames) {
49691     const properties = {};
49692     for (const property of propertyNames) {
49693       val1(node, property, (val) => {
49694         properties[property] = val;
49695       });
49696     }
49697     return properties;
49698   }
49699   function isElement(node) {
49700     return (node == null ? void 0 : node.nodeType) === 1;
49701   }
49702   function getExtensions(node) {
49703     let values = [];
49704     if (node === null)
49705       return values;
49706     for (const child of Array.from(node.childNodes)) {
49707       if (!isElement(child))
49708         continue;
49709       const name = abbreviateName(child.nodeName);
49710       if (name === "gpxtpx:TrackPointExtension") {
49711         values = values.concat(getExtensions(child));
49712       } else {
49713         const val = nodeVal(child);
49714         values.push([name, parseNumeric(val)]);
49715       }
49716     }
49717     return values;
49718   }
49719   function abbreviateName(name) {
49720     return ["heart", "gpxtpx:hr", "hr"].includes(name) ? "heart" : name;
49721   }
49722   function parseNumeric(val) {
49723     const num = Number.parseFloat(val);
49724     return Number.isNaN(num) ? val : num;
49725   }
49726   function coordPair$1(node) {
49727     const ll = [
49728       Number.parseFloat(node.getAttribute("lon") || ""),
49729       Number.parseFloat(node.getAttribute("lat") || "")
49730     ];
49731     if (Number.isNaN(ll[0]) || Number.isNaN(ll[1])) {
49732       return null;
49733     }
49734     num1(node, "ele", (val) => {
49735       ll.push(val);
49736     });
49737     const time = get1(node, "time");
49738     return {
49739       coordinates: ll,
49740       time: time ? nodeVal(time) : null,
49741       extendedValues: getExtensions(get1(node, "extensions"))
49742     };
49743   }
49744   function getLineStyle(node) {
49745     return get3(node, "line", (lineStyle) => {
49746       const val = Object.assign({}, val1(lineStyle, "color", (color2) => {
49747         return { stroke: "#".concat(color2) };
49748       }), $num(lineStyle, "opacity", (opacity) => {
49749         return { "stroke-opacity": opacity };
49750       }), $num(lineStyle, "width", (width) => {
49751         return { "stroke-width": width * 96 / 25.4 };
49752       }));
49753       return val;
49754     });
49755   }
49756   function extractProperties(ns, node) {
49757     var _a4;
49758     const properties = getMulti(node, [
49759       "name",
49760       "cmt",
49761       "desc",
49762       "type",
49763       "time",
49764       "keywords"
49765     ]);
49766     for (const [n3, url] of ns) {
49767       for (const child of Array.from(node.getElementsByTagNameNS(url, "*"))) {
49768         properties[child.tagName.replace(":", "_")] = (_a4 = nodeVal(child)) == null ? void 0 : _a4.trim();
49769       }
49770     }
49771     const links = $(node, "link");
49772     if (links.length) {
49773       properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"])));
49774     }
49775     return properties;
49776   }
49777   function getPoints$1(node, pointname) {
49778     const pts = $(node, pointname);
49779     const line = [];
49780     const times = [];
49781     const extendedValues = {};
49782     for (let i3 = 0; i3 < pts.length; i3++) {
49783       const c2 = coordPair$1(pts[i3]);
49784       if (!c2) {
49785         continue;
49786       }
49787       line.push(c2.coordinates);
49788       if (c2.time)
49789         times.push(c2.time);
49790       for (const [name, val] of c2.extendedValues) {
49791         const plural = name === "heart" ? name : "".concat(name.replace("gpxtpx:", ""), "s");
49792         if (!extendedValues[plural]) {
49793           extendedValues[plural] = Array(pts.length).fill(null);
49794         }
49795         extendedValues[plural][i3] = val;
49796       }
49797     }
49798     if (line.length < 2)
49799       return;
49800     return {
49801       line,
49802       times,
49803       extendedValues
49804     };
49805   }
49806   function getRoute(ns, node) {
49807     const line = getPoints$1(node, "rtept");
49808     if (!line)
49809       return;
49810     return {
49811       type: "Feature",
49812       properties: Object.assign({ _gpxType: "rte" }, extractProperties(ns, node), getLineStyle(get1(node, "extensions"))),
49813       geometry: {
49814         type: "LineString",
49815         coordinates: line.line
49816       }
49817     };
49818   }
49819   function getTrack(ns, node) {
49820     var _a4;
49821     const segments = $(node, "trkseg");
49822     const track = [];
49823     const times = [];
49824     const extractedLines = [];
49825     for (const segment of segments) {
49826       const line = getPoints$1(segment, "trkpt");
49827       if (line) {
49828         extractedLines.push(line);
49829         if ((_a4 = line.times) == null ? void 0 : _a4.length)
49830           times.push(line.times);
49831       }
49832     }
49833     if (extractedLines.length === 0)
49834       return null;
49835     const multi = extractedLines.length > 1;
49836     const properties = Object.assign({ _gpxType: "trk" }, extractProperties(ns, node), getLineStyle(get1(node, "extensions")), times.length ? {
49837       coordinateProperties: {
49838         times: multi ? times : times[0]
49839       }
49840     } : {});
49841     for (const line of extractedLines) {
49842       track.push(line.line);
49843       if (!properties.coordinateProperties) {
49844         properties.coordinateProperties = {};
49845       }
49846       const props = properties.coordinateProperties;
49847       const entries = Object.entries(line.extendedValues);
49848       for (let i3 = 0; i3 < entries.length; i3++) {
49849         const [name, val] = entries[i3];
49850         if (multi) {
49851           if (!props[name]) {
49852             props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
49853           }
49854           props[name][i3] = val;
49855         } else {
49856           props[name] = val;
49857         }
49858       }
49859     }
49860     return {
49861       type: "Feature",
49862       properties,
49863       geometry: multi ? {
49864         type: "MultiLineString",
49865         coordinates: track
49866       } : {
49867         type: "LineString",
49868         coordinates: track[0]
49869       }
49870     };
49871   }
49872   function getPoint(ns, node) {
49873     const properties = Object.assign(extractProperties(ns, node), getMulti(node, ["sym"]));
49874     const pair3 = coordPair$1(node);
49875     if (!pair3)
49876       return null;
49877     return {
49878       type: "Feature",
49879       properties,
49880       geometry: {
49881         type: "Point",
49882         coordinates: pair3.coordinates
49883       }
49884     };
49885   }
49886   function* gpxGen(node) {
49887     var _a4, _b3;
49888     const GPXX = "gpxx";
49889     const GPXX_URI = "http://www.garmin.com/xmlschemas/GpxExtensions/v3";
49890     const ns = [[GPXX, GPXX_URI]];
49891     const attrs = (_a4 = node.getElementsByTagName("gpx")[0]) == null ? void 0 : _a4.attributes;
49892     if (attrs) {
49893       for (const attr of Array.from(attrs)) {
49894         if (((_b3 = attr.name) == null ? void 0 : _b3.startsWith("xmlns:")) && attr.value !== GPXX_URI) {
49895           ns.push([attr.name, attr.value]);
49896         }
49897       }
49898     }
49899     for (const track of $(node, "trk")) {
49900       const feature3 = getTrack(ns, track);
49901       if (feature3)
49902         yield feature3;
49903     }
49904     for (const route of $(node, "rte")) {
49905       const feature3 = getRoute(ns, route);
49906       if (feature3)
49907         yield feature3;
49908     }
49909     for (const waypoint of $(node, "wpt")) {
49910       const point = getPoint(ns, waypoint);
49911       if (point)
49912         yield point;
49913     }
49914   }
49915   function gpx(node) {
49916     return {
49917       type: "FeatureCollection",
49918       features: Array.from(gpxGen(node))
49919     };
49920   }
49921   function fixColor(v2, prefix) {
49922     const properties = {};
49923     const colorProp = prefix === "stroke" || prefix === "fill" ? prefix : "".concat(prefix, "-color");
49924     if (v2[0] === "#") {
49925       v2 = v2.substring(1);
49926     }
49927     if (v2.length === 6 || v2.length === 3) {
49928       properties[colorProp] = "#".concat(v2);
49929     } else if (v2.length === 8) {
49930       properties["".concat(prefix, "-opacity")] = Number.parseInt(v2.substring(0, 2), 16) / 255;
49931       properties[colorProp] = "#".concat(v2.substring(6, 8)).concat(v2.substring(4, 6)).concat(v2.substring(2, 4));
49932     }
49933     return properties;
49934   }
49935   function numericProperty(node, source, target) {
49936     const properties = {};
49937     num1(node, source, (val) => {
49938       properties[target] = val;
49939     });
49940     return properties;
49941   }
49942   function getColor(node, output) {
49943     return get3(node, "color", (elem) => fixColor(nodeVal(elem), output));
49944   }
49945   function extractIconHref(node) {
49946     return get3(node, "Icon", (icon2, properties) => {
49947       val1(icon2, "href", (href) => {
49948         properties.icon = href;
49949       });
49950       return properties;
49951     });
49952   }
49953   function extractIcon(node) {
49954     return get3(node, "IconStyle", (iconStyle) => {
49955       return Object.assign(getColor(iconStyle, "icon"), numericProperty(iconStyle, "scale", "icon-scale"), numericProperty(iconStyle, "heading", "icon-heading"), get3(iconStyle, "hotSpot", (hotspot) => {
49956         const left = Number.parseFloat(hotspot.getAttribute("x") || "");
49957         const top = Number.parseFloat(hotspot.getAttribute("y") || "");
49958         const xunits = hotspot.getAttribute("xunits") || "";
49959         const yunits = hotspot.getAttribute("yunits") || "";
49960         if (!Number.isNaN(left) && !Number.isNaN(top))
49961           return {
49962             "icon-offset": [left, top],
49963             "icon-offset-units": [xunits, yunits]
49964           };
49965         return {};
49966       }), extractIconHref(iconStyle));
49967     });
49968   }
49969   function extractLabel(node) {
49970     return get3(node, "LabelStyle", (labelStyle) => {
49971       return Object.assign(getColor(labelStyle, "label"), numericProperty(labelStyle, "scale", "label-scale"));
49972     });
49973   }
49974   function extractLine(node) {
49975     return get3(node, "LineStyle", (lineStyle) => {
49976       return Object.assign(getColor(lineStyle, "stroke"), numericProperty(lineStyle, "width", "stroke-width"));
49977     });
49978   }
49979   function extractPoly(node) {
49980     return get3(node, "PolyStyle", (polyStyle, properties) => {
49981       return Object.assign(properties, get3(polyStyle, "color", (elem) => fixColor(nodeVal(elem), "fill")), val1(polyStyle, "fill", (fill) => {
49982         if (fill === "0")
49983           return { "fill-opacity": 0 };
49984       }), val1(polyStyle, "outline", (outline) => {
49985         if (outline === "0")
49986           return { "stroke-opacity": 0 };
49987       }));
49988     });
49989   }
49990   function extractStyle(node) {
49991     return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node));
49992   }
49993   var removeSpace = /\s*/g;
49994   var trimSpace = /^\s*|\s*$/g;
49995   var splitSpace = /\s+/;
49996   function coord1(value) {
49997     return value.replace(removeSpace, "").split(",").map(Number.parseFloat).filter((num) => !Number.isNaN(num)).slice(0, 3);
49998   }
49999   function coord(value) {
50000     return value.replace(trimSpace, "").split(splitSpace).map(coord1).filter((coord2) => {
50001       return coord2.length >= 2;
50002     });
50003   }
50004   function gxCoords(node) {
50005     let elems = $(node, "coord");
50006     if (elems.length === 0) {
50007       elems = $ns(node, "coord", "*");
50008     }
50009     const coordinates = elems.map((elem) => {
50010       return nodeVal(elem).split(" ").map(Number.parseFloat);
50011     });
50012     if (coordinates.length === 0) {
50013       return null;
50014     }
50015     return {
50016       geometry: coordinates.length > 2 ? {
50017         type: "LineString",
50018         coordinates
50019       } : {
50020         type: "Point",
50021         coordinates: coordinates[0]
50022       },
50023       times: $(node, "when").map((elem) => nodeVal(elem))
50024     };
50025   }
50026   function fixRing(ring) {
50027     if (ring.length === 0)
50028       return ring;
50029     const first = ring[0];
50030     const last = ring[ring.length - 1];
50031     let equal = true;
50032     for (let i3 = 0; i3 < Math.max(first.length, last.length); i3++) {
50033       if (first[i3] !== last[i3]) {
50034         equal = false;
50035         break;
50036       }
50037     }
50038     if (!equal) {
50039       return ring.concat([ring[0]]);
50040     }
50041     return ring;
50042   }
50043   function getCoordinates(node) {
50044     return nodeVal(get1(node, "coordinates"));
50045   }
50046   function getGeometry(node) {
50047     let geometries = [];
50048     let coordTimes = [];
50049     for (let i3 = 0; i3 < node.childNodes.length; i3++) {
50050       const child = node.childNodes.item(i3);
50051       if (isElement(child)) {
50052         switch (child.tagName) {
50053           case "MultiGeometry":
50054           case "MultiTrack":
50055           case "gx:MultiTrack": {
50056             const childGeometries = getGeometry(child);
50057             geometries = geometries.concat(childGeometries.geometries);
50058             coordTimes = coordTimes.concat(childGeometries.coordTimes);
50059             break;
50060           }
50061           case "Point": {
50062             const coordinates = coord1(getCoordinates(child));
50063             if (coordinates.length >= 2) {
50064               geometries.push({
50065                 type: "Point",
50066                 coordinates
50067               });
50068             }
50069             break;
50070           }
50071           case "LinearRing":
50072           case "LineString": {
50073             const coordinates = coord(getCoordinates(child));
50074             if (coordinates.length >= 2) {
50075               geometries.push({
50076                 type: "LineString",
50077                 coordinates
50078               });
50079             }
50080             break;
50081           }
50082           case "Polygon": {
50083             const coords = [];
50084             for (const linearRing of $(child, "LinearRing")) {
50085               const ring = fixRing(coord(getCoordinates(linearRing)));
50086               if (ring.length >= 4) {
50087                 coords.push(ring);
50088               }
50089             }
50090             if (coords.length) {
50091               geometries.push({
50092                 type: "Polygon",
50093                 coordinates: coords
50094               });
50095             }
50096             break;
50097           }
50098           case "Track":
50099           case "gx:Track": {
50100             const gx = gxCoords(child);
50101             if (!gx)
50102               break;
50103             const { times, geometry } = gx;
50104             geometries.push(geometry);
50105             if (times.length)
50106               coordTimes.push(times);
50107             break;
50108           }
50109         }
50110       }
50111     }
50112     return {
50113       geometries,
50114       coordTimes
50115     };
50116   }
50117   var toNumber2 = (x2) => Number(x2);
50118   var typeConverters = {
50119     string: (x2) => x2,
50120     int: toNumber2,
50121     uint: toNumber2,
50122     short: toNumber2,
50123     ushort: toNumber2,
50124     float: toNumber2,
50125     double: toNumber2,
50126     bool: (x2) => Boolean(x2)
50127   };
50128   function extractExtendedData(node, schema) {
50129     return get3(node, "ExtendedData", (extendedData, properties) => {
50130       for (const data of $(extendedData, "Data")) {
50131         properties[data.getAttribute("name") || ""] = nodeVal(get1(data, "value"));
50132       }
50133       for (const simpleData of $(extendedData, "SimpleData")) {
50134         const name = simpleData.getAttribute("name") || "";
50135         const typeConverter = schema[name] || typeConverters.string;
50136         properties[name] = typeConverter(nodeVal(simpleData));
50137       }
50138       return properties;
50139     });
50140   }
50141   function getMaybeHTMLDescription(node) {
50142     const descriptionNode = get1(node, "description");
50143     for (const c2 of Array.from((descriptionNode == null ? void 0 : descriptionNode.childNodes) || [])) {
50144       if (c2.nodeType === 4) {
50145         return {
50146           description: {
50147             "@type": "html",
50148             value: nodeVal(c2)
50149           }
50150         };
50151       }
50152     }
50153     return {};
50154   }
50155   function extractTimeSpan(node) {
50156     return get3(node, "TimeSpan", (timeSpan) => {
50157       return {
50158         timespan: {
50159           begin: nodeVal(get1(timeSpan, "begin")),
50160           end: nodeVal(get1(timeSpan, "end"))
50161         }
50162       };
50163     });
50164   }
50165   function extractTimeStamp(node) {
50166     return get3(node, "TimeStamp", (timeStamp) => {
50167       return { timestamp: nodeVal(get1(timeStamp, "when")) };
50168     });
50169   }
50170   function extractCascadedStyle(node, styleMap) {
50171     return val1(node, "styleUrl", (styleUrl) => {
50172       styleUrl = normalizeId(styleUrl);
50173       if (styleMap[styleUrl]) {
50174         return Object.assign({ styleUrl }, styleMap[styleUrl]);
50175       }
50176       return { styleUrl };
50177     });
50178   }
50179   function getGroundOverlayBox(node) {
50180     const latLonQuad = get1(node, "gx:LatLonQuad");
50181     if (latLonQuad) {
50182       const ring = fixRing(coord(getCoordinates(node)));
50183       return {
50184         geometry: {
50185           type: "Polygon",
50186           coordinates: [ring]
50187         }
50188       };
50189     }
50190     return getLatLonBox(node);
50191   }
50192   var DEGREES_TO_RADIANS = Math.PI / 180;
50193   function rotateBox(bbox2, coordinates, rotation) {
50194     const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2];
50195     return [
50196       coordinates[0].map((coordinate) => {
50197         const dy = coordinate[1] - center[1];
50198         const dx = coordinate[0] - center[0];
50199         const distance = Math.sqrt(dy ** 2 + dx ** 2);
50200         const angle2 = Math.atan2(dy, dx) + rotation * DEGREES_TO_RADIANS;
50201         return [
50202           center[0] + Math.cos(angle2) * distance,
50203           center[1] + Math.sin(angle2) * distance
50204         ];
50205       })
50206     ];
50207   }
50208   function getLatLonBox(node) {
50209     const latLonBox = get1(node, "LatLonBox");
50210     if (latLonBox) {
50211       const north = num1(latLonBox, "north");
50212       const west = num1(latLonBox, "west");
50213       const east = num1(latLonBox, "east");
50214       const south = num1(latLonBox, "south");
50215       const rotation = num1(latLonBox, "rotation");
50216       if (typeof north === "number" && typeof south === "number" && typeof west === "number" && typeof east === "number") {
50217         const bbox2 = [west, south, east, north];
50218         let coordinates = [
50219           [
50220             [west, north],
50221             // top left
50222             [east, north],
50223             // top right
50224             [east, south],
50225             // top right
50226             [west, south],
50227             // bottom left
50228             [west, north]
50229             // top left (again)
50230           ]
50231         ];
50232         if (typeof rotation === "number") {
50233           coordinates = rotateBox(bbox2, coordinates, rotation);
50234         }
50235         return {
50236           bbox: bbox2,
50237           geometry: {
50238             type: "Polygon",
50239             coordinates
50240           }
50241         };
50242       }
50243     }
50244     return null;
50245   }
50246   function getGroundOverlay(node, styleMap, schema, options2) {
50247     var _a4;
50248     const box = getGroundOverlayBox(node);
50249     const geometry = (box == null ? void 0 : box.geometry) || null;
50250     if (!geometry && options2.skipNullGeometry) {
50251       return null;
50252     }
50253     const feature3 = {
50254       type: "Feature",
50255       geometry,
50256       properties: Object.assign(
50257         /**
50258          * Related to
50259          * https://gist.github.com/tmcw/037a1cb6660d74a392e9da7446540f46
50260          */
50261         { "@geometry-type": "groundoverlay" },
50262         getMulti(node, [
50263           "name",
50264           "address",
50265           "visibility",
50266           "open",
50267           "phoneNumber",
50268           "description"
50269         ]),
50270         getMaybeHTMLDescription(node),
50271         extractCascadedStyle(node, styleMap),
50272         extractStyle(node),
50273         extractIconHref(node),
50274         extractExtendedData(node, schema),
50275         extractTimeSpan(node),
50276         extractTimeStamp(node)
50277       )
50278     };
50279     if (box == null ? void 0 : box.bbox) {
50280       feature3.bbox = box.bbox;
50281     }
50282     if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) {
50283       feature3.properties.visibility = feature3.properties.visibility !== "0";
50284     }
50285     const id2 = node.getAttribute("id");
50286     if (id2 !== null && id2 !== "")
50287       feature3.id = id2;
50288     return feature3;
50289   }
50290   function geometryListToGeometry(geometries) {
50291     return geometries.length === 0 ? null : geometries.length === 1 ? geometries[0] : {
50292       type: "GeometryCollection",
50293       geometries
50294     };
50295   }
50296   function getPlacemark(node, styleMap, schema, options2) {
50297     var _a4;
50298     const { coordTimes, geometries } = getGeometry(node);
50299     const geometry = geometryListToGeometry(geometries);
50300     if (!geometry && options2.skipNullGeometry) {
50301       return null;
50302     }
50303     const feature3 = {
50304       type: "Feature",
50305       geometry,
50306       properties: Object.assign(getMulti(node, [
50307         "name",
50308         "address",
50309         "visibility",
50310         "open",
50311         "phoneNumber",
50312         "description"
50313       ]), getMaybeHTMLDescription(node), extractCascadedStyle(node, styleMap), extractStyle(node), extractExtendedData(node, schema), extractTimeSpan(node), extractTimeStamp(node), coordTimes.length ? {
50314         coordinateProperties: {
50315           times: coordTimes.length === 1 ? coordTimes[0] : coordTimes
50316         }
50317       } : {})
50318     };
50319     if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) {
50320       feature3.properties.visibility = feature3.properties.visibility !== "0";
50321     }
50322     const id2 = node.getAttribute("id");
50323     if (id2 !== null && id2 !== "")
50324       feature3.id = id2;
50325     return feature3;
50326   }
50327   function getStyleId(style) {
50328     let id2 = style.getAttribute("id");
50329     const parentNode = style.parentNode;
50330     if (!id2 && isElement(parentNode) && parentNode.localName === "CascadingStyle") {
50331       id2 = parentNode.getAttribute("kml:id") || parentNode.getAttribute("id");
50332     }
50333     return normalizeId(id2 || "");
50334   }
50335   function buildStyleMap(node) {
50336     const styleMap = {};
50337     for (const style of $(node, "Style")) {
50338       styleMap[getStyleId(style)] = extractStyle(style);
50339     }
50340     for (const map2 of $(node, "StyleMap")) {
50341       const id2 = normalizeId(map2.getAttribute("id") || "");
50342       val1(map2, "styleUrl", (styleUrl) => {
50343         styleUrl = normalizeId(styleUrl);
50344         if (styleMap[styleUrl]) {
50345           styleMap[id2] = styleMap[styleUrl];
50346         }
50347       });
50348     }
50349     return styleMap;
50350   }
50351   function buildSchema(node) {
50352     const schema = {};
50353     for (const field of $(node, "SimpleField")) {
50354       schema[field.getAttribute("name") || ""] = typeConverters[field.getAttribute("type") || ""] || typeConverters.string;
50355     }
50356     return schema;
50357   }
50358   function* kmlGen(node, options2 = {
50359     skipNullGeometry: false
50360   }) {
50361     const styleMap = buildStyleMap(node);
50362     const schema = buildSchema(node);
50363     for (const placemark of $(node, "Placemark")) {
50364       const feature3 = getPlacemark(placemark, styleMap, schema, options2);
50365       if (feature3)
50366         yield feature3;
50367     }
50368     for (const groundOverlay of $(node, "GroundOverlay")) {
50369       const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2);
50370       if (feature3)
50371         yield feature3;
50372     }
50373   }
50374   function kml(node, options2 = {
50375     skipNullGeometry: false
50376   }) {
50377     return {
50378       type: "FeatureCollection",
50379       features: Array.from(kmlGen(node, options2))
50380     };
50381   }
50382
50383   // modules/svg/data.js
50384   var _initialized = false;
50385   var _enabled = false;
50386   var _geojson;
50387   function svgData(projection2, context, dispatch14) {
50388     var throttledRedraw = throttle_default(function() {
50389       dispatch14.call("change");
50390     }, 1e3);
50391     var _showLabels = true;
50392     var detected = utilDetect();
50393     var layer = select_default2(null);
50394     var _vtService;
50395     var _fileList;
50396     var _template;
50397     var _src;
50398     const supportedFormats = [
50399       ".gpx",
50400       ".kml",
50401       ".geojson",
50402       ".json"
50403     ];
50404     function init2() {
50405       if (_initialized) return;
50406       _geojson = {};
50407       _enabled = true;
50408       function over(d3_event) {
50409         d3_event.stopPropagation();
50410         d3_event.preventDefault();
50411         d3_event.dataTransfer.dropEffect = "copy";
50412       }
50413       context.container().attr("dropzone", "copy").on("drop.svgData", function(d3_event) {
50414         d3_event.stopPropagation();
50415         d3_event.preventDefault();
50416         if (!detected.filedrop) return;
50417         var f2 = d3_event.dataTransfer.files[0];
50418         var extension = getExtension(f2.name);
50419         if (!supportedFormats.includes(extension)) return;
50420         drawData.fileList(d3_event.dataTransfer.files);
50421       }).on("dragenter.svgData", over).on("dragexit.svgData", over).on("dragover.svgData", over);
50422       _initialized = true;
50423     }
50424     function getService() {
50425       if (services.vectorTile && !_vtService) {
50426         _vtService = services.vectorTile;
50427         _vtService.event.on("loadedData", throttledRedraw);
50428       } else if (!services.vectorTile && _vtService) {
50429         _vtService = null;
50430       }
50431       return _vtService;
50432     }
50433     function showLayer() {
50434       layerOn();
50435       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
50436         dispatch14.call("change");
50437       });
50438     }
50439     function hideLayer() {
50440       throttledRedraw.cancel();
50441       layer.transition().duration(250).style("opacity", 0).on("end", layerOff);
50442     }
50443     function layerOn() {
50444       layer.style("display", "block");
50445     }
50446     function layerOff() {
50447       layer.selectAll(".viewfield-group").remove();
50448       layer.style("display", "none");
50449     }
50450     function ensureIDs(gj) {
50451       if (!gj) return null;
50452       if (gj.type === "FeatureCollection") {
50453         for (var i3 = 0; i3 < gj.features.length; i3++) {
50454           ensureFeatureID(gj.features[i3]);
50455         }
50456       } else {
50457         ensureFeatureID(gj);
50458       }
50459       return gj;
50460     }
50461     function ensureFeatureID(feature3) {
50462       if (!feature3) return;
50463       feature3.__featurehash__ = utilHashcode((0, import_fast_json_stable_stringify.default)(feature3));
50464       return feature3;
50465     }
50466     function getFeatures(gj) {
50467       if (!gj) return [];
50468       if (gj.type === "FeatureCollection") {
50469         return gj.features;
50470       } else {
50471         return [gj];
50472       }
50473     }
50474     function featureKey(d2) {
50475       return d2.__featurehash__;
50476     }
50477     function isPolygon(d2) {
50478       return d2.geometry.type === "Polygon" || d2.geometry.type === "MultiPolygon";
50479     }
50480     function clipPathID(d2) {
50481       return "ideditor-data-" + d2.__featurehash__ + "-clippath";
50482     }
50483     function featureClasses(d2) {
50484       return [
50485         "data" + d2.__featurehash__,
50486         d2.geometry.type,
50487         isPolygon(d2) ? "area" : "",
50488         d2.__layerID__ || ""
50489       ].filter(Boolean).join(" ");
50490     }
50491     function drawData(selection2) {
50492       var vtService = getService();
50493       var getPath = svgPath(projection2).geojson;
50494       var getAreaPath = svgPath(projection2, null, true).geojson;
50495       var hasData = drawData.hasData();
50496       layer = selection2.selectAll(".layer-mapdata").data(_enabled && hasData ? [0] : []);
50497       layer.exit().remove();
50498       layer = layer.enter().append("g").attr("class", "layer-mapdata").merge(layer);
50499       var surface = context.surface();
50500       if (!surface || surface.empty()) return;
50501       var geoData, polygonData;
50502       if (_template && vtService) {
50503         var sourceID = _template;
50504         vtService.loadTiles(sourceID, _template, projection2);
50505         geoData = vtService.data(sourceID, projection2);
50506       } else {
50507         geoData = getFeatures(_geojson);
50508       }
50509       geoData = geoData.filter(getPath);
50510       polygonData = geoData.filter(isPolygon);
50511       var clipPaths = surface.selectAll("defs").selectAll(".clipPath-data").data(polygonData, featureKey);
50512       clipPaths.exit().remove();
50513       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-data").attr("id", clipPathID);
50514       clipPathsEnter.append("path");
50515       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", getAreaPath);
50516       var datagroups = layer.selectAll("g.datagroup").data(["fill", "shadow", "stroke"]);
50517       datagroups = datagroups.enter().append("g").attr("class", function(d2) {
50518         return "datagroup datagroup-" + d2;
50519       }).merge(datagroups);
50520       var pathData = {
50521         fill: polygonData,
50522         shadow: geoData,
50523         stroke: geoData
50524       };
50525       var paths = datagroups.selectAll("path").data(function(layer2) {
50526         return pathData[layer2];
50527       }, featureKey);
50528       paths.exit().remove();
50529       paths = paths.enter().append("path").attr("class", function(d2) {
50530         var datagroup = this.parentNode.__data__;
50531         return "pathdata " + datagroup + " " + featureClasses(d2);
50532       }).attr("clip-path", function(d2) {
50533         var datagroup = this.parentNode.__data__;
50534         return datagroup === "fill" ? "url(#" + clipPathID(d2) + ")" : null;
50535       }).merge(paths).attr("d", function(d2) {
50536         var datagroup = this.parentNode.__data__;
50537         return datagroup === "fill" ? getAreaPath(d2) : getPath(d2);
50538       });
50539       layer.call(drawLabels, "label-halo", geoData).call(drawLabels, "label", geoData);
50540       function drawLabels(selection3, textClass, data) {
50541         var labelPath = path_default(projection2);
50542         var labelData = data.filter(function(d2) {
50543           return _showLabels && d2.properties && (d2.properties.desc || d2.properties.name);
50544         });
50545         var labels = selection3.selectAll("text." + textClass).data(labelData, featureKey);
50546         labels.exit().remove();
50547         labels = labels.enter().append("text").attr("class", function(d2) {
50548           return textClass + " " + featureClasses(d2);
50549         }).merge(labels).text(function(d2) {
50550           return d2.properties.desc || d2.properties.name;
50551         }).attr("x", function(d2) {
50552           var centroid = labelPath.centroid(d2);
50553           return centroid[0] + 11;
50554         }).attr("y", function(d2) {
50555           var centroid = labelPath.centroid(d2);
50556           return centroid[1];
50557         });
50558       }
50559     }
50560     function getExtension(fileName) {
50561       if (!fileName) return;
50562       var re3 = /\.(gpx|kml|(geo)?json|png)$/i;
50563       var match = fileName.toLowerCase().match(re3);
50564       return match && match.length && match[0];
50565     }
50566     function xmlToDom(textdata) {
50567       return new DOMParser().parseFromString(textdata, "text/xml");
50568     }
50569     function stringifyGeojsonProperties(feature3) {
50570       const properties = feature3.properties;
50571       for (const key in properties) {
50572         const property = properties[key];
50573         if (typeof property === "number" || typeof property === "boolean" || Array.isArray(property)) {
50574           properties[key] = property.toString();
50575         } else if (property === null) {
50576           properties[key] = "null";
50577         } else if (typeof property === "object") {
50578           properties[key] = JSON.stringify(property);
50579         }
50580       }
50581     }
50582     drawData.setFile = function(extension, data) {
50583       _template = null;
50584       _fileList = null;
50585       _geojson = null;
50586       _src = null;
50587       var gj;
50588       switch (extension) {
50589         case ".gpx":
50590           gj = gpx(xmlToDom(data));
50591           break;
50592         case ".kml":
50593           gj = kml(xmlToDom(data));
50594           break;
50595         case ".geojson":
50596         case ".json":
50597           gj = JSON.parse(data);
50598           if (gj.type === "FeatureCollection") {
50599             gj.features.forEach(stringifyGeojsonProperties);
50600           } else if (gj.type === "Feature") {
50601             stringifyGeojsonProperties(gj);
50602           }
50603           break;
50604       }
50605       gj = gj || {};
50606       if (Object.keys(gj).length) {
50607         _geojson = ensureIDs(gj);
50608         _src = extension + " data file";
50609         this.fitZoom();
50610       }
50611       dispatch14.call("change");
50612       return this;
50613     };
50614     drawData.showLabels = function(val) {
50615       if (!arguments.length) return _showLabels;
50616       _showLabels = val;
50617       return this;
50618     };
50619     drawData.enabled = function(val) {
50620       if (!arguments.length) return _enabled;
50621       _enabled = val;
50622       if (_enabled) {
50623         showLayer();
50624       } else {
50625         hideLayer();
50626       }
50627       dispatch14.call("change");
50628       return this;
50629     };
50630     drawData.hasData = function() {
50631       var gj = _geojson || {};
50632       return !!(_template || Object.keys(gj).length);
50633     };
50634     drawData.template = function(val, src) {
50635       if (!arguments.length) return _template;
50636       var osm = context.connection();
50637       if (osm) {
50638         var blocklists = osm.imageryBlocklists();
50639         var fail = false;
50640         var tested = 0;
50641         var regex;
50642         for (var i3 = 0; i3 < blocklists.length; i3++) {
50643           regex = blocklists[i3];
50644           fail = regex.test(val);
50645           tested++;
50646           if (fail) break;
50647         }
50648         if (!tested) {
50649           regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
50650           fail = regex.test(val);
50651         }
50652       }
50653       _template = val;
50654       _fileList = null;
50655       _geojson = null;
50656       _src = src || "vectortile:" + val.split(/[?#]/)[0];
50657       dispatch14.call("change");
50658       return this;
50659     };
50660     drawData.geojson = function(gj, src) {
50661       if (!arguments.length) return _geojson;
50662       _template = null;
50663       _fileList = null;
50664       _geojson = null;
50665       _src = null;
50666       gj = gj || {};
50667       if (Object.keys(gj).length) {
50668         _geojson = ensureIDs(gj);
50669         _src = src || "unknown.geojson";
50670       }
50671       dispatch14.call("change");
50672       return this;
50673     };
50674     drawData.fileList = function(fileList) {
50675       if (!arguments.length) return _fileList;
50676       _template = null;
50677       _geojson = null;
50678       _src = null;
50679       _fileList = fileList;
50680       if (!fileList || !fileList.length) return this;
50681       var f2 = fileList[0];
50682       var extension = getExtension(f2.name);
50683       var reader = new FileReader();
50684       reader.onload = /* @__PURE__ */ function() {
50685         return function(e3) {
50686           drawData.setFile(extension, e3.target.result);
50687         };
50688       }(f2);
50689       reader.readAsText(f2);
50690       return this;
50691     };
50692     drawData.url = function(url, defaultExtension) {
50693       _template = null;
50694       _fileList = null;
50695       _geojson = null;
50696       _src = null;
50697       var testUrl = url.split(/[?#]/)[0];
50698       var extension = getExtension(testUrl) || defaultExtension;
50699       if (extension) {
50700         _template = null;
50701         text_default3(url).then(function(data) {
50702           drawData.setFile(extension, data);
50703         }).catch(function() {
50704         });
50705       } else {
50706         drawData.template(url);
50707       }
50708       return this;
50709     };
50710     drawData.getSrc = function() {
50711       return _src || "";
50712     };
50713     drawData.fitZoom = function() {
50714       var features = getFeatures(_geojson);
50715       if (!features.length) return;
50716       var map2 = context.map();
50717       var viewport = map2.trimmedExtent().polygon();
50718       var coords = features.reduce(function(coords2, feature3) {
50719         var geom = feature3.geometry;
50720         if (!geom) return coords2;
50721         var c2 = geom.coordinates;
50722         switch (geom.type) {
50723           case "Point":
50724             c2 = [c2];
50725           case "MultiPoint":
50726           case "LineString":
50727             break;
50728           case "MultiPolygon":
50729             c2 = utilArrayFlatten(c2);
50730           case "Polygon":
50731           case "MultiLineString":
50732             c2 = utilArrayFlatten(c2);
50733             break;
50734         }
50735         return utilArrayUnion(coords2, c2);
50736       }, []);
50737       if (!geoPolygonIntersectsPolygon(viewport, coords, true)) {
50738         var extent = geoExtent(bounds_default({ type: "LineString", coordinates: coords }));
50739         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
50740       }
50741       return this;
50742     };
50743     init2();
50744     return drawData;
50745   }
50746
50747   // modules/svg/debug.js
50748   function svgDebug(projection2, context) {
50749     function drawDebug(selection2) {
50750       const showTile = context.getDebug("tile");
50751       const showCollision = context.getDebug("collision");
50752       const showImagery = context.getDebug("imagery");
50753       const showTouchTargets = context.getDebug("target");
50754       const showDownloaded = context.getDebug("downloaded");
50755       let debugData = [];
50756       if (showTile) {
50757         debugData.push({ class: "red", label: "tile" });
50758       }
50759       if (showCollision) {
50760         debugData.push({ class: "yellow", label: "collision" });
50761       }
50762       if (showImagery) {
50763         debugData.push({ class: "orange", label: "imagery" });
50764       }
50765       if (showTouchTargets) {
50766         debugData.push({ class: "pink", label: "touchTargets" });
50767       }
50768       if (showDownloaded) {
50769         debugData.push({ class: "purple", label: "downloaded" });
50770       }
50771       let legend = context.container().select(".main-content").selectAll(".debug-legend").data(debugData.length ? [0] : []);
50772       legend.exit().remove();
50773       legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend);
50774       let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label);
50775       legendItems.exit().remove();
50776       legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label);
50777       let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []);
50778       layer.exit().remove();
50779       layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer);
50780       const extent = context.map().extent();
50781       _mainFileFetcher.get("imagery").then((d2) => {
50782         const hits = showImagery && d2.query.bbox(extent.rectangle(), true) || [];
50783         const features = hits.map((d4) => d4.features[d4.id]);
50784         let imagery = layer.selectAll("path.debug-imagery").data(features);
50785         imagery.exit().remove();
50786         imagery.enter().append("path").attr("class", "debug-imagery debug orange");
50787       }).catch(() => {
50788       });
50789       const osm = context.connection();
50790       let dataDownloaded = [];
50791       if (osm && showDownloaded) {
50792         const rtree = osm.caches("get").tile.rtree;
50793         dataDownloaded = rtree.all().map((bbox2) => {
50794           return {
50795             type: "Feature",
50796             properties: { id: bbox2.id },
50797             geometry: {
50798               type: "Polygon",
50799               coordinates: [[
50800                 [bbox2.minX, bbox2.minY],
50801                 [bbox2.minX, bbox2.maxY],
50802                 [bbox2.maxX, bbox2.maxY],
50803                 [bbox2.maxX, bbox2.minY],
50804                 [bbox2.minX, bbox2.minY]
50805               ]]
50806             }
50807           };
50808         });
50809       }
50810       let downloaded = layer.selectAll("path.debug-downloaded").data(showDownloaded ? dataDownloaded : []);
50811       downloaded.exit().remove();
50812       downloaded.enter().append("path").attr("class", "debug-downloaded debug purple");
50813       layer.selectAll("path").attr("d", svgPath(projection2).geojson);
50814     }
50815     drawDebug.enabled = function() {
50816       if (!arguments.length) {
50817         return context.getDebug("tile") || context.getDebug("collision") || context.getDebug("imagery") || context.getDebug("target") || context.getDebug("downloaded");
50818       } else {
50819         return this;
50820       }
50821     };
50822     return drawDebug;
50823   }
50824
50825   // modules/svg/defs.js
50826   function svgDefs(context) {
50827     var _defsSelection = select_default2(null);
50828     var _spritesheetIds = [
50829       "iD-sprite",
50830       "maki-sprite",
50831       "temaki-sprite",
50832       "fa-sprite",
50833       "roentgen-sprite",
50834       "community-sprite"
50835     ];
50836     function drawDefs(selection2) {
50837       _defsSelection = selection2.append("defs");
50838       function addOnewayMarker(name, colour) {
50839         _defsSelection.append("marker").attr("id", "ideditor-oneway-marker-".concat(name)).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", colour).attr("opacity", "0.75");
50840       }
50841       addOnewayMarker("black", "#000");
50842       addOnewayMarker("white", "#fff");
50843       addOnewayMarker("pink", "#eaf");
50844       function addSidedMarker(name, color2, offset) {
50845         _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);
50846       }
50847       addSidedMarker("natural", "rgb(170, 170, 170)", 0);
50848       addSidedMarker("coastline", "#77dede", 1);
50849       addSidedMarker("waterway", "#77dede", 1);
50850       addSidedMarker("barrier", "#ddd", 1);
50851       addSidedMarker("man_made", "#fff", 0);
50852       _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");
50853       _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");
50854       var patterns2 = _defsSelection.selectAll("pattern").data([
50855         // pattern name, pattern image name
50856         ["beach", "dots"],
50857         ["construction", "construction"],
50858         ["cemetery", "cemetery"],
50859         ["cemetery_christian", "cemetery_christian"],
50860         ["cemetery_buddhist", "cemetery_buddhist"],
50861         ["cemetery_muslim", "cemetery_muslim"],
50862         ["cemetery_jewish", "cemetery_jewish"],
50863         ["farmland", "farmland"],
50864         ["farmyard", "farmyard"],
50865         ["forest", "forest"],
50866         ["forest_broadleaved", "forest_broadleaved"],
50867         ["forest_needleleaved", "forest_needleleaved"],
50868         ["forest_leafless", "forest_leafless"],
50869         ["golf_green", "grass"],
50870         ["grass", "grass"],
50871         ["landfill", "landfill"],
50872         ["meadow", "grass"],
50873         ["orchard", "orchard"],
50874         ["pond", "pond"],
50875         ["quarry", "quarry"],
50876         ["scrub", "bushes"],
50877         ["vineyard", "vineyard"],
50878         ["water_standing", "lines"],
50879         ["waves", "waves"],
50880         ["wetland", "wetland"],
50881         ["wetland_marsh", "wetland_marsh"],
50882         ["wetland_swamp", "wetland_swamp"],
50883         ["wetland_bog", "wetland_bog"],
50884         ["wetland_reedbed", "wetland_reedbed"]
50885       ]).enter().append("pattern").attr("id", function(d2) {
50886         return "ideditor-pattern-" + d2[0];
50887       }).attr("width", 32).attr("height", 32).attr("patternUnits", "userSpaceOnUse");
50888       patterns2.append("rect").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("class", function(d2) {
50889         return "pattern-color-" + d2[0];
50890       });
50891       patterns2.append("image").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("xlink:href", function(d2) {
50892         return context.imagePath("pattern/" + d2[1] + ".png");
50893       });
50894       _defsSelection.selectAll("clipPath").data([12, 18, 20, 32, 45]).enter().append("clipPath").attr("id", function(d2) {
50895         return "ideditor-clip-square-" + d2;
50896       }).append("rect").attr("x", 0).attr("y", 0).attr("width", function(d2) {
50897         return d2;
50898       }).attr("height", function(d2) {
50899         return d2;
50900       });
50901       const filters = _defsSelection.selectAll("filter").data(["alpha-slope5"]).enter().append("filter").attr("id", (d2) => d2);
50902       const alphaSlope5 = filters.filter("#alpha-slope5").append("feComponentTransfer");
50903       alphaSlope5.append("feFuncR").attr("type", "identity");
50904       alphaSlope5.append("feFuncG").attr("type", "identity");
50905       alphaSlope5.append("feFuncB").attr("type", "identity");
50906       alphaSlope5.append("feFuncA").attr("type", "linear").attr("slope", 5);
50907       addSprites(_spritesheetIds, true);
50908     }
50909     function addSprites(ids, overrideColors) {
50910       _spritesheetIds = utilArrayUniq(_spritesheetIds.concat(ids));
50911       var spritesheets = _defsSelection.selectAll(".spritesheet").data(_spritesheetIds);
50912       spritesheets.enter().append("g").attr("class", function(d2) {
50913         return "spritesheet spritesheet-" + d2;
50914       }).each(function(d2) {
50915         var url = context.imagePath(d2 + ".svg");
50916         var node = select_default2(this).node();
50917         svg(url).then(function(svg2) {
50918           node.appendChild(
50919             select_default2(svg2.documentElement).attr("id", "ideditor-" + d2).node()
50920           );
50921           if (overrideColors && d2 !== "iD-sprite") {
50922             select_default2(node).selectAll("path").attr("fill", "currentColor");
50923           }
50924         }).catch(function() {
50925         });
50926       });
50927       spritesheets.exit().remove();
50928     }
50929     drawDefs.addSprites = addSprites;
50930     return drawDefs;
50931   }
50932
50933   // modules/svg/keepRight.js
50934   var _layerEnabled = false;
50935   var _qaService;
50936   function svgKeepRight(projection2, context, dispatch14) {
50937     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
50938     const minZoom5 = 12;
50939     let touchLayer = select_default2(null);
50940     let drawLayer = select_default2(null);
50941     let layerVisible = false;
50942     function markerPath(selection2, klass) {
50943       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");
50944     }
50945     function getService() {
50946       if (services.keepRight && !_qaService) {
50947         _qaService = services.keepRight;
50948         _qaService.on("loaded", throttledRedraw);
50949       } else if (!services.keepRight && _qaService) {
50950         _qaService = null;
50951       }
50952       return _qaService;
50953     }
50954     function editOn() {
50955       if (!layerVisible) {
50956         layerVisible = true;
50957         drawLayer.style("display", "block");
50958       }
50959     }
50960     function editOff() {
50961       if (layerVisible) {
50962         layerVisible = false;
50963         drawLayer.style("display", "none");
50964         drawLayer.selectAll(".qaItem.keepRight").remove();
50965         touchLayer.selectAll(".qaItem.keepRight").remove();
50966       }
50967     }
50968     function layerOn() {
50969       editOn();
50970       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
50971     }
50972     function layerOff() {
50973       throttledRedraw.cancel();
50974       drawLayer.interrupt();
50975       touchLayer.selectAll(".qaItem.keepRight").remove();
50976       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
50977         editOff();
50978         dispatch14.call("change");
50979       });
50980     }
50981     function updateMarkers() {
50982       if (!layerVisible || !_layerEnabled) return;
50983       const service = getService();
50984       const selectedID = context.selectedErrorID();
50985       const data = service ? service.getItems(projection2) : [];
50986       const getTransform = svgPointTransform(projection2);
50987       const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
50988       markers.exit().remove();
50989       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType));
50990       markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
50991       markersEnter.append("path").call(markerPath, "shadow");
50992       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");
50993       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
50994       if (touchLayer.empty()) return;
50995       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
50996       const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
50997       targets.exit().remove();
50998       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);
50999       function sortY(a2, b2) {
51000         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];
51001       }
51002     }
51003     function drawKeepRight(selection2) {
51004       const service = getService();
51005       const surface = context.surface();
51006       if (surface && !surface.empty()) {
51007         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
51008       }
51009       drawLayer = selection2.selectAll(".layer-keepRight").data(service ? [0] : []);
51010       drawLayer.exit().remove();
51011       drawLayer = drawLayer.enter().append("g").attr("class", "layer-keepRight").style("display", _layerEnabled ? "block" : "none").merge(drawLayer);
51012       if (_layerEnabled) {
51013         if (service && ~~context.map().zoom() >= minZoom5) {
51014           editOn();
51015           service.loadIssues(projection2);
51016           updateMarkers();
51017         } else {
51018           editOff();
51019         }
51020       }
51021     }
51022     drawKeepRight.enabled = function(val) {
51023       if (!arguments.length) return _layerEnabled;
51024       _layerEnabled = val;
51025       if (_layerEnabled) {
51026         layerOn();
51027       } else {
51028         layerOff();
51029         if (context.selectedErrorID()) {
51030           context.enter(modeBrowse(context));
51031         }
51032       }
51033       dispatch14.call("change");
51034       return this;
51035     };
51036     drawKeepRight.supported = () => !!getService();
51037     return drawKeepRight;
51038   }
51039
51040   // modules/svg/geolocate.js
51041   function svgGeolocate(projection2) {
51042     var layer = select_default2(null);
51043     var _position;
51044     function init2() {
51045       if (svgGeolocate.initialized) return;
51046       svgGeolocate.enabled = false;
51047       svgGeolocate.initialized = true;
51048     }
51049     function showLayer() {
51050       layer.style("display", "block");
51051     }
51052     function hideLayer() {
51053       layer.transition().duration(250).style("opacity", 0);
51054     }
51055     function layerOn() {
51056       layer.style("opacity", 0).transition().duration(250).style("opacity", 1);
51057     }
51058     function layerOff() {
51059       layer.style("display", "none");
51060     }
51061     function transform2(d2) {
51062       return svgPointTransform(projection2)(d2);
51063     }
51064     function accuracy(accuracy2, loc) {
51065       var degreesRadius = geoMetersToLat(accuracy2), tangentLoc = [loc[0], loc[1] + degreesRadius], projectedTangent = projection2(tangentLoc), projectedLoc = projection2([loc[0], loc[1]]);
51066       return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
51067     }
51068     function update() {
51069       var geolocation = { loc: [_position.coords.longitude, _position.coords.latitude] };
51070       var groups = layer.selectAll(".geolocations").selectAll(".geolocation").data([geolocation]);
51071       groups.exit().remove();
51072       var pointsEnter = groups.enter().append("g").attr("class", "geolocation");
51073       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");
51074       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");
51075       groups.merge(pointsEnter).attr("transform", transform2);
51076       layer.select(".geolocate-radius").attr("r", accuracy(_position.coords.accuracy, geolocation.loc));
51077     }
51078     function drawLocation(selection2) {
51079       var enabled = svgGeolocate.enabled;
51080       layer = selection2.selectAll(".layer-geolocate").data([0]);
51081       layer.exit().remove();
51082       var layerEnter = layer.enter().append("g").attr("class", "layer-geolocate").style("display", enabled ? "block" : "none");
51083       layerEnter.append("g").attr("class", "geolocations");
51084       layer = layerEnter.merge(layer);
51085       if (enabled) {
51086         update();
51087       } else {
51088         layerOff();
51089       }
51090     }
51091     drawLocation.enabled = function(position, enabled) {
51092       if (!arguments.length) return svgGeolocate.enabled;
51093       _position = position;
51094       svgGeolocate.enabled = enabled;
51095       if (svgGeolocate.enabled) {
51096         showLayer();
51097         layerOn();
51098       } else {
51099         hideLayer();
51100       }
51101       return this;
51102     };
51103     init2();
51104     return drawLocation;
51105   }
51106
51107   // modules/svg/labels.js
51108   function svgLabels(projection2, context) {
51109     var path = path_default(projection2);
51110     var detected = utilDetect();
51111     var baselineHack = detected.ie || detected.browser.toLowerCase() === "edge" || detected.browser.toLowerCase() === "firefox" && detected.version >= 70;
51112     var _rdrawn = new RBush();
51113     var _rskipped = new RBush();
51114     var _textWidthCache = {};
51115     var _entitybboxes = {};
51116     var labelStack = [
51117       ["line", "aeroway", "*", 12],
51118       ["line", "highway", "motorway", 12],
51119       ["line", "highway", "trunk", 12],
51120       ["line", "highway", "primary", 12],
51121       ["line", "highway", "secondary", 12],
51122       ["line", "highway", "tertiary", 12],
51123       ["line", "highway", "*", 12],
51124       ["line", "railway", "*", 12],
51125       ["line", "waterway", "*", 12],
51126       ["area", "aeroway", "*", 12],
51127       ["area", "amenity", "*", 12],
51128       ["area", "building", "*", 12],
51129       ["area", "historic", "*", 12],
51130       ["area", "leisure", "*", 12],
51131       ["area", "man_made", "*", 12],
51132       ["area", "natural", "*", 12],
51133       ["area", "shop", "*", 12],
51134       ["area", "tourism", "*", 12],
51135       ["area", "camp_site", "*", 12],
51136       ["point", "aeroway", "*", 10],
51137       ["point", "amenity", "*", 10],
51138       ["point", "building", "*", 10],
51139       ["point", "historic", "*", 10],
51140       ["point", "leisure", "*", 10],
51141       ["point", "man_made", "*", 10],
51142       ["point", "natural", "*", 10],
51143       ["point", "shop", "*", 10],
51144       ["point", "tourism", "*", 10],
51145       ["point", "camp_site", "*", 10],
51146       ["line", "ref", "*", 12],
51147       ["area", "ref", "*", 12],
51148       ["point", "ref", "*", 10],
51149       ["line", "name", "*", 12],
51150       ["area", "name", "*", 12],
51151       ["point", "name", "*", 10]
51152     ];
51153     function shouldSkipIcon(preset) {
51154       var noIcons = ["building", "landuse", "natural"];
51155       return noIcons.some(function(s2) {
51156         return preset.id.indexOf(s2) >= 0;
51157       });
51158     }
51159     function get4(array2, prop) {
51160       return function(d2, i3) {
51161         return array2[i3][prop];
51162       };
51163     }
51164     function textWidth(text, size, elem) {
51165       var c2 = _textWidthCache[size];
51166       if (!c2) c2 = _textWidthCache[size] = {};
51167       if (c2[text]) {
51168         return c2[text];
51169       } else if (elem) {
51170         c2[text] = elem.getComputedTextLength();
51171         return c2[text];
51172       } else {
51173         var str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
51174         if (str === null) {
51175           return size / 3 * 2 * text.length;
51176         } else {
51177           return size / 3 * (2 * text.length + str.length);
51178         }
51179       }
51180     }
51181     function drawLinePaths(selection2, entities, filter2, classes, labels) {
51182       var paths = selection2.selectAll("path").filter(filter2).data(entities, osmEntity.key);
51183       paths.exit().remove();
51184       paths.enter().append("path").style("stroke-width", get4(labels, "font-size")).attr("id", function(d2) {
51185         return "ideditor-labelpath-" + d2.id;
51186       }).attr("class", classes).merge(paths).attr("d", get4(labels, "lineString"));
51187     }
51188     function drawLineLabels(selection2, entities, filter2, classes, labels) {
51189       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51190       texts.exit().remove();
51191       texts.enter().append("text").attr("class", function(d2, i3) {
51192         return classes + " " + labels[i3].classes + " " + d2.id;
51193       }).attr("dy", baselineHack ? "0.35em" : null).append("textPath").attr("class", "textpath");
51194       selection2.selectAll("text." + classes).selectAll(".textpath").filter(filter2).data(entities, osmEntity.key).attr("startOffset", "50%").attr("xlink:href", function(d2) {
51195         return "#ideditor-labelpath-" + d2.id;
51196       }).text(utilDisplayNameForPath);
51197     }
51198     function drawPointLabels(selection2, entities, filter2, classes, labels) {
51199       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51200       texts.exit().remove();
51201       texts.enter().append("text").attr("class", function(d2, i3) {
51202         return classes + " " + labels[i3].classes + " " + d2.id;
51203       }).merge(texts).attr("x", get4(labels, "x")).attr("y", get4(labels, "y")).style("text-anchor", get4(labels, "textAnchor")).text(utilDisplayName).each(function(d2, i3) {
51204         textWidth(utilDisplayName(d2), labels[i3].height, this);
51205       });
51206     }
51207     function drawAreaLabels(selection2, entities, filter2, classes, labels) {
51208       entities = entities.filter(hasText);
51209       labels = labels.filter(hasText);
51210       drawPointLabels(selection2, entities, filter2, classes, labels);
51211       function hasText(d2, i3) {
51212         return labels[i3].hasOwnProperty("x") && labels[i3].hasOwnProperty("y");
51213       }
51214     }
51215     function drawAreaIcons(selection2, entities, filter2, classes, labels) {
51216       var icons = selection2.selectAll("use." + classes).filter(filter2).data(entities, osmEntity.key);
51217       icons.exit().remove();
51218       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) {
51219         var preset = _mainPresetIndex.match(d2, context.graph());
51220         var picon = preset && preset.icon;
51221         return picon ? "#" + picon : "";
51222       });
51223     }
51224     function drawCollisionBoxes(selection2, rtree, which) {
51225       var classes = "debug " + which + " " + (which === "debug-skipped" ? "orange" : "yellow");
51226       var gj = [];
51227       if (context.getDebug("collision")) {
51228         gj = rtree.all().map(function(d2) {
51229           return { type: "Polygon", coordinates: [[
51230             [d2.minX, d2.minY],
51231             [d2.maxX, d2.minY],
51232             [d2.maxX, d2.maxY],
51233             [d2.minX, d2.maxY],
51234             [d2.minX, d2.minY]
51235           ]] };
51236         });
51237       }
51238       var boxes = selection2.selectAll("." + which).data(gj);
51239       boxes.exit().remove();
51240       boxes.enter().append("path").attr("class", classes).merge(boxes).attr("d", path_default());
51241     }
51242     function drawLabels(selection2, graph, entities, filter2, dimensions, fullRedraw) {
51243       var wireframe = context.surface().classed("fill-wireframe");
51244       var zoom = geoScaleToZoom(projection2.scale());
51245       var labelable = [];
51246       var renderNodeAs = {};
51247       var i3, j2, k2, entity, geometry;
51248       for (i3 = 0; i3 < labelStack.length; i3++) {
51249         labelable.push([]);
51250       }
51251       if (fullRedraw) {
51252         _rdrawn.clear();
51253         _rskipped.clear();
51254         _entitybboxes = {};
51255       } else {
51256         for (i3 = 0; i3 < entities.length; i3++) {
51257           entity = entities[i3];
51258           var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []);
51259           for (j2 = 0; j2 < toRemove.length; j2++) {
51260             _rdrawn.remove(toRemove[j2]);
51261             _rskipped.remove(toRemove[j2]);
51262           }
51263         }
51264       }
51265       for (i3 = 0; i3 < entities.length; i3++) {
51266         entity = entities[i3];
51267         geometry = entity.geometry(graph);
51268         if (geometry === "point" || geometry === "vertex" && isInterestingVertex(entity)) {
51269           var hasDirections = entity.directions(graph, projection2).length;
51270           var markerPadding;
51271           if (!wireframe && geometry === "point" && !(zoom >= 18 && hasDirections)) {
51272             renderNodeAs[entity.id] = "point";
51273             markerPadding = 20;
51274           } else {
51275             renderNodeAs[entity.id] = "vertex";
51276             markerPadding = 0;
51277           }
51278           var coord2 = projection2(entity.loc);
51279           var nodePadding = 10;
51280           var bbox2 = {
51281             minX: coord2[0] - nodePadding,
51282             minY: coord2[1] - nodePadding - markerPadding,
51283             maxX: coord2[0] + nodePadding,
51284             maxY: coord2[1] + nodePadding
51285           };
51286           doInsert(bbox2, entity.id + "P");
51287         }
51288         if (geometry === "vertex") {
51289           geometry = "point";
51290         }
51291         var preset = geometry === "area" && _mainPresetIndex.match(entity, graph);
51292         var icon2 = preset && !shouldSkipIcon(preset) && preset.icon;
51293         if (!icon2 && !utilDisplayName(entity)) continue;
51294         for (k2 = 0; k2 < labelStack.length; k2++) {
51295           var matchGeom = labelStack[k2][0];
51296           var matchKey = labelStack[k2][1];
51297           var matchVal = labelStack[k2][2];
51298           var hasVal = entity.tags[matchKey];
51299           if (geometry === matchGeom && hasVal && (matchVal === "*" || matchVal === hasVal)) {
51300             labelable[k2].push(entity);
51301             break;
51302           }
51303         }
51304       }
51305       var positions = {
51306         point: [],
51307         line: [],
51308         area: []
51309       };
51310       var labelled = {
51311         point: [],
51312         line: [],
51313         area: []
51314       };
51315       for (k2 = 0; k2 < labelable.length; k2++) {
51316         var fontSize = labelStack[k2][3];
51317         for (i3 = 0; i3 < labelable[k2].length; i3++) {
51318           entity = labelable[k2][i3];
51319           geometry = entity.geometry(graph);
51320           var getName = geometry === "line" ? utilDisplayNameForPath : utilDisplayName;
51321           var name = getName(entity);
51322           var width = name && textWidth(name, fontSize);
51323           var p2 = null;
51324           if (geometry === "point" || geometry === "vertex") {
51325             if (wireframe) continue;
51326             var renderAs = renderNodeAs[entity.id];
51327             if (renderAs === "vertex" && zoom < 17) continue;
51328             p2 = getPointLabel(entity, width, fontSize, renderAs);
51329           } else if (geometry === "line") {
51330             p2 = getLineLabel(entity, width, fontSize);
51331           } else if (geometry === "area") {
51332             p2 = getAreaLabel(entity, width, fontSize);
51333           }
51334           if (p2) {
51335             if (geometry === "vertex") {
51336               geometry = "point";
51337             }
51338             p2.classes = geometry + " tag-" + labelStack[k2][1];
51339             positions[geometry].push(p2);
51340             labelled[geometry].push(entity);
51341           }
51342         }
51343       }
51344       function isInterestingVertex(entity2) {
51345         var selectedIDs = context.selectedIDs();
51346         return entity2.hasInterestingTags() || entity2.isEndpoint(graph) || entity2.isConnected(graph) || selectedIDs.indexOf(entity2.id) !== -1 || graph.parentWays(entity2).some(function(parent) {
51347           return selectedIDs.indexOf(parent.id) !== -1;
51348         });
51349       }
51350       function getPointLabel(entity2, width2, height, geometry2) {
51351         var y2 = geometry2 === "point" ? -12 : 0;
51352         var pointOffsets = {
51353           ltr: [15, y2, "start"],
51354           rtl: [-15, y2, "end"]
51355         };
51356         var textDirection = _mainLocalizer.textDirection();
51357         var coord3 = projection2(entity2.loc);
51358         var textPadding = 2;
51359         var offset = pointOffsets[textDirection];
51360         var p3 = {
51361           height,
51362           width: width2,
51363           x: coord3[0] + offset[0],
51364           y: coord3[1] + offset[1],
51365           textAnchor: offset[2]
51366         };
51367         var bbox3;
51368         if (textDirection === "rtl") {
51369           bbox3 = {
51370             minX: p3.x - width2 - textPadding,
51371             minY: p3.y - height / 2 - textPadding,
51372             maxX: p3.x + textPadding,
51373             maxY: p3.y + height / 2 + textPadding
51374           };
51375         } else {
51376           bbox3 = {
51377             minX: p3.x - textPadding,
51378             minY: p3.y - height / 2 - textPadding,
51379             maxX: p3.x + width2 + textPadding,
51380             maxY: p3.y + height / 2 + textPadding
51381           };
51382         }
51383         if (tryInsert([bbox3], entity2.id, true)) {
51384           return p3;
51385         }
51386       }
51387       function getLineLabel(entity2, width2, height) {
51388         var viewport = geoExtent(context.projection.clipExtent()).polygon();
51389         var points = graph.childNodes(entity2).map(function(node) {
51390           return projection2(node.loc);
51391         });
51392         var length2 = geoPathLength(points);
51393         if (length2 < width2 + 20) return;
51394         var lineOffsets = [
51395           50,
51396           45,
51397           55,
51398           40,
51399           60,
51400           35,
51401           65,
51402           30,
51403           70,
51404           25,
51405           75,
51406           20,
51407           80,
51408           15,
51409           95,
51410           10,
51411           90,
51412           5,
51413           95
51414         ];
51415         var padding = 3;
51416         for (var i4 = 0; i4 < lineOffsets.length; i4++) {
51417           var offset = lineOffsets[i4];
51418           var middle = offset / 100 * length2;
51419           var start2 = middle - width2 / 2;
51420           if (start2 < 0 || start2 + width2 > length2) continue;
51421           var sub = subpath(points, start2, start2 + width2);
51422           if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) {
51423             continue;
51424           }
51425           var isReverse = reverse(sub);
51426           if (isReverse) {
51427             sub = sub.reverse();
51428           }
51429           var bboxes = [];
51430           var boxsize = (height + 2) / 2;
51431           for (var j3 = 0; j3 < sub.length - 1; j3++) {
51432             var a2 = sub[j3];
51433             var b2 = sub[j3 + 1];
51434             var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2));
51435             for (var box = 0; box < num; box++) {
51436               var p3 = geoVecInterp(a2, b2, box / num);
51437               var x05 = p3[0] - boxsize - padding;
51438               var y05 = p3[1] - boxsize - padding;
51439               var x12 = p3[0] + boxsize + padding;
51440               var y12 = p3[1] + boxsize + padding;
51441               bboxes.push({
51442                 minX: Math.min(x05, x12),
51443                 minY: Math.min(y05, y12),
51444                 maxX: Math.max(x05, x12),
51445                 maxY: Math.max(y05, y12)
51446               });
51447             }
51448           }
51449           if (tryInsert(bboxes, entity2.id, false)) {
51450             return {
51451               "font-size": height + 2,
51452               lineString: lineString2(sub),
51453               startOffset: offset + "%"
51454             };
51455           }
51456         }
51457         function reverse(p4) {
51458           var angle2 = Math.atan2(p4[1][1] - p4[0][1], p4[1][0] - p4[0][0]);
51459           return !(p4[0][0] < p4[p4.length - 1][0] && angle2 < Math.PI / 2 && angle2 > -Math.PI / 2);
51460         }
51461         function lineString2(points2) {
51462           return "M" + points2.join("L");
51463         }
51464         function subpath(points2, from, to) {
51465           var sofar = 0;
51466           var start3, end, i0, i1;
51467           for (var i5 = 0; i5 < points2.length - 1; i5++) {
51468             var a3 = points2[i5];
51469             var b3 = points2[i5 + 1];
51470             var current = geoVecLength(a3, b3);
51471             var portion;
51472             if (!start3 && sofar + current >= from) {
51473               portion = (from - sofar) / current;
51474               start3 = [
51475                 a3[0] + portion * (b3[0] - a3[0]),
51476                 a3[1] + portion * (b3[1] - a3[1])
51477               ];
51478               i0 = i5 + 1;
51479             }
51480             if (!end && sofar + current >= to) {
51481               portion = (to - sofar) / current;
51482               end = [
51483                 a3[0] + portion * (b3[0] - a3[0]),
51484                 a3[1] + portion * (b3[1] - a3[1])
51485               ];
51486               i1 = i5 + 1;
51487             }
51488             sofar += current;
51489           }
51490           var result = points2.slice(i0, i1);
51491           result.unshift(start3);
51492           result.push(end);
51493           return result;
51494         }
51495       }
51496       function getAreaLabel(entity2, width2, height) {
51497         var centroid = path.centroid(entity2.asGeoJSON(graph));
51498         var extent = entity2.extent(graph);
51499         var areaWidth = projection2(extent[1])[0] - projection2(extent[0])[0];
51500         if (isNaN(centroid[0]) || areaWidth < 20) return;
51501         var preset2 = _mainPresetIndex.match(entity2, context.graph());
51502         var picon = preset2 && preset2.icon;
51503         var iconSize = 17;
51504         var padding = 2;
51505         var p3 = {};
51506         if (picon) {
51507           if (addIcon()) {
51508             addLabel(iconSize + padding);
51509             return p3;
51510           }
51511         } else {
51512           if (addLabel(0)) {
51513             return p3;
51514           }
51515         }
51516         function addIcon() {
51517           var iconX = centroid[0] - iconSize / 2;
51518           var iconY = centroid[1] - iconSize / 2;
51519           var bbox3 = {
51520             minX: iconX,
51521             minY: iconY,
51522             maxX: iconX + iconSize,
51523             maxY: iconY + iconSize
51524           };
51525           if (tryInsert([bbox3], entity2.id + "I", true)) {
51526             p3.transform = "translate(" + iconX + "," + iconY + ")";
51527             return true;
51528           }
51529           return false;
51530         }
51531         function addLabel(yOffset) {
51532           if (width2 && areaWidth >= width2 + 20) {
51533             var labelX = centroid[0];
51534             var labelY = centroid[1] + yOffset;
51535             var bbox3 = {
51536               minX: labelX - width2 / 2 - padding,
51537               minY: labelY - height / 2 - padding,
51538               maxX: labelX + width2 / 2 + padding,
51539               maxY: labelY + height / 2 + padding
51540             };
51541             if (tryInsert([bbox3], entity2.id, true)) {
51542               p3.x = labelX;
51543               p3.y = labelY;
51544               p3.textAnchor = "middle";
51545               p3.height = height;
51546               return true;
51547             }
51548           }
51549           return false;
51550         }
51551       }
51552       function doInsert(bbox3, id2) {
51553         bbox3.id = id2;
51554         var oldbox = _entitybboxes[id2];
51555         if (oldbox) {
51556           _rdrawn.remove(oldbox);
51557         }
51558         _entitybboxes[id2] = bbox3;
51559         _rdrawn.insert(bbox3);
51560       }
51561       function tryInsert(bboxes, id2, saveSkipped) {
51562         var skipped = false;
51563         for (var i4 = 0; i4 < bboxes.length; i4++) {
51564           var bbox3 = bboxes[i4];
51565           bbox3.id = id2;
51566           if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) {
51567             skipped = true;
51568             break;
51569           }
51570           if (_rdrawn.collides(bbox3)) {
51571             skipped = true;
51572             break;
51573           }
51574         }
51575         _entitybboxes[id2] = bboxes;
51576         if (skipped) {
51577           if (saveSkipped) {
51578             _rskipped.load(bboxes);
51579           }
51580         } else {
51581           _rdrawn.load(bboxes);
51582         }
51583         return !skipped;
51584       }
51585       var layer = selection2.selectAll(".layer-osm.labels");
51586       layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) {
51587         return "labels-group " + d2;
51588       });
51589       var halo = layer.selectAll(".labels-group.halo");
51590       var label = layer.selectAll(".labels-group.label");
51591       var debug2 = layer.selectAll(".labels-group.debug");
51592       drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point);
51593       drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point);
51594       drawLinePaths(layer, labelled.line, filter2, "", positions.line);
51595       drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line);
51596       drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line);
51597       drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area);
51598       drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area);
51599       drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area);
51600       drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area);
51601       drawCollisionBoxes(debug2, _rskipped, "debug-skipped");
51602       drawCollisionBoxes(debug2, _rdrawn, "debug-drawn");
51603       layer.call(filterLabels);
51604     }
51605     function filterLabels(selection2) {
51606       var drawLayer = selection2.selectAll(".layer-osm.labels");
51607       var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label");
51608       layers.selectAll(".nolabel").classed("nolabel", false);
51609       var mouse = context.map().mouse();
51610       var graph = context.graph();
51611       var selectedIDs = context.selectedIDs();
51612       var ids = [];
51613       var pad2, bbox2;
51614       if (mouse) {
51615         pad2 = 20;
51616         bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 };
51617         var nearMouse = _rdrawn.search(bbox2).map(function(entity2) {
51618           return entity2.id;
51619         });
51620         ids.push.apply(ids, nearMouse);
51621       }
51622       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
51623         var entity = graph.hasEntity(selectedIDs[i3]);
51624         if (entity && entity.type === "node") {
51625           ids.push(selectedIDs[i3]);
51626         }
51627       }
51628       layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true);
51629       var debug2 = selection2.selectAll(".labels-group.debug");
51630       var gj = [];
51631       if (context.getDebug("collision")) {
51632         gj = bbox2 ? [{
51633           type: "Polygon",
51634           coordinates: [[
51635             [bbox2.minX, bbox2.minY],
51636             [bbox2.maxX, bbox2.minY],
51637             [bbox2.maxX, bbox2.maxY],
51638             [bbox2.minX, bbox2.maxY],
51639             [bbox2.minX, bbox2.minY]
51640           ]]
51641         }] : [];
51642       }
51643       var box = debug2.selectAll(".debug-mouse").data(gj);
51644       box.exit().remove();
51645       box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default());
51646     }
51647     var throttleFilterLabels = throttle_default(filterLabels, 100);
51648     drawLabels.observe = function(selection2) {
51649       var listener = function() {
51650         throttleFilterLabels(selection2);
51651       };
51652       selection2.on("mousemove.hidelabels", listener);
51653       context.on("enter.hidelabels", listener);
51654     };
51655     drawLabels.off = function(selection2) {
51656       throttleFilterLabels.cancel();
51657       selection2.on("mousemove.hidelabels", null);
51658       context.on("enter.hidelabels", null);
51659     };
51660     return drawLabels;
51661   }
51662
51663   // node_modules/exifr/dist/full.esm.mjs
51664   var e = "undefined" != typeof self ? self : global;
51665   var t = "undefined" != typeof navigator;
51666   var i2 = t && "undefined" == typeof HTMLImageElement;
51667   var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node);
51668   var s = e.Buffer;
51669   var r = e.BigInt;
51670   var a = !!s;
51671   var o = (e3) => e3;
51672   function l(e3, t2 = o) {
51673     if (n2) try {
51674       return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import(
51675         /* webpackIgnore: true */
51676         e3
51677       ).then(t2);
51678     } catch (t3) {
51679       console.warn("Couldn't load ".concat(e3));
51680     }
51681   }
51682   var h = e.fetch;
51683   var u = (e3) => h = e3;
51684   if (!e.fetch) {
51685     const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => {
51686       let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3);
51687       const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 };
51688       "" !== o2 && (f2.port = Number(o2));
51689       const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => {
51690         if (301 === e4.statusCode || 302 === e4.statusCode) {
51691           let t3 = new URL(e4.headers.location, n3).toString();
51692           return i3(t3, { headers: s2 }).then(r2).catch(a2);
51693         }
51694         r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => {
51695           let i4 = [];
51696           e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4)));
51697         }) });
51698       });
51699       d2.on("error", a2), d2.end();
51700     });
51701     u(i3);
51702   }
51703   function c(e3, t2, i3) {
51704     return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3;
51705   }
51706   var f = (e3) => p(e3) ? void 0 : e3;
51707   var d = (e3) => void 0 !== e3;
51708   function p(e3) {
51709     return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length);
51710   }
51711   function g2(e3) {
51712     let t2 = new Error(e3);
51713     throw delete t2.stack, t2;
51714   }
51715   function m(e3) {
51716     return "" === (e3 = function(e4) {
51717       for (; e4.endsWith("\0"); ) e4 = e4.slice(0, -1);
51718       return e4;
51719     }(e3).trim()) ? void 0 : e3;
51720   }
51721   function S(e3) {
51722     let t2 = function(e4) {
51723       let t3 = 0;
51724       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;
51725     }(e3);
51726     return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2;
51727   }
51728   var C = (e3) => String.fromCharCode.apply(null, e3);
51729   var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0;
51730   function b(e3) {
51731     return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3)));
51732   }
51733   var I = class _I {
51734     static from(e3, t2) {
51735       return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2);
51736     }
51737     constructor(e3, t2 = 0, i3, n3) {
51738       if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3) this.byteOffset = 0, this.byteLength = 0;
51739       else if (e3 instanceof ArrayBuffer) {
51740         void 0 === i3 && (i3 = e3.byteLength - t2);
51741         let n4 = new DataView(e3, t2, i3);
51742         this._swapDataView(n4);
51743       } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) {
51744         void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer");
51745         let n4 = new DataView(e3.buffer, t2, i3);
51746         this._swapDataView(n4);
51747       } else if ("number" == typeof e3) {
51748         let t3 = new DataView(new ArrayBuffer(e3));
51749         this._swapDataView(t3);
51750       } else g2("Invalid input argument for BufferView: " + e3);
51751     }
51752     _swapArrayBuffer(e3) {
51753       this._swapDataView(new DataView(e3));
51754     }
51755     _swapBuffer(e3) {
51756       this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength));
51757     }
51758     _swapDataView(e3) {
51759       this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength;
51760     }
51761     _lengthToEnd(e3) {
51762       return this.byteLength - e3;
51763     }
51764     set(e3, t2, i3 = _I) {
51765       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);
51766     }
51767     subarray(e3, t2) {
51768       return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2);
51769     }
51770     toUint8() {
51771       return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
51772     }
51773     getUint8Array(e3, t2) {
51774       return new Uint8Array(this.buffer, this.byteOffset + e3, t2);
51775     }
51776     getString(e3 = 0, t2 = this.byteLength) {
51777       return b(this.getUint8Array(e3, t2));
51778     }
51779     getLatin1String(e3 = 0, t2 = this.byteLength) {
51780       let i3 = this.getUint8Array(e3, t2);
51781       return C(i3);
51782     }
51783     getUnicodeString(e3 = 0, t2 = this.byteLength) {
51784       const i3 = [];
51785       for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2) i3.push(this.getUint16(e3 + n3));
51786       return C(i3);
51787     }
51788     getInt8(e3) {
51789       return this.dataView.getInt8(e3);
51790     }
51791     getUint8(e3) {
51792       return this.dataView.getUint8(e3);
51793     }
51794     getInt16(e3, t2 = this.le) {
51795       return this.dataView.getInt16(e3, t2);
51796     }
51797     getInt32(e3, t2 = this.le) {
51798       return this.dataView.getInt32(e3, t2);
51799     }
51800     getUint16(e3, t2 = this.le) {
51801       return this.dataView.getUint16(e3, t2);
51802     }
51803     getUint32(e3, t2 = this.le) {
51804       return this.dataView.getUint32(e3, t2);
51805     }
51806     getFloat32(e3, t2 = this.le) {
51807       return this.dataView.getFloat32(e3, t2);
51808     }
51809     getFloat64(e3, t2 = this.le) {
51810       return this.dataView.getFloat64(e3, t2);
51811     }
51812     getFloat(e3, t2 = this.le) {
51813       return this.dataView.getFloat32(e3, t2);
51814     }
51815     getDouble(e3, t2 = this.le) {
51816       return this.dataView.getFloat64(e3, t2);
51817     }
51818     getUintBytes(e3, t2, i3) {
51819       switch (t2) {
51820         case 1:
51821           return this.getUint8(e3, i3);
51822         case 2:
51823           return this.getUint16(e3, i3);
51824         case 4:
51825           return this.getUint32(e3, i3);
51826         case 8:
51827           return this.getUint64 && this.getUint64(e3, i3);
51828       }
51829     }
51830     getUint(e3, t2, i3) {
51831       switch (t2) {
51832         case 8:
51833           return this.getUint8(e3, i3);
51834         case 16:
51835           return this.getUint16(e3, i3);
51836         case 32:
51837           return this.getUint32(e3, i3);
51838         case 64:
51839           return this.getUint64 && this.getUint64(e3, i3);
51840       }
51841     }
51842     toString(e3) {
51843       return this.dataView.toString(e3, this.constructor.name);
51844     }
51845     ensureChunk() {
51846     }
51847   };
51848   function P(e3, t2) {
51849     g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr."));
51850   }
51851   var k = class extends Map {
51852     constructor(e3) {
51853       super(), this.kind = e3;
51854     }
51855     get(e3, t2) {
51856       return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) {
51857         g2("Unknown ".concat(e4, " '").concat(t3, "'."));
51858       }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3);
51859     }
51860     keyList() {
51861       return Array.from(this.keys());
51862     }
51863   };
51864   var w = new k("file parser");
51865   var T = new k("segment parser");
51866   var A = new k("file reader");
51867   function D(e3, n3) {
51868     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");
51869   }
51870   function O(e3, i3) {
51871     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");
51872     var s2;
51873   }
51874   async function x(e3, t2, i3, n3) {
51875     return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) {
51876       let i4 = await t3(e4);
51877       return new I(i4);
51878     }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded"));
51879   }
51880   async function v(e3, t2, i3) {
51881     let n3 = new (A.get(i3))(e3, t2);
51882     return await n3.read(), n3;
51883   }
51884   var M = (e3) => h(e3).then((e4) => e4.arrayBuffer());
51885   var R = (e3) => new Promise((t2, i3) => {
51886     let n3 = new FileReader();
51887     n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3);
51888   });
51889   var L = class extends Map {
51890     get tagKeys() {
51891       return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys;
51892     }
51893     get tagValues() {
51894       return this.allValues || (this.allValues = Array.from(this.values())), this.allValues;
51895     }
51896   };
51897   function U(e3, t2, i3) {
51898     let n3 = new L();
51899     for (let [e4, t3] of i3) n3.set(e4, t3);
51900     if (Array.isArray(t2)) for (let i4 of t2) e3.set(i4, n3);
51901     else e3.set(t2, n3);
51902     return n3;
51903   }
51904   function F(e3, t2, i3) {
51905     let n3, s2 = e3.get(t2);
51906     for (n3 of i3) s2.set(n3[0], n3[1]);
51907   }
51908   var E = /* @__PURE__ */ new Map();
51909   var B = /* @__PURE__ */ new Map();
51910   var N = /* @__PURE__ */ new Map();
51911   var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"];
51912   var V = ["jfif", "xmp", "icc", "iptc", "ihdr"];
51913   var z = ["tiff", ...V];
51914   var H = ["ifd0", "ifd1", "exif", "gps", "interop"];
51915   var j = [...z, ...H];
51916   var W = ["makerNote", "userComment"];
51917   var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"];
51918   var X = [...K, "sanitize", "mergeOutput", "silentErrors"];
51919   var _ = class {
51920     get translate() {
51921       return this.translateKeys || this.translateValues || this.reviveValues;
51922     }
51923   };
51924   var Y = class extends _ {
51925     get needed() {
51926       return this.enabled || this.deps.size > 0;
51927     }
51928     constructor(e3, t2, i3, n3) {
51929       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) if (Array.isArray(i3)) this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick);
51930       else if ("object" == typeof i3) {
51931         if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) {
51932           let { pick: e4, skip: t3 } = i3;
51933           e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip);
51934         }
51935         this.applyInheritables(i3);
51936       } else true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3));
51937     }
51938     applyInheritables(e3) {
51939       let t2, i3;
51940       for (t2 of K) i3 = e3[t2], void 0 !== i3 && (this[t2] = i3);
51941     }
51942     translateTagSet(e3, t2) {
51943       if (this.dict) {
51944         let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict;
51945         for (i3 of e3) "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3);
51946       } else for (let i3 of e3) t2.add(i3);
51947     }
51948     finalizeFilters() {
51949       !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);
51950     }
51951   };
51952   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 };
51953   var J = /* @__PURE__ */ new Map();
51954   var q = class extends _ {
51955     static useCached(e3) {
51956       let t2 = J.get(e3);
51957       return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2;
51958     }
51959     constructor(e3) {
51960       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();
51961     }
51962     setupFromUndefined() {
51963       let e3;
51964       for (e3 of G) this[e3] = $2[e3];
51965       for (e3 of X) this[e3] = $2[e3];
51966       for (e3 of W) this[e3] = $2[e3];
51967       for (e3 of j) this[e3] = new Y(e3, $2[e3], void 0, this);
51968     }
51969     setupFromTrue() {
51970       let e3;
51971       for (e3 of G) this[e3] = $2[e3];
51972       for (e3 of X) this[e3] = $2[e3];
51973       for (e3 of W) this[e3] = true;
51974       for (e3 of j) this[e3] = new Y(e3, true, void 0, this);
51975     }
51976     setupFromArray(e3) {
51977       let t2;
51978       for (t2 of G) this[t2] = $2[t2];
51979       for (t2 of X) this[t2] = $2[t2];
51980       for (t2 of W) this[t2] = $2[t2];
51981       for (t2 of j) this[t2] = new Y(t2, false, void 0, this);
51982       this.setupGlobalFilters(e3, void 0, H);
51983     }
51984     setupFromObject(e3) {
51985       let t2;
51986       for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G)) this[t2] = Z(e3[t2], $2[t2]);
51987       for (t2 of X) this[t2] = Z(e3[t2], $2[t2]);
51988       for (t2 of W) this[t2] = Z(e3[t2], $2[t2]);
51989       for (t2 of z) this[t2] = new Y(t2, $2[t2], e3[t2], this);
51990       for (t2 of H) this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff);
51991       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);
51992     }
51993     batchEnableWithBool(e3, t2) {
51994       for (let i3 of e3) this[i3].enabled = t2;
51995     }
51996     batchEnableWithUserValue(e3, t2) {
51997       for (let i3 of e3) {
51998         let e4 = t2[i3];
51999         this[i3].enabled = false !== e4 && void 0 !== e4;
52000       }
52001     }
52002     setupGlobalFilters(e3, t2, i3, n3 = i3) {
52003       if (e3 && e3.length) {
52004         for (let e4 of n3) this[e4].enabled = false;
52005         let t3 = Q(e3, i3);
52006         for (let [e4, i4] of t3) ee(this[e4].pick, i4), this[e4].enabled = true;
52007       } else if (t2 && t2.length) {
52008         let e4 = Q(t2, i3);
52009         for (let [t3, i4] of e4) ee(this[t3].skip, i4);
52010       }
52011     }
52012     filterNestedSegmentTags() {
52013       let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this;
52014       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);
52015     }
52016     traverseTiffDependencyTree() {
52017       let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this;
52018       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;
52019       for (let e4 of H) this[e4].finalizeFilters();
52020     }
52021     get onlyTiff() {
52022       return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled;
52023     }
52024     checkLoadedPlugins() {
52025       for (let e3 of z) this[e3].enabled && !T.has(e3) && P("segment parser", e3);
52026     }
52027   };
52028   function Q(e3, t2) {
52029     let i3, n3, s2, r2, a2 = [];
52030     for (s2 of t2) {
52031       for (r2 of (i3 = E.get(s2), n3 = [], i3)) (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]);
52032       n3.length && a2.push([s2, n3]);
52033     }
52034     return a2;
52035   }
52036   function Z(e3, t2) {
52037     return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0;
52038   }
52039   function ee(e3, t2) {
52040     for (let i3 of t2) e3.add(i3);
52041   }
52042   c(q, "default", $2);
52043   var te = class {
52044     constructor(e3) {
52045       c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3);
52046     }
52047     async read(e3) {
52048       this.file = await D(e3, this.options);
52049     }
52050     setup() {
52051       if (this.fileParser) return;
52052       let { file: e3 } = this, t2 = e3.getUint16(0);
52053       for (let [i3, n3] of w) if (n3.canHandle(e3, t2)) return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true;
52054       this.file.close && this.file.close(), g2("Unknown file format");
52055     }
52056     async parse() {
52057       let { output: e3, errors: t2 } = this;
52058       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);
52059     }
52060     async executeParsers() {
52061       let { output: e3 } = this;
52062       await this.fileParser.parse();
52063       let t2 = Object.values(this.parsers).map(async (t3) => {
52064         let i3 = await t3.parse();
52065         t3.assignToOutput(e3, i3);
52066       });
52067       this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2);
52068     }
52069     async extractThumbnail() {
52070       this.setup();
52071       let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3);
52072       var n3;
52073       if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3) return;
52074       let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail();
52075       return t2.close && t2.close(), a2;
52076     }
52077   };
52078   async function ie(e3, t2) {
52079     let i3 = new te(t2);
52080     return await i3.read(e3), i3.parse();
52081   }
52082   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 });
52083   var se = class {
52084     constructor(e3, t2, i3) {
52085       c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => {
52086         let t3 = e4.start, i4 = e4.size || 65536;
52087         if (this.file.chunked) if (this.file.available(t3, i4)) e4.chunk = this.file.subarray(t3, i4);
52088         else try {
52089           e4.chunk = await this.file.readChunk(t3, i4);
52090         } catch (t4) {
52091           g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message));
52092         }
52093         else 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));
52094         return e4.chunk;
52095       }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3;
52096     }
52097     injectSegment(e3, t2) {
52098       this.options[e3].enabled && this.createParser(e3, t2);
52099     }
52100     createParser(e3, t2) {
52101       let i3 = new (T.get(e3))(t2, this.options, this.file);
52102       return this.parsers[e3] = i3;
52103     }
52104     createParsers(e3) {
52105       for (let t2 of e3) {
52106         let { type: e4, chunk: i3 } = t2, n3 = this.options[e4];
52107         if (n3 && n3.enabled) {
52108           let t3 = this.parsers[e4];
52109           t3 && t3.append || t3 || this.createParser(e4, i3);
52110         }
52111       }
52112     }
52113     async readSegments(e3) {
52114       let t2 = e3.map(this.ensureSegmentChunk);
52115       await Promise.all(t2);
52116     }
52117   };
52118   var re2 = class {
52119     static findPosition(e3, t2) {
52120       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;
52121       return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 };
52122     }
52123     static parse(e3, t2 = {}) {
52124       return new this(e3, new q({ [this.type]: t2 }), e3).parse();
52125     }
52126     normalizeInput(e3) {
52127       return e3 instanceof I ? e3 : new I(e3);
52128     }
52129     constructor(e3, t2 = {}, i3) {
52130       c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => {
52131         if (!this.options.silentErrors) throw e4;
52132         this.errors.push(e4.message);
52133       }), 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;
52134     }
52135     translate() {
52136       this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type));
52137     }
52138     get output() {
52139       return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0;
52140     }
52141     translateBlock(e3, t2) {
52142       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 = {};
52143       for (let [t3, r3] of e3) 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;
52144       return h2;
52145     }
52146     translateValue(e3, t2) {
52147       return t2[e3] || t2.DEFAULT || e3;
52148     }
52149     assignToOutput(e3, t2) {
52150       this.assignObjectToOutput(e3, this.constructor.type, t2);
52151     }
52152     assignObjectToOutput(e3, t2, i3) {
52153       if (this.globalOptions.mergeOutput) return Object.assign(e3, i3);
52154       e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3;
52155     }
52156   };
52157   c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false);
52158   function ae(e3) {
52159     return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3;
52160   }
52161   function oe(e3) {
52162     return e3 >= 224 && e3 <= 239;
52163   }
52164   function le(e3, t2, i3) {
52165     for (let [n3, s2] of T) if (s2.canHandle(e3, t2, i3)) return n3;
52166   }
52167   var he = class extends se {
52168     constructor(...e3) {
52169       super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []);
52170     }
52171     static canHandle(e3, t2) {
52172       return 65496 === t2;
52173     }
52174     async parse() {
52175       await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments);
52176     }
52177     setupSegmentFinderArgs(e3) {
52178       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;
52179     }
52180     async findAppSegments(e3 = 0, t2) {
52181       this.setupSegmentFinderArgs(t2);
52182       let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this;
52183       if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => {
52184         let t3 = T.get(e4), i4 = this.options[e4];
52185         return t3.multiSegment && i4.multiSegment;
52186       }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) {
52187         let t3 = false;
52188         for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) {
52189           let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size));
52190           if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength))) return;
52191         }
52192       }
52193     }
52194     findAppSegmentsInRange(e3, t2) {
52195       t2 -= 2;
52196       let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this;
52197       for (; e3 < t2; e3++) if (255 === l2.getUint8(e3)) {
52198         if (i3 = l2.getUint8(e3 + 1), oe(i3)) {
52199           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))) break;
52200           f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1;
52201         } else if (ae(i3)) {
52202           if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos) return;
52203           f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1;
52204         }
52205       }
52206       return e3;
52207     }
52208     mergeMultiSegments() {
52209       if (!this.appSegments.some((e4) => e4.multiSegment)) return;
52210       let e3 = function(e4, t2) {
52211         let i3, n3, s2, r2 = /* @__PURE__ */ new Map();
52212         for (let a2 = 0; a2 < e4.length; a2++) i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3);
52213         return Array.from(r2);
52214       }(this.appSegments, "type");
52215       this.mergedAppSegments = e3.map(([e4, t2]) => {
52216         let i3 = T.get(e4, this.options);
52217         if (i3.handleMultiSegments) {
52218           return { type: e4, chunk: i3.handleMultiSegments(t2) };
52219         }
52220         return t2[0];
52221       });
52222     }
52223     getSegment(e3) {
52224       return this.appSegments.find((t2) => t2.type === e3);
52225     }
52226     async getOrFindSegment(e3) {
52227       let t2 = this.getSegment(e3);
52228       return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2;
52229     }
52230   };
52231   c(he, "type", "jpeg"), w.set("jpeg", he);
52232   var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4];
52233   var ce = class extends re2 {
52234     parseHeader() {
52235       var e3 = this.chunk.getUint16();
52236       18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true;
52237     }
52238     parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) {
52239       let { pick: n3, skip: s2 } = this.options[t2];
52240       n3 = new Set(n3);
52241       let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3);
52242       e3 += 2;
52243       for (let l2 = 0; l2 < o2; l2++) {
52244         let o3 = this.chunk.getUint16(e3);
52245         if (r2) {
52246           if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size)) break;
52247         } else !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2));
52248         e3 += 12;
52249       }
52250       return i3;
52251     }
52252     parseTag(e3, t2, i3) {
52253       let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2];
52254       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) return n3.getUint8Array(e3, r2);
52255       if (2 === s2) return m(n3.getString(e3, r2));
52256       if (7 === s2) return n3.getUint8Array(e3, r2);
52257       if (1 === r2) return this.parseTagValue(s2, e3);
52258       {
52259         let t3 = new (function(e4) {
52260           switch (e4) {
52261             case 1:
52262               return Uint8Array;
52263             case 3:
52264               return Uint16Array;
52265             case 4:
52266               return Uint32Array;
52267             case 5:
52268               return Array;
52269             case 6:
52270               return Int8Array;
52271             case 8:
52272               return Int16Array;
52273             case 9:
52274               return Int32Array;
52275             case 10:
52276               return Array;
52277             case 11:
52278               return Float32Array;
52279             case 12:
52280               return Float64Array;
52281             default:
52282               return Array;
52283           }
52284         }(s2))(r2), i4 = a2;
52285         for (let n4 = 0; n4 < r2; n4++) t3[n4] = this.parseTagValue(s2, e3), e3 += i4;
52286         return t3;
52287       }
52288     }
52289     parseTagValue(e3, t2) {
52290       let { chunk: i3 } = this;
52291       switch (e3) {
52292         case 1:
52293           return i3.getUint8(t2);
52294         case 3:
52295           return i3.getUint16(t2);
52296         case 4:
52297           return i3.getUint32(t2);
52298         case 5:
52299           return i3.getUint32(t2) / i3.getUint32(t2 + 4);
52300         case 6:
52301           return i3.getInt8(t2);
52302         case 8:
52303           return i3.getInt16(t2);
52304         case 9:
52305           return i3.getInt32(t2);
52306         case 10:
52307           return i3.getInt32(t2) / i3.getInt32(t2 + 4);
52308         case 11:
52309           return i3.getFloat(t2);
52310         case 12:
52311           return i3.getDouble(t2);
52312         case 13:
52313           return i3.getUint32(t2);
52314         default:
52315           g2("Invalid tiff type ".concat(e3));
52316       }
52317     }
52318   };
52319   var fe = class extends ce {
52320     static canHandle(e3, t2) {
52321       return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8);
52322     }
52323     async parse() {
52324       this.parseHeader();
52325       let { options: e3 } = this;
52326       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();
52327     }
52328     safeParse(e3) {
52329       let t2 = this[e3]();
52330       return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2;
52331     }
52332     findIfd0Offset() {
52333       void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4));
52334     }
52335     findIfd1Offset() {
52336       if (void 0 === this.ifd1Offset) {
52337         this.findIfd0Offset();
52338         let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3;
52339         this.ifd1Offset = this.chunk.getUint32(t2);
52340       }
52341     }
52342     parseBlock(e3, t2) {
52343       let i3 = /* @__PURE__ */ new Map();
52344       return this[t2] = i3, this.parseTags(e3, t2, i3), i3;
52345     }
52346     async parseIfd0Block() {
52347       if (this.ifd0) return;
52348       let { file: e3 } = this;
52349       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));
52350       let t2 = this.parseBlock(this.ifd0Offset, "ifd0");
52351       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;
52352     }
52353     async parseExifBlock() {
52354       if (this.exif) return;
52355       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset) return;
52356       this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options));
52357       let e3 = this.parseBlock(this.exifOffset, "exif");
52358       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;
52359     }
52360     unpack(e3, t2) {
52361       let i3 = e3.get(t2);
52362       i3 && 1 === i3.length && e3.set(t2, i3[0]);
52363     }
52364     async parseGpsBlock() {
52365       if (this.gps) return;
52366       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset) return;
52367       let e3 = this.parseBlock(this.gpsOffset, "gps");
52368       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;
52369     }
52370     async parseInteropBlock() {
52371       if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset)) return this.parseBlock(this.interopOffset, "interop");
52372     }
52373     async parseThumbnailBlock(e3 = false) {
52374       if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3)) return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1;
52375     }
52376     async extractThumbnail() {
52377       if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1) return;
52378       let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514);
52379       return this.chunk.getUint8Array(e3, t2);
52380     }
52381     get image() {
52382       return this.ifd0;
52383     }
52384     get thumbnail() {
52385       return this.ifd1;
52386     }
52387     createOutput() {
52388       let e3, t2, i3, n3 = {};
52389       for (t2 of H) if (e3 = this[t2], !p(e3)) if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) {
52390         if ("ifd1" === t2) continue;
52391         Object.assign(n3, i3);
52392       } else n3[t2] = i3;
52393       return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3;
52394     }
52395     assignToOutput(e3, t2) {
52396       if (this.globalOptions.mergeOutput) Object.assign(e3, t2);
52397       else for (let [i3, n3] of Object.entries(t2)) this.assignObjectToOutput(e3, i3, n3);
52398     }
52399   };
52400   function de(e3, t2, i3, n3) {
52401     var s2 = e3 + t2 / 60 + i3 / 3600;
52402     return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2;
52403   }
52404   c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe);
52405   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 });
52406   var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false };
52407   var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] });
52408   async function Se(e3) {
52409     let t2 = new te(me);
52410     await t2.read(e3);
52411     let i3 = await t2.parse();
52412     if (i3 && i3.gps) {
52413       let { latitude: e4, longitude: t3 } = i3.gps;
52414       return { latitude: e4, longitude: t3 };
52415     }
52416   }
52417   var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false });
52418   async function ye(e3) {
52419     let t2 = new te(Ce);
52420     await t2.read(e3);
52421     let i3 = await t2.extractThumbnail();
52422     return i3 && a ? s.from(i3) : i3;
52423   }
52424   async function be(e3) {
52425     let t2 = await this.thumbnail(e3);
52426     if (void 0 !== t2) {
52427       let e4 = new Blob([t2]);
52428       return URL.createObjectURL(e4);
52429     }
52430   }
52431   var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] });
52432   async function Pe(e3) {
52433     let t2 = new te(Ie);
52434     await t2.read(e3);
52435     let i3 = await t2.parse();
52436     if (i3 && i3.ifd0) return i3.ifd0[274];
52437   }
52438   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 } });
52439   var we = true;
52440   var Te = true;
52441   if ("object" == typeof navigator) {
52442     let e3 = navigator.userAgent;
52443     if (e3.includes("iPad") || e3.includes("iPhone")) {
52444       let t2 = e3.match(/OS (\d+)_(\d+)/);
52445       if (t2) {
52446         let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3);
52447         we = n3 < 13.4, Te = false;
52448       }
52449     } else if (e3.includes("OS X 10")) {
52450       let [, t2] = e3.match(/OS X 10[_.](\d+)/);
52451       we = Te = Number(t2) < 15;
52452     }
52453     if (e3.includes("Chrome/")) {
52454       let [, t2] = e3.match(/Chrome\/(\d+)/);
52455       we = Te = Number(t2) < 81;
52456     } else if (e3.includes("Firefox/")) {
52457       let [, t2] = e3.match(/Firefox\/(\d+)/);
52458       we = Te = Number(t2) < 77;
52459     }
52460   }
52461   async function Ae(e3) {
52462     let t2 = await Pe(e3);
52463     return Object.assign({ canvas: we, css: Te }, ke[t2]);
52464   }
52465   var De = class extends I {
52466     constructor(...e3) {
52467       super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength);
52468     }
52469     _tryExtend(e3, t2, i3) {
52470       if (0 === e3 && 0 === this.byteLength && i3) {
52471         let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength);
52472         this._swapDataView(e4);
52473       } else {
52474         let i4 = e3 + t2;
52475         if (i4 > this.byteLength) {
52476           let { dataView: e4 } = this._extend(i4);
52477           this._swapDataView(e4);
52478         }
52479       }
52480     }
52481     _extend(e3) {
52482       let t2;
52483       t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3);
52484       let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength);
52485       return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 };
52486     }
52487     subarray(e3, t2, i3 = false) {
52488       return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2);
52489     }
52490     set(e3, t2, i3 = false) {
52491       i3 && this._tryExtend(t2, e3.byteLength, e3);
52492       let n3 = super.set(e3, t2);
52493       return this.ranges.add(t2, n3.byteLength), n3;
52494     }
52495     async ensureChunk(e3, t2) {
52496       this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2));
52497     }
52498     available(e3, t2) {
52499       return this.ranges.available(e3, t2);
52500     }
52501   };
52502   var Oe = class {
52503     constructor() {
52504       c(this, "list", []);
52505     }
52506     get length() {
52507       return this.list.length;
52508     }
52509     add(e3, t2, i3 = 0) {
52510       let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3));
52511       if (s2.length > 0) {
52512         e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3;
52513         let i4 = s2.shift();
52514         i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4));
52515       } else this.list.push({ offset: e3, length: t2, end: n3 });
52516     }
52517     available(e3, t2) {
52518       let i3 = e3 + t2;
52519       return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end);
52520     }
52521   };
52522   function xe(e3, t2, i3) {
52523     return e3 <= t2 && t2 <= i3;
52524   }
52525   var ve = class extends De {
52526     constructor(e3, t2) {
52527       super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2;
52528     }
52529     async readWhole() {
52530       this.chunked = false, await this.readChunk(this.nextChunkOffset);
52531     }
52532     async readChunked() {
52533       this.chunked = true, await this.readChunk(0, this.options.firstChunkSize);
52534     }
52535     async readNextChunk(e3 = this.nextChunkOffset) {
52536       if (this.fullyRead) return this.chunksRead++, false;
52537       let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2);
52538       return !!i3 && i3.byteLength === t2;
52539     }
52540     async readChunk(e3, t2) {
52541       if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2))) return this._readChunk(e3, t2);
52542     }
52543     safeWrapAddress(e3, t2) {
52544       return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2;
52545     }
52546     get nextChunkOffset() {
52547       if (0 !== this.ranges.list.length) return this.ranges.list[0].length;
52548     }
52549     get canReadNextChunk() {
52550       return this.chunksRead < this.options.chunkLimit;
52551     }
52552     get fullyRead() {
52553       return void 0 !== this.size && this.nextChunkOffset === this.size;
52554     }
52555     read() {
52556       return this.options.chunked ? this.readChunked() : this.readWhole();
52557     }
52558     close() {
52559     }
52560   };
52561   A.set("blob", class extends ve {
52562     async readWhole() {
52563       this.chunked = false;
52564       let e3 = await R(this.input);
52565       this._swapArrayBuffer(e3);
52566     }
52567     readChunked() {
52568       return this.chunked = true, this.size = this.input.size, super.readChunked();
52569     }
52570     async _readChunk(e3, t2) {
52571       let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3);
52572       return this.set(s2, e3, true);
52573     }
52574   });
52575   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() {
52576     return we;
52577   }, get rotateCss() {
52578     return Te;
52579   }, rotation: Ae });
52580   A.set("url", class extends ve {
52581     async readWhole() {
52582       this.chunked = false;
52583       let e3 = await M(this.input);
52584       e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3);
52585     }
52586     async _readChunk(e3, t2) {
52587       let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {};
52588       (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-")));
52589       let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength;
52590       if (416 !== s2.status) return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true);
52591     }
52592   });
52593   I.prototype.getUint64 = function(e3) {
52594     let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4);
52595     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.");
52596   };
52597   var Re = class extends se {
52598     parseBoxes(e3 = 0) {
52599       let t2 = [];
52600       for (; e3 < this.file.byteLength - 4; ) {
52601         let i3 = this.parseBoxHead(e3);
52602         if (t2.push(i3), 0 === i3.length) break;
52603         e3 += i3.length;
52604       }
52605       return t2;
52606     }
52607     parseSubBoxes(e3) {
52608       e3.boxes = this.parseBoxes(e3.start);
52609     }
52610     findBox(e3, t2) {
52611       return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2);
52612     }
52613     parseBoxHead(e3) {
52614       let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8;
52615       return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 };
52616     }
52617     parseBoxFullHead(e3) {
52618       if (void 0 !== e3.version) return;
52619       let t2 = this.file.getUint32(e3.start);
52620       e3.version = t2 >> 24, e3.start += 4;
52621     }
52622   };
52623   var Le = class extends Re {
52624     static canHandle(e3, t2) {
52625       if (0 !== t2) return false;
52626       let i3 = e3.getUint16(2);
52627       if (i3 > 50) return false;
52628       let n3 = 16, s2 = [];
52629       for (; n3 < i3; ) s2.push(e3.getString(n3, 4)), n3 += 4;
52630       return s2.includes(this.type);
52631     }
52632     async parse() {
52633       let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3);
52634       for (; "meta" !== t2.kind; ) e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3);
52635       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);
52636     }
52637     async registerSegment(e3, t2, i3) {
52638       await this.file.ensureChunk(t2, i3);
52639       let n3 = this.file.subarray(t2, i3);
52640       this.createParser(e3, n3);
52641     }
52642     async findIcc(e3) {
52643       let t2 = this.findBox(e3, "iprp");
52644       if (void 0 === t2) return;
52645       let i3 = this.findBox(t2, "ipco");
52646       if (void 0 === i3) return;
52647       let n3 = this.findBox(i3, "colr");
52648       void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length);
52649     }
52650     async findExif(e3) {
52651       let t2 = this.findBox(e3, "iinf");
52652       if (void 0 === t2) return;
52653       let i3 = this.findBox(e3, "iloc");
52654       if (void 0 === i3) return;
52655       let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3);
52656       if (void 0 === s2) return;
52657       let [r2, a2] = s2;
52658       await this.file.ensureChunk(r2, a2);
52659       let o2 = 4 + this.file.getUint32(r2);
52660       r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2);
52661     }
52662     findExifLocIdInIinf(e3) {
52663       this.parseBoxFullHead(e3);
52664       let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2);
52665       for (r2 += 2; a2--; ) {
52666         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)) return this.file.getUintBytes(i3, n3);
52667         r2 += t2.length;
52668       }
52669     }
52670     get8bits(e3) {
52671       let t2 = this.file.getUint8(e3);
52672       return [t2 >> 4, 15 & t2];
52673     }
52674     findExtentInIloc(e3, t2) {
52675       this.parseBoxFullHead(e3);
52676       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);
52677       for (i3 += u2; c2--; ) {
52678         let e4 = this.file.getUintBytes(i3, o2);
52679         i3 += o2 + l2 + 2 + r2;
52680         let u3 = this.file.getUint16(i3);
52681         if (i3 += 2, e4 === t2) 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)];
52682         i3 += u3 * h2;
52683       }
52684     }
52685   };
52686   var Ue = class extends Le {
52687   };
52688   c(Ue, "type", "heic");
52689   var Fe = class extends Le {
52690   };
52691   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" }]]);
52692   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" }]]);
52693   var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" };
52694   Ee.set(37392, Be), Ee.set(41488, Be);
52695   var Ne = { 0: "Normal", 1: "Low", 2: "High" };
52696   function Ge(e3) {
52697     return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3;
52698   }
52699   function Ve(e3) {
52700     let t2 = Array.from(e3).slice(1);
52701     return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join(".");
52702   }
52703   function ze(e3) {
52704     if ("string" == typeof e3) {
52705       var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3);
52706       return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2;
52707     }
52708   }
52709   function He(e3) {
52710     if ("string" == typeof e3) return e3;
52711     let t2 = [];
52712     if (0 === e3[1] && 0 === e3[e3.length - 1]) for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3 + 1], e3[i3]));
52713     else for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3], e3[i3 + 1]));
52714     return m(String.fromCodePoint(...t2));
52715   }
52716   function je(e3, t2) {
52717     return e3 << 8 | t2;
52718   }
52719   Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) {
52720     return "string" != typeof e3 ? b(e3) : e3;
52721   }], [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(":")]]);
52722   var We = class extends re2 {
52723     static canHandle(e3, t2) {
52724       return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length);
52725     }
52726     static headerLength(e3, t2) {
52727       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;
52728     }
52729     static findPosition(e3, t2) {
52730       let i3 = super.findPosition(e3, t2);
52731       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;
52732     }
52733     static handleMultiSegments(e3) {
52734       return e3.map((e4) => e4.chunk.getString()).join("");
52735     }
52736     normalizeInput(e3) {
52737       return "string" == typeof e3 ? e3 : I.from(e3).getString();
52738     }
52739     parse(e3 = this.chunk) {
52740       if (!this.localOptions.parse) return e3;
52741       e3 = function(e4) {
52742         let t3 = {}, i4 = {};
52743         for (let e6 of Ze) t3[e6] = [], i4[e6] = 0;
52744         return e4.replace(et, (e6, n4, s2) => {
52745           if ("<" === n4) {
52746             let n5 = ++i4[s2];
52747             return t3[s2].push(n5), "".concat(e6, "#").concat(n5);
52748           }
52749           return "".concat(e6, "#").concat(t3[s2].pop());
52750         });
52751       }(e3);
52752       let t2 = Xe.findAll(e3, "rdf", "Description");
52753       0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3));
52754       let i3, n3 = {};
52755       for (let e4 of t2) for (let t3 of e4.properties) i3 = Je(t3.ns, n3), _e(t3, i3);
52756       return function(e4) {
52757         let t3;
52758         for (let i4 in e4) t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4];
52759         return f(e4);
52760       }(n3);
52761     }
52762     assignToOutput(e3, t2) {
52763       if (this.localOptions.parse) for (let [i3, n3] of Object.entries(t2)) switch (i3) {
52764         case "tiff":
52765           this.assignObjectToOutput(e3, "ifd0", n3);
52766           break;
52767         case "exif":
52768           this.assignObjectToOutput(e3, "exif", n3);
52769           break;
52770         case "xmlns":
52771           break;
52772         default:
52773           this.assignObjectToOutput(e3, i3, n3);
52774       }
52775       else e3.xmp = t2;
52776     }
52777   };
52778   c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We);
52779   var Ke = class _Ke {
52780     static findAll(e3) {
52781       return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch);
52782     }
52783     static unpackMatch(e3) {
52784       let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1);
52785       return n3 = Qe(n3), new _Ke(t2, i3, n3);
52786     }
52787     constructor(e3, t2, i3) {
52788       this.ns = e3, this.name = t2, this.value = i3;
52789     }
52790     serialize() {
52791       return this.value;
52792     }
52793   };
52794   var Xe = class _Xe {
52795     static findAll(e3, t2, i3) {
52796       if (void 0 !== t2 || void 0 !== i3) {
52797         t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+";
52798         var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm");
52799       } else n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;
52800       return qe(e3, n3).map(_Xe.unpackMatch);
52801     }
52802     static unpackMatch(e3) {
52803       let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8];
52804       return new _Xe(t2, i3, n3, s2);
52805     }
52806     constructor(e3, t2, i3, n3) {
52807       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];
52808     }
52809     get isPrimitive() {
52810       return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length;
52811     }
52812     get isListContainer() {
52813       return 1 === this.children.length && this.children[0].isList;
52814     }
52815     get isList() {
52816       let { ns: e3, name: t2 } = this;
52817       return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2);
52818     }
52819     get isListItem() {
52820       return "rdf" === this.ns && "li" === this.name;
52821     }
52822     serialize() {
52823       if (0 === this.properties.length && void 0 === this.value) return;
52824       if (this.isPrimitive) return this.value;
52825       if (this.isListContainer) return this.children[0].serialize();
52826       if (this.isList) return $e(this.children.map(Ye));
52827       if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length) return this.children[0].serialize();
52828       let e3 = {};
52829       for (let t2 of this.properties) _e(t2, e3);
52830       return void 0 !== this.value && (e3.value = this.value), f(e3);
52831     }
52832   };
52833   function _e(e3, t2) {
52834     let i3 = e3.serialize();
52835     void 0 !== i3 && (t2[e3.name] = i3);
52836   }
52837   var Ye = (e3) => e3.serialize();
52838   var $e = (e3) => 1 === e3.length ? e3[0] : e3;
52839   var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {};
52840   function qe(e3, t2) {
52841     let i3, n3 = [];
52842     if (!e3) return n3;
52843     for (; null !== (i3 = t2.exec(e3)); ) n3.push(i3);
52844     return n3;
52845   }
52846   function Qe(e3) {
52847     if (function(e4) {
52848       return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim();
52849     }(e3)) return;
52850     let t2 = Number(e3);
52851     if (!Number.isNaN(t2)) return t2;
52852     let i3 = e3.toLowerCase();
52853     return "true" === i3 || "false" !== i3 && e3.trim();
52854   }
52855   var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"];
52856   var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g");
52857   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() {
52858     return we;
52859   }, get rotateCss() {
52860     return Te;
52861   }, rotation: Ae });
52862   var at = l("fs", (e3) => e3.promises);
52863   A.set("fs", class extends ve {
52864     async readWhole() {
52865       this.chunked = false, this.fs = await at;
52866       let e3 = await this.fs.readFile(this.input);
52867       this._swapBuffer(e3);
52868     }
52869     async readChunked() {
52870       this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize);
52871     }
52872     async open() {
52873       void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size);
52874     }
52875     async _readChunk(e3, t2) {
52876       void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3);
52877       var i3 = this.subarray(e3, t2, true);
52878       return await this.fh.read(i3.dataView, 0, t2, e3), i3;
52879     }
52880     async close() {
52881       if (this.fh) {
52882         let e3 = this.fh;
52883         this.fh = void 0, await e3.close();
52884       }
52885     }
52886   });
52887   A.set("base64", class extends ve {
52888     constructor(...e3) {
52889       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);
52890     }
52891     async _readChunk(e3, t2) {
52892       let i3, n3, r2 = this.input;
52893       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);
52894       let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3);
52895       r2 = r2.slice(i3, l2);
52896       let h2 = Math.min(t2, this.size - e3);
52897       if (a) {
52898         let t3 = s.from(r2, "base64").slice(n3, n3 + h2);
52899         return this.set(t3, e3, true);
52900       }
52901       {
52902         let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8();
52903         for (let e4 = 0; e4 < h2; e4++) s2[e4] = i4.charCodeAt(n3 + e4);
52904         return t3;
52905       }
52906     }
52907   });
52908   var ot = class extends se {
52909     static canHandle(e3, t2) {
52910       return 18761 === t2 || 19789 === t2;
52911     }
52912     extendOptions(e3) {
52913       let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3;
52914       i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters();
52915     }
52916     async parse() {
52917       let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options;
52918       if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) {
52919         let e4 = Math.max(S(this.options), this.options.chunkSize);
52920         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");
52921       }
52922     }
52923     adaptTiffPropAsSegment(e3) {
52924       if (this.parsers.tiff[e3]) {
52925         let t2 = this.parsers.tiff[e3];
52926         this.injectSegment(e3, t2);
52927       }
52928     }
52929   };
52930   c(ot, "type", "tiff"), w.set("tiff", ot);
52931   var lt = l("zlib");
52932   var ht = ["ihdr", "iccp", "text", "itxt", "exif"];
52933   var ut = class extends se {
52934     constructor(...e3) {
52935       super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []);
52936     }
52937     static canHandle(e3, t2) {
52938       return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4);
52939     }
52940     async parse() {
52941       let { file: e3 } = this;
52942       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);
52943     }
52944     async findPngChunksInRange(e3, t2) {
52945       let { file: i3 } = this;
52946       for (; e3 < t2; ) {
52947         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 };
52948         ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2;
52949       }
52950     }
52951     parseTextChunks() {
52952       let e3 = this.metaChunks.filter((e4) => "text" === e4.type);
52953       for (let t2 of e3) {
52954         let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0");
52955         this.injectKeyValToIhdr(e4, i3);
52956       }
52957     }
52958     injectKeyValToIhdr(e3, t2) {
52959       let i3 = this.parsers.ihdr;
52960       i3 && i3.raw.set(e3, t2);
52961     }
52962     findIhdr() {
52963       let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type);
52964       e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk);
52965     }
52966     async findExif() {
52967       let e3 = this.metaChunks.find((e4) => "exif" === e4.type);
52968       e3 && this.injectSegment("tiff", e3.chunk);
52969     }
52970     async findXmp() {
52971       let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type);
52972       for (let t2 of e3) {
52973         "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk);
52974       }
52975     }
52976     async findIcc() {
52977       let e3 = this.metaChunks.find((e4) => "iccp" === e4.type);
52978       if (!e3) return;
52979       let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0;
52980       for (; s2 < 80 && 0 !== i3[s2]; ) s2++;
52981       let r2 = s2 + 2, a2 = t2.getString(0, s2);
52982       if (this.injectKeyValToIhdr("ProfileName", a2), n2) {
52983         let e4 = await lt, i4 = t2.getUint8Array(r2);
52984         i4 = e4.inflateSync(i4), this.injectSegment("icc", i4);
52985       }
52986     }
52987   };
52988   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"]]);
52989   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"]];
52990   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" }]]);
52991   var ft = class extends re2 {
52992     static canHandle(e3, t2) {
52993       return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8);
52994     }
52995     parse() {
52996       return this.parseTags(), this.translate(), this.output;
52997     }
52998     parseTags() {
52999       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)]]);
53000     }
53001   };
53002   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"]]);
53003   var dt = class extends re2 {
53004     parse() {
53005       return this.parseTags(), this.translate(), this.output;
53006     }
53007     parseTags() {
53008       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)]);
53009     }
53010   };
53011   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" }]]);
53012   var pt = class extends re2 {
53013     static canHandle(e3, t2) {
53014       return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4);
53015     }
53016     static findPosition(e3, t2) {
53017       let i3 = super.findPosition(e3, t2);
53018       return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3;
53019     }
53020     static handleMultiSegments(e3) {
53021       return function(e4) {
53022         let t2 = function(e6) {
53023           let t3 = e6[0].constructor, i3 = 0;
53024           for (let t4 of e6) i3 += t4.length;
53025           let n3 = new t3(i3), s2 = 0;
53026           for (let t4 of e6) n3.set(t4, s2), s2 += t4.length;
53027           return n3;
53028         }(e4.map((e6) => e6.chunk.toUint8()));
53029         return new I(t2);
53030       }(e3);
53031     }
53032     parse() {
53033       return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output;
53034     }
53035     parseHeader() {
53036       let { raw: e3 } = this;
53037       this.chunk.byteLength < 84 && g2("ICC header is too short");
53038       for (let [t2, i3] of Object.entries(gt)) {
53039         t2 = parseInt(t2, 10);
53040         let n3 = i3(this.chunk, t2);
53041         "\0\0\0\0" !== n3 && e3.set(t2, n3);
53042       }
53043     }
53044     parseTags() {
53045       let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength;
53046       for (; a2--; ) {
53047         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) return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments.");
53048         s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12;
53049       }
53050     }
53051     parseTag(e3, t2, i3) {
53052       switch (e3) {
53053         case "desc":
53054           return this.parseDesc(t2);
53055         case "mluc":
53056           return this.parseMluc(t2);
53057         case "text":
53058           return this.parseText(t2, i3);
53059         case "sig ":
53060           return this.parseSig(t2);
53061       }
53062       if (!(t2 + i3 > this.chunk.byteLength)) return this.chunk.getUint8Array(t2, i3);
53063     }
53064     parseDesc(e3) {
53065       let t2 = this.chunk.getUint32(e3 + 8) - 1;
53066       return m(this.chunk.getString(e3 + 12, t2));
53067     }
53068     parseText(e3, t2) {
53069       return m(this.chunk.getString(e3 + 8, t2 - 8));
53070     }
53071     parseSig(e3) {
53072       return m(this.chunk.getString(e3 + 8, 4));
53073     }
53074     parseMluc(e3) {
53075       let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = [];
53076       for (let a2 = 0; a2 < i3; a2++) {
53077         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));
53078         r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3;
53079       }
53080       return 1 === i3 ? r2[0].text : r2;
53081     }
53082     translateValue(e3, t2) {
53083       return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3;
53084     }
53085   };
53086   c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18);
53087   var gt = { 4: mt, 8: function(e3, t2) {
53088     return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join(".");
53089   }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) {
53090     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);
53091     return new Date(Date.UTC(i3, n3, s2, r2, a2, o2));
53092   }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt };
53093   function mt(e3, t2) {
53094     return m(e3.getString(t2, 4));
53095   }
53096   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"]]);
53097   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" };
53098   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!)" };
53099   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" }]]);
53100   var yt = class extends re2 {
53101     static canHandle(e3, t2, i3) {
53102       return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3);
53103     }
53104     static headerLength(e3, t2, i3) {
53105       let n3, s2 = this.containsIptc8bim(e3, t2, i3);
53106       if (void 0 !== s2) return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3;
53107     }
53108     static containsIptc8bim(e3, t2, i3) {
53109       for (let n3 = 0; n3 < i3; n3++) if (this.isIptcSegmentHead(e3, t2 + n3)) return n3;
53110     }
53111     static isIptcSegmentHead(e3, t2) {
53112       return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4);
53113     }
53114     parse() {
53115       let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false;
53116       for (let n3 = 0; n3 < t2; n3++) if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) {
53117         i3 = true;
53118         let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3);
53119         e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3;
53120       } else if (i3) break;
53121       return this.translate(), this.output;
53122     }
53123     pluralizeValue(e3, t2) {
53124       return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2;
53125     }
53126   };
53127   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" }]]);
53128   var full_esm_default = tt;
53129
53130   // modules/services/plane_photo.js
53131   var dispatch5 = dispatch_default("viewerChanged");
53132   var _photo;
53133   var _wrapper;
53134   var imgZoom;
53135   var _widthOverflow;
53136   function zoomPan(d3_event) {
53137     let t2 = d3_event.transform;
53138     _photo.call(utilSetTransform, t2.x, t2.y, t2.k);
53139   }
53140   function zoomBeahvior() {
53141     const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect();
53142     const { naturalHeight, naturalWidth } = _photo.node();
53143     const intrinsicRatio = naturalWidth / naturalHeight;
53144     _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth;
53145     return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan);
53146   }
53147   function loadImage(selection2, path) {
53148     return new Promise((resolve) => {
53149       selection2.attr("src", path);
53150       selection2.on("load", () => {
53151         resolve(selection2);
53152       });
53153     });
53154   }
53155   var plane_photo_default = {
53156     init: async function(context, selection2) {
53157       this.event = utilRebind(this, dispatch5, "on");
53158       _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true);
53159       _photo = _wrapper.append("img").attr("class", "plane-photo");
53160       context.ui().photoviewer.on("resize.plane", () => {
53161         imgZoom = zoomBeahvior();
53162         _wrapper.call(imgZoom);
53163       });
53164       await Promise.resolve();
53165       return this;
53166     },
53167     showPhotoFrame: function(context) {
53168       const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size();
53169       if (isHidden) {
53170         context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true);
53171         context.selectAll(".photo-frame.plane-frame").classed("hide", false);
53172       }
53173       return this;
53174     },
53175     hidePhotoFrame: function(context) {
53176       context.select("photo-frame.plane-frame").classed("hide", false);
53177       return this;
53178     },
53179     selectPhoto: function(data) {
53180       dispatch5.call("viewerChanged");
53181       loadImage(_photo, "");
53182       loadImage(_photo, data.image_path).then(() => {
53183         imgZoom = zoomBeahvior();
53184         _wrapper.call(imgZoom);
53185         _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0));
53186       });
53187       return this;
53188     },
53189     getYaw: function() {
53190       return 0;
53191     }
53192   };
53193
53194   // modules/svg/local_photos.js
53195   var _initialized2 = false;
53196   var _enabled2 = false;
53197   var minViewfieldZoom = 16;
53198   function svgLocalPhotos(projection2, context, dispatch14) {
53199     const detected = utilDetect();
53200     let layer = select_default2(null);
53201     let _fileList;
53202     let _photos = [];
53203     let _idAutoinc = 0;
53204     let _photoFrame;
53205     function init2() {
53206       if (_initialized2) return;
53207       _enabled2 = true;
53208       function over(d3_event) {
53209         d3_event.stopPropagation();
53210         d3_event.preventDefault();
53211         d3_event.dataTransfer.dropEffect = "copy";
53212       }
53213       context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) {
53214         d3_event.stopPropagation();
53215         d3_event.preventDefault();
53216         if (!detected.filedrop) return;
53217         drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => {
53218           if (loaded.length > 0) {
53219             drawPhotos.fitZoom(false);
53220           }
53221         });
53222       }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over);
53223       _initialized2 = true;
53224     }
53225     function ensureViewerLoaded(context2) {
53226       if (_photoFrame) {
53227         return Promise.resolve(_photoFrame);
53228       }
53229       const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]);
53230       const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true);
53231       viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD");
53232       return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => {
53233         _photoFrame = planePhotoFrame;
53234       });
53235     }
53236     function click(d3_event, image, zoomTo) {
53237       ensureViewerLoaded(context).then(() => {
53238         const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false);
53239         const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false);
53240         const attribution = viewerWrap.selectAll(".photo-attribution").text("");
53241         if (image.date) {
53242           attribution.append("span").text(image.date.toLocaleString());
53243         }
53244         if (image.name) {
53245           attribution.append("span").classed("filename", true).text(image.name);
53246         }
53247         _photoFrame.selectPhoto({ image_path: "" });
53248         image.getSrc().then((src) => {
53249           _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap);
53250           setStyles();
53251         });
53252       });
53253       if (zoomTo) {
53254         context.map().centerEase(image.loc);
53255       }
53256     }
53257     function transform2(d2) {
53258       var svgpoint = projection2(d2.loc);
53259       return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")";
53260     }
53261     function setStyles(hovered) {
53262       const viewer = context.container().select(".photoviewer");
53263       const selected = viewer.empty() ? void 0 : viewer.datum();
53264       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));
53265     }
53266     function display_markers(imageList) {
53267       imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1]));
53268       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) {
53269         return d2.id;
53270       });
53271       groups.exit().remove();
53272       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click);
53273       groupsEnter.append("g").attr("class", "viewfield-scale");
53274       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
53275       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53276       const showViewfields = context.map().zoom() >= minViewfieldZoom;
53277       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53278       viewfields.exit().remove();
53279       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() {
53280         var _a4;
53281         const d2 = this.parentNode.__data__;
53282         return "rotate(".concat(Math.round((_a4 = d2.direction) != null ? _a4 : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)");
53283       }).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() {
53284         const d2 = this.parentNode.__data__;
53285         return isNumber_default(d2.direction) ? "visible" : "hidden";
53286       });
53287     }
53288     function drawPhotos(selection2) {
53289       layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []);
53290       layer.exit().remove();
53291       const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos");
53292       layerEnter.append("g").attr("class", "markers");
53293       layer = layerEnter.merge(layer);
53294       if (_photos) {
53295         display_markers(_photos);
53296       }
53297     }
53298     function readFileAsDataURL(file) {
53299       return new Promise((resolve, reject) => {
53300         const reader = new FileReader();
53301         reader.onload = () => resolve(reader.result);
53302         reader.onerror = (error) => reject(error);
53303         reader.readAsDataURL(file);
53304       });
53305     }
53306     async function readmultifiles(files, callback) {
53307       const loaded = [];
53308       for (const file of files) {
53309         try {
53310           const exifData = await full_esm_default.parse(file);
53311           const photo = {
53312             id: _idAutoinc++,
53313             name: file.name,
53314             getSrc: () => readFileAsDataURL(file),
53315             file,
53316             loc: [exifData.longitude, exifData.latitude],
53317             direction: exifData.GPSImgDirection,
53318             date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate
53319           };
53320           loaded.push(photo);
53321           const sameName = _photos.filter((i3) => i3.name === photo.name);
53322           if (sameName.length === 0) {
53323             _photos.push(photo);
53324           } else {
53325             const thisContent = await photo.getSrc();
53326             const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc()));
53327             if (!sameNameContent.some((i3) => i3.value === thisContent)) {
53328               _photos.push(photo);
53329             }
53330           }
53331         } catch (e3) {
53332         }
53333       }
53334       if (typeof callback === "function") callback(loaded);
53335       dispatch14.call("change");
53336     }
53337     drawPhotos.setFiles = function(fileList, callback) {
53338       readmultifiles(Array.from(fileList), callback);
53339       return this;
53340     };
53341     drawPhotos.fileList = function(fileList, callback) {
53342       if (!arguments.length) return _fileList;
53343       _fileList = fileList;
53344       if (!fileList || !fileList.length) return this;
53345       drawPhotos.setFiles(_fileList, callback);
53346       return this;
53347     };
53348     drawPhotos.getPhotos = function() {
53349       return _photos;
53350     };
53351     drawPhotos.removePhoto = function(id2) {
53352       _photos = _photos.filter((i3) => i3.id !== id2);
53353       dispatch14.call("change");
53354       return _photos;
53355     };
53356     drawPhotos.openPhoto = click;
53357     drawPhotos.fitZoom = function(force) {
53358       const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1]));
53359       if (coords.length === 0) return;
53360       const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2));
53361       const map2 = context.map();
53362       var viewport = map2.trimmedExtent().polygon();
53363       if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) {
53364         map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent)));
53365       }
53366     };
53367     function showLayer() {
53368       layer.style("display", "block");
53369       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
53370         dispatch14.call("change");
53371       });
53372     }
53373     function hideLayer() {
53374       layer.transition().duration(250).style("opacity", 0).on("end", () => {
53375         layer.selectAll(".viewfield-group").remove();
53376         layer.style("display", "none");
53377       });
53378     }
53379     drawPhotos.enabled = function(val) {
53380       if (!arguments.length) return _enabled2;
53381       _enabled2 = val;
53382       if (_enabled2) {
53383         showLayer();
53384       } else {
53385         hideLayer();
53386       }
53387       dispatch14.call("change");
53388       return this;
53389     };
53390     drawPhotos.hasData = function() {
53391       return isArray_default(_photos) && _photos.length > 0;
53392     };
53393     init2();
53394     return drawPhotos;
53395   }
53396
53397   // modules/svg/osmose.js
53398   var _layerEnabled2 = false;
53399   var _qaService2;
53400   function svgOsmose(projection2, context, dispatch14) {
53401     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
53402     const minZoom5 = 12;
53403     let touchLayer = select_default2(null);
53404     let drawLayer = select_default2(null);
53405     let layerVisible = false;
53406     function markerPath(selection2, klass) {
53407       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");
53408     }
53409     function getService() {
53410       if (services.osmose && !_qaService2) {
53411         _qaService2 = services.osmose;
53412         _qaService2.on("loaded", throttledRedraw);
53413       } else if (!services.osmose && _qaService2) {
53414         _qaService2 = null;
53415       }
53416       return _qaService2;
53417     }
53418     function editOn() {
53419       if (!layerVisible) {
53420         layerVisible = true;
53421         drawLayer.style("display", "block");
53422       }
53423     }
53424     function editOff() {
53425       if (layerVisible) {
53426         layerVisible = false;
53427         drawLayer.style("display", "none");
53428         drawLayer.selectAll(".qaItem.osmose").remove();
53429         touchLayer.selectAll(".qaItem.osmose").remove();
53430       }
53431     }
53432     function layerOn() {
53433       editOn();
53434       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
53435     }
53436     function layerOff() {
53437       throttledRedraw.cancel();
53438       drawLayer.interrupt();
53439       touchLayer.selectAll(".qaItem.osmose").remove();
53440       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
53441         editOff();
53442         dispatch14.call("change");
53443       });
53444     }
53445     function updateMarkers() {
53446       if (!layerVisible || !_layerEnabled2) return;
53447       const service = getService();
53448       const selectedID = context.selectedErrorID();
53449       const data = service ? service.getItems(projection2) : [];
53450       const getTransform = svgPointTransform(projection2);
53451       const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
53452       markers.exit().remove();
53453       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
53454       markersEnter.append("polygon").call(markerPath, "shadow");
53455       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
53456       markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill");
53457       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 : "");
53458       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
53459       if (touchLayer.empty()) return;
53460       const fillClass = context.getDebug("target") ? "pink" : "nocolor";
53461       const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
53462       targets.exit().remove();
53463       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);
53464       function sortY(a2, b2) {
53465         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
53466       }
53467     }
53468     function drawOsmose(selection2) {
53469       const service = getService();
53470       const surface = context.surface();
53471       if (surface && !surface.empty()) {
53472         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
53473       }
53474       drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []);
53475       drawLayer.exit().remove();
53476       drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer);
53477       if (_layerEnabled2) {
53478         if (service && ~~context.map().zoom() >= minZoom5) {
53479           editOn();
53480           service.loadIssues(projection2);
53481           updateMarkers();
53482         } else {
53483           editOff();
53484         }
53485       }
53486     }
53487     drawOsmose.enabled = function(val) {
53488       if (!arguments.length) return _layerEnabled2;
53489       _layerEnabled2 = val;
53490       if (_layerEnabled2) {
53491         getService().loadStrings().then(layerOn).catch((err) => {
53492           console.log(err);
53493         });
53494       } else {
53495         layerOff();
53496         if (context.selectedErrorID()) {
53497           context.enter(modeBrowse(context));
53498         }
53499       }
53500       dispatch14.call("change");
53501       return this;
53502     };
53503     drawOsmose.supported = () => !!getService();
53504     return drawOsmose;
53505   }
53506
53507   // modules/svg/streetside.js
53508   function svgStreetside(projection2, context, dispatch14) {
53509     var throttledRedraw = throttle_default(function() {
53510       dispatch14.call("change");
53511     }, 1e3);
53512     var minZoom5 = 14;
53513     var minMarkerZoom = 16;
53514     var minViewfieldZoom2 = 18;
53515     var layer = select_default2(null);
53516     var _viewerYaw = 0;
53517     var _selectedSequence = null;
53518     var _streetside;
53519     function init2() {
53520       if (svgStreetside.initialized) return;
53521       svgStreetside.enabled = false;
53522       svgStreetside.initialized = true;
53523     }
53524     function getService() {
53525       if (services.streetside && !_streetside) {
53526         _streetside = services.streetside;
53527         _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw);
53528       } else if (!services.streetside && _streetside) {
53529         _streetside = null;
53530       }
53531       return _streetside;
53532     }
53533     function showLayer() {
53534       var service = getService();
53535       if (!service) return;
53536       editOn();
53537       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
53538         dispatch14.call("change");
53539       });
53540     }
53541     function hideLayer() {
53542       throttledRedraw.cancel();
53543       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53544     }
53545     function editOn() {
53546       layer.style("display", "block");
53547     }
53548     function editOff() {
53549       layer.selectAll(".viewfield-group").remove();
53550       layer.style("display", "none");
53551     }
53552     function click(d3_event, d2) {
53553       var service = getService();
53554       if (!service) return;
53555       if (d2.sequenceKey !== _selectedSequence) {
53556         _viewerYaw = 0;
53557       }
53558       _selectedSequence = d2.sequenceKey;
53559       service.ensureViewerLoaded(context).then(function() {
53560         service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context);
53561       });
53562       context.map().centerEase(d2.loc);
53563     }
53564     function mouseover(d3_event, d2) {
53565       var service = getService();
53566       if (service) service.setStyles(context, d2);
53567     }
53568     function mouseout() {
53569       var service = getService();
53570       if (service) service.setStyles(context, null);
53571     }
53572     function transform2(d2) {
53573       var t2 = svgPointTransform(projection2)(d2);
53574       var rot = d2.ca + _viewerYaw;
53575       if (rot) {
53576         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
53577       }
53578       return t2;
53579     }
53580     function viewerChanged() {
53581       var service = getService();
53582       if (!service) return;
53583       var viewer = service.viewer();
53584       if (!viewer) return;
53585       _viewerYaw = viewer.getYaw();
53586       if (context.map().isTransformed()) return;
53587       layer.selectAll(".viewfield-group.currentView").attr("transform", transform2);
53588     }
53589     function filterBubbles(bubbles) {
53590       var fromDate = context.photos().fromDate();
53591       var toDate = context.photos().toDate();
53592       var usernames = context.photos().usernames();
53593       if (fromDate) {
53594         var fromTimestamp = new Date(fromDate).getTime();
53595         bubbles = bubbles.filter(function(bubble) {
53596           return new Date(bubble.captured_at).getTime() >= fromTimestamp;
53597         });
53598       }
53599       if (toDate) {
53600         var toTimestamp = new Date(toDate).getTime();
53601         bubbles = bubbles.filter(function(bubble) {
53602           return new Date(bubble.captured_at).getTime() <= toTimestamp;
53603         });
53604       }
53605       if (usernames) {
53606         bubbles = bubbles.filter(function(bubble) {
53607           return usernames.indexOf(bubble.captured_by) !== -1;
53608         });
53609       }
53610       return bubbles;
53611     }
53612     function filterSequences(sequences) {
53613       var fromDate = context.photos().fromDate();
53614       var toDate = context.photos().toDate();
53615       var usernames = context.photos().usernames();
53616       if (fromDate) {
53617         var fromTimestamp = new Date(fromDate).getTime();
53618         sequences = sequences.filter(function(sequences2) {
53619           return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp;
53620         });
53621       }
53622       if (toDate) {
53623         var toTimestamp = new Date(toDate).getTime();
53624         sequences = sequences.filter(function(sequences2) {
53625           return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp;
53626         });
53627       }
53628       if (usernames) {
53629         sequences = sequences.filter(function(sequences2) {
53630           return usernames.indexOf(sequences2.properties.captured_by) !== -1;
53631         });
53632       }
53633       return sequences;
53634     }
53635     function update() {
53636       var viewer = context.container().select(".photoviewer");
53637       var selected = viewer.empty() ? void 0 : viewer.datum();
53638       var z2 = ~~context.map().zoom();
53639       var showMarkers = z2 >= minMarkerZoom;
53640       var showViewfields = z2 >= minViewfieldZoom2;
53641       var service = getService();
53642       var sequences = [];
53643       var bubbles = [];
53644       if (context.photos().showsPanoramic()) {
53645         sequences = service ? service.sequences(projection2) : [];
53646         bubbles = service && showMarkers ? service.bubbles(projection2) : [];
53647         sequences = filterSequences(sequences);
53648         bubbles = filterBubbles(bubbles);
53649       }
53650       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
53651         return d2.properties.key;
53652       });
53653       traces.exit().remove();
53654       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
53655       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) {
53656         return d2.key + (d2.sequenceKey ? "v1" : "v0");
53657       });
53658       groups.exit().remove();
53659       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
53660       groupsEnter.append("g").attr("class", "viewfield-scale");
53661       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
53662         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
53663       }).attr("transform", transform2).select(".viewfield-scale");
53664       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53665       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53666       viewfields.exit().remove();
53667       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
53668       function viewfieldPath() {
53669         var d2 = this.parentNode.__data__;
53670         if (d2.pano) {
53671           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
53672         } else {
53673           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
53674         }
53675       }
53676     }
53677     function drawImages(selection2) {
53678       var enabled = svgStreetside.enabled;
53679       var service = getService();
53680       layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []);
53681       layer.exit().remove();
53682       var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none");
53683       layerEnter.append("g").attr("class", "sequences");
53684       layerEnter.append("g").attr("class", "markers");
53685       layer = layerEnter.merge(layer);
53686       if (enabled) {
53687         if (service && ~~context.map().zoom() >= minZoom5) {
53688           editOn();
53689           update();
53690           service.loadBubbles(projection2);
53691         } else {
53692           editOff();
53693         }
53694       }
53695     }
53696     drawImages.enabled = function(_2) {
53697       if (!arguments.length) return svgStreetside.enabled;
53698       svgStreetside.enabled = _2;
53699       if (svgStreetside.enabled) {
53700         showLayer();
53701         context.photos().on("change.streetside", update);
53702       } else {
53703         hideLayer();
53704         context.photos().on("change.streetside", null);
53705       }
53706       dispatch14.call("change");
53707       return this;
53708     };
53709     drawImages.supported = function() {
53710       return !!getService();
53711     };
53712     drawImages.rendered = function(zoom) {
53713       return zoom >= minZoom5;
53714     };
53715     init2();
53716     return drawImages;
53717   }
53718
53719   // modules/svg/vegbilder.js
53720   function svgVegbilder(projection2, context, dispatch14) {
53721     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
53722     const minZoom5 = 14;
53723     const minMarkerZoom = 16;
53724     const minViewfieldZoom2 = 18;
53725     let layer = select_default2(null);
53726     let _viewerYaw = 0;
53727     let _vegbilder;
53728     function init2() {
53729       if (svgVegbilder.initialized) return;
53730       svgVegbilder.enabled = false;
53731       svgVegbilder.initialized = true;
53732     }
53733     function getService() {
53734       if (services.vegbilder && !_vegbilder) {
53735         _vegbilder = services.vegbilder;
53736         _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw);
53737       } else if (!services.vegbilder && _vegbilder) {
53738         _vegbilder = null;
53739       }
53740       return _vegbilder;
53741     }
53742     function showLayer() {
53743       const service = getService();
53744       if (!service) return;
53745       editOn();
53746       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change"));
53747     }
53748     function hideLayer() {
53749       throttledRedraw.cancel();
53750       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53751     }
53752     function editOn() {
53753       layer.style("display", "block");
53754     }
53755     function editOff() {
53756       layer.selectAll(".viewfield-group").remove();
53757       layer.style("display", "none");
53758     }
53759     function click(d3_event, d2) {
53760       const service = getService();
53761       if (!service) return;
53762       service.ensureViewerLoaded(context).then(() => {
53763         service.selectImage(context, d2.key).showViewer(context);
53764       });
53765       context.map().centerEase(d2.loc);
53766     }
53767     function mouseover(d3_event, d2) {
53768       const service = getService();
53769       if (service) service.setStyles(context, d2);
53770     }
53771     function mouseout() {
53772       const service = getService();
53773       if (service) service.setStyles(context, null);
53774     }
53775     function transform2(d2, selected) {
53776       let t2 = svgPointTransform(projection2)(d2);
53777       let rot = d2.ca;
53778       if (d2 === selected) {
53779         rot += _viewerYaw;
53780       }
53781       if (rot) {
53782         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
53783       }
53784       return t2;
53785     }
53786     function viewerChanged() {
53787       const service = getService();
53788       if (!service) return;
53789       const frame2 = service.photoFrame();
53790       _viewerYaw = frame2.getYaw();
53791       if (context.map().isTransformed()) return;
53792       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2));
53793     }
53794     function filterImages(images) {
53795       const photoContext = context.photos();
53796       const fromDateString = photoContext.fromDate();
53797       const toDateString = photoContext.toDate();
53798       const showsFlat = photoContext.showsFlat();
53799       const showsPano = photoContext.showsPanoramic();
53800       if (fromDateString) {
53801         const fromDate = new Date(fromDateString);
53802         images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime());
53803       }
53804       if (toDateString) {
53805         const toDate = new Date(toDateString);
53806         images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime());
53807       }
53808       if (!showsPano) {
53809         images = images.filter((image) => !image.is_sphere);
53810       }
53811       if (!showsFlat) {
53812         images = images.filter((image) => image.is_sphere);
53813       }
53814       return images;
53815     }
53816     function filterSequences(sequences) {
53817       const photoContext = context.photos();
53818       const fromDateString = photoContext.fromDate();
53819       const toDateString = photoContext.toDate();
53820       const showsFlat = photoContext.showsFlat();
53821       const showsPano = photoContext.showsPanoramic();
53822       if (fromDateString) {
53823         const fromDate = new Date(fromDateString);
53824         sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime());
53825       }
53826       if (toDateString) {
53827         const toDate = new Date(toDateString);
53828         sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime());
53829       }
53830       if (!showsPano) {
53831         sequences = sequences.filter(({ images }) => !images[0].is_sphere);
53832       }
53833       if (!showsFlat) {
53834         sequences = sequences.filter(({ images }) => images[0].is_sphere);
53835       }
53836       return sequences;
53837     }
53838     function update() {
53839       const viewer = context.container().select(".photoviewer");
53840       const selected = viewer.empty() ? void 0 : viewer.datum();
53841       const z2 = ~~context.map().zoom();
53842       const showMarkers = z2 >= minMarkerZoom;
53843       const showViewfields = z2 >= minViewfieldZoom2;
53844       const service = getService();
53845       let sequences = [];
53846       let images = [];
53847       if (service) {
53848         service.loadImages(context);
53849         sequences = service.sequences(projection2);
53850         images = showMarkers ? service.images(projection2) : [];
53851         images = filterImages(images);
53852         sequences = filterSequences(sequences);
53853       }
53854       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key);
53855       traces.exit().remove();
53856       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
53857       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key);
53858       groups.exit().remove();
53859       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
53860       groupsEnter.append("g").attr("class", "viewfield-scale");
53861       const markers = groups.merge(groupsEnter).sort((a2, b2) => {
53862         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
53863       }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale");
53864       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53865       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53866       viewfields.exit().remove();
53867       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
53868       function viewfieldPath() {
53869         const d2 = this.parentNode.__data__;
53870         if (d2.is_sphere) {
53871           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
53872         } else {
53873           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
53874         }
53875       }
53876     }
53877     function drawImages(selection2) {
53878       const enabled = svgVegbilder.enabled;
53879       const service = getService();
53880       layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []);
53881       layer.exit().remove();
53882       const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none");
53883       layerEnter.append("g").attr("class", "sequences");
53884       layerEnter.append("g").attr("class", "markers");
53885       layer = layerEnter.merge(layer);
53886       if (enabled) {
53887         if (service && ~~context.map().zoom() >= minZoom5) {
53888           editOn();
53889           update();
53890           service.loadImages(context);
53891         } else {
53892           editOff();
53893         }
53894       }
53895     }
53896     drawImages.enabled = function(_2) {
53897       if (!arguments.length) return svgVegbilder.enabled;
53898       svgVegbilder.enabled = _2;
53899       if (svgVegbilder.enabled) {
53900         showLayer();
53901         context.photos().on("change.vegbilder", update);
53902       } else {
53903         hideLayer();
53904         context.photos().on("change.vegbilder", null);
53905       }
53906       dispatch14.call("change");
53907       return this;
53908     };
53909     drawImages.supported = function() {
53910       return !!getService();
53911     };
53912     drawImages.rendered = function(zoom) {
53913       return zoom >= minZoom5;
53914     };
53915     drawImages.validHere = function(extent, zoom) {
53916       return zoom >= minZoom5 - 2 && getService().validHere(extent);
53917     };
53918     init2();
53919     return drawImages;
53920   }
53921
53922   // modules/svg/mapillary_images.js
53923   function svgMapillaryImages(projection2, context, dispatch14) {
53924     const throttledRedraw = throttle_default(function() {
53925       dispatch14.call("change");
53926     }, 1e3);
53927     const minZoom5 = 12;
53928     const minMarkerZoom = 16;
53929     const minViewfieldZoom2 = 18;
53930     let layer = select_default2(null);
53931     let _mapillary;
53932     function init2() {
53933       if (svgMapillaryImages.initialized) return;
53934       svgMapillaryImages.enabled = false;
53935       svgMapillaryImages.initialized = true;
53936     }
53937     function getService() {
53938       if (services.mapillary && !_mapillary) {
53939         _mapillary = services.mapillary;
53940         _mapillary.event.on("loadedImages", throttledRedraw);
53941       } else if (!services.mapillary && _mapillary) {
53942         _mapillary = null;
53943       }
53944       return _mapillary;
53945     }
53946     function showLayer() {
53947       const service = getService();
53948       if (!service) return;
53949       editOn();
53950       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
53951         dispatch14.call("change");
53952       });
53953     }
53954     function hideLayer() {
53955       throttledRedraw.cancel();
53956       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53957     }
53958     function editOn() {
53959       layer.style("display", "block");
53960     }
53961     function editOff() {
53962       layer.selectAll(".viewfield-group").remove();
53963       layer.style("display", "none");
53964     }
53965     function click(d3_event, image) {
53966       const service = getService();
53967       if (!service) return;
53968       service.ensureViewerLoaded(context).then(function() {
53969         service.selectImage(context, image.id).showViewer(context);
53970       });
53971       context.map().centerEase(image.loc);
53972     }
53973     function mouseover(d3_event, image) {
53974       const service = getService();
53975       if (service) service.setStyles(context, image);
53976     }
53977     function mouseout() {
53978       const service = getService();
53979       if (service) service.setStyles(context, null);
53980     }
53981     function transform2(d2) {
53982       let t2 = svgPointTransform(projection2)(d2);
53983       if (d2.ca) {
53984         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
53985       }
53986       return t2;
53987     }
53988     function filterImages(images) {
53989       const showsPano = context.photos().showsPanoramic();
53990       const showsFlat = context.photos().showsFlat();
53991       const fromDate = context.photos().fromDate();
53992       const toDate = context.photos().toDate();
53993       if (!showsPano || !showsFlat) {
53994         images = images.filter(function(image) {
53995           if (image.is_pano) return showsPano;
53996           return showsFlat;
53997         });
53998       }
53999       if (fromDate) {
54000         images = images.filter(function(image) {
54001           return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime();
54002         });
54003       }
54004       if (toDate) {
54005         images = images.filter(function(image) {
54006           return new Date(image.captured_at).getTime() <= new Date(toDate).getTime();
54007         });
54008       }
54009       return images;
54010     }
54011     function filterSequences(sequences) {
54012       const showsPano = context.photos().showsPanoramic();
54013       const showsFlat = context.photos().showsFlat();
54014       const fromDate = context.photos().fromDate();
54015       const toDate = context.photos().toDate();
54016       if (!showsPano || !showsFlat) {
54017         sequences = sequences.filter(function(sequence) {
54018           if (sequence.properties.hasOwnProperty("is_pano")) {
54019             if (sequence.properties.is_pano) return showsPano;
54020             return showsFlat;
54021           }
54022           return false;
54023         });
54024       }
54025       if (fromDate) {
54026         sequences = sequences.filter(function(sequence) {
54027           return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString();
54028         });
54029       }
54030       if (toDate) {
54031         sequences = sequences.filter(function(sequence) {
54032           return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString();
54033         });
54034       }
54035       return sequences;
54036     }
54037     function update() {
54038       const z2 = ~~context.map().zoom();
54039       const showMarkers = z2 >= minMarkerZoom;
54040       const showViewfields = z2 >= minViewfieldZoom2;
54041       const service = getService();
54042       let sequences = service ? service.sequences(projection2) : [];
54043       let images = service && showMarkers ? service.images(projection2) : [];
54044       images = filterImages(images);
54045       sequences = filterSequences(sequences, service);
54046       service.filterViewer(context);
54047       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54048         return d2.properties.id;
54049       });
54050       traces.exit().remove();
54051       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54052       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54053         return d2.id;
54054       });
54055       groups.exit().remove();
54056       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54057       groupsEnter.append("g").attr("class", "viewfield-scale");
54058       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54059         return b2.loc[1] - a2.loc[1];
54060       }).attr("transform", transform2).select(".viewfield-scale");
54061       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54062       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54063       viewfields.exit().remove();
54064       viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() {
54065         return this.parentNode.__data__.is_pano;
54066       }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54067       function viewfieldPath() {
54068         if (this.parentNode.__data__.is_pano) {
54069           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54070         } else {
54071           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54072         }
54073       }
54074     }
54075     function drawImages(selection2) {
54076       const enabled = svgMapillaryImages.enabled;
54077       const service = getService();
54078       layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []);
54079       layer.exit().remove();
54080       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none");
54081       layerEnter.append("g").attr("class", "sequences");
54082       layerEnter.append("g").attr("class", "markers");
54083       layer = layerEnter.merge(layer);
54084       if (enabled) {
54085         if (service && ~~context.map().zoom() >= minZoom5) {
54086           editOn();
54087           update();
54088           service.loadImages(projection2);
54089         } else {
54090           editOff();
54091         }
54092       }
54093     }
54094     drawImages.enabled = function(_2) {
54095       if (!arguments.length) return svgMapillaryImages.enabled;
54096       svgMapillaryImages.enabled = _2;
54097       if (svgMapillaryImages.enabled) {
54098         showLayer();
54099         context.photos().on("change.mapillary_images", update);
54100       } else {
54101         hideLayer();
54102         context.photos().on("change.mapillary_images", null);
54103       }
54104       dispatch14.call("change");
54105       return this;
54106     };
54107     drawImages.supported = function() {
54108       return !!getService();
54109     };
54110     drawImages.rendered = function(zoom) {
54111       return zoom >= minZoom5;
54112     };
54113     init2();
54114     return drawImages;
54115   }
54116
54117   // modules/svg/mapillary_position.js
54118   function svgMapillaryPosition(projection2, context) {
54119     const throttledRedraw = throttle_default(function() {
54120       update();
54121     }, 1e3);
54122     const minZoom5 = 12;
54123     const minViewfieldZoom2 = 18;
54124     let layer = select_default2(null);
54125     let _mapillary;
54126     let viewerCompassAngle;
54127     function init2() {
54128       if (svgMapillaryPosition.initialized) return;
54129       svgMapillaryPosition.initialized = true;
54130     }
54131     function getService() {
54132       if (services.mapillary && !_mapillary) {
54133         _mapillary = services.mapillary;
54134         _mapillary.event.on("imageChanged", throttledRedraw);
54135         _mapillary.event.on("bearingChanged", function(e3) {
54136           viewerCompassAngle = e3.bearing;
54137           if (context.map().isTransformed()) return;
54138           layer.selectAll(".viewfield-group.currentView").filter(function(d2) {
54139             return d2.is_pano;
54140           }).attr("transform", transform2);
54141         });
54142       } else if (!services.mapillary && _mapillary) {
54143         _mapillary = null;
54144       }
54145       return _mapillary;
54146     }
54147     function editOn() {
54148       layer.style("display", "block");
54149     }
54150     function editOff() {
54151       layer.selectAll(".viewfield-group").remove();
54152       layer.style("display", "none");
54153     }
54154     function transform2(d2) {
54155       let t2 = svgPointTransform(projection2)(d2);
54156       if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) {
54157         t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)";
54158       } else if (d2.ca) {
54159         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
54160       }
54161       return t2;
54162     }
54163     function update() {
54164       const z2 = ~~context.map().zoom();
54165       const showViewfields = z2 >= minViewfieldZoom2;
54166       const service = getService();
54167       const image = service && service.getActiveImage();
54168       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) {
54169         return d2.id;
54170       });
54171       groups.exit().remove();
54172       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted");
54173       groupsEnter.append("g").attr("class", "viewfield-scale");
54174       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
54175       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54176       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54177       viewfields.exit().remove();
54178       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");
54179     }
54180     function drawImages(selection2) {
54181       const service = getService();
54182       layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []);
54183       layer.exit().remove();
54184       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position");
54185       layerEnter.append("g").attr("class", "markers");
54186       layer = layerEnter.merge(layer);
54187       if (service && ~~context.map().zoom() >= minZoom5) {
54188         editOn();
54189         update();
54190       } else {
54191         editOff();
54192       }
54193     }
54194     drawImages.enabled = function() {
54195       update();
54196       return this;
54197     };
54198     drawImages.supported = function() {
54199       return !!getService();
54200     };
54201     drawImages.rendered = function(zoom) {
54202       return zoom >= minZoom5;
54203     };
54204     init2();
54205     return drawImages;
54206   }
54207
54208   // modules/svg/mapillary_signs.js
54209   function svgMapillarySigns(projection2, context, dispatch14) {
54210     const throttledRedraw = throttle_default(function() {
54211       dispatch14.call("change");
54212     }, 1e3);
54213     const minZoom5 = 12;
54214     let layer = select_default2(null);
54215     let _mapillary;
54216     function init2() {
54217       if (svgMapillarySigns.initialized) return;
54218       svgMapillarySigns.enabled = false;
54219       svgMapillarySigns.initialized = true;
54220     }
54221     function getService() {
54222       if (services.mapillary && !_mapillary) {
54223         _mapillary = services.mapillary;
54224         _mapillary.event.on("loadedSigns", throttledRedraw);
54225       } else if (!services.mapillary && _mapillary) {
54226         _mapillary = null;
54227       }
54228       return _mapillary;
54229     }
54230     function showLayer() {
54231       const service = getService();
54232       if (!service) return;
54233       service.loadSignResources(context);
54234       editOn();
54235     }
54236     function hideLayer() {
54237       throttledRedraw.cancel();
54238       editOff();
54239     }
54240     function editOn() {
54241       layer.style("display", "block");
54242     }
54243     function editOff() {
54244       layer.selectAll(".icon-sign").remove();
54245       layer.style("display", "none");
54246     }
54247     function click(d3_event, d2) {
54248       const service = getService();
54249       if (!service) return;
54250       context.map().centerEase(d2.loc);
54251       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
54252       service.getDetections(d2.id).then((detections) => {
54253         if (detections.length) {
54254           const imageId = detections[0].image.id;
54255           if (imageId === selectedImageId) {
54256             service.highlightDetection(detections[0]).selectImage(context, imageId);
54257           } else {
54258             service.ensureViewerLoaded(context).then(function() {
54259               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
54260             });
54261           }
54262         }
54263       });
54264     }
54265     function filterData(detectedFeatures) {
54266       var fromDate = context.photos().fromDate();
54267       var toDate = context.photos().toDate();
54268       if (fromDate) {
54269         var fromTimestamp = new Date(fromDate).getTime();
54270         detectedFeatures = detectedFeatures.filter(function(feature3) {
54271           return new Date(feature3.last_seen_at).getTime() >= fromTimestamp;
54272         });
54273       }
54274       if (toDate) {
54275         var toTimestamp = new Date(toDate).getTime();
54276         detectedFeatures = detectedFeatures.filter(function(feature3) {
54277           return new Date(feature3.first_seen_at).getTime() <= toTimestamp;
54278         });
54279       }
54280       return detectedFeatures;
54281     }
54282     function update() {
54283       const service = getService();
54284       let data = service ? service.signs(projection2) : [];
54285       data = filterData(data);
54286       const transform2 = svgPointTransform(projection2);
54287       const signs = layer.selectAll(".icon-sign").data(data, function(d2) {
54288         return d2.id;
54289       });
54290       signs.exit().remove();
54291       const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click);
54292       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
54293         return "#" + d2.value;
54294       });
54295       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
54296       signs.merge(enter).attr("transform", transform2);
54297     }
54298     function drawSigns(selection2) {
54299       const enabled = svgMapillarySigns.enabled;
54300       const service = getService();
54301       layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []);
54302       layer.exit().remove();
54303       layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
54304       if (enabled) {
54305         if (service && ~~context.map().zoom() >= minZoom5) {
54306           editOn();
54307           update();
54308           service.loadSigns(projection2);
54309           service.showSignDetections(true);
54310         } else {
54311           editOff();
54312         }
54313       } else if (service) {
54314         service.showSignDetections(false);
54315       }
54316     }
54317     drawSigns.enabled = function(_2) {
54318       if (!arguments.length) return svgMapillarySigns.enabled;
54319       svgMapillarySigns.enabled = _2;
54320       if (svgMapillarySigns.enabled) {
54321         showLayer();
54322         context.photos().on("change.mapillary_signs", update);
54323       } else {
54324         hideLayer();
54325         context.photos().on("change.mapillary_signs", null);
54326       }
54327       dispatch14.call("change");
54328       return this;
54329     };
54330     drawSigns.supported = function() {
54331       return !!getService();
54332     };
54333     drawSigns.rendered = function(zoom) {
54334       return zoom >= minZoom5;
54335     };
54336     init2();
54337     return drawSigns;
54338   }
54339
54340   // modules/svg/mapillary_map_features.js
54341   function svgMapillaryMapFeatures(projection2, context, dispatch14) {
54342     const throttledRedraw = throttle_default(function() {
54343       dispatch14.call("change");
54344     }, 1e3);
54345     const minZoom5 = 12;
54346     let layer = select_default2(null);
54347     let _mapillary;
54348     function init2() {
54349       if (svgMapillaryMapFeatures.initialized) return;
54350       svgMapillaryMapFeatures.enabled = false;
54351       svgMapillaryMapFeatures.initialized = true;
54352     }
54353     function getService() {
54354       if (services.mapillary && !_mapillary) {
54355         _mapillary = services.mapillary;
54356         _mapillary.event.on("loadedMapFeatures", throttledRedraw);
54357       } else if (!services.mapillary && _mapillary) {
54358         _mapillary = null;
54359       }
54360       return _mapillary;
54361     }
54362     function showLayer() {
54363       const service = getService();
54364       if (!service) return;
54365       service.loadObjectResources(context);
54366       editOn();
54367     }
54368     function hideLayer() {
54369       throttledRedraw.cancel();
54370       editOff();
54371     }
54372     function editOn() {
54373       layer.style("display", "block");
54374     }
54375     function editOff() {
54376       layer.selectAll(".icon-map-feature").remove();
54377       layer.style("display", "none");
54378     }
54379     function click(d3_event, d2) {
54380       const service = getService();
54381       if (!service) return;
54382       context.map().centerEase(d2.loc);
54383       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
54384       service.getDetections(d2.id).then((detections) => {
54385         if (detections.length) {
54386           const imageId = detections[0].image.id;
54387           if (imageId === selectedImageId) {
54388             service.highlightDetection(detections[0]).selectImage(context, imageId);
54389           } else {
54390             service.ensureViewerLoaded(context).then(function() {
54391               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
54392             });
54393           }
54394         }
54395       });
54396     }
54397     function filterData(detectedFeatures) {
54398       const fromDate = context.photos().fromDate();
54399       const toDate = context.photos().toDate();
54400       if (fromDate) {
54401         detectedFeatures = detectedFeatures.filter(function(feature3) {
54402           return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime();
54403         });
54404       }
54405       if (toDate) {
54406         detectedFeatures = detectedFeatures.filter(function(feature3) {
54407           return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime();
54408         });
54409       }
54410       return detectedFeatures;
54411     }
54412     function update() {
54413       const service = getService();
54414       let data = service ? service.mapFeatures(projection2) : [];
54415       data = filterData(data);
54416       const transform2 = svgPointTransform(projection2);
54417       const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) {
54418         return d2.id;
54419       });
54420       mapFeatures.exit().remove();
54421       const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click);
54422       enter.append("title").text(function(d2) {
54423         var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_");
54424         return _t("mapillary_map_features." + id2);
54425       });
54426       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
54427         if (d2.value === "object--billboard") {
54428           return "#object--sign--advertisement";
54429         }
54430         return "#" + d2.value;
54431       });
54432       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
54433       mapFeatures.merge(enter).attr("transform", transform2);
54434     }
54435     function drawMapFeatures(selection2) {
54436       const enabled = svgMapillaryMapFeatures.enabled;
54437       const service = getService();
54438       layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []);
54439       layer.exit().remove();
54440       layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
54441       if (enabled) {
54442         if (service && ~~context.map().zoom() >= minZoom5) {
54443           editOn();
54444           update();
54445           service.loadMapFeatures(projection2);
54446           service.showFeatureDetections(true);
54447         } else {
54448           editOff();
54449         }
54450       } else if (service) {
54451         service.showFeatureDetections(false);
54452       }
54453     }
54454     drawMapFeatures.enabled = function(_2) {
54455       if (!arguments.length) return svgMapillaryMapFeatures.enabled;
54456       svgMapillaryMapFeatures.enabled = _2;
54457       if (svgMapillaryMapFeatures.enabled) {
54458         showLayer();
54459         context.photos().on("change.mapillary_map_features", update);
54460       } else {
54461         hideLayer();
54462         context.photos().on("change.mapillary_map_features", null);
54463       }
54464       dispatch14.call("change");
54465       return this;
54466     };
54467     drawMapFeatures.supported = function() {
54468       return !!getService();
54469     };
54470     drawMapFeatures.rendered = function(zoom) {
54471       return zoom >= minZoom5;
54472     };
54473     init2();
54474     return drawMapFeatures;
54475   }
54476
54477   // modules/svg/kartaview_images.js
54478   function svgKartaviewImages(projection2, context, dispatch14) {
54479     var throttledRedraw = throttle_default(function() {
54480       dispatch14.call("change");
54481     }, 1e3);
54482     var minZoom5 = 12;
54483     var minMarkerZoom = 16;
54484     var minViewfieldZoom2 = 18;
54485     var layer = select_default2(null);
54486     var _kartaview;
54487     function init2() {
54488       if (svgKartaviewImages.initialized) return;
54489       svgKartaviewImages.enabled = false;
54490       svgKartaviewImages.initialized = true;
54491     }
54492     function getService() {
54493       if (services.kartaview && !_kartaview) {
54494         _kartaview = services.kartaview;
54495         _kartaview.event.on("loadedImages", throttledRedraw);
54496       } else if (!services.kartaview && _kartaview) {
54497         _kartaview = null;
54498       }
54499       return _kartaview;
54500     }
54501     function showLayer() {
54502       var service = getService();
54503       if (!service) return;
54504       editOn();
54505       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54506         dispatch14.call("change");
54507       });
54508     }
54509     function hideLayer() {
54510       throttledRedraw.cancel();
54511       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54512     }
54513     function editOn() {
54514       layer.style("display", "block");
54515     }
54516     function editOff() {
54517       layer.selectAll(".viewfield-group").remove();
54518       layer.style("display", "none");
54519     }
54520     function click(d3_event, d2) {
54521       var service = getService();
54522       if (!service) return;
54523       service.ensureViewerLoaded(context).then(function() {
54524         service.selectImage(context, d2.key).showViewer(context);
54525       });
54526       context.map().centerEase(d2.loc);
54527     }
54528     function mouseover(d3_event, d2) {
54529       var service = getService();
54530       if (service) service.setStyles(context, d2);
54531     }
54532     function mouseout() {
54533       var service = getService();
54534       if (service) service.setStyles(context, null);
54535     }
54536     function transform2(d2) {
54537       var t2 = svgPointTransform(projection2)(d2);
54538       if (d2.ca) {
54539         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
54540       }
54541       return t2;
54542     }
54543     function filterImages(images) {
54544       var fromDate = context.photos().fromDate();
54545       var toDate = context.photos().toDate();
54546       var usernames = context.photos().usernames();
54547       if (fromDate) {
54548         var fromTimestamp = new Date(fromDate).getTime();
54549         images = images.filter(function(item) {
54550           return new Date(item.captured_at).getTime() >= fromTimestamp;
54551         });
54552       }
54553       if (toDate) {
54554         var toTimestamp = new Date(toDate).getTime();
54555         images = images.filter(function(item) {
54556           return new Date(item.captured_at).getTime() <= toTimestamp;
54557         });
54558       }
54559       if (usernames) {
54560         images = images.filter(function(item) {
54561           return usernames.indexOf(item.captured_by) !== -1;
54562         });
54563       }
54564       return images;
54565     }
54566     function filterSequences(sequences) {
54567       var fromDate = context.photos().fromDate();
54568       var toDate = context.photos().toDate();
54569       var usernames = context.photos().usernames();
54570       if (fromDate) {
54571         var fromTimestamp = new Date(fromDate).getTime();
54572         sequences = sequences.filter(function(image) {
54573           return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
54574         });
54575       }
54576       if (toDate) {
54577         var toTimestamp = new Date(toDate).getTime();
54578         sequences = sequences.filter(function(image) {
54579           return new Date(image.properties.captured_at).getTime() <= toTimestamp;
54580         });
54581       }
54582       if (usernames) {
54583         sequences = sequences.filter(function(image) {
54584           return usernames.indexOf(image.properties.captured_by) !== -1;
54585         });
54586       }
54587       return sequences;
54588     }
54589     function update() {
54590       var viewer = context.container().select(".photoviewer");
54591       var selected = viewer.empty() ? void 0 : viewer.datum();
54592       var z2 = ~~context.map().zoom();
54593       var showMarkers = z2 >= minMarkerZoom;
54594       var showViewfields = z2 >= minViewfieldZoom2;
54595       var service = getService();
54596       var sequences = [];
54597       var images = [];
54598       if (context.photos().showsFlat()) {
54599         sequences = service ? service.sequences(projection2) : [];
54600         images = service && showMarkers ? service.images(projection2) : [];
54601         sequences = filterSequences(sequences);
54602         images = filterImages(images);
54603       }
54604       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54605         return d2.properties.key;
54606       });
54607       traces.exit().remove();
54608       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54609       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54610         return d2.key;
54611       });
54612       groups.exit().remove();
54613       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54614       groupsEnter.append("g").attr("class", "viewfield-scale");
54615       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54616         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54617       }).attr("transform", transform2).select(".viewfield-scale");
54618       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54619       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54620       viewfields.exit().remove();
54621       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");
54622     }
54623     function drawImages(selection2) {
54624       var enabled = svgKartaviewImages.enabled, service = getService();
54625       layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []);
54626       layer.exit().remove();
54627       var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none");
54628       layerEnter.append("g").attr("class", "sequences");
54629       layerEnter.append("g").attr("class", "markers");
54630       layer = layerEnter.merge(layer);
54631       if (enabled) {
54632         if (service && ~~context.map().zoom() >= minZoom5) {
54633           editOn();
54634           update();
54635           service.loadImages(projection2);
54636         } else {
54637           editOff();
54638         }
54639       }
54640     }
54641     drawImages.enabled = function(_2) {
54642       if (!arguments.length) return svgKartaviewImages.enabled;
54643       svgKartaviewImages.enabled = _2;
54644       if (svgKartaviewImages.enabled) {
54645         showLayer();
54646         context.photos().on("change.kartaview_images", update);
54647       } else {
54648         hideLayer();
54649         context.photos().on("change.kartaview_images", null);
54650       }
54651       dispatch14.call("change");
54652       return this;
54653     };
54654     drawImages.supported = function() {
54655       return !!getService();
54656     };
54657     drawImages.rendered = function(zoom) {
54658       return zoom >= minZoom5;
54659     };
54660     init2();
54661     return drawImages;
54662   }
54663
54664   // modules/svg/mapilio_images.js
54665   function svgMapilioImages(projection2, context, dispatch14) {
54666     const throttledRedraw = throttle_default(function() {
54667       dispatch14.call("change");
54668     }, 1e3);
54669     const minZoom5 = 12;
54670     let layer = select_default2(null);
54671     let _mapilio;
54672     const viewFieldZoomLevel = 18;
54673     function init2() {
54674       if (svgMapilioImages.initialized) return;
54675       svgMapilioImages.enabled = false;
54676       svgMapilioImages.initialized = true;
54677     }
54678     function getService() {
54679       if (services.mapilio && !_mapilio) {
54680         _mapilio = services.mapilio;
54681         _mapilio.event.on("loadedImages", throttledRedraw);
54682       } else if (!services.mapilio && _mapilio) {
54683         _mapilio = null;
54684       }
54685       return _mapilio;
54686     }
54687     function showLayer() {
54688       const service = getService();
54689       if (!service) return;
54690       editOn();
54691       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54692         dispatch14.call("change");
54693       });
54694     }
54695     function hideLayer() {
54696       throttledRedraw.cancel();
54697       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54698     }
54699     function transform2(d2) {
54700       let t2 = svgPointTransform(projection2)(d2);
54701       if (d2.heading) {
54702         t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)";
54703       }
54704       return t2;
54705     }
54706     function editOn() {
54707       layer.style("display", "block");
54708     }
54709     function editOff() {
54710       layer.selectAll(".viewfield-group").remove();
54711       layer.style("display", "none");
54712     }
54713     function click(d3_event, image) {
54714       const service = getService();
54715       if (!service) return;
54716       service.ensureViewerLoaded(context, image.id).then(function() {
54717         service.selectImage(context, image.id).showViewer(context);
54718       });
54719       context.map().centerEase(image.loc);
54720     }
54721     function mouseover(d3_event, image) {
54722       const service = getService();
54723       if (service) service.setStyles(context, image);
54724     }
54725     function mouseout() {
54726       const service = getService();
54727       if (service) service.setStyles(context, null);
54728     }
54729     function update() {
54730       const z2 = ~~context.map().zoom();
54731       const showViewfields = z2 >= viewFieldZoomLevel;
54732       const service = getService();
54733       let sequences = service ? service.sequences(projection2) : [];
54734       let images = service ? service.images(projection2) : [];
54735       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54736         return d2.properties.id;
54737       });
54738       traces.exit().remove();
54739       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54740       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54741         return d2.id;
54742       });
54743       groups.exit().remove();
54744       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54745       groupsEnter.append("g").attr("class", "viewfield-scale");
54746       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54747         return b2.loc[1] - a2.loc[1];
54748       }).attr("transform", transform2).select(".viewfield-scale");
54749       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54750       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54751       viewfields.exit().remove();
54752       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54753       function viewfieldPath() {
54754         if (this.parentNode.__data__.isPano) {
54755           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54756         } else {
54757           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54758         }
54759       }
54760     }
54761     function drawImages(selection2) {
54762       const enabled = svgMapilioImages.enabled;
54763       const service = getService();
54764       layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []);
54765       layer.exit().remove();
54766       const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none");
54767       layerEnter.append("g").attr("class", "sequences");
54768       layerEnter.append("g").attr("class", "markers");
54769       layer = layerEnter.merge(layer);
54770       if (enabled) {
54771         if (service && ~~context.map().zoom() >= minZoom5) {
54772           editOn();
54773           update();
54774           service.loadImages(projection2);
54775           service.loadLines(projection2);
54776         } else {
54777           editOff();
54778         }
54779       }
54780     }
54781     drawImages.enabled = function(_2) {
54782       if (!arguments.length) return svgMapilioImages.enabled;
54783       svgMapilioImages.enabled = _2;
54784       if (svgMapilioImages.enabled) {
54785         showLayer();
54786         context.photos().on("change.mapilio_images", update);
54787       } else {
54788         hideLayer();
54789         context.photos().on("change.mapilio_images", null);
54790       }
54791       dispatch14.call("change");
54792       return this;
54793     };
54794     drawImages.supported = function() {
54795       return !!getService();
54796     };
54797     drawImages.rendered = function(zoom) {
54798       return zoom >= minZoom5;
54799     };
54800     init2();
54801     return drawImages;
54802   }
54803
54804   // modules/svg/panoramax_images.js
54805   function svgPanoramaxImages(projection2, context, dispatch14) {
54806     const throttledRedraw = throttle_default(function() {
54807       dispatch14.call("change");
54808     }, 1e3);
54809     const imageMinZoom2 = 15;
54810     const lineMinZoom2 = 10;
54811     const viewFieldZoomLevel = 18;
54812     let layer = select_default2(null);
54813     let _panoramax;
54814     let _viewerYaw = 0;
54815     let _selectedSequence;
54816     let _activeUsernameFilter;
54817     let _activeIds;
54818     function init2() {
54819       if (svgPanoramaxImages.initialized) return;
54820       svgPanoramaxImages.enabled = false;
54821       svgPanoramaxImages.initialized = true;
54822     }
54823     function getService() {
54824       if (services.panoramax && !_panoramax) {
54825         _panoramax = services.panoramax;
54826         _panoramax.event.on("viewerChanged", viewerChanged).on("loadedLines", throttledRedraw).on("loadedImages", throttledRedraw);
54827       } else if (!services.panoramax && _panoramax) {
54828         _panoramax = null;
54829       }
54830       return _panoramax;
54831     }
54832     async function filterImages(images) {
54833       const showsPano = context.photos().showsPanoramic();
54834       const showsFlat = context.photos().showsFlat();
54835       const fromDate = context.photos().fromDate();
54836       const toDate = context.photos().toDate();
54837       const username = context.photos().usernames();
54838       const service = getService();
54839       if (!showsPano || !showsFlat) {
54840         images = images.filter(function(image) {
54841           if (image.isPano) return showsPano;
54842           return showsFlat;
54843         });
54844       }
54845       if (fromDate) {
54846         images = images.filter(function(image) {
54847           return new Date(image.capture_time).getTime() >= new Date(fromDate).getTime();
54848         });
54849       }
54850       if (toDate) {
54851         images = images.filter(function(image) {
54852           return new Date(image.capture_time).getTime() <= new Date(toDate).getTime();
54853         });
54854       }
54855       if (username && service) {
54856         if (_activeUsernameFilter !== username) {
54857           _activeUsernameFilter = username;
54858           const tempIds = await service.getUserIds(username);
54859           _activeIds = {};
54860           tempIds.forEach((id2) => {
54861             _activeIds[id2] = true;
54862           });
54863         }
54864         images = images.filter(function(image) {
54865           return _activeIds[image.account_id];
54866         });
54867       }
54868       return images;
54869     }
54870     async function filterSequences(sequences) {
54871       const showsPano = context.photos().showsPanoramic();
54872       const showsFlat = context.photos().showsFlat();
54873       const fromDate = context.photos().fromDate();
54874       const toDate = context.photos().toDate();
54875       const username = context.photos().usernames();
54876       const service = getService();
54877       if (!showsPano || !showsFlat) {
54878         sequences = sequences.filter(function(sequence) {
54879           if (sequence.properties.type === "equirectangular") return showsPano;
54880           return showsFlat;
54881         });
54882       }
54883       if (fromDate) {
54884         sequences = sequences.filter(function(sequence) {
54885           return new Date(sequence.properties.date).getTime() >= new Date(fromDate).getTime().toString();
54886         });
54887       }
54888       if (toDate) {
54889         sequences = sequences.filter(function(sequence) {
54890           return new Date(sequence.properties.date).getTime() <= new Date(toDate).getTime().toString();
54891         });
54892       }
54893       if (username && service) {
54894         if (_activeUsernameFilter !== username) {
54895           _activeUsernameFilter = username;
54896           const tempIds = await service.getUserIds(username);
54897           _activeIds = {};
54898           tempIds.forEach((id2) => {
54899             _activeIds[id2] = true;
54900           });
54901         }
54902         sequences = sequences.filter(function(sequence) {
54903           return _activeIds[sequence.properties.account_id];
54904         });
54905       }
54906       return sequences;
54907     }
54908     function showLayer() {
54909       const service = getService();
54910       if (!service) return;
54911       editOn();
54912       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54913         dispatch14.call("change");
54914       });
54915     }
54916     function hideLayer() {
54917       throttledRedraw.cancel();
54918       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54919     }
54920     function transform2(d2, selectedImageId) {
54921       let t2 = svgPointTransform(projection2)(d2);
54922       let rot = d2.heading;
54923       if (d2.id === selectedImageId) {
54924         rot += _viewerYaw;
54925       }
54926       if (rot) {
54927         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54928       }
54929       return t2;
54930     }
54931     function editOn() {
54932       layer.style("display", "block");
54933     }
54934     function editOff() {
54935       layer.selectAll(".viewfield-group").remove();
54936       layer.style("display", "none");
54937     }
54938     function click(d3_event, image) {
54939       const service = getService();
54940       if (!service) return;
54941       if (image.sequence_id !== _selectedSequence) {
54942         _viewerYaw = 0;
54943       }
54944       _selectedSequence = image.sequence_id;
54945       service.ensureViewerLoaded(context).then(function() {
54946         service.selectImage(context, image.id).showViewer(context);
54947       });
54948       context.map().centerEase(image.loc);
54949     }
54950     function mouseover(d3_event, image) {
54951       const service = getService();
54952       if (service) service.setStyles(context, image);
54953     }
54954     function mouseout() {
54955       const service = getService();
54956       if (service) service.setStyles(context, null);
54957     }
54958     async function update() {
54959       var _a4;
54960       const zoom = ~~context.map().zoom();
54961       const showViewfields = zoom >= viewFieldZoomLevel;
54962       const service = getService();
54963       let sequences = service ? service.sequences(projection2, zoom) : [];
54964       let images = service && zoom >= imageMinZoom2 ? service.images(projection2) : [];
54965       images = await filterImages(images);
54966       sequences = await filterSequences(sequences, service);
54967       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54968         return d2.properties.id;
54969       });
54970       traces.exit().remove();
54971       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54972       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54973         return d2.id;
54974       });
54975       groups.exit().remove();
54976       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54977       groupsEnter.append("g").attr("class", "viewfield-scale");
54978       const activeImageId = (_a4 = service.getActiveImage()) == null ? void 0 : _a4.id;
54979       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54980         if (a2.id === activeImageId) return 1;
54981         if (b2.id === activeImageId) return -1;
54982         return a2.capture_time_parsed - b2.capture_time_parsed;
54983       }).attr("transform", (d2) => transform2(d2, activeImageId)).select(".viewfield-scale");
54984       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54985       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54986       viewfields.exit().remove();
54987       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54988       service.setStyles(context, null);
54989       function viewfieldPath() {
54990         if (this.parentNode.__data__.isPano) {
54991           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54992         } else {
54993           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54994         }
54995       }
54996     }
54997     function viewerChanged() {
54998       const service = getService();
54999       if (!service) return;
55000       const frame2 = service.photoFrame();
55001       if (!frame2) return;
55002       _viewerYaw = frame2.getYaw();
55003       if (context.map().isTransformed()) return;
55004       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2.id));
55005     }
55006     function drawImages(selection2) {
55007       const enabled = svgPanoramaxImages.enabled;
55008       const service = getService();
55009       layer = selection2.selectAll(".layer-panoramax").data(service ? [0] : []);
55010       layer.exit().remove();
55011       const layerEnter = layer.enter().append("g").attr("class", "layer-panoramax").style("display", enabled ? "block" : "none");
55012       layerEnter.append("g").attr("class", "sequences");
55013       layerEnter.append("g").attr("class", "markers");
55014       layer = layerEnter.merge(layer);
55015       if (enabled) {
55016         let zoom = ~~context.map().zoom();
55017         if (service) {
55018           if (zoom >= imageMinZoom2) {
55019             editOn();
55020             update();
55021             service.loadImages(projection2);
55022           } else if (zoom >= lineMinZoom2) {
55023             editOn();
55024             update();
55025             service.loadLines(projection2, zoom);
55026           } else {
55027             editOff();
55028           }
55029         } else {
55030           editOff();
55031         }
55032       }
55033     }
55034     drawImages.enabled = function(_2) {
55035       if (!arguments.length) return svgPanoramaxImages.enabled;
55036       svgPanoramaxImages.enabled = _2;
55037       if (svgPanoramaxImages.enabled) {
55038         showLayer();
55039         context.photos().on("change.panoramax_images", update);
55040       } else {
55041         hideLayer();
55042         context.photos().on("change.panoramax_images", null);
55043       }
55044       dispatch14.call("change");
55045       return this;
55046     };
55047     drawImages.supported = function() {
55048       return !!getService();
55049     };
55050     drawImages.rendered = function(zoom) {
55051       return zoom >= lineMinZoom2;
55052     };
55053     init2();
55054     return drawImages;
55055   }
55056
55057   // modules/svg/osm.js
55058   function svgOsm(projection2, context, dispatch14) {
55059     var enabled = true;
55060     function drawOsm(selection2) {
55061       selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) {
55062         return "layer-osm " + d2;
55063       });
55064       selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) {
55065         return "points-group " + d2;
55066       });
55067     }
55068     function showLayer() {
55069       var layer = context.surface().selectAll(".data-layer.osm");
55070       layer.interrupt();
55071       layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55072         dispatch14.call("change");
55073       });
55074     }
55075     function hideLayer() {
55076       var layer = context.surface().selectAll(".data-layer.osm");
55077       layer.interrupt();
55078       layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55079         layer.classed("disabled", true);
55080         dispatch14.call("change");
55081       });
55082     }
55083     drawOsm.enabled = function(val) {
55084       if (!arguments.length) return enabled;
55085       enabled = val;
55086       if (enabled) {
55087         showLayer();
55088       } else {
55089         hideLayer();
55090       }
55091       dispatch14.call("change");
55092       return this;
55093     };
55094     return drawOsm;
55095   }
55096
55097   // modules/svg/notes.js
55098   var hash = utilStringQs(window.location.hash);
55099   var _notesEnabled = !!hash.notes;
55100   var _osmService;
55101   function svgNotes(projection2, context, dispatch14) {
55102     if (!dispatch14) {
55103       dispatch14 = dispatch_default("change");
55104     }
55105     var throttledRedraw = throttle_default(function() {
55106       dispatch14.call("change");
55107     }, 1e3);
55108     var minZoom5 = 12;
55109     var touchLayer = select_default2(null);
55110     var drawLayer = select_default2(null);
55111     var _notesVisible = false;
55112     function markerPath(selection2, klass) {
55113       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");
55114     }
55115     function getService() {
55116       if (services.osm && !_osmService) {
55117         _osmService = services.osm;
55118         _osmService.on("loadedNotes", throttledRedraw);
55119       } else if (!services.osm && _osmService) {
55120         _osmService = null;
55121       }
55122       return _osmService;
55123     }
55124     function editOn() {
55125       if (!_notesVisible) {
55126         _notesVisible = true;
55127         drawLayer.style("display", "block");
55128       }
55129     }
55130     function editOff() {
55131       if (_notesVisible) {
55132         _notesVisible = false;
55133         drawLayer.style("display", "none");
55134         drawLayer.selectAll(".note").remove();
55135         touchLayer.selectAll(".note").remove();
55136       }
55137     }
55138     function layerOn() {
55139       editOn();
55140       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55141         dispatch14.call("change");
55142       });
55143     }
55144     function layerOff() {
55145       throttledRedraw.cancel();
55146       drawLayer.interrupt();
55147       touchLayer.selectAll(".note").remove();
55148       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55149         editOff();
55150         dispatch14.call("change");
55151       });
55152     }
55153     function updateMarkers() {
55154       if (!_notesVisible || !_notesEnabled) return;
55155       var service = getService();
55156       var selectedID = context.selectedNoteID();
55157       var data = service ? service.notes(projection2) : [];
55158       var getTransform = svgPointTransform(projection2);
55159       var notes = drawLayer.selectAll(".note").data(data, function(d2) {
55160         return d2.status + d2.id;
55161       });
55162       notes.exit().remove();
55163       var notesEnter = notes.enter().append("g").attr("class", function(d2) {
55164         return "note note-" + d2.id + " " + d2.status;
55165       }).classed("new", function(d2) {
55166         return d2.id < 0;
55167       });
55168       notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55169       notesEnter.append("path").call(markerPath, "shadow");
55170       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");
55171       notesEnter.selectAll(".icon-annotation").data(function(d2) {
55172         return [d2];
55173       }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) {
55174         if (d2.id < 0) return "#iD-icon-plus";
55175         if (d2.status === "open") return "#iD-icon-close";
55176         return "#iD-icon-apply";
55177       });
55178       notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) {
55179         var mode = context.mode();
55180         var isMoving = mode && mode.id === "drag-note";
55181         return !isMoving && d2.id === selectedID;
55182       }).attr("transform", getTransform);
55183       if (touchLayer.empty()) return;
55184       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55185       var targets = touchLayer.selectAll(".note").data(data, function(d2) {
55186         return d2.id;
55187       });
55188       targets.exit().remove();
55189       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) {
55190         var newClass = d2.id < 0 ? "new" : "";
55191         return "note target note-" + d2.id + " " + fillClass + newClass;
55192       }).attr("transform", getTransform);
55193       function sortY(a2, b2) {
55194         if (a2.id === selectedID) return 1;
55195         if (b2.id === selectedID) return -1;
55196         return b2.loc[1] - a2.loc[1];
55197       }
55198     }
55199     function drawNotes(selection2) {
55200       var service = getService();
55201       var surface = context.surface();
55202       if (surface && !surface.empty()) {
55203         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
55204       }
55205       drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []);
55206       drawLayer.exit().remove();
55207       drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer);
55208       if (_notesEnabled) {
55209         if (service && ~~context.map().zoom() >= minZoom5) {
55210           editOn();
55211           service.loadNotes(projection2);
55212           updateMarkers();
55213         } else {
55214           editOff();
55215         }
55216       }
55217     }
55218     drawNotes.enabled = function(val) {
55219       if (!arguments.length) return _notesEnabled;
55220       _notesEnabled = val;
55221       if (_notesEnabled) {
55222         layerOn();
55223       } else {
55224         layerOff();
55225         if (context.selectedNoteID()) {
55226           context.enter(modeBrowse(context));
55227         }
55228       }
55229       dispatch14.call("change");
55230       return this;
55231     };
55232     return drawNotes;
55233   }
55234
55235   // modules/svg/touch.js
55236   function svgTouch() {
55237     function drawTouch(selection2) {
55238       selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) {
55239         return "layer-touch " + d2;
55240       });
55241     }
55242     return drawTouch;
55243   }
55244
55245   // modules/util/dimensions.js
55246   function refresh(selection2, node) {
55247     var cr = node.getBoundingClientRect();
55248     var prop = [cr.width, cr.height];
55249     selection2.property("__dimensions__", prop);
55250     return prop;
55251   }
55252   function utilGetDimensions(selection2, force) {
55253     if (!selection2 || selection2.empty()) {
55254       return [0, 0];
55255     }
55256     var node = selection2.node(), cached = selection2.property("__dimensions__");
55257     return !cached || force ? refresh(selection2, node) : cached;
55258   }
55259   function utilSetDimensions(selection2, dimensions) {
55260     if (!selection2 || selection2.empty()) {
55261       return selection2;
55262     }
55263     var node = selection2.node();
55264     if (dimensions === null) {
55265       refresh(selection2, node);
55266       return selection2;
55267     }
55268     return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]);
55269   }
55270
55271   // modules/svg/layers.js
55272   function svgLayers(projection2, context) {
55273     var dispatch14 = dispatch_default("change");
55274     var svg2 = select_default2(null);
55275     var _layers = [
55276       { id: "osm", layer: svgOsm(projection2, context, dispatch14) },
55277       { id: "notes", layer: svgNotes(projection2, context, dispatch14) },
55278       { id: "data", layer: svgData(projection2, context, dispatch14) },
55279       { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) },
55280       { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) },
55281       { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) },
55282       { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) },
55283       { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) },
55284       { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) },
55285       { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) },
55286       { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) },
55287       { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) },
55288       { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) },
55289       { id: "panoramax", layer: svgPanoramaxImages(projection2, context, dispatch14) },
55290       { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) },
55291       { id: "debug", layer: svgDebug(projection2, context, dispatch14) },
55292       { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) },
55293       { id: "touch", layer: svgTouch(projection2, context, dispatch14) }
55294     ];
55295     function drawLayers(selection2) {
55296       svg2 = selection2.selectAll(".surface").data([0]);
55297       svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2);
55298       var defs = svg2.selectAll(".surface-defs").data([0]);
55299       defs.enter().append("defs").attr("class", "surface-defs");
55300       var groups = svg2.selectAll(".data-layer").data(_layers);
55301       groups.exit().remove();
55302       groups.enter().append("g").attr("class", function(d2) {
55303         return "data-layer " + d2.id;
55304       }).merge(groups).each(function(d2) {
55305         select_default2(this).call(d2.layer);
55306       });
55307     }
55308     drawLayers.all = function() {
55309       return _layers;
55310     };
55311     drawLayers.layer = function(id2) {
55312       var obj = _layers.find(function(o2) {
55313         return o2.id === id2;
55314       });
55315       return obj && obj.layer;
55316     };
55317     drawLayers.only = function(what) {
55318       var arr = [].concat(what);
55319       var all = _layers.map(function(layer) {
55320         return layer.id;
55321       });
55322       return drawLayers.remove(utilArrayDifference(all, arr));
55323     };
55324     drawLayers.remove = function(what) {
55325       var arr = [].concat(what);
55326       arr.forEach(function(id2) {
55327         _layers = _layers.filter(function(o2) {
55328           return o2.id !== id2;
55329         });
55330       });
55331       dispatch14.call("change");
55332       return this;
55333     };
55334     drawLayers.add = function(what) {
55335       var arr = [].concat(what);
55336       arr.forEach(function(obj) {
55337         if ("id" in obj && "layer" in obj) {
55338           _layers.push(obj);
55339         }
55340       });
55341       dispatch14.call("change");
55342       return this;
55343     };
55344     drawLayers.dimensions = function(val) {
55345       if (!arguments.length) return utilGetDimensions(svg2);
55346       utilSetDimensions(svg2, val);
55347       return this;
55348     };
55349     return utilRebind(drawLayers, dispatch14, "on");
55350   }
55351
55352   // modules/svg/lines.js
55353   var import_fast_deep_equal6 = __toESM(require_fast_deep_equal());
55354   function onewayArrowColour(tags) {
55355     if (tags.highway === "construction" && tags.bridge) return "white";
55356     if (tags.highway === "pedestrian" && tags.bridge) return "pink";
55357     if (tags.railway) return "black";
55358     if (tags.aeroway === "runway") return "pink";
55359     return "black";
55360   }
55361   function svgLines(projection2, context) {
55362     var detected = utilDetect();
55363     var highway_stack = {
55364       motorway: 0,
55365       motorway_link: 1,
55366       trunk: 2,
55367       trunk_link: 3,
55368       primary: 4,
55369       primary_link: 5,
55370       secondary: 6,
55371       tertiary: 7,
55372       unclassified: 8,
55373       residential: 9,
55374       service: 10,
55375       busway: 11,
55376       footway: 12
55377     };
55378     function drawTargets(selection2, graph, entities, filter2) {
55379       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
55380       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
55381       var getPath = svgPath(projection2).geojson;
55382       var activeID = context.activeID();
55383       var base = context.history().base();
55384       var data = { targets: [], nopes: [] };
55385       entities.forEach(function(way) {
55386         var features = svgSegmentWay(way, graph, activeID);
55387         data.targets.push.apply(data.targets, features.passive);
55388         data.nopes.push.apply(data.nopes, features.active);
55389       });
55390       var targetData = data.targets.filter(getPath);
55391       var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) {
55392         return filter2(d2.properties.entity);
55393       }).data(targetData, function key(d2) {
55394         return d2.id;
55395       });
55396       targets.exit().remove();
55397       var segmentWasEdited = function(d2) {
55398         var wayID = d2.properties.entity.id;
55399         if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
55400           return false;
55401         }
55402         return d2.properties.nodes.some(function(n3) {
55403           return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
55404         });
55405       };
55406       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
55407         return "way line target target-allowed " + targetClass + d2.id;
55408       }).classed("segment-edited", segmentWasEdited);
55409       var nopeData = data.nopes.filter(getPath);
55410       var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) {
55411         return filter2(d2.properties.entity);
55412       }).data(nopeData, function key(d2) {
55413         return d2.id;
55414       });
55415       nopes.exit().remove();
55416       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
55417         return "way line target target-nope " + nopeClass + d2.id;
55418       }).classed("segment-edited", segmentWasEdited);
55419     }
55420     function drawLines(selection2, graph, entities, filter2) {
55421       var base = context.history().base();
55422       function waystack(a2, b2) {
55423         var selected = context.selectedIDs();
55424         var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0;
55425         var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0;
55426         if (a2.tags.highway) {
55427           scoreA -= highway_stack[a2.tags.highway];
55428         }
55429         if (b2.tags.highway) {
55430           scoreB -= highway_stack[b2.tags.highway];
55431         }
55432         return scoreA - scoreB;
55433       }
55434       function drawLineGroup(selection3, klass, isSelected) {
55435         var mode = context.mode();
55436         var isDrawing = mode && /^draw/.test(mode.id);
55437         var selectedClass = !isDrawing && isSelected ? "selected " : "";
55438         var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key);
55439         lines.exit().remove();
55440         lines.enter().append("path").attr("class", function(d2) {
55441           var prefix = "way line";
55442           if (!d2.hasInterestingTags()) {
55443             var parentRelations = graph.parentRelations(d2);
55444             var parentMultipolygons = parentRelations.filter(function(relation) {
55445               return relation.isMultipolygon();
55446             });
55447             if (parentMultipolygons.length > 0 && // and only multipolygon relations
55448             parentRelations.length === parentMultipolygons.length) {
55449               prefix = "relation area";
55450             }
55451           }
55452           var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : "";
55453           return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id;
55454         }).classed("added", function(d2) {
55455           return !base.entities[d2.id];
55456         }).classed("geometry-edited", function(d2) {
55457           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);
55458         }).classed("retagged", function(d2) {
55459           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);
55460         }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph)));
55461         return selection3;
55462       }
55463       function getPathData(isSelected) {
55464         return function() {
55465           var layer = this.parentNode.__data__;
55466           var data = pathdata[layer] || [];
55467           return data.filter(function(d2) {
55468             if (isSelected) {
55469               return context.selectedIDs().indexOf(d2.id) !== -1;
55470             } else {
55471               return context.selectedIDs().indexOf(d2.id) === -1;
55472             }
55473           });
55474         };
55475       }
55476       function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) {
55477         var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]);
55478         markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup);
55479         var markers = markergroup.selectAll("path").filter(filter2).data(
55480           function data() {
55481             return groupdata[this.parentNode.__data__] || [];
55482           },
55483           function key(d2) {
55484             return [d2.id, d2.index];
55485           }
55486         );
55487         markers.exit().remove();
55488         markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) {
55489           return d2.d;
55490         });
55491         if (detected.ie) {
55492           markers.each(function() {
55493             this.parentNode.insertBefore(this, this);
55494           });
55495         }
55496       }
55497       var getPath = svgPath(projection2, graph);
55498       var ways = [];
55499       var onewaydata = {};
55500       var sideddata = {};
55501       var oldMultiPolygonOuters = {};
55502       for (var i3 = 0; i3 < entities.length; i3++) {
55503         var entity = entities[i3];
55504         if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") {
55505           ways.push(entity);
55506         }
55507       }
55508       ways = ways.filter(getPath);
55509       const pathdata = utilArrayGroupBy(ways, (way) => Math.trunc(way.layer()));
55510       Object.keys(pathdata).forEach(function(k2) {
55511         var v2 = pathdata[k2];
55512         var onewayArr = v2.filter(function(d2) {
55513           return d2.isOneWay();
55514         });
55515         var onewaySegments = svgMarkerSegments(
55516           projection2,
55517           graph,
55518           35,
55519           (entity2) => entity2.isOneWayBackwards(),
55520           (entity2) => entity2.isBiDirectional()
55521         );
55522         onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments));
55523         var sidedArr = v2.filter(function(d2) {
55524           return d2.isSided();
55525         });
55526         var sidedSegments = svgMarkerSegments(
55527           projection2,
55528           graph,
55529           30,
55530           function shouldReverse() {
55531             return false;
55532           },
55533           function bothDirections() {
55534             return false;
55535           }
55536         );
55537         sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments));
55538       });
55539       var covered = selection2.selectAll(".layer-osm.covered");
55540       var uncovered = selection2.selectAll(".layer-osm.lines");
55541       var touchLayer = selection2.selectAll(".layer-touch.lines");
55542       [covered, uncovered].forEach(function(selection3) {
55543         var range3 = selection3 === covered ? range(-10, 0) : range(0, 11);
55544         var layergroup = selection3.selectAll("g.layergroup").data(range3);
55545         layergroup = layergroup.enter().append("g").attr("class", function(d2) {
55546           return "layergroup layer" + String(d2);
55547         }).merge(layergroup);
55548         layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) {
55549           return "linegroup line-" + d2;
55550         });
55551         layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false);
55552         layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false);
55553         layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false);
55554         layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true);
55555         layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true);
55556         layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true);
55557         addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, (d2) => {
55558           const category = onewayArrowColour(graph.entity(d2.id).tags);
55559           return "url(#ideditor-oneway-marker-".concat(category, ")");
55560         });
55561         addMarkers(
55562           layergroup,
55563           "sided",
55564           "sidedgroup",
55565           sideddata,
55566           function marker(d2) {
55567             var category = graph.entity(d2.id).sidednessIdentifier();
55568             return "url(#ideditor-sided-marker-" + category + ")";
55569           }
55570         );
55571       });
55572       touchLayer.call(drawTargets, graph, ways, filter2);
55573     }
55574     return drawLines;
55575   }
55576
55577   // modules/svg/midpoints.js
55578   function svgMidpoints(projection2, context) {
55579     var targetRadius = 8;
55580     function drawTargets(selection2, graph, entities, filter2) {
55581       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55582       var getTransform = svgPointTransform(projection2).geojson;
55583       var data = entities.map(function(midpoint) {
55584         return {
55585           type: "Feature",
55586           id: midpoint.id,
55587           properties: {
55588             target: true,
55589             entity: midpoint
55590           },
55591           geometry: {
55592             type: "Point",
55593             coordinates: midpoint.loc
55594           }
55595         };
55596       });
55597       var targets = selection2.selectAll(".midpoint.target").filter(function(d2) {
55598         return filter2(d2.properties.entity);
55599       }).data(data, function key(d2) {
55600         return d2.id;
55601       });
55602       targets.exit().remove();
55603       targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) {
55604         return "node midpoint target " + fillClass + d2.id;
55605       }).attr("transform", getTransform);
55606     }
55607     function drawMidpoints(selection2, graph, entities, filter2, extent) {
55608       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints");
55609       var touchLayer = selection2.selectAll(".layer-touch.points");
55610       var mode = context.mode();
55611       if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) {
55612         drawLayer.selectAll(".midpoint").remove();
55613         touchLayer.selectAll(".midpoint.target").remove();
55614         return;
55615       }
55616       var poly = extent.polygon();
55617       var midpoints = {};
55618       for (var i3 = 0; i3 < entities.length; i3++) {
55619         var entity = entities[i3];
55620         if (entity.type !== "way") continue;
55621         if (!filter2(entity)) continue;
55622         if (context.selectedIDs().indexOf(entity.id) < 0) continue;
55623         var nodes = graph.childNodes(entity);
55624         for (var j2 = 0; j2 < nodes.length - 1; j2++) {
55625           var a2 = nodes[j2];
55626           var b2 = nodes[j2 + 1];
55627           var id2 = [a2.id, b2.id].sort().join("-");
55628           if (midpoints[id2]) {
55629             midpoints[id2].parents.push(entity);
55630           } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) {
55631             var point = geoVecInterp(a2.loc, b2.loc, 0.5);
55632             var loc = null;
55633             if (extent.intersects(point)) {
55634               loc = point;
55635             } else {
55636               for (var k2 = 0; k2 < 4; k2++) {
55637                 point = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]);
55638                 if (point && geoVecLength(projection2(a2.loc), projection2(point)) > 20 && geoVecLength(projection2(b2.loc), projection2(point)) > 20) {
55639                   loc = point;
55640                   break;
55641                 }
55642               }
55643             }
55644             if (loc) {
55645               midpoints[id2] = {
55646                 type: "midpoint",
55647                 id: id2,
55648                 loc,
55649                 edge: [a2.id, b2.id],
55650                 parents: [entity]
55651               };
55652             }
55653           }
55654         }
55655       }
55656       function midpointFilter(d2) {
55657         if (midpoints[d2.id]) return true;
55658         for (var i4 = 0; i4 < d2.parents.length; i4++) {
55659           if (filter2(d2.parents[i4])) {
55660             return true;
55661           }
55662         }
55663         return false;
55664       }
55665       var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) {
55666         return d2.id;
55667       });
55668       groups.exit().remove();
55669       var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint");
55670       enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow");
55671       enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill");
55672       groups = groups.merge(enter).attr("transform", function(d2) {
55673         var translate = svgPointTransform(projection2);
55674         var a3 = graph.entity(d2.edge[0]);
55675         var b3 = graph.entity(d2.edge[1]);
55676         var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI);
55677         return translate(d2) + " rotate(" + angle2 + ")";
55678       }).call(svgTagClasses().tags(
55679         function(d2) {
55680           return d2.parents[0].tags;
55681         }
55682       ));
55683       groups.select("polygon.shadow");
55684       groups.select("polygon.fill");
55685       touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter);
55686     }
55687     return drawMidpoints;
55688   }
55689
55690   // modules/svg/points.js
55691   var import_fast_deep_equal7 = __toESM(require_fast_deep_equal());
55692   function svgPoints(projection2, context) {
55693     function markerPath(selection2, klass) {
55694       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");
55695     }
55696     function sortY(a2, b2) {
55697       return b2.loc[1] - a2.loc[1];
55698     }
55699     function fastEntityKey(d2) {
55700       var mode = context.mode();
55701       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
55702       return isMoving ? d2.id : osmEntity.key(d2);
55703     }
55704     function drawTargets(selection2, graph, entities, filter2) {
55705       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55706       var getTransform = svgPointTransform(projection2).geojson;
55707       var activeID = context.activeID();
55708       var data = [];
55709       entities.forEach(function(node) {
55710         if (activeID === node.id) return;
55711         data.push({
55712           type: "Feature",
55713           id: node.id,
55714           properties: {
55715             target: true,
55716             entity: node
55717           },
55718           geometry: node.asGeoJSON()
55719         });
55720       });
55721       var targets = selection2.selectAll(".point.target").filter(function(d2) {
55722         return filter2(d2.properties.entity);
55723       }).data(data, function key(d2) {
55724         return d2.id;
55725       });
55726       targets.exit().remove();
55727       targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) {
55728         return "node point target " + fillClass + d2.id;
55729       }).attr("transform", getTransform);
55730     }
55731     function drawPoints(selection2, graph, entities, filter2) {
55732       var wireframe = context.surface().classed("fill-wireframe");
55733       var zoom = geoScaleToZoom(projection2.scale());
55734       var base = context.history().base();
55735       function renderAsPoint(entity) {
55736         return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length);
55737       }
55738       var points = wireframe ? [] : entities.filter(renderAsPoint);
55739       points.sort(sortY);
55740       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points");
55741       var touchLayer = selection2.selectAll(".layer-touch.points");
55742       var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey);
55743       groups.exit().remove();
55744       var enter = groups.enter().append("g").attr("class", function(d2) {
55745         return "node point " + d2.id;
55746       }).order();
55747       enter.append("path").call(markerPath, "shadow");
55748       enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55749       enter.append("path").call(markerPath, "stroke");
55750       enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px");
55751       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) {
55752         return !base.entities[d2.id];
55753       }).classed("moved", function(d2) {
55754         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
55755       }).classed("retagged", function(d2) {
55756         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
55757       }).call(svgTagClasses());
55758       groups.select(".shadow");
55759       groups.select(".stroke");
55760       groups.select(".icon").attr("xlink:href", function(entity) {
55761         var preset = _mainPresetIndex.match(entity, graph);
55762         var picon = preset && preset.icon;
55763         return picon ? "#" + picon : "";
55764       });
55765       touchLayer.call(drawTargets, graph, points, filter2);
55766     }
55767     return drawPoints;
55768   }
55769
55770   // modules/svg/turns.js
55771   function svgTurns(projection2, context) {
55772     function icon2(turn) {
55773       var u2 = turn.u ? "-u" : "";
55774       if (turn.no) return "#iD-turn-no" + u2;
55775       if (turn.only) return "#iD-turn-only" + u2;
55776       return "#iD-turn-yes" + u2;
55777     }
55778     function drawTurns(selection2, graph, turns) {
55779       function turnTransform(d2) {
55780         var pxRadius = 50;
55781         var toWay = graph.entity(d2.to.way);
55782         var toPoints = graph.childNodes(toWay).map(function(n3) {
55783           return n3.loc;
55784         }).map(projection2);
55785         var toLength = geoPathLength(toPoints);
55786         var mid = toLength / 2;
55787         var toNode = graph.entity(d2.to.node);
55788         var toVertex = graph.entity(d2.to.vertex);
55789         var a2 = geoAngle(toVertex, toNode, projection2);
55790         var o2 = projection2(toVertex.loc);
55791         var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius);
55792         return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")";
55793       }
55794       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns");
55795       var touchLayer = selection2.selectAll(".layer-touch.turns");
55796       var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) {
55797         return d2.key;
55798       });
55799       groups.exit().remove();
55800       var groupsEnter = groups.enter().append("g").attr("class", function(d2) {
55801         return "turn " + d2.key;
55802       });
55803       var turnsEnter = groupsEnter.filter(function(d2) {
55804         return !d2.u;
55805       });
55806       turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55807       turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55808       var uEnter = groupsEnter.filter(function(d2) {
55809         return d2.u;
55810       });
55811       uEnter.append("circle").attr("r", "16");
55812       uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32");
55813       groups = groups.merge(groupsEnter).attr("opacity", function(d2) {
55814         return d2.direct === false ? "0.7" : null;
55815       }).attr("transform", turnTransform);
55816       groups.select("use").attr("xlink:href", icon2);
55817       groups.select("rect");
55818       groups.select("circle");
55819       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55820       groups = touchLayer.selectAll("g.turn").data(turns, function(d2) {
55821         return d2.key;
55822       });
55823       groups.exit().remove();
55824       groupsEnter = groups.enter().append("g").attr("class", function(d2) {
55825         return "turn " + d2.key;
55826       });
55827       turnsEnter = groupsEnter.filter(function(d2) {
55828         return !d2.u;
55829       });
55830       turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55831       uEnter = groupsEnter.filter(function(d2) {
55832         return d2.u;
55833       });
55834       uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16");
55835       groups = groups.merge(groupsEnter).attr("transform", turnTransform);
55836       groups.select("rect");
55837       groups.select("circle");
55838       return this;
55839     }
55840     return drawTurns;
55841   }
55842
55843   // modules/svg/vertices.js
55844   var import_fast_deep_equal8 = __toESM(require_fast_deep_equal());
55845   function svgVertices(projection2, context) {
55846     var radiuses = {
55847       //       z16-, z17,   z18+,  w/icon
55848       shadow: [6, 7.5, 7.5, 12],
55849       stroke: [2.5, 3.5, 3.5, 8],
55850       fill: [1, 1.5, 1.5, 1.5]
55851     };
55852     var _currHoverTarget;
55853     var _currPersistent = {};
55854     var _currHover = {};
55855     var _prevHover = {};
55856     var _currSelected = {};
55857     var _prevSelected = {};
55858     var _radii = {};
55859     function sortY(a2, b2) {
55860       return b2.loc[1] - a2.loc[1];
55861     }
55862     function fastEntityKey(d2) {
55863       var mode = context.mode();
55864       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
55865       return isMoving ? d2.id : osmEntity.key(d2);
55866     }
55867     function draw(selection2, graph, vertices, sets2, filter2) {
55868       sets2 = sets2 || { selected: {}, important: {}, hovered: {} };
55869       var icons = {};
55870       var directions = {};
55871       var wireframe = context.surface().classed("fill-wireframe");
55872       var zoom = geoScaleToZoom(projection2.scale());
55873       var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2;
55874       var activeID = context.activeID();
55875       var base = context.history().base();
55876       function getIcon(d2) {
55877         var entity = graph.entity(d2.id);
55878         if (entity.id in icons) return icons[entity.id];
55879         icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon;
55880         return icons[entity.id];
55881       }
55882       function getDirections(entity) {
55883         if (entity.id in directions) return directions[entity.id];
55884         var angles = entity.directions(graph, projection2);
55885         directions[entity.id] = angles.length ? angles : false;
55886         return angles;
55887       }
55888       function updateAttributes(selection3) {
55889         ["shadow", "stroke", "fill"].forEach(function(klass) {
55890           var rads = radiuses[klass];
55891           selection3.selectAll("." + klass).each(function(entity) {
55892             var i3 = z2 && getIcon(entity);
55893             var r2 = rads[i3 ? 3 : z2];
55894             if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) {
55895               r2 += 1.5;
55896             }
55897             if (klass === "shadow") {
55898               _radii[entity.id] = r2;
55899             }
55900             select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null);
55901           });
55902         });
55903       }
55904       vertices.sort(sortY);
55905       var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey);
55906       groups.exit().remove();
55907       var enter = groups.enter().append("g").attr("class", function(d2) {
55908         return "node vertex " + d2.id;
55909       }).order();
55910       enter.append("circle").attr("class", "shadow");
55911       enter.append("circle").attr("class", "stroke");
55912       enter.filter(function(d2) {
55913         return d2.hasInterestingTags();
55914       }).append("circle").attr("class", "fill");
55915       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) {
55916         return d2.id in sets2.selected;
55917       }).classed("shared", function(d2) {
55918         return graph.isShared(d2);
55919       }).classed("endpoint", function(d2) {
55920         return d2.isEndpoint(graph);
55921       }).classed("added", function(d2) {
55922         return !base.entities[d2.id];
55923       }).classed("moved", function(d2) {
55924         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
55925       }).classed("retagged", function(d2) {
55926         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
55927       }).call(svgTagClasses()).call(updateAttributes);
55928       var iconUse = groups.selectAll(".icon").data(function data(d2) {
55929         return zoom >= 17 && getIcon(d2) ? [d2] : [];
55930       }, fastEntityKey);
55931       iconUse.exit().remove();
55932       iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) {
55933         var picon = getIcon(d2);
55934         return picon ? "#" + picon : "";
55935       });
55936       var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) {
55937         return zoom >= 18 && getDirections(d2) ? [d2] : [];
55938       }, fastEntityKey);
55939       dgroups.exit().remove();
55940       dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups);
55941       var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) {
55942         return osmEntity.key(d2);
55943       });
55944       viewfields.exit().remove();
55945       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) {
55946         return "rotate(" + d2 + ")";
55947       });
55948     }
55949     function drawTargets(selection2, graph, entities, filter2) {
55950       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
55951       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
55952       var getTransform = svgPointTransform(projection2).geojson;
55953       var activeID = context.activeID();
55954       var data = { targets: [], nopes: [] };
55955       entities.forEach(function(node) {
55956         if (activeID === node.id) return;
55957         var vertexType = svgPassiveVertex(node, graph, activeID);
55958         if (vertexType !== 0) {
55959           data.targets.push({
55960             type: "Feature",
55961             id: node.id,
55962             properties: {
55963               target: true,
55964               entity: node
55965             },
55966             geometry: node.asGeoJSON()
55967           });
55968         } else {
55969           data.nopes.push({
55970             type: "Feature",
55971             id: node.id + "-nope",
55972             properties: {
55973               nope: true,
55974               target: true,
55975               entity: node
55976             },
55977             geometry: node.asGeoJSON()
55978           });
55979         }
55980       });
55981       var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) {
55982         return filter2(d2.properties.entity);
55983       }).data(data.targets, function key(d2) {
55984         return d2.id;
55985       });
55986       targets.exit().remove();
55987       targets.enter().append("circle").attr("r", function(d2) {
55988         return _radii[d2.id] || radiuses.shadow[3];
55989       }).merge(targets).attr("class", function(d2) {
55990         return "node vertex target target-allowed " + targetClass + d2.id;
55991       }).attr("transform", getTransform);
55992       var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) {
55993         return filter2(d2.properties.entity);
55994       }).data(data.nopes, function key(d2) {
55995         return d2.id;
55996       });
55997       nopes.exit().remove();
55998       nopes.enter().append("circle").attr("r", function(d2) {
55999         return _radii[d2.properties.entity.id] || radiuses.shadow[3];
56000       }).merge(nopes).attr("class", function(d2) {
56001         return "node vertex target target-nope " + nopeClass + d2.id;
56002       }).attr("transform", getTransform);
56003     }
56004     function renderAsVertex(entity, graph, wireframe, zoom) {
56005       var geometry = entity.geometry(graph);
56006       return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length);
56007     }
56008     function isEditedNode(node, base, head) {
56009       var baseNode = base.entities[node.id];
56010       var headNode = head.entities[node.id];
56011       return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc);
56012     }
56013     function getSiblingAndChildVertices(ids, graph, wireframe, zoom) {
56014       var results = {};
56015       var seenIds = {};
56016       function addChildVertices(entity) {
56017         if (seenIds[entity.id]) return;
56018         seenIds[entity.id] = true;
56019         var geometry = entity.geometry(graph);
56020         if (!context.features().isHiddenFeature(entity, graph, geometry)) {
56021           var i3;
56022           if (entity.type === "way") {
56023             for (i3 = 0; i3 < entity.nodes.length; i3++) {
56024               var child = graph.hasEntity(entity.nodes[i3]);
56025               if (child) {
56026                 addChildVertices(child);
56027               }
56028             }
56029           } else if (entity.type === "relation") {
56030             for (i3 = 0; i3 < entity.members.length; i3++) {
56031               var member = graph.hasEntity(entity.members[i3].id);
56032               if (member) {
56033                 addChildVertices(member);
56034               }
56035             }
56036           } else if (renderAsVertex(entity, graph, wireframe, zoom)) {
56037             results[entity.id] = entity;
56038           }
56039         }
56040       }
56041       ids.forEach(function(id2) {
56042         var entity = graph.hasEntity(id2);
56043         if (!entity) return;
56044         if (entity.type === "node") {
56045           if (renderAsVertex(entity, graph, wireframe, zoom)) {
56046             results[entity.id] = entity;
56047             graph.parentWays(entity).forEach(function(entity2) {
56048               addChildVertices(entity2);
56049             });
56050           }
56051         } else {
56052           addChildVertices(entity);
56053         }
56054       });
56055       return results;
56056     }
56057     function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) {
56058       var wireframe = context.surface().classed("fill-wireframe");
56059       var visualDiff = context.surface().classed("highlight-edited");
56060       var zoom = geoScaleToZoom(projection2.scale());
56061       var mode = context.mode();
56062       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56063       var base = context.history().base();
56064       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices");
56065       var touchLayer = selection2.selectAll(".layer-touch.points");
56066       if (fullRedraw) {
56067         _currPersistent = {};
56068         _radii = {};
56069       }
56070       for (var i3 = 0; i3 < entities.length; i3++) {
56071         var entity = entities[i3];
56072         var geometry = entity.geometry(graph);
56073         var keep = false;
56074         if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) {
56075           _currPersistent[entity.id] = entity;
56076           keep = true;
56077         } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) {
56078           _currPersistent[entity.id] = entity;
56079           keep = true;
56080         }
56081         if (!keep && !fullRedraw) {
56082           delete _currPersistent[entity.id];
56083         }
56084       }
56085       var sets2 = {
56086         persistent: _currPersistent,
56087         // persistent = important vertices (render always)
56088         selected: _currSelected,
56089         // selected + siblings of selected (render always)
56090         hovered: _currHover
56091         // hovered + siblings of hovered (render only in draw modes)
56092       };
56093       var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent);
56094       var filterRendered = function(d2) {
56095         return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2);
56096       };
56097       drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered);
56098       var filterTouch = function(d2) {
56099         return isMoving ? true : filterRendered(d2);
56100       };
56101       touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch);
56102       function currentVisible(which) {
56103         return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) {
56104           return entity2 && entity2.intersects(extent, graph);
56105         });
56106       }
56107     }
56108     drawVertices.drawSelected = function(selection2, graph, extent) {
56109       var wireframe = context.surface().classed("fill-wireframe");
56110       var zoom = geoScaleToZoom(projection2.scale());
56111       _prevSelected = _currSelected || {};
56112       if (context.map().isInWideSelection()) {
56113         _currSelected = {};
56114         context.selectedIDs().forEach(function(id2) {
56115           var entity = graph.hasEntity(id2);
56116           if (!entity) return;
56117           if (entity.type === "node") {
56118             if (renderAsVertex(entity, graph, wireframe, zoom)) {
56119               _currSelected[entity.id] = entity;
56120             }
56121           }
56122         });
56123       } else {
56124         _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom);
56125       }
56126       var filter2 = function(d2) {
56127         return d2.id in _prevSelected;
56128       };
56129       drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false);
56130     };
56131     drawVertices.drawHover = function(selection2, graph, target, extent) {
56132       if (target === _currHoverTarget) return;
56133       var wireframe = context.surface().classed("fill-wireframe");
56134       var zoom = geoScaleToZoom(projection2.scale());
56135       _prevHover = _currHover || {};
56136       _currHoverTarget = target;
56137       var entity = target && target.properties && target.properties.entity;
56138       if (entity) {
56139         _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom);
56140       } else {
56141         _currHover = {};
56142       }
56143       var filter2 = function(d2) {
56144         return d2.id in _prevHover;
56145       };
56146       drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false);
56147     };
56148     return drawVertices;
56149   }
56150
56151   // modules/ui/length_indicator.js
56152   function uiLengthIndicator(maxChars) {
56153     var _wrap = select_default2(null);
56154     var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => {
56155       selection2.text("");
56156       selection2.call(svgIcon("#iD-icon-alert", "inline"));
56157       selection2.call(_t.append("inspector.max_length_reached", { maxChars }));
56158     });
56159     var _silent = false;
56160     var lengthIndicator = function(selection2) {
56161       _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]);
56162       _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true);
56163       selection2.call(_tooltip);
56164     };
56165     lengthIndicator.update = function(val) {
56166       const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY));
56167       let indicator = _wrap.selectAll("span.length-indicator").data([strLen]);
56168       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");
56169       if (_silent) return;
56170       if (strLen > maxChars) {
56171         _tooltip.show();
56172       } else {
56173         _tooltip.hide();
56174       }
56175     };
56176     lengthIndicator.silent = function(val) {
56177       if (!arguments.length) return _silent;
56178       _silent = val;
56179       return lengthIndicator;
56180     };
56181     return lengthIndicator;
56182   }
56183
56184   // modules/ui/fields/combo.js
56185   function uiFieldCombo(field, context) {
56186     var dispatch14 = dispatch_default("change");
56187     var _isMulti = field.type === "multiCombo" || field.type === "manyCombo";
56188     var _isNetwork = field.type === "networkCombo";
56189     var _isSemi = field.type === "semiCombo";
56190     var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false;
56191     var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false;
56192     var _snake_case = field.snake_case || field.snake_case === void 0;
56193     var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1);
56194     var _container = select_default2(null);
56195     var _inputWrap = select_default2(null);
56196     var _input = select_default2(null);
56197     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
56198     var _comboData = [];
56199     var _multiData = [];
56200     var _entityIDs = [];
56201     var _tags;
56202     var _countryCode;
56203     var _staticPlaceholder;
56204     var _customOptions = [];
56205     var _dataDeprecated = [];
56206     _mainFileFetcher.get("deprecated").then(function(d2) {
56207       _dataDeprecated = d2;
56208     }).catch(function() {
56209     });
56210     if (_isMulti && field.key && /[^:]$/.test(field.key)) {
56211       field.key += ":";
56212     }
56213     function snake(s2) {
56214       return s2.replace(/\s+/g, "_");
56215     }
56216     function clean2(s2) {
56217       return s2.split(";").map(function(s3) {
56218         return s3.trim();
56219       }).join(";");
56220     }
56221     function tagValue(dval) {
56222       dval = clean2(dval || "");
56223       var found = getOptions(true).find(function(o2) {
56224         return o2.key && clean2(o2.value) === dval;
56225       });
56226       if (found) return found.key;
56227       if (field.type === "typeCombo" && !dval) {
56228         return "yes";
56229       }
56230       return restrictTagValueSpelling(dval) || void 0;
56231     }
56232     function restrictTagValueSpelling(dval) {
56233       if (_snake_case) {
56234         dval = snake(dval);
56235       }
56236       if (!field.caseSensitive) {
56237         dval = dval.toLowerCase();
56238       }
56239       return dval;
56240     }
56241     function getLabelId(field2, v2) {
56242       return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2);
56243     }
56244     function displayValue(tval) {
56245       tval = tval || "";
56246       var stringsField = field.resolveReference("stringsCrossReference");
56247       const labelId = getLabelId(stringsField, tval);
56248       if (stringsField.hasTextForStringId(labelId)) {
56249         return stringsField.t(labelId, { default: tval });
56250       }
56251       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
56252         return "";
56253       }
56254       return tval;
56255     }
56256     function renderValue(tval) {
56257       tval = tval || "";
56258       var stringsField = field.resolveReference("stringsCrossReference");
56259       const labelId = getLabelId(stringsField, tval);
56260       if (stringsField.hasTextForStringId(labelId)) {
56261         return stringsField.t.append(labelId, { default: tval });
56262       }
56263       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
56264         tval = "";
56265       }
56266       return (selection2) => selection2.text(tval);
56267     }
56268     function objectDifference(a2, b2) {
56269       return a2.filter(function(d1) {
56270         return !b2.some(function(d2) {
56271           return d1.value === d2.value;
56272         });
56273       });
56274     }
56275     function initCombo(selection2, attachTo) {
56276       if (!_allowCustomValues) {
56277         selection2.attr("readonly", "readonly");
56278       }
56279       if (_showTagInfoSuggestions && services.taginfo) {
56280         selection2.call(_combobox.fetcher(setTaginfoValues), attachTo);
56281         setTaginfoValues("", setPlaceholder);
56282       } else {
56283         selection2.call(_combobox, attachTo);
56284         setTimeout(() => setStaticValues(setPlaceholder), 0);
56285       }
56286     }
56287     function getOptions(allOptions) {
56288       var stringsField = field.resolveReference("stringsCrossReference");
56289       if (!(field.options || stringsField.options)) return [];
56290       let options2;
56291       if (allOptions !== true) {
56292         options2 = field.options || stringsField.options;
56293       } else {
56294         options2 = [].concat(field.options, stringsField.options).filter(Boolean);
56295       }
56296       const result = options2.map(function(v2) {
56297         const labelId = getLabelId(stringsField, v2);
56298         return {
56299           key: v2,
56300           value: stringsField.t(labelId, { default: v2 }),
56301           title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }),
56302           display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
56303           klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option"
56304         };
56305       });
56306       return [...result, ..._customOptions];
56307     }
56308     function hasStaticValues() {
56309       return getOptions().length > 0;
56310     }
56311     function setStaticValues(callback, filter2) {
56312       _comboData = getOptions();
56313       if (filter2 !== void 0) {
56314         _comboData = _comboData.filter(filter2);
56315       }
56316       _comboData = objectDifference(_comboData, _multiData);
56317       _combobox.data(_comboData);
56318       _container.classed("empty-combobox", _comboData.length === 0);
56319       if (callback) callback(_comboData);
56320     }
56321     function setTaginfoValues(q2, callback) {
56322       var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase());
56323       if (hasStaticValues()) {
56324         setStaticValues(callback, queryFilter);
56325       }
56326       var stringsField = field.resolveReference("stringsCrossReference");
56327       var fn = _isMulti ? "multikeys" : "values";
56328       var query = (_isMulti ? field.key : "") + q2;
56329       var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0;
56330       if (hasCountryPrefix) {
56331         query = _countryCode + ":";
56332       }
56333       var params = {
56334         debounce: q2 !== "",
56335         key: field.key,
56336         query
56337       };
56338       if (_entityIDs.length) {
56339         params.geometry = context.graph().geometry(_entityIDs[0]);
56340       }
56341       services.taginfo[fn](params, function(err, data) {
56342         if (err) return;
56343         data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes");
56344         data = data.filter((d2) => {
56345           var value = d2.value;
56346           if (_isMulti) {
56347             value = value.slice(field.key.length);
56348           }
56349           return value === restrictTagValueSpelling(value);
56350         });
56351         var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key];
56352         if (deprecatedValues) {
56353           data = data.filter((d2) => !deprecatedValues.includes(d2.value));
56354         }
56355         if (hasCountryPrefix) {
56356           data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0);
56357         }
56358         const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 }));
56359         _container.classed("empty-combobox", data.length === 0);
56360         _comboData = data.concat(additionalOptions).map(function(d2) {
56361           var v2 = d2.value;
56362           if (_isMulti) v2 = v2.replace(field.key, "");
56363           const labelId = getLabelId(stringsField, v2);
56364           var isLocalizable = stringsField.hasTextForStringId(labelId);
56365           var label = stringsField.t(labelId, { default: v2 });
56366           return {
56367             key: v2,
56368             value: label,
56369             title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }),
56370             display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
56371             klass: isLocalizable ? "" : "raw-option"
56372           };
56373         });
56374         _comboData = _comboData.filter(queryFilter);
56375         _comboData = objectDifference(_comboData, _multiData);
56376         if (callback) callback(_comboData, hasStaticValues());
56377       });
56378     }
56379     function addComboboxIcons(disp, value) {
56380       const iconsField = field.resolveReference("iconsCrossReference");
56381       if (iconsField.icons) {
56382         return function(selection2) {
56383           var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon");
56384           if (iconsField.icons[value]) {
56385             span.call(svgIcon("#".concat(iconsField.icons[value])));
56386           }
56387           disp.call(this, selection2);
56388         };
56389       }
56390       return disp;
56391     }
56392     function setPlaceholder(values) {
56393       if (_isMulti || _isSemi) {
56394         _staticPlaceholder = field.placeholder() || _t("inspector.add");
56395       } else {
56396         var vals = values.map(function(d2) {
56397           return d2.value;
56398         }).filter(function(s2) {
56399           return s2.length < 20;
56400         });
56401         var placeholders = vals.length > 1 ? vals : values.map(function(d2) {
56402           return d2.key;
56403         });
56404         _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", ");
56405       }
56406       if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) {
56407         _staticPlaceholder += "\u2026";
56408       }
56409       var ph;
56410       if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
56411         ph = _t("inspector.multiple_values");
56412       } else {
56413         ph = _staticPlaceholder;
56414       }
56415       _container.selectAll("input").attr("placeholder", ph);
56416       var hideAdd = !_allowCustomValues && !values.length;
56417       _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
56418     }
56419     function change() {
56420       var t2 = {};
56421       var val;
56422       if (_isMulti || _isSemi) {
56423         var vals;
56424         if (_isMulti) {
56425           vals = [tagValue(utilGetSetValue(_input))];
56426         } else if (_isSemi) {
56427           val = tagValue(utilGetSetValue(_input)) || "";
56428           val = val.replace(/,/g, ";");
56429           vals = val.split(";");
56430         }
56431         vals = vals.filter(Boolean);
56432         if (!vals.length) return;
56433         _container.classed("active", false);
56434         utilGetSetValue(_input, "");
56435         if (_isMulti) {
56436           utilArrayUniq(vals).forEach(function(v2) {
56437             var key = (field.key || "") + v2;
56438             if (_tags) {
56439               var old = _tags[key];
56440               if (typeof old === "string" && old.toLowerCase() !== "no") return;
56441             }
56442             key = context.cleanTagKey(key);
56443             field.keys.push(key);
56444             t2[key] = "yes";
56445           });
56446         } else if (_isSemi) {
56447           var arr = _multiData.map(function(d2) {
56448             return d2.key;
56449           });
56450           arr = arr.concat(vals);
56451           t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";"));
56452         }
56453         window.setTimeout(function() {
56454           _input.node().focus();
56455         }, 10);
56456       } else {
56457         var rawValue = utilGetSetValue(_input);
56458         if (!rawValue && Array.isArray(_tags[field.key])) return;
56459         val = context.cleanTagValue(tagValue(rawValue));
56460         t2[field.key] = val || void 0;
56461       }
56462       dispatch14.call("change", this, t2);
56463     }
56464     function removeMultikey(d3_event, d2) {
56465       d3_event.preventDefault();
56466       d3_event.stopPropagation();
56467       var t2 = {};
56468       if (_isMulti) {
56469         t2[d2.key] = void 0;
56470       } else if (_isSemi) {
56471         var arr = _multiData.map(function(md) {
56472           return md.key === d2.key ? null : md.key;
56473         }).filter(Boolean);
56474         arr = utilArrayUniq(arr);
56475         t2[field.key] = arr.length ? arr.join(";") : void 0;
56476         _lengthIndicator.update(t2[field.key]);
56477       }
56478       dispatch14.call("change", this, t2);
56479     }
56480     function invertMultikey(d3_event, d2) {
56481       d3_event.preventDefault();
56482       d3_event.stopPropagation();
56483       var t2 = {};
56484       if (_isMulti) {
56485         t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes";
56486       }
56487       dispatch14.call("change", this, t2);
56488     }
56489     function combo(selection2) {
56490       _container = selection2.selectAll(".form-field-input-wrap").data([0]);
56491       var type2 = _isMulti || _isSemi ? "multicombo" : "combo";
56492       _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container);
56493       if (_isMulti || _isSemi) {
56494         _container = _container.selectAll(".chiplist").data([0]);
56495         var listClass = "chiplist";
56496         if (field.key === "destination" || field.key === "via") {
56497           listClass += " full-line-chips";
56498         }
56499         _container = _container.enter().append("ul").attr("class", listClass).on("click", function() {
56500           window.setTimeout(function() {
56501             _input.node().focus();
56502           }, 10);
56503         }).merge(_container);
56504         _inputWrap = _container.selectAll(".input-wrap").data([0]);
56505         _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap);
56506         var hideAdd = !_allowCustomValues && !_comboData.length;
56507         _inputWrap.style("display", hideAdd ? "none" : null);
56508         _input = _inputWrap.selectAll("input").data([0]);
56509       } else {
56510         _input = _container.selectAll("input").data([0]);
56511       }
56512       _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input);
56513       if (_isSemi) {
56514         _inputWrap.call(_lengthIndicator);
56515       } else if (!_isMulti) {
56516         _container.call(_lengthIndicator);
56517       }
56518       if (_isNetwork) {
56519         var extent = combinedEntityExtent();
56520         var countryCode = extent && iso1A2Code(extent.center());
56521         _countryCode = countryCode && countryCode.toLowerCase();
56522       }
56523       _input.on("change", change).on("blur", change).on("input", function() {
56524         let val = utilGetSetValue(_input);
56525         updateIcon(val);
56526         if (_isSemi && _tags[field.key]) {
56527           val += ";" + _tags[field.key];
56528         }
56529         _lengthIndicator.update(val);
56530       });
56531       _input.on("keydown.field", function(d3_event) {
56532         switch (d3_event.keyCode) {
56533           case 13:
56534             _input.node().blur();
56535             d3_event.stopPropagation();
56536             break;
56537         }
56538       });
56539       if (_isMulti || _isSemi) {
56540         _combobox.on("accept", function() {
56541           _input.node().blur();
56542           _input.node().focus();
56543         });
56544         _input.on("focus", function() {
56545           _container.classed("active", true);
56546         });
56547       }
56548       _combobox.on("cancel", function() {
56549         _input.node().blur();
56550       }).on("update", function() {
56551         updateIcon(utilGetSetValue(_input));
56552       });
56553     }
56554     function updateIcon(value) {
56555       value = tagValue(value);
56556       let container = _container;
56557       if (field.type === "multiCombo" || field.type === "semiCombo") {
56558         container = _container.select(".input-wrap");
56559       }
56560       const iconsField = field.resolveReference("iconsCrossReference");
56561       if (iconsField.icons) {
56562         container.selectAll(".tag-value-icon").remove();
56563         if (iconsField.icons[value]) {
56564           container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value])));
56565         }
56566       }
56567     }
56568     combo.tags = function(tags) {
56569       _tags = tags;
56570       var stringsField = field.resolveReference("stringsCrossReference");
56571       var isMixed = Array.isArray(tags[field.key]);
56572       var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes");
56573       var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title"));
56574       var isKnownValue = (value) => showsValue(value) && !isRawValue(value);
56575       var isReadOnly = !_allowCustomValues;
56576       if (_isMulti || _isSemi) {
56577         _multiData = [];
56578         var maxLength;
56579         if (_isMulti) {
56580           for (var k2 in tags) {
56581             if (field.key && k2.indexOf(field.key) !== 0) continue;
56582             if (!field.key && field.keys.indexOf(k2) === -1) continue;
56583             var v2 = tags[k2];
56584             var suffix = field.key ? k2.slice(field.key.length) : k2;
56585             _multiData.push({
56586               key: k2,
56587               value: displayValue(suffix),
56588               display: addComboboxIcons(renderValue(suffix), suffix),
56589               state: typeof v2 === "string" ? v2.toLowerCase() : "",
56590               isMixed: Array.isArray(v2)
56591             });
56592           }
56593           if (field.key) {
56594             field.keys = _multiData.map(function(d2) {
56595               return d2.key;
56596             });
56597             maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
56598           } else {
56599             maxLength = context.maxCharsForTagKey();
56600           }
56601         } else if (_isSemi) {
56602           var allValues = [];
56603           var commonValues;
56604           if (Array.isArray(tags[field.key])) {
56605             tags[field.key].forEach(function(tagVal) {
56606               var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean);
56607               allValues = allValues.concat(thisVals);
56608               if (!commonValues) {
56609                 commonValues = thisVals;
56610               } else {
56611                 commonValues = commonValues.filter((value) => thisVals.includes(value));
56612               }
56613             });
56614             allValues = utilArrayUniq(allValues).filter(Boolean);
56615           } else {
56616             allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean);
56617             commonValues = allValues;
56618           }
56619           _multiData = allValues.map(function(v3) {
56620             return {
56621               key: v3,
56622               value: displayValue(v3),
56623               display: addComboboxIcons(renderValue(v3), v3),
56624               isMixed: !commonValues.includes(v3)
56625             };
56626           });
56627           var currLength = utilUnicodeCharsCount(commonValues.join(";"));
56628           maxLength = context.maxCharsForTagValue() - currLength;
56629           if (currLength > 0) {
56630             maxLength -= 1;
56631           }
56632         }
56633         maxLength = Math.max(0, maxLength);
56634         var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length;
56635         _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
56636         var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]);
56637         var chips = _container.selectAll(".chip").data(_multiData);
56638         chips.exit().remove();
56639         var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip");
56640         enter.append("span");
56641         const field_buttons = enter.append("div").attr("class", "field_buttons");
56642         field_buttons.append("a").attr("class", "remove");
56643         chips = chips.merge(enter).order().classed("raw-value", function(d2) {
56644           var k3 = d2.key;
56645           if (_isMulti) k3 = k3.replace(field.key, "");
56646           return !stringsField.hasTextForStringId("options." + k3);
56647         }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) {
56648           return d2.isMixed;
56649         }).attr("title", function(d2) {
56650           if (d2.isMixed) {
56651             return _t("inspector.unshared_value_tooltip");
56652           }
56653           if (!["yes", "no"].includes(d2.state)) {
56654             return d2.state;
56655           }
56656           return null;
56657         }).classed("negated", (d2) => d2.state === "no");
56658         if (!_isSemi) {
56659           chips.selectAll("input[type=checkbox]").remove();
56660           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);
56661         }
56662         if (allowDragAndDrop) {
56663           registerDragAndDrop(chips);
56664         }
56665         chips.each(function(d2) {
56666           const selection2 = select_default2(this);
56667           const text_span = selection2.select("span");
56668           const field_buttons2 = selection2.select(".field_buttons");
56669           const clean_value = d2.value.trim();
56670           text_span.text("");
56671           if (!field_buttons2.select("button").empty()) {
56672             field_buttons2.select("button").remove();
56673           }
56674           if (clean_value.startsWith("https://")) {
56675             text_span.text(clean_value);
56676             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) {
56677               d3_event.preventDefault();
56678               window.open(clean_value, "_blank");
56679             });
56680             return;
56681           }
56682           if (d2.display) {
56683             d2.display(text_span);
56684             return;
56685           }
56686           text_span.text(d2.value);
56687         });
56688         chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7");
56689         updateIcon("");
56690       } else {
56691         var mixedValues = isMixed && tags[field.key].map(function(val) {
56692           return displayValue(val);
56693         }).filter(Boolean);
56694         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) {
56695           if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
56696             d3_event.preventDefault();
56697             d3_event.stopPropagation();
56698             var t2 = {};
56699             t2[field.key] = void 0;
56700             dispatch14.call("change", this, t2);
56701           }
56702         });
56703         if (!Array.isArray(tags[field.key])) {
56704           updateIcon(tags[field.key]);
56705         }
56706         if (!isMixed) {
56707           _lengthIndicator.update(tags[field.key]);
56708         }
56709       }
56710       const refreshStyles = () => {
56711         _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue);
56712       };
56713       _input.on("input.refreshStyles", refreshStyles);
56714       _combobox.on("update.refreshStyles", refreshStyles);
56715       refreshStyles();
56716     };
56717     function registerDragAndDrop(selection2) {
56718       var dragOrigin, targetIndex;
56719       selection2.call(
56720         drag_default().on("start", function(d3_event) {
56721           dragOrigin = {
56722             x: d3_event.x,
56723             y: d3_event.y
56724           };
56725           targetIndex = null;
56726         }).on("drag", function(d3_event) {
56727           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
56728           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
56729           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) return;
56730           var index = selection2.nodes().indexOf(this);
56731           select_default2(this).classed("dragging", true);
56732           targetIndex = null;
56733           var targetIndexOffsetTop = null;
56734           var draggedTagWidth = select_default2(this).node().offsetWidth;
56735           if (field.key === "destination" || field.key === "via") {
56736             _container.selectAll(".chip").style("transform", function(d2, index2) {
56737               var node = select_default2(this).node();
56738               if (index === index2) {
56739                 return "translate(" + x2 + "px, " + y2 + "px)";
56740               } else if (index2 > index && d3_event.y > node.offsetTop) {
56741                 if (targetIndex === null || index2 > targetIndex) {
56742                   targetIndex = index2;
56743                 }
56744                 return "translateY(-100%)";
56745               } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
56746                 if (targetIndex === null || index2 < targetIndex) {
56747                   targetIndex = index2;
56748                 }
56749                 return "translateY(100%)";
56750               }
56751               return null;
56752             });
56753           } else {
56754             _container.selectAll(".chip").each(function(d2, index2) {
56755               var node = select_default2(this).node();
56756               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) {
56757                 targetIndex = index2;
56758                 targetIndexOffsetTop = node.offsetTop;
56759               }
56760             }).style("transform", function(d2, index2) {
56761               var node = select_default2(this).node();
56762               if (index === index2) {
56763                 return "translate(" + x2 + "px, " + y2 + "px)";
56764               }
56765               if (node.offsetTop === targetIndexOffsetTop) {
56766                 if (index2 < index && index2 >= targetIndex) {
56767                   return "translateX(" + draggedTagWidth + "px)";
56768                 } else if (index2 > index && index2 <= targetIndex) {
56769                   return "translateX(-" + draggedTagWidth + "px)";
56770                 }
56771               }
56772               return null;
56773             });
56774           }
56775         }).on("end", function() {
56776           if (!select_default2(this).classed("dragging")) {
56777             return;
56778           }
56779           var index = selection2.nodes().indexOf(this);
56780           select_default2(this).classed("dragging", false);
56781           _container.selectAll(".chip").style("transform", null);
56782           if (typeof targetIndex === "number") {
56783             var element = _multiData[index];
56784             _multiData.splice(index, 1);
56785             _multiData.splice(targetIndex, 0, element);
56786             var t2 = {};
56787             if (_multiData.length) {
56788               t2[field.key] = _multiData.map(function(element2) {
56789                 return element2.key;
56790               }).join(";");
56791             } else {
56792               t2[field.key] = void 0;
56793             }
56794             dispatch14.call("change", this, t2);
56795           }
56796           dragOrigin = void 0;
56797           targetIndex = void 0;
56798         })
56799       );
56800     }
56801     combo.setCustomOptions = (newValue) => {
56802       _customOptions = newValue;
56803     };
56804     combo.focus = function() {
56805       _input.node().focus();
56806     };
56807     combo.entityIDs = function(val) {
56808       if (!arguments.length) return _entityIDs;
56809       _entityIDs = val;
56810       return combo;
56811     };
56812     function combinedEntityExtent() {
56813       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
56814     }
56815     return utilRebind(combo, dispatch14, "on");
56816   }
56817
56818   // modules/ui/account.js
56819   function uiAccount(context) {
56820     const osm = context.connection();
56821     function updateUserDetails(selection2) {
56822       if (!osm) return;
56823       if (!osm.authenticated()) {
56824         render(selection2, null);
56825       } else {
56826         osm.userDetails((err, user) => render(selection2, user));
56827       }
56828     }
56829     function render(selection2, user) {
56830       let userInfo = selection2.select(".userInfo");
56831       let loginLogout = selection2.select(".loginLogout");
56832       if (user) {
56833         userInfo.html("").classed("hide", false);
56834         let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
56835         if (user.image_url) {
56836           userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url);
56837         } else {
56838           userLink.call(svgIcon("#iD-icon-avatar", "pre-text light"));
56839         }
56840         userLink.append("span").attr("class", "label").text(user.display_name);
56841         loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => {
56842           e3.preventDefault();
56843           osm.logout();
56844           osm.authenticate(void 0, { switchUser: true });
56845         });
56846       } else {
56847         userInfo.html("").classed("hide", true);
56848         loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => {
56849           e3.preventDefault();
56850           osm.authenticate();
56851         });
56852       }
56853     }
56854     return function(selection2) {
56855       if (!osm) return;
56856       selection2.append("li").attr("class", "userInfo").classed("hide", true);
56857       selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#");
56858       osm.on("change.account", () => updateUserDetails(selection2));
56859       updateUserDetails(selection2);
56860     };
56861   }
56862
56863   // modules/ui/attribution.js
56864   function uiAttribution(context) {
56865     let _selection = select_default2(null);
56866     function render(selection2, data, klass) {
56867       let div = selection2.selectAll(".".concat(klass)).data([0]);
56868       div = div.enter().append("div").attr("class", klass).merge(div);
56869       let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id);
56870       attributions.exit().remove();
56871       attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => {
56872         let attribution = select_default2(nodes[i3]);
56873         if (d2.terms_html) {
56874           attribution.html(d2.terms_html);
56875           return;
56876         }
56877         if (d2.terms_url) {
56878           attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank");
56879         }
56880         const sourceID = d2.id.replace(/\./g, "<TX_DOT>");
56881         const terms_text = _t(
56882           "imagery.".concat(sourceID, ".attribution.text"),
56883           { default: d2.terms_text || d2.id || d2.name() }
56884         );
56885         if (d2.icon && !d2.overlay) {
56886           attribution.append("img").attr("class", "source-image").attr("src", d2.icon);
56887         }
56888         attribution.append("span").attr("class", "attribution-text").text(terms_text);
56889       }).merge(attributions);
56890       let copyright = attributions.selectAll(".copyright-notice").data((d2) => {
56891         let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent());
56892         return notice ? [notice] : [];
56893       });
56894       copyright.exit().remove();
56895       copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright);
56896       copyright.text(String);
56897     }
56898     function update() {
56899       let baselayer = context.background().baseLayerSource();
56900       _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution");
56901       const z2 = context.map().zoom();
56902       let overlays = context.background().overlayLayerSources() || [];
56903       _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution");
56904     }
56905     return function(selection2) {
56906       _selection = selection2;
56907       context.background().on("change.attribution", update);
56908       context.map().on("move.attribution", throttle_default(update, 400, { leading: false }));
56909       update();
56910     };
56911   }
56912
56913   // modules/ui/contributors.js
56914   function uiContributors(context) {
56915     var osm = context.connection(), debouncedUpdate = debounce_default(function() {
56916       update();
56917     }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null);
56918     function update() {
56919       if (!osm) return;
56920       var users = {}, entities = context.history().intersects(context.map().extent());
56921       entities.forEach(function(entity) {
56922         if (entity && entity.user) users[entity.user] = true;
56923       });
56924       var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit);
56925       wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light"));
56926       var userList = select_default2(document.createElement("span"));
56927       userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) {
56928         return osm.userURL(d2);
56929       }).attr("target", "_blank").text(String);
56930       if (u2.length > limit) {
56931         var count = select_default2(document.createElement("span"));
56932         var othersNum = u2.length - limit + 1;
56933         count.append("a").attr("target", "_blank").attr("href", function() {
56934           return osm.changesetsURL(context.map().center(), context.map().zoom());
56935         }).text(othersNum);
56936         wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } }));
56937       } else {
56938         wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } }));
56939       }
56940       if (!u2.length) {
56941         hidden = true;
56942         wrap2.transition().style("opacity", 0);
56943       } else if (hidden) {
56944         wrap2.transition().style("opacity", 1);
56945       }
56946     }
56947     return function(selection2) {
56948       if (!osm) return;
56949       wrap2 = selection2;
56950       update();
56951       osm.on("loaded.contributors", debouncedUpdate);
56952       context.map().on("move.contributors", debouncedUpdate);
56953     };
56954   }
56955
56956   // modules/ui/edit_menu.js
56957   function uiEditMenu(context) {
56958     var dispatch14 = dispatch_default("toggled");
56959     var _menu = select_default2(null);
56960     var _operations = [];
56961     var _anchorLoc = [0, 0];
56962     var _anchorLocLonLat = [0, 0];
56963     var _triggerType = "";
56964     var _vpTopMargin = 85;
56965     var _vpBottomMargin = 45;
56966     var _vpSideMargin = 35;
56967     var _menuTop = false;
56968     var _menuHeight;
56969     var _menuWidth;
56970     var _verticalPadding = 4;
56971     var _tooltipWidth = 210;
56972     var _menuSideMargin = 10;
56973     var _tooltips = [];
56974     var editMenu = function(selection2) {
56975       var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen");
56976       var ops = _operations.filter(function(op) {
56977         return !isTouchMenu || !op.mouseOnly;
56978       });
56979       if (!ops.length) return;
56980       _tooltips = [];
56981       _menuTop = isTouchMenu;
56982       var showLabels = isTouchMenu;
56983       var buttonHeight = showLabels ? 32 : 34;
56984       if (showLabels) {
56985         _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) {
56986           return op.title.length;
56987         })));
56988       } else {
56989         _menuWidth = 44;
56990       }
56991       _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight;
56992       _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0");
56993       var buttons = _menu.selectAll(".edit-menu-item").data(ops);
56994       var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
56995         return "edit-menu-item edit-menu-item-" + d2.id;
56996       }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) {
56997         d3_event.stopPropagation();
56998       }).on("mouseenter.highlight", function(d3_event, d2) {
56999         if (!d2.relatedEntityIds || select_default2(this).classed("disabled")) return;
57000         utilHighlightEntities(d2.relatedEntityIds(), true, context);
57001       }).on("mouseleave.highlight", function(d3_event, d2) {
57002         if (!d2.relatedEntityIds) return;
57003         utilHighlightEntities(d2.relatedEntityIds(), false, context);
57004       });
57005       buttonsEnter.each(function(d2) {
57006         var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]);
57007         _tooltips.push(tooltip);
57008         select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation"));
57009       });
57010       if (showLabels) {
57011         buttonsEnter.append("span").attr("class", "label").each(function(d2) {
57012           select_default2(this).call(d2.title);
57013         });
57014       }
57015       buttonsEnter.merge(buttons).classed("disabled", function(d2) {
57016         return d2.disabled();
57017       });
57018       updatePosition();
57019       var initialScale = context.projection.scale();
57020       context.map().on("move.edit-menu", function() {
57021         if (initialScale !== context.projection.scale()) {
57022           editMenu.close();
57023         }
57024       }).on("drawn.edit-menu", function(info) {
57025         if (info.full) updatePosition();
57026       });
57027       var lastPointerUpType;
57028       function pointerup(d3_event) {
57029         lastPointerUpType = d3_event.pointerType;
57030       }
57031       function click(d3_event, operation2) {
57032         d3_event.stopPropagation();
57033         if (operation2.relatedEntityIds) {
57034           utilHighlightEntities(operation2.relatedEntityIds(), false, context);
57035         }
57036         if (operation2.disabled()) {
57037           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
57038             context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())();
57039           }
57040         } else {
57041           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
57042             context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)();
57043           }
57044           operation2();
57045           editMenu.close();
57046         }
57047         lastPointerUpType = null;
57048       }
57049       dispatch14.call("toggled", this, true);
57050     };
57051     function updatePosition() {
57052       if (!_menu || _menu.empty()) return;
57053       var anchorLoc = context.projection(_anchorLocLonLat);
57054       var viewport = context.surfaceRect();
57055       if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) {
57056         editMenu.close();
57057         return;
57058       }
57059       var menuLeft = displayOnLeft(viewport);
57060       var offset = [0, 0];
57061       offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin;
57062       if (_menuTop) {
57063         if (anchorLoc[1] - _menuHeight < _vpTopMargin) {
57064           offset[1] = -anchorLoc[1] + _vpTopMargin;
57065         } else {
57066           offset[1] = -_menuHeight;
57067         }
57068       } else {
57069         if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) {
57070           offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin;
57071         } else {
57072           offset[1] = 0;
57073         }
57074       }
57075       var origin = geoVecAdd(anchorLoc, offset);
57076       var _verticalOffset = parseFloat(utilGetDimensions(select_default2(".top-toolbar-wrap"))[1]);
57077       origin[1] -= _verticalOffset;
57078       _menu.style("left", origin[0] + "px").style("top", origin[1] + "px");
57079       var tooltipSide = tooltipPosition(viewport, menuLeft);
57080       _tooltips.forEach(function(tooltip) {
57081         tooltip.placement(tooltipSide);
57082       });
57083       function displayOnLeft(viewport2) {
57084         if (_mainLocalizer.textDirection() === "ltr") {
57085           if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) {
57086             return true;
57087           }
57088           return false;
57089         } else {
57090           if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) {
57091             return false;
57092           }
57093           return true;
57094         }
57095       }
57096       function tooltipPosition(viewport2, menuLeft2) {
57097         if (_mainLocalizer.textDirection() === "ltr") {
57098           if (menuLeft2) {
57099             return "left";
57100           }
57101           if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) {
57102             return "left";
57103           }
57104           return "right";
57105         } else {
57106           if (!menuLeft2) {
57107             return "right";
57108           }
57109           if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) {
57110             return "right";
57111           }
57112           return "left";
57113         }
57114       }
57115     }
57116     editMenu.close = function() {
57117       context.map().on("move.edit-menu", null).on("drawn.edit-menu", null);
57118       _menu.remove();
57119       _tooltips = [];
57120       dispatch14.call("toggled", this, false);
57121     };
57122     editMenu.anchorLoc = function(val) {
57123       if (!arguments.length) return _anchorLoc;
57124       _anchorLoc = val;
57125       _anchorLocLonLat = context.projection.invert(_anchorLoc);
57126       return editMenu;
57127     };
57128     editMenu.triggerType = function(val) {
57129       if (!arguments.length) return _triggerType;
57130       _triggerType = val;
57131       return editMenu;
57132     };
57133     editMenu.operations = function(val) {
57134       if (!arguments.length) return _operations;
57135       _operations = val;
57136       return editMenu;
57137     };
57138     return utilRebind(editMenu, dispatch14, "on");
57139   }
57140
57141   // modules/ui/feature_info.js
57142   function uiFeatureInfo(context) {
57143     function update(selection2) {
57144       var features = context.features();
57145       var stats = features.stats();
57146       var count = 0;
57147       var hiddenList = features.hidden().map(function(k2) {
57148         if (stats[k2]) {
57149           count += stats[k2];
57150           return _t.append("inspector.title_count", {
57151             title: _t("feature." + k2 + ".description"),
57152             count: stats[k2]
57153           });
57154         }
57155         return null;
57156       }).filter(Boolean);
57157       selection2.text("");
57158       if (hiddenList.length) {
57159         var tooltipBehavior = uiTooltip().placement("top").title(function() {
57160           return (selection3) => {
57161             hiddenList.forEach((hiddenFeature) => {
57162               selection3.append("div").call(hiddenFeature);
57163             });
57164           };
57165         });
57166         selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) {
57167           tooltipBehavior.hide();
57168           d3_event.preventDefault();
57169           context.ui().togglePanes(context.container().select(".map-panes .map-data-pane"));
57170         });
57171       }
57172       selection2.classed("hide", !hiddenList.length);
57173     }
57174     return function(selection2) {
57175       update(selection2);
57176       context.features().on("change.feature_info", function() {
57177         update(selection2);
57178       });
57179     };
57180   }
57181
57182   // modules/ui/flash.js
57183   function uiFlash(context) {
57184     var _flashTimer;
57185     var _duration = 2e3;
57186     var _iconName = "#iD-icon-no";
57187     var _iconClass = "disabled";
57188     var _label = (s2) => s2.text("");
57189     function flash() {
57190       if (_flashTimer) {
57191         _flashTimer.stop();
57192       }
57193       context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false);
57194       context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true);
57195       var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]);
57196       var contentEnter = content.enter().append("div").attr("class", "flash-content");
57197       var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)");
57198       iconEnter.append("circle").attr("r", 9);
57199       iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14");
57200       contentEnter.append("div").attr("class", "flash-text");
57201       content = content.merge(contentEnter);
57202       content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || ""));
57203       content.selectAll(".flash-icon use").attr("xlink:href", _iconName);
57204       content.selectAll(".flash-text").attr("class", "flash-text").call(_label);
57205       _flashTimer = timeout_default(function() {
57206         _flashTimer = null;
57207         context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true);
57208         context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false);
57209       }, _duration);
57210       return content;
57211     }
57212     flash.duration = function(_2) {
57213       if (!arguments.length) return _duration;
57214       _duration = _2;
57215       return flash;
57216     };
57217     flash.label = function(_2) {
57218       if (!arguments.length) return _label;
57219       if (typeof _2 !== "function") {
57220         _label = (selection2) => selection2.text(_2);
57221       } else {
57222         _label = (selection2) => selection2.text("").call(_2);
57223       }
57224       return flash;
57225     };
57226     flash.iconName = function(_2) {
57227       if (!arguments.length) return _iconName;
57228       _iconName = _2;
57229       return flash;
57230     };
57231     flash.iconClass = function(_2) {
57232       if (!arguments.length) return _iconClass;
57233       _iconClass = _2;
57234       return flash;
57235     };
57236     return flash;
57237   }
57238
57239   // modules/ui/full_screen.js
57240   function uiFullScreen(context) {
57241     var element = context.container().node();
57242     function getFullScreenFn() {
57243       if (element.requestFullscreen) {
57244         return element.requestFullscreen;
57245       } else if (element.msRequestFullscreen) {
57246         return element.msRequestFullscreen;
57247       } else if (element.mozRequestFullScreen) {
57248         return element.mozRequestFullScreen;
57249       } else if (element.webkitRequestFullscreen) {
57250         return element.webkitRequestFullscreen;
57251       }
57252     }
57253     function getExitFullScreenFn() {
57254       if (document.exitFullscreen) {
57255         return document.exitFullscreen;
57256       } else if (document.msExitFullscreen) {
57257         return document.msExitFullscreen;
57258       } else if (document.mozCancelFullScreen) {
57259         return document.mozCancelFullScreen;
57260       } else if (document.webkitExitFullscreen) {
57261         return document.webkitExitFullscreen;
57262       }
57263     }
57264     function isFullScreen() {
57265       return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
57266     }
57267     function isSupported() {
57268       return !!getFullScreenFn();
57269     }
57270     function fullScreen(d3_event) {
57271       d3_event.preventDefault();
57272       if (!isFullScreen()) {
57273         getFullScreenFn().apply(element);
57274       } else {
57275         getExitFullScreenFn().apply(document);
57276       }
57277     }
57278     return function() {
57279       if (!isSupported()) return;
57280       var detected = utilDetect();
57281       var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"];
57282       context.keybinding().on(keys2, fullScreen);
57283     };
57284   }
57285
57286   // modules/ui/geolocate.js
57287   function uiGeolocate(context) {
57288     var _geolocationOptions = {
57289       // prioritize speed and power usage over precision
57290       enableHighAccuracy: false,
57291       // don't hang indefinitely getting the location
57292       timeout: 6e3
57293       // 6sec
57294     };
57295     var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true);
57296     var _layer = context.layers().layer("geolocate");
57297     var _position;
57298     var _extent;
57299     var _timeoutID;
57300     var _button = select_default2(null);
57301     function click() {
57302       if (context.inIntro()) return;
57303       if (!_layer.enabled() && !_locating.isShown()) {
57304         _timeoutID = setTimeout(
57305           error,
57306           1e4
57307           /* 10sec */
57308         );
57309         context.container().call(_locating);
57310         navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions);
57311       } else {
57312         _locating.close();
57313         _layer.enabled(null, false);
57314         updateButtonState();
57315       }
57316     }
57317     function zoomTo() {
57318       context.enter(modeBrowse(context));
57319       var map2 = context.map();
57320       _layer.enabled(_position, true);
57321       updateButtonState();
57322       map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent)));
57323     }
57324     function success(geolocation) {
57325       _position = geolocation;
57326       var coords = _position.coords;
57327       _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy);
57328       zoomTo();
57329       finish();
57330     }
57331     function error() {
57332       if (_position) {
57333         zoomTo();
57334       } else {
57335         context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")();
57336       }
57337       finish();
57338     }
57339     function finish() {
57340       _locating.close();
57341       if (_timeoutID) {
57342         clearTimeout(_timeoutID);
57343       }
57344       _timeoutID = void 0;
57345     }
57346     function updateButtonState() {
57347       _button.classed("active", _layer.enabled());
57348       _button.attr("aria-pressed", _layer.enabled());
57349     }
57350     return function(selection2) {
57351       if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition) return;
57352       _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call(
57353         uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title"))
57354       );
57355     };
57356   }
57357
57358   // modules/ui/panels/background.js
57359   function uiPanelBackground(context) {
57360     var background = context.background();
57361     var _currSourceName = null;
57362     var _metadata = {};
57363     var _metadataKeys = [
57364       "zoom",
57365       "vintage",
57366       "source",
57367       "description",
57368       "resolution",
57369       "accuracy"
57370     ];
57371     var debouncedRedraw = debounce_default(redraw, 250);
57372     function redraw(selection2) {
57373       var source = background.baseLayerSource();
57374       if (!source) return;
57375       var isDG = source.id.match(/^DigitalGlobe/i) !== null;
57376       var sourceLabel = source.label();
57377       if (_currSourceName !== sourceLabel) {
57378         _currSourceName = sourceLabel;
57379         _metadata = {};
57380       }
57381       selection2.text("");
57382       var list2 = selection2.append("ul").attr("class", "background-info");
57383       list2.append("li").call(_currSourceName);
57384       _metadataKeys.forEach(function(k2) {
57385         if (isDG && k2 === "vintage") return;
57386         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]);
57387       });
57388       debouncedGetMetadata(selection2);
57389       var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles";
57390       selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) {
57391         d3_event.preventDefault();
57392         context.setDebug("tile", !context.getDebug("tile"));
57393         selection2.call(redraw);
57394       });
57395       if (isDG) {
57396         var key = source.id + "-vintage";
57397         var sourceVintage = context.background().findSource(key);
57398         var showsVintage = context.background().showsLayer(sourceVintage);
57399         var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage";
57400         selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) {
57401           d3_event.preventDefault();
57402           context.background().toggleOverlayLayer(sourceVintage);
57403           selection2.call(redraw);
57404         });
57405       }
57406       ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) {
57407         if (source.id !== layerId) {
57408           var key2 = layerId + "-vintage";
57409           var sourceVintage2 = context.background().findSource(key2);
57410           if (context.background().showsLayer(sourceVintage2)) {
57411             context.background().toggleOverlayLayer(sourceVintage2);
57412           }
57413         }
57414       });
57415     }
57416     var debouncedGetMetadata = debounce_default(getMetadata, 250);
57417     function getMetadata(selection2) {
57418       var tile = context.container().select(".layer-background img.tile-center");
57419       if (tile.empty()) return;
57420       var sourceName = _currSourceName;
57421       var d2 = tile.datum();
57422       var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom());
57423       var center = context.map().center();
57424       _metadata.zoom = String(zoom);
57425       selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom);
57426       if (!d2 || !d2.length >= 3) return;
57427       background.baseLayerSource().getMetadata(center, d2, function(err, result) {
57428         if (err || _currSourceName !== sourceName) return;
57429         var vintage = result.vintage;
57430         _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown");
57431         selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage);
57432         _metadataKeys.forEach(function(k2) {
57433           if (k2 === "zoom" || k2 === "vintage") return;
57434           var val = result[k2];
57435           _metadata[k2] = val;
57436           selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val);
57437         });
57438       });
57439     }
57440     var panel = function(selection2) {
57441       selection2.call(redraw);
57442       context.map().on("drawn.info-background", function() {
57443         selection2.call(debouncedRedraw);
57444       }).on("move.info-background", function() {
57445         selection2.call(debouncedGetMetadata);
57446       });
57447     };
57448     panel.off = function() {
57449       context.map().on("drawn.info-background", null).on("move.info-background", null);
57450     };
57451     panel.id = "background";
57452     panel.label = _t.append("info_panels.background.title");
57453     panel.key = _t("info_panels.background.key");
57454     return panel;
57455   }
57456
57457   // modules/ui/panels/history.js
57458   function uiPanelHistory(context) {
57459     var osm;
57460     function displayTimestamp(timestamp) {
57461       if (!timestamp) return _t("info_panels.history.unknown");
57462       var options2 = {
57463         day: "numeric",
57464         month: "short",
57465         year: "numeric",
57466         hour: "numeric",
57467         minute: "numeric",
57468         second: "numeric"
57469       };
57470       var d2 = new Date(timestamp);
57471       if (isNaN(d2.getTime())) return _t("info_panels.history.unknown");
57472       return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
57473     }
57474     function displayUser(selection2, userName) {
57475       if (!userName) {
57476         selection2.append("span").call(_t.append("info_panels.history.unknown"));
57477         return;
57478       }
57479       selection2.append("span").attr("class", "user-name").text(userName);
57480       var links = selection2.append("div").attr("class", "links");
57481       if (osm) {
57482         links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link"));
57483       }
57484       links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC");
57485     }
57486     function displayChangeset(selection2, changeset) {
57487       if (!changeset) {
57488         selection2.append("span").call(_t.append("info_panels.history.unknown"));
57489         return;
57490       }
57491       selection2.append("span").attr("class", "changeset-id").text(changeset);
57492       var links = selection2.append("div").attr("class", "links");
57493       if (osm) {
57494         links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link"));
57495       }
57496       links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha");
57497       links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi");
57498     }
57499     function redraw(selection2) {
57500       var selectedNoteID = context.selectedNoteID();
57501       osm = context.connection();
57502       var selected, note, entity;
57503       if (selectedNoteID && osm) {
57504         selected = [_t.html("note.note") + " " + selectedNoteID];
57505         note = osm.getNote(selectedNoteID);
57506       } else {
57507         selected = context.selectedIDs().filter(function(e3) {
57508           return context.hasEntity(e3);
57509         });
57510         if (selected.length) {
57511           entity = context.entity(selected[0]);
57512         }
57513       }
57514       var singular = selected.length === 1 ? selected[0] : null;
57515       selection2.html("");
57516       if (singular) {
57517         selection2.append("h4").attr("class", "history-heading").html(singular);
57518       } else {
57519         selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length }));
57520       }
57521       if (!singular) return;
57522       if (entity) {
57523         selection2.call(redrawEntity, entity);
57524       } else if (note) {
57525         selection2.call(redrawNote, note);
57526       }
57527     }
57528     function redrawNote(selection2, note) {
57529       if (!note || note.isNew()) {
57530         selection2.append("div").call(_t.append("info_panels.history.note_no_history"));
57531         return;
57532       }
57533       var list2 = selection2.append("ul");
57534       list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length);
57535       if (note.comments.length) {
57536         list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date));
57537         list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user);
57538       }
57539       if (osm) {
57540         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"));
57541       }
57542     }
57543     function redrawEntity(selection2, entity) {
57544       if (!entity || entity.isNew()) {
57545         selection2.append("div").call(_t.append("info_panels.history.no_history"));
57546         return;
57547       }
57548       var links = selection2.append("div").attr("class", "links");
57549       if (osm) {
57550         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"));
57551       }
57552       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");
57553       var list2 = selection2.append("ul");
57554       list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version);
57555       list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp));
57556       list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user);
57557       list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset);
57558     }
57559     var panel = function(selection2) {
57560       selection2.call(redraw);
57561       context.map().on("drawn.info-history", function() {
57562         selection2.call(redraw);
57563       });
57564       context.on("enter.info-history", function() {
57565         selection2.call(redraw);
57566       });
57567     };
57568     panel.off = function() {
57569       context.map().on("drawn.info-history", null);
57570       context.on("enter.info-history", null);
57571     };
57572     panel.id = "history";
57573     panel.label = _t.append("info_panels.history.title");
57574     panel.key = _t("info_panels.history.key");
57575     return panel;
57576   }
57577
57578   // modules/ui/panels/location.js
57579   function uiPanelLocation(context) {
57580     var currLocation = "";
57581     function redraw(selection2) {
57582       selection2.html("");
57583       var list2 = selection2.append("ul");
57584       var coord2 = context.map().mouseCoordinates();
57585       if (coord2.some(isNaN)) {
57586         coord2 = context.map().center();
57587       }
57588       list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2));
57589       selection2.append("div").attr("class", "location-info").text(currLocation || " ");
57590       debouncedGetLocation(selection2, coord2);
57591     }
57592     var debouncedGetLocation = debounce_default(getLocation, 250);
57593     function getLocation(selection2, coord2) {
57594       if (!services.geocoder) {
57595         currLocation = _t("info_panels.location.unknown_location");
57596         selection2.selectAll(".location-info").text(currLocation);
57597       } else {
57598         services.geocoder.reverse(coord2, function(err, result) {
57599           currLocation = result ? result.display_name : _t("info_panels.location.unknown_location");
57600           selection2.selectAll(".location-info").text(currLocation);
57601         });
57602       }
57603     }
57604     var panel = function(selection2) {
57605       selection2.call(redraw);
57606       context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() {
57607         selection2.call(redraw);
57608       });
57609     };
57610     panel.off = function() {
57611       context.surface().on(".info-location", null);
57612     };
57613     panel.id = "location";
57614     panel.label = _t.append("info_panels.location.title");
57615     panel.key = _t("info_panels.location.key");
57616     return panel;
57617   }
57618
57619   // modules/ui/panels/measurement.js
57620   function uiPanelMeasurement(context) {
57621     function radiansToMeters(r2) {
57622       return r2 * 63710071809e-4;
57623     }
57624     function steradiansToSqmeters(r2) {
57625       return r2 / (4 * Math.PI) * 510065621724e3;
57626     }
57627     function toLineString(feature3) {
57628       if (feature3.type === "LineString") return feature3;
57629       var result = { type: "LineString", coordinates: [] };
57630       if (feature3.type === "Polygon") {
57631         result.coordinates = feature3.coordinates[0];
57632       } else if (feature3.type === "MultiPolygon") {
57633         result.coordinates = feature3.coordinates[0][0];
57634       }
57635       return result;
57636     }
57637     var _isImperial = !_mainLocalizer.usesMetric();
57638     function redraw(selection2) {
57639       var graph = context.graph();
57640       var selectedNoteID = context.selectedNoteID();
57641       var osm = services.osm;
57642       var localeCode = _mainLocalizer.localeCode();
57643       var heading2;
57644       var center, location, centroid;
57645       var closed, geometry;
57646       var totalNodeCount, length2 = 0, area = 0, distance;
57647       if (selectedNoteID && osm) {
57648         var note = osm.getNote(selectedNoteID);
57649         heading2 = _t.html("note.note") + " " + selectedNoteID;
57650         location = note.loc;
57651         geometry = "note";
57652       } else {
57653         var selectedIDs = context.selectedIDs().filter(function(id2) {
57654           return context.hasEntity(id2);
57655         });
57656         var selected = selectedIDs.map(function(id2) {
57657           return context.entity(id2);
57658         });
57659         heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length });
57660         if (selected.length) {
57661           var extent = geoExtent();
57662           for (var i3 in selected) {
57663             var entity = selected[i3];
57664             extent._extend(entity.extent(graph));
57665             geometry = entity.geometry(graph);
57666             if (geometry === "line" || geometry === "area") {
57667               closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate();
57668               var feature3 = entity.asGeoJSON(graph);
57669               length2 += radiansToMeters(length_default(toLineString(feature3)));
57670               centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph));
57671               centroid = centroid && context.projection.invert(centroid);
57672               if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) {
57673                 centroid = entity.extent(graph).center();
57674               }
57675               if (closed) {
57676                 area += steradiansToSqmeters(entity.area(graph));
57677               }
57678             }
57679           }
57680           if (selected.length > 1) {
57681             geometry = null;
57682             closed = null;
57683             centroid = null;
57684           }
57685           if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") {
57686             distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
57687           }
57688           if (selected.length === 1 && selected[0].type === "node") {
57689             location = selected[0].loc;
57690           } else {
57691             totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length;
57692           }
57693           if (!location && !centroid) {
57694             center = extent.center();
57695           }
57696         }
57697       }
57698       selection2.html("");
57699       if (heading2) {
57700         selection2.append("h4").attr("class", "measurement-heading").html(heading2);
57701       }
57702       var list2 = selection2.append("ul");
57703       var coordItem;
57704       if (geometry) {
57705         list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html(
57706           closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry)
57707         );
57708       }
57709       if (totalNodeCount) {
57710         list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode));
57711       }
57712       if (area) {
57713         list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial));
57714       }
57715       if (length2) {
57716         list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial));
57717       }
57718       if (typeof distance === "number") {
57719         list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial));
57720       }
57721       if (location) {
57722         coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" }));
57723         coordItem.append("span").text(dmsCoordinatePair(location));
57724         coordItem.append("span").text(decimalCoordinatePair(location));
57725       }
57726       if (centroid) {
57727         coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" }));
57728         coordItem.append("span").text(dmsCoordinatePair(centroid));
57729         coordItem.append("span").text(decimalCoordinatePair(centroid));
57730       }
57731       if (center) {
57732         coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" }));
57733         coordItem.append("span").text(dmsCoordinatePair(center));
57734         coordItem.append("span").text(decimalCoordinatePair(center));
57735       }
57736       if (length2 || area || typeof distance === "number") {
57737         var toggle = _isImperial ? "imperial" : "metric";
57738         selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) {
57739           d3_event.preventDefault();
57740           _isImperial = !_isImperial;
57741           selection2.call(redraw);
57742         });
57743       }
57744     }
57745     var panel = function(selection2) {
57746       selection2.call(redraw);
57747       context.map().on("drawn.info-measurement", function() {
57748         selection2.call(redraw);
57749       });
57750       context.on("enter.info-measurement", function() {
57751         selection2.call(redraw);
57752       });
57753     };
57754     panel.off = function() {
57755       context.map().on("drawn.info-measurement", null);
57756       context.on("enter.info-measurement", null);
57757     };
57758     panel.id = "measurement";
57759     panel.label = _t.append("info_panels.measurement.title");
57760     panel.key = _t("info_panels.measurement.key");
57761     return panel;
57762   }
57763
57764   // modules/ui/panels/index.js
57765   var uiInfoPanels = {
57766     background: uiPanelBackground,
57767     history: uiPanelHistory,
57768     location: uiPanelLocation,
57769     measurement: uiPanelMeasurement
57770   };
57771
57772   // modules/ui/info.js
57773   function uiInfo(context) {
57774     var ids = Object.keys(uiInfoPanels);
57775     var wasActive = ["measurement"];
57776     var panels = {};
57777     var active = {};
57778     ids.forEach(function(k2) {
57779       if (!panels[k2]) {
57780         panels[k2] = uiInfoPanels[k2](context);
57781         active[k2] = false;
57782       }
57783     });
57784     function info(selection2) {
57785       function redraw() {
57786         var activeids = ids.filter(function(k2) {
57787           return active[k2];
57788         }).sort();
57789         var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) {
57790           return k2;
57791         });
57792         containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) {
57793           select_default2(this).call(panels[d2].off).remove();
57794         });
57795         var enter = containers.enter().append("div").attr("class", function(d2) {
57796           return "fillD2 panel-container panel-container-" + d2;
57797         });
57798         enter.style("opacity", 0).transition().duration(200).style("opacity", 1);
57799         var title = enter.append("div").attr("class", "panel-title fillD2");
57800         title.append("h3").each(function(d2) {
57801           return panels[d2].label(select_default2(this));
57802         });
57803         title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) {
57804           d3_event.stopImmediatePropagation();
57805           d3_event.preventDefault();
57806           info.toggle(d2);
57807         }).call(svgIcon("#iD-icon-close"));
57808         enter.append("div").attr("class", function(d2) {
57809           return "panel-content panel-content-" + d2;
57810         });
57811         infoPanels.selectAll(".panel-content").each(function(d2) {
57812           select_default2(this).call(panels[d2]);
57813         });
57814       }
57815       info.toggle = function(which) {
57816         var activeids = ids.filter(function(k2) {
57817           return active[k2];
57818         });
57819         if (which) {
57820           active[which] = !active[which];
57821           if (activeids.length === 1 && activeids[0] === which) {
57822             wasActive = [which];
57823           }
57824           context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]);
57825         } else {
57826           if (activeids.length) {
57827             wasActive = activeids;
57828             activeids.forEach(function(k2) {
57829               active[k2] = false;
57830             });
57831           } else {
57832             wasActive.forEach(function(k2) {
57833               active[k2] = true;
57834             });
57835           }
57836         }
57837         redraw();
57838       };
57839       var infoPanels = selection2.selectAll(".info-panels").data([0]);
57840       infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels);
57841       redraw();
57842       context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) {
57843         d3_event.stopImmediatePropagation();
57844         d3_event.preventDefault();
57845         info.toggle();
57846       });
57847       ids.forEach(function(k2) {
57848         var key = _t("info_panels." + k2 + ".key", { default: null });
57849         if (!key) return;
57850         context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) {
57851           d3_event.stopImmediatePropagation();
57852           d3_event.preventDefault();
57853           info.toggle(k2);
57854         });
57855       });
57856     }
57857     return info;
57858   }
57859
57860   // modules/ui/toggle.js
57861   function uiToggle(show, callback) {
57862     return function(selection2) {
57863       selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() {
57864         select_default2(this).classed("hide", !show).style("opacity", null);
57865         if (callback) callback.apply(this);
57866       });
57867     };
57868   }
57869
57870   // modules/ui/curtain.js
57871   function uiCurtain(containerNode) {
57872     var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null);
57873     function curtain(selection2) {
57874       surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0);
57875       darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness");
57876       select_default2(window).on("resize.curtain", resize);
57877       tooltip = selection2.append("div").attr("class", "tooltip");
57878       tooltip.append("div").attr("class", "popover-arrow");
57879       tooltip.append("div").attr("class", "popover-inner");
57880       resize();
57881       function resize() {
57882         surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight);
57883         curtain.cut(darkness.datum());
57884       }
57885     }
57886     curtain.reveal = function(box, html3, options2) {
57887       options2 = options2 || {};
57888       if (typeof box === "string") {
57889         box = select_default2(box).node();
57890       }
57891       if (box && box.getBoundingClientRect) {
57892         box = copyBox(box.getBoundingClientRect());
57893       }
57894       if (box) {
57895         var containerRect = containerNode.getBoundingClientRect();
57896         box.top -= containerRect.top;
57897         box.left -= containerRect.left;
57898       }
57899       if (box && options2.padding) {
57900         box.top -= options2.padding;
57901         box.left -= options2.padding;
57902         box.bottom += options2.padding;
57903         box.right += options2.padding;
57904         box.height += options2.padding * 2;
57905         box.width += options2.padding * 2;
57906       }
57907       var tooltipBox;
57908       if (options2.tooltipBox) {
57909         tooltipBox = options2.tooltipBox;
57910         if (typeof tooltipBox === "string") {
57911           tooltipBox = select_default2(tooltipBox).node();
57912         }
57913         if (tooltipBox && tooltipBox.getBoundingClientRect) {
57914           tooltipBox = copyBox(tooltipBox.getBoundingClientRect());
57915         }
57916       } else {
57917         tooltipBox = box;
57918       }
57919       if (tooltipBox && html3) {
57920         if (html3.indexOf("**") !== -1) {
57921           if (html3.indexOf("<span") === 0) {
57922             html3 = html3.replace(/^(<span.*?>)(.+?)(\*\*)/, "$1<span>$2</span>$3");
57923           } else {
57924             html3 = html3.replace(/^(.+?)(\*\*)/, "<span>$1</span>$2");
57925           }
57926           html3 = html3.replace(/\*\*(.*?)\*\*/g, '<span class="instruction">$1</span>');
57927         }
57928         html3 = html3.replace(/\*(.*?)\*/g, "<em>$1</em>");
57929         html3 = html3.replace(/\{br\}/g, "<br/><br/>");
57930         if (options2.buttonText && options2.buttonCallback) {
57931           html3 += '<div class="button-section"><button href="#" class="button action">' + options2.buttonText + "</button></div>";
57932         }
57933         var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || "");
57934         tooltip.classed(classes, true).selectAll(".popover-inner").html(html3);
57935         if (options2.buttonText && options2.buttonCallback) {
57936           var button = tooltip.selectAll(".button-section .button.action");
57937           button.on("click", function(d3_event) {
57938             d3_event.preventDefault();
57939             options2.buttonCallback();
57940           });
57941         }
57942         var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos;
57943         if (options2.tooltipClass === "intro-mouse") {
57944           tip.height += 80;
57945         }
57946         if (tooltipBox.top + tooltipBox.height > h2) {
57947           tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2;
57948         }
57949         if (tooltipBox.left + tooltipBox.width > w2) {
57950           tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2;
57951         }
57952         const onLeftOrRightEdge = tooltipBox.left + tooltipBox.width / 2 > w2 - 100 || tooltipBox.left + tooltipBox.width / 2 < 100;
57953         if (tooltipBox.top + tooltipBox.height < 100 && !onLeftOrRightEdge) {
57954           side = "bottom";
57955           pos = [
57956             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
57957             tooltipBox.top + tooltipBox.height
57958           ];
57959         } else if (tooltipBox.top > h2 - 140 && !onLeftOrRightEdge) {
57960           side = "top";
57961           pos = [
57962             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
57963             tooltipBox.top - tip.height
57964           ];
57965         } else {
57966           var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2;
57967           if (_mainLocalizer.textDirection() === "rtl") {
57968             if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) {
57969               side = "right";
57970               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
57971             } else {
57972               side = "left";
57973               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
57974             }
57975           } else {
57976             if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) {
57977               side = "left";
57978               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
57979             } else {
57980               side = "right";
57981               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
57982             }
57983           }
57984         }
57985         if (options2.duration !== 0 || !tooltip.classed(side)) {
57986           tooltip.call(uiToggle(true));
57987         }
57988         tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side);
57989         var shiftY = 0;
57990         if (side === "left" || side === "right") {
57991           if (pos[1] < 60) {
57992             shiftY = 60 - pos[1];
57993           } else if (pos[1] + tip.height > h2 - 100) {
57994             shiftY = h2 - pos[1] - tip.height - 100;
57995           }
57996         }
57997         tooltip.selectAll(".popover-inner").style("top", shiftY + "px");
57998       } else {
57999         tooltip.classed("in", false).call(uiToggle(false));
58000       }
58001       curtain.cut(box, options2.duration);
58002       return tooltip;
58003     };
58004     curtain.cut = function(datum2, duration) {
58005       darkness.datum(datum2).interrupt();
58006       var selection2;
58007       if (duration === 0) {
58008         selection2 = darkness;
58009       } else {
58010         selection2 = darkness.transition().duration(duration || 600).ease(linear2);
58011       }
58012       selection2.attr("d", function(d2) {
58013         var containerWidth = containerNode.clientWidth;
58014         var containerHeight = containerNode.clientHeight;
58015         var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z";
58016         if (!d2) return string;
58017         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";
58018       });
58019     };
58020     curtain.remove = function() {
58021       surface.remove();
58022       tooltip.remove();
58023       select_default2(window).on("resize.curtain", null);
58024     };
58025     function copyBox(src) {
58026       return {
58027         top: src.top,
58028         right: src.right,
58029         bottom: src.bottom,
58030         left: src.left,
58031         width: src.width,
58032         height: src.height
58033       };
58034     }
58035     return curtain;
58036   }
58037
58038   // modules/ui/intro/welcome.js
58039   function uiIntroWelcome(context, reveal) {
58040     var dispatch14 = dispatch_default("done");
58041     var chapter = {
58042       title: "intro.welcome.title"
58043     };
58044     function welcome() {
58045       context.map().centerZoom([-85.63591, 41.94285], 19);
58046       reveal(
58047         ".intro-nav-wrap .chapter-welcome",
58048         helpHtml("intro.welcome.welcome"),
58049         { buttonText: _t.html("intro.ok"), buttonCallback: practice }
58050       );
58051     }
58052     function practice() {
58053       reveal(
58054         ".intro-nav-wrap .chapter-welcome",
58055         helpHtml("intro.welcome.practice"),
58056         { buttonText: _t.html("intro.ok"), buttonCallback: words }
58057       );
58058     }
58059     function words() {
58060       reveal(
58061         ".intro-nav-wrap .chapter-welcome",
58062         helpHtml("intro.welcome.words"),
58063         { buttonText: _t.html("intro.ok"), buttonCallback: chapters }
58064       );
58065     }
58066     function chapters() {
58067       dispatch14.call("done");
58068       reveal(
58069         ".intro-nav-wrap .chapter-navigation",
58070         helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") })
58071       );
58072     }
58073     chapter.enter = function() {
58074       welcome();
58075     };
58076     chapter.exit = function() {
58077       context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove();
58078     };
58079     chapter.restart = function() {
58080       chapter.exit();
58081       chapter.enter();
58082     };
58083     return utilRebind(chapter, dispatch14, "on");
58084   }
58085
58086   // modules/ui/intro/navigation.js
58087   function uiIntroNavigation(context, reveal) {
58088     var dispatch14 = dispatch_default("done");
58089     var timeouts = [];
58090     var hallId = "n2061";
58091     var townHall = [-85.63591, 41.94285];
58092     var springStreetId = "w397";
58093     var springStreetEndId = "n1834";
58094     var springStreet = [-85.63582, 41.94255];
58095     var onewayField = _mainPresetIndex.field("oneway");
58096     var maxspeedField = _mainPresetIndex.field("maxspeed");
58097     var chapter = {
58098       title: "intro.navigation.title"
58099     };
58100     function timeout2(f2, t2) {
58101       timeouts.push(window.setTimeout(f2, t2));
58102     }
58103     function eventCancel(d3_event) {
58104       d3_event.stopPropagation();
58105       d3_event.preventDefault();
58106     }
58107     function isTownHallSelected() {
58108       var ids = context.selectedIDs();
58109       return ids.length === 1 && ids[0] === hallId;
58110     }
58111     function dragMap() {
58112       context.enter(modeBrowse(context));
58113       context.history().reset("initial");
58114       var msec = transitionTime(townHall, context.map().center());
58115       if (msec) {
58116         reveal(null, null, { duration: 0 });
58117       }
58118       context.map().centerZoomEase(townHall, 19, msec);
58119       timeout2(function() {
58120         var centerStart = context.map().center();
58121         var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch";
58122         var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId);
58123         reveal(".main-map .surface", dragString);
58124         context.map().on("drawn.intro", function() {
58125           reveal(".main-map .surface", dragString, { duration: 0 });
58126         });
58127         context.map().on("move.intro", function() {
58128           var centerNow = context.map().center();
58129           if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) {
58130             context.map().on("move.intro", null);
58131             timeout2(function() {
58132               continueTo(zoomMap);
58133             }, 3e3);
58134           }
58135         });
58136       }, msec + 100);
58137       function continueTo(nextStep) {
58138         context.map().on("move.intro drawn.intro", null);
58139         nextStep();
58140       }
58141     }
58142     function zoomMap() {
58143       var zoomStart = context.map().zoom();
58144       var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch";
58145       var zoomString = helpHtml("intro.navigation." + textId);
58146       reveal(".main-map .surface", zoomString);
58147       context.map().on("drawn.intro", function() {
58148         reveal(".main-map .surface", zoomString, { duration: 0 });
58149       });
58150       context.map().on("move.intro", function() {
58151         if (context.map().zoom() !== zoomStart) {
58152           context.map().on("move.intro", null);
58153           timeout2(function() {
58154             continueTo(features);
58155           }, 3e3);
58156         }
58157       });
58158       function continueTo(nextStep) {
58159         context.map().on("move.intro drawn.intro", null);
58160         nextStep();
58161       }
58162     }
58163     function features() {
58164       var onClick = function() {
58165         continueTo(pointsLinesAreas);
58166       };
58167       reveal(
58168         ".main-map .surface",
58169         helpHtml("intro.navigation.features"),
58170         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58171       );
58172       context.map().on("drawn.intro", function() {
58173         reveal(
58174           ".main-map .surface",
58175           helpHtml("intro.navigation.features"),
58176           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58177         );
58178       });
58179       function continueTo(nextStep) {
58180         context.map().on("drawn.intro", null);
58181         nextStep();
58182       }
58183     }
58184     function pointsLinesAreas() {
58185       var onClick = function() {
58186         continueTo(nodesWays);
58187       };
58188       reveal(
58189         ".main-map .surface",
58190         helpHtml("intro.navigation.points_lines_areas"),
58191         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58192       );
58193       context.map().on("drawn.intro", function() {
58194         reveal(
58195           ".main-map .surface",
58196           helpHtml("intro.navigation.points_lines_areas"),
58197           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58198         );
58199       });
58200       function continueTo(nextStep) {
58201         context.map().on("drawn.intro", null);
58202         nextStep();
58203       }
58204     }
58205     function nodesWays() {
58206       var onClick = function() {
58207         continueTo(clickTownHall);
58208       };
58209       reveal(
58210         ".main-map .surface",
58211         helpHtml("intro.navigation.nodes_ways"),
58212         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58213       );
58214       context.map().on("drawn.intro", function() {
58215         reveal(
58216           ".main-map .surface",
58217           helpHtml("intro.navigation.nodes_ways"),
58218           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58219         );
58220       });
58221       function continueTo(nextStep) {
58222         context.map().on("drawn.intro", null);
58223         nextStep();
58224       }
58225     }
58226     function clickTownHall() {
58227       context.enter(modeBrowse(context));
58228       context.history().reset("initial");
58229       var entity = context.hasEntity(hallId);
58230       if (!entity) return;
58231       reveal(null, null, { duration: 0 });
58232       context.map().centerZoomEase(entity.loc, 19, 500);
58233       timeout2(function() {
58234         var entity2 = context.hasEntity(hallId);
58235         if (!entity2) return;
58236         var box = pointBox(entity2.loc, context);
58237         var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall";
58238         reveal(box, helpHtml("intro.navigation." + textId));
58239         context.map().on("move.intro drawn.intro", function() {
58240           var entity3 = context.hasEntity(hallId);
58241           if (!entity3) return;
58242           var box2 = pointBox(entity3.loc, context);
58243           reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 });
58244         });
58245         context.on("enter.intro", function() {
58246           if (isTownHallSelected()) continueTo(selectedTownHall);
58247         });
58248       }, 550);
58249       context.history().on("change.intro", function() {
58250         if (!context.hasEntity(hallId)) {
58251           continueTo(clickTownHall);
58252         }
58253       });
58254       function continueTo(nextStep) {
58255         context.on("enter.intro", null);
58256         context.map().on("move.intro drawn.intro", null);
58257         context.history().on("change.intro", null);
58258         nextStep();
58259       }
58260     }
58261     function selectedTownHall() {
58262       if (!isTownHallSelected()) return clickTownHall();
58263       var entity = context.hasEntity(hallId);
58264       if (!entity) return clickTownHall();
58265       var box = pointBox(entity.loc, context);
58266       var onClick = function() {
58267         continueTo(editorTownHall);
58268       };
58269       reveal(
58270         box,
58271         helpHtml("intro.navigation.selected_townhall"),
58272         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58273       );
58274       context.map().on("move.intro drawn.intro", function() {
58275         var entity2 = context.hasEntity(hallId);
58276         if (!entity2) return;
58277         var box2 = pointBox(entity2.loc, context);
58278         reveal(
58279           box2,
58280           helpHtml("intro.navigation.selected_townhall"),
58281           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58282         );
58283       });
58284       context.history().on("change.intro", function() {
58285         if (!context.hasEntity(hallId)) {
58286           continueTo(clickTownHall);
58287         }
58288       });
58289       function continueTo(nextStep) {
58290         context.map().on("move.intro drawn.intro", null);
58291         context.history().on("change.intro", null);
58292         nextStep();
58293       }
58294     }
58295     function editorTownHall() {
58296       if (!isTownHallSelected()) return clickTownHall();
58297       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58298       var onClick = function() {
58299         continueTo(presetTownHall);
58300       };
58301       reveal(
58302         ".entity-editor-pane",
58303         helpHtml("intro.navigation.editor_townhall"),
58304         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58305       );
58306       context.on("exit.intro", function() {
58307         continueTo(clickTownHall);
58308       });
58309       context.history().on("change.intro", function() {
58310         if (!context.hasEntity(hallId)) {
58311           continueTo(clickTownHall);
58312         }
58313       });
58314       function continueTo(nextStep) {
58315         context.on("exit.intro", null);
58316         context.history().on("change.intro", null);
58317         context.container().select(".inspector-wrap").on("wheel.intro", null);
58318         nextStep();
58319       }
58320     }
58321     function presetTownHall() {
58322       if (!isTownHallSelected()) return clickTownHall();
58323       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58324       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58325       var entity = context.entity(context.selectedIDs()[0]);
58326       var preset = _mainPresetIndex.match(entity, context.graph());
58327       var onClick = function() {
58328         continueTo(fieldsTownHall);
58329       };
58330       reveal(
58331         ".entity-editor-pane .section-feature-type",
58332         helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }),
58333         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58334       );
58335       context.on("exit.intro", function() {
58336         continueTo(clickTownHall);
58337       });
58338       context.history().on("change.intro", function() {
58339         if (!context.hasEntity(hallId)) {
58340           continueTo(clickTownHall);
58341         }
58342       });
58343       function continueTo(nextStep) {
58344         context.on("exit.intro", null);
58345         context.history().on("change.intro", null);
58346         context.container().select(".inspector-wrap").on("wheel.intro", null);
58347         nextStep();
58348       }
58349     }
58350     function fieldsTownHall() {
58351       if (!isTownHallSelected()) return clickTownHall();
58352       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58353       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58354       var onClick = function() {
58355         continueTo(closeTownHall);
58356       };
58357       reveal(
58358         ".entity-editor-pane .section-preset-fields",
58359         helpHtml("intro.navigation.fields_townhall"),
58360         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58361       );
58362       context.on("exit.intro", function() {
58363         continueTo(clickTownHall);
58364       });
58365       context.history().on("change.intro", function() {
58366         if (!context.hasEntity(hallId)) {
58367           continueTo(clickTownHall);
58368         }
58369       });
58370       function continueTo(nextStep) {
58371         context.on("exit.intro", null);
58372         context.history().on("change.intro", null);
58373         context.container().select(".inspector-wrap").on("wheel.intro", null);
58374         nextStep();
58375       }
58376     }
58377     function closeTownHall() {
58378       if (!isTownHallSelected()) return clickTownHall();
58379       var selector = ".entity-editor-pane button.close svg use";
58380       var href = select_default2(selector).attr("href") || "#iD-icon-close";
58381       reveal(
58382         ".entity-editor-pane",
58383         helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } })
58384       );
58385       context.on("exit.intro", function() {
58386         continueTo(searchStreet);
58387       });
58388       context.history().on("change.intro", function() {
58389         var selector2 = ".entity-editor-pane button.close svg use";
58390         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
58391         reveal(
58392           ".entity-editor-pane",
58393           helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }),
58394           { duration: 0 }
58395         );
58396       });
58397       function continueTo(nextStep) {
58398         context.on("exit.intro", null);
58399         context.history().on("change.intro", null);
58400         nextStep();
58401       }
58402     }
58403     function searchStreet() {
58404       context.enter(modeBrowse(context));
58405       context.history().reset("initial");
58406       var msec = transitionTime(springStreet, context.map().center());
58407       if (msec) {
58408         reveal(null, null, { duration: 0 });
58409       }
58410       context.map().centerZoomEase(springStreet, 19, msec);
58411       timeout2(function() {
58412         reveal(
58413           ".search-header input",
58414           helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") })
58415         );
58416         context.container().select(".search-header input").on("keyup.intro", checkSearchResult);
58417       }, msec + 100);
58418     }
58419     function checkSearchResult() {
58420       var first = context.container().select(".feature-list-item:nth-child(0n+2)");
58421       var firstName = first.select(".entity-name");
58422       var name = _t("intro.graph.name.spring-street");
58423       if (!firstName.empty() && firstName.html() === name) {
58424         reveal(
58425           first.node(),
58426           helpHtml("intro.navigation.choose_street", { name }),
58427           { duration: 300 }
58428         );
58429         context.on("exit.intro", function() {
58430           continueTo(selectedStreet);
58431         });
58432         context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
58433       }
58434       function continueTo(nextStep) {
58435         context.on("exit.intro", null);
58436         context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null);
58437         nextStep();
58438       }
58439     }
58440     function selectedStreet() {
58441       if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
58442         return searchStreet();
58443       }
58444       var onClick = function() {
58445         continueTo(editorStreet);
58446       };
58447       var entity = context.entity(springStreetEndId);
58448       var box = pointBox(entity.loc, context);
58449       box.height = 500;
58450       reveal(
58451         box,
58452         helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
58453         { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58454       );
58455       timeout2(function() {
58456         context.map().on("move.intro drawn.intro", function() {
58457           var entity2 = context.hasEntity(springStreetEndId);
58458           if (!entity2) return;
58459           var box2 = pointBox(entity2.loc, context);
58460           box2.height = 500;
58461           reveal(
58462             box2,
58463             helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
58464             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
58465           );
58466         });
58467       }, 600);
58468       context.on("enter.intro", function(mode) {
58469         if (!context.hasEntity(springStreetId)) {
58470           return continueTo(searchStreet);
58471         }
58472         var ids = context.selectedIDs();
58473         if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) {
58474           context.enter(modeSelect(context, [springStreetId]));
58475         }
58476       });
58477       context.history().on("change.intro", function() {
58478         if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
58479           timeout2(function() {
58480             continueTo(searchStreet);
58481           }, 300);
58482         }
58483       });
58484       function continueTo(nextStep) {
58485         context.map().on("move.intro drawn.intro", null);
58486         context.on("enter.intro", null);
58487         context.history().on("change.intro", null);
58488         nextStep();
58489       }
58490     }
58491     function editorStreet() {
58492       var selector = ".entity-editor-pane button.close svg use";
58493       var href = select_default2(selector).attr("href") || "#iD-icon-close";
58494       reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
58495         button: { html: icon(href, "inline") },
58496         field1: onewayField.title(),
58497         field2: maxspeedField.title()
58498       }));
58499       context.on("exit.intro", function() {
58500         continueTo(play);
58501       });
58502       context.history().on("change.intro", function() {
58503         var selector2 = ".entity-editor-pane button.close svg use";
58504         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
58505         reveal(
58506           ".entity-editor-pane",
58507           helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
58508             button: { html: icon(href2, "inline") },
58509             field1: onewayField.title(),
58510             field2: maxspeedField.title()
58511           }),
58512           { duration: 0 }
58513         );
58514       });
58515       function continueTo(nextStep) {
58516         context.on("exit.intro", null);
58517         context.history().on("change.intro", null);
58518         nextStep();
58519       }
58520     }
58521     function play() {
58522       dispatch14.call("done");
58523       reveal(
58524         ".ideditor",
58525         helpHtml("intro.navigation.play", { next: _t("intro.points.title") }),
58526         {
58527           tooltipBox: ".intro-nav-wrap .chapter-point",
58528           buttonText: _t.html("intro.ok"),
58529           buttonCallback: function() {
58530             reveal(".ideditor");
58531           }
58532         }
58533       );
58534     }
58535     chapter.enter = function() {
58536       dragMap();
58537     };
58538     chapter.exit = function() {
58539       timeouts.forEach(window.clearTimeout);
58540       context.on("enter.intro exit.intro", null);
58541       context.map().on("move.intro drawn.intro", null);
58542       context.history().on("change.intro", null);
58543       context.container().select(".inspector-wrap").on("wheel.intro", null);
58544       context.container().select(".search-header input").on("keydown.intro keyup.intro", null);
58545     };
58546     chapter.restart = function() {
58547       chapter.exit();
58548       chapter.enter();
58549     };
58550     return utilRebind(chapter, dispatch14, "on");
58551   }
58552
58553   // modules/ui/intro/point.js
58554   function uiIntroPoint(context, reveal) {
58555     var dispatch14 = dispatch_default("done");
58556     var timeouts = [];
58557     var intersection2 = [-85.63279, 41.94394];
58558     var building = [-85.632422, 41.944045];
58559     var cafePreset = _mainPresetIndex.item("amenity/cafe");
58560     var _pointID = null;
58561     var chapter = {
58562       title: "intro.points.title"
58563     };
58564     function timeout2(f2, t2) {
58565       timeouts.push(window.setTimeout(f2, t2));
58566     }
58567     function eventCancel(d3_event) {
58568       d3_event.stopPropagation();
58569       d3_event.preventDefault();
58570     }
58571     function addPoint() {
58572       context.enter(modeBrowse(context));
58573       context.history().reset("initial");
58574       var msec = transitionTime(intersection2, context.map().center());
58575       if (msec) {
58576         reveal(null, null, { duration: 0 });
58577       }
58578       context.map().centerZoomEase(intersection2, 19, msec);
58579       timeout2(function() {
58580         var tooltip = reveal(
58581           "button.add-point",
58582           helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point")
58583         );
58584         _pointID = null;
58585         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points");
58586         context.on("enter.intro", function(mode) {
58587           if (mode.id !== "add-point") return;
58588           continueTo(placePoint);
58589         });
58590       }, msec + 100);
58591       function continueTo(nextStep) {
58592         context.on("enter.intro", null);
58593         nextStep();
58594       }
58595     }
58596     function placePoint() {
58597       if (context.mode().id !== "add-point") {
58598         return chapter.restart();
58599       }
58600       var pointBox2 = pad(building, 150, context);
58601       var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch";
58602       reveal(pointBox2, helpHtml("intro.points." + textId));
58603       context.map().on("move.intro drawn.intro", function() {
58604         pointBox2 = pad(building, 150, context);
58605         reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 });
58606       });
58607       context.on("enter.intro", function(mode) {
58608         if (mode.id !== "select") return chapter.restart();
58609         _pointID = context.mode().selectedIDs()[0];
58610         if (context.graph().geometry(_pointID) === "vertex") {
58611           context.map().on("move.intro drawn.intro", null);
58612           context.on("enter.intro", null);
58613           reveal(pointBox2, helpHtml("intro.points.place_point_error"), {
58614             buttonText: _t.html("intro.ok"),
58615             buttonCallback: function() {
58616               return chapter.restart();
58617             }
58618           });
58619         } else {
58620           continueTo(searchPreset);
58621         }
58622       });
58623       function continueTo(nextStep) {
58624         context.map().on("move.intro drawn.intro", null);
58625         context.on("enter.intro", null);
58626         nextStep();
58627       }
58628     }
58629     function searchPreset() {
58630       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58631         return addPoint();
58632       }
58633       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58634       context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
58635       reveal(
58636         ".preset-search-input",
58637         helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
58638       );
58639       context.on("enter.intro", function(mode) {
58640         if (!_pointID || !context.hasEntity(_pointID)) {
58641           return continueTo(addPoint);
58642         }
58643         var ids = context.selectedIDs();
58644         if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) {
58645           context.enter(modeSelect(context, [_pointID]));
58646           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58647           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
58648           reveal(
58649             ".preset-search-input",
58650             helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
58651           );
58652           context.history().on("change.intro", null);
58653         }
58654       });
58655       function checkPresetSearch() {
58656         var first = context.container().select(".preset-list-item:first-child");
58657         if (first.classed("preset-amenity-cafe")) {
58658           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
58659           reveal(
58660             first.select(".preset-list-button").node(),
58661             helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }),
58662             { duration: 300 }
58663           );
58664           context.history().on("change.intro", function() {
58665             continueTo(aboutFeatureEditor);
58666           });
58667         }
58668       }
58669       function continueTo(nextStep) {
58670         context.on("enter.intro", null);
58671         context.history().on("change.intro", null);
58672         context.container().select(".inspector-wrap").on("wheel.intro", null);
58673         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
58674         nextStep();
58675       }
58676     }
58677     function aboutFeatureEditor() {
58678       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58679         return addPoint();
58680       }
58681       timeout2(function() {
58682         reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), {
58683           tooltipClass: "intro-points-describe",
58684           buttonText: _t.html("intro.ok"),
58685           buttonCallback: function() {
58686             continueTo(addName);
58687           }
58688         });
58689       }, 400);
58690       context.on("exit.intro", function() {
58691         continueTo(reselectPoint);
58692       });
58693       function continueTo(nextStep) {
58694         context.on("exit.intro", null);
58695         nextStep();
58696       }
58697     }
58698     function addName() {
58699       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58700         return addPoint();
58701       }
58702       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58703       var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name") + "{br}" + helpHtml("intro.points.add_reminder");
58704       timeout2(function() {
58705         var entity = context.entity(_pointID);
58706         if (entity.tags.name) {
58707           var tooltip = reveal(".entity-editor-pane", addNameString, {
58708             tooltipClass: "intro-points-describe",
58709             buttonText: _t.html("intro.ok"),
58710             buttonCallback: function() {
58711               continueTo(addCloseEditor);
58712             }
58713           });
58714           tooltip.select(".instruction").style("display", "none");
58715         } else {
58716           reveal(
58717             ".entity-editor-pane",
58718             addNameString,
58719             { tooltipClass: "intro-points-describe" }
58720           );
58721         }
58722       }, 400);
58723       context.history().on("change.intro", function() {
58724         continueTo(addCloseEditor);
58725       });
58726       context.on("exit.intro", function() {
58727         continueTo(reselectPoint);
58728       });
58729       function continueTo(nextStep) {
58730         context.on("exit.intro", null);
58731         context.history().on("change.intro", null);
58732         nextStep();
58733       }
58734     }
58735     function addCloseEditor() {
58736       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58737       var selector = ".entity-editor-pane button.close svg use";
58738       var href = select_default2(selector).attr("href") || "#iD-icon-close";
58739       context.on("exit.intro", function() {
58740         continueTo(reselectPoint);
58741       });
58742       reveal(
58743         ".entity-editor-pane",
58744         helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } })
58745       );
58746       function continueTo(nextStep) {
58747         context.on("exit.intro", null);
58748         nextStep();
58749       }
58750     }
58751     function reselectPoint() {
58752       if (!_pointID) return chapter.restart();
58753       var entity = context.hasEntity(_pointID);
58754       if (!entity) return chapter.restart();
58755       var oldPreset = _mainPresetIndex.match(entity, context.graph());
58756       context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
58757       context.enter(modeBrowse(context));
58758       var msec = transitionTime(entity.loc, context.map().center());
58759       if (msec) {
58760         reveal(null, null, { duration: 0 });
58761       }
58762       context.map().centerEase(entity.loc, msec);
58763       timeout2(function() {
58764         var box = pointBox(entity.loc, context);
58765         reveal(box, helpHtml("intro.points.reselect"), { duration: 600 });
58766         timeout2(function() {
58767           context.map().on("move.intro drawn.intro", function() {
58768             var entity2 = context.hasEntity(_pointID);
58769             if (!entity2) return chapter.restart();
58770             var box2 = pointBox(entity2.loc, context);
58771             reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 });
58772           });
58773         }, 600);
58774         context.on("enter.intro", function(mode) {
58775           if (mode.id !== "select") return;
58776           continueTo(updatePoint);
58777         });
58778       }, msec + 100);
58779       function continueTo(nextStep) {
58780         context.map().on("move.intro drawn.intro", null);
58781         context.on("enter.intro", null);
58782         nextStep();
58783       }
58784     }
58785     function updatePoint() {
58786       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58787         return continueTo(reselectPoint);
58788       }
58789       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58790       context.on("exit.intro", function() {
58791         continueTo(reselectPoint);
58792       });
58793       context.history().on("change.intro", function() {
58794         continueTo(updateCloseEditor);
58795       });
58796       timeout2(function() {
58797         reveal(
58798           ".entity-editor-pane",
58799           helpHtml("intro.points.update"),
58800           { tooltipClass: "intro-points-describe" }
58801         );
58802       }, 400);
58803       function continueTo(nextStep) {
58804         context.on("exit.intro", null);
58805         context.history().on("change.intro", null);
58806         nextStep();
58807       }
58808     }
58809     function updateCloseEditor() {
58810       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58811         return continueTo(reselectPoint);
58812       }
58813       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58814       context.on("exit.intro", function() {
58815         continueTo(rightClickPoint);
58816       });
58817       timeout2(function() {
58818         reveal(
58819           ".entity-editor-pane",
58820           helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } })
58821         );
58822       }, 500);
58823       function continueTo(nextStep) {
58824         context.on("exit.intro", null);
58825         nextStep();
58826       }
58827     }
58828     function rightClickPoint() {
58829       if (!_pointID) return chapter.restart();
58830       var entity = context.hasEntity(_pointID);
58831       if (!entity) return chapter.restart();
58832       context.enter(modeBrowse(context));
58833       var box = pointBox(entity.loc, context);
58834       var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch";
58835       reveal(box, helpHtml("intro.points." + textId), { duration: 600 });
58836       timeout2(function() {
58837         context.map().on("move.intro", function() {
58838           var entity2 = context.hasEntity(_pointID);
58839           if (!entity2) return chapter.restart();
58840           var box2 = pointBox(entity2.loc, context);
58841           reveal(box2, helpHtml("intro.points." + textId), { duration: 0 });
58842         });
58843       }, 600);
58844       context.on("enter.intro", function(mode) {
58845         if (mode.id !== "select") return;
58846         var ids = context.selectedIDs();
58847         if (ids.length !== 1 || ids[0] !== _pointID) return;
58848         timeout2(function() {
58849           var node = selectMenuItem(context, "delete").node();
58850           if (!node) return;
58851           continueTo(enterDelete);
58852         }, 50);
58853       });
58854       function continueTo(nextStep) {
58855         context.on("enter.intro", null);
58856         context.map().on("move.intro", null);
58857         nextStep();
58858       }
58859     }
58860     function enterDelete() {
58861       if (!_pointID) return chapter.restart();
58862       var entity = context.hasEntity(_pointID);
58863       if (!entity) return chapter.restart();
58864       var node = selectMenuItem(context, "delete").node();
58865       if (!node) {
58866         return continueTo(rightClickPoint);
58867       }
58868       reveal(
58869         ".edit-menu",
58870         helpHtml("intro.points.delete"),
58871         { padding: 50 }
58872       );
58873       timeout2(function() {
58874         context.map().on("move.intro", function() {
58875           if (selectMenuItem(context, "delete").empty()) {
58876             return continueTo(rightClickPoint);
58877           }
58878           reveal(
58879             ".edit-menu",
58880             helpHtml("intro.points.delete"),
58881             { duration: 0, padding: 50 }
58882           );
58883         });
58884       }, 300);
58885       context.on("exit.intro", function() {
58886         if (!_pointID) return chapter.restart();
58887         var entity2 = context.hasEntity(_pointID);
58888         if (entity2) return continueTo(rightClickPoint);
58889       });
58890       context.history().on("change.intro", function(changed) {
58891         if (changed.deleted().length) {
58892           continueTo(undo);
58893         }
58894       });
58895       function continueTo(nextStep) {
58896         context.map().on("move.intro", null);
58897         context.history().on("change.intro", null);
58898         context.on("exit.intro", null);
58899         nextStep();
58900       }
58901     }
58902     function undo() {
58903       context.history().on("change.intro", function() {
58904         continueTo(play);
58905       });
58906       reveal(
58907         ".top-toolbar button.undo-button",
58908         helpHtml("intro.points.undo")
58909       );
58910       function continueTo(nextStep) {
58911         context.history().on("change.intro", null);
58912         nextStep();
58913       }
58914     }
58915     function play() {
58916       dispatch14.call("done");
58917       reveal(
58918         ".ideditor",
58919         helpHtml("intro.points.play", { next: _t("intro.areas.title") }),
58920         {
58921           tooltipBox: ".intro-nav-wrap .chapter-area",
58922           buttonText: _t.html("intro.ok"),
58923           buttonCallback: function() {
58924             reveal(".ideditor");
58925           }
58926         }
58927       );
58928     }
58929     chapter.enter = function() {
58930       addPoint();
58931     };
58932     chapter.exit = function() {
58933       timeouts.forEach(window.clearTimeout);
58934       context.on("enter.intro exit.intro", null);
58935       context.map().on("move.intro drawn.intro", null);
58936       context.history().on("change.intro", null);
58937       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58938       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
58939     };
58940     chapter.restart = function() {
58941       chapter.exit();
58942       chapter.enter();
58943     };
58944     return utilRebind(chapter, dispatch14, "on");
58945   }
58946
58947   // modules/ui/intro/area.js
58948   function uiIntroArea(context, reveal) {
58949     var dispatch14 = dispatch_default("done");
58950     var playground = [-85.63552, 41.94159];
58951     var playgroundPreset = _mainPresetIndex.item("leisure/playground");
58952     var nameField = _mainPresetIndex.field("name");
58953     var descriptionField = _mainPresetIndex.field("description");
58954     var timeouts = [];
58955     var _areaID;
58956     var chapter = {
58957       title: "intro.areas.title"
58958     };
58959     function timeout2(f2, t2) {
58960       timeouts.push(window.setTimeout(f2, t2));
58961     }
58962     function eventCancel(d3_event) {
58963       d3_event.stopPropagation();
58964       d3_event.preventDefault();
58965     }
58966     function revealPlayground(center, text, options2) {
58967       var padding = 180 * Math.pow(2, context.map().zoom() - 19.5);
58968       var box = pad(center, padding, context);
58969       reveal(box, text, options2);
58970     }
58971     function addArea() {
58972       context.enter(modeBrowse(context));
58973       context.history().reset("initial");
58974       _areaID = null;
58975       var msec = transitionTime(playground, context.map().center());
58976       if (msec) {
58977         reveal(null, null, { duration: 0 });
58978       }
58979       context.map().centerZoomEase(playground, 19, msec);
58980       timeout2(function() {
58981         var tooltip = reveal(
58982           "button.add-area",
58983           helpHtml("intro.areas.add_playground")
58984         );
58985         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas");
58986         context.on("enter.intro", function(mode) {
58987           if (mode.id !== "add-area") return;
58988           continueTo(startPlayground);
58989         });
58990       }, msec + 100);
58991       function continueTo(nextStep) {
58992         context.on("enter.intro", null);
58993         nextStep();
58994       }
58995     }
58996     function startPlayground() {
58997       if (context.mode().id !== "add-area") {
58998         return chapter.restart();
58999       }
59000       _areaID = null;
59001       context.map().zoomEase(19.5, 500);
59002       timeout2(function() {
59003         var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap";
59004         var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId);
59005         revealPlayground(
59006           playground,
59007           startDrawString,
59008           { duration: 250 }
59009         );
59010         timeout2(function() {
59011           context.map().on("move.intro drawn.intro", function() {
59012             revealPlayground(
59013               playground,
59014               startDrawString,
59015               { duration: 0 }
59016             );
59017           });
59018           context.on("enter.intro", function(mode) {
59019             if (mode.id !== "draw-area") return chapter.restart();
59020             continueTo(continuePlayground);
59021           });
59022         }, 250);
59023       }, 550);
59024       function continueTo(nextStep) {
59025         context.map().on("move.intro drawn.intro", null);
59026         context.on("enter.intro", null);
59027         nextStep();
59028       }
59029     }
59030     function continuePlayground() {
59031       if (context.mode().id !== "draw-area") {
59032         return chapter.restart();
59033       }
59034       _areaID = null;
59035       revealPlayground(
59036         playground,
59037         helpHtml("intro.areas.continue_playground"),
59038         { duration: 250 }
59039       );
59040       timeout2(function() {
59041         context.map().on("move.intro drawn.intro", function() {
59042           revealPlayground(
59043             playground,
59044             helpHtml("intro.areas.continue_playground"),
59045             { duration: 0 }
59046           );
59047         });
59048       }, 250);
59049       context.on("enter.intro", function(mode) {
59050         if (mode.id === "draw-area") {
59051           var entity = context.hasEntity(context.selectedIDs()[0]);
59052           if (entity && entity.nodes.length >= 6) {
59053             return continueTo(finishPlayground);
59054           } else {
59055             return;
59056           }
59057         } else if (mode.id === "select") {
59058           _areaID = context.selectedIDs()[0];
59059           return continueTo(searchPresets);
59060         } else {
59061           return chapter.restart();
59062         }
59063       });
59064       function continueTo(nextStep) {
59065         context.map().on("move.intro drawn.intro", null);
59066         context.on("enter.intro", null);
59067         nextStep();
59068       }
59069     }
59070     function finishPlayground() {
59071       if (context.mode().id !== "draw-area") {
59072         return chapter.restart();
59073       }
59074       _areaID = null;
59075       var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground");
59076       revealPlayground(
59077         playground,
59078         finishString,
59079         { duration: 250 }
59080       );
59081       timeout2(function() {
59082         context.map().on("move.intro drawn.intro", function() {
59083           revealPlayground(
59084             playground,
59085             finishString,
59086             { duration: 0 }
59087           );
59088         });
59089       }, 250);
59090       context.on("enter.intro", function(mode) {
59091         if (mode.id === "draw-area") {
59092           return;
59093         } else if (mode.id === "select") {
59094           _areaID = context.selectedIDs()[0];
59095           return continueTo(searchPresets);
59096         } else {
59097           return chapter.restart();
59098         }
59099       });
59100       function continueTo(nextStep) {
59101         context.map().on("move.intro drawn.intro", null);
59102         context.on("enter.intro", null);
59103         nextStep();
59104       }
59105     }
59106     function searchPresets() {
59107       if (!_areaID || !context.hasEntity(_areaID)) {
59108         return addArea();
59109       }
59110       var ids = context.selectedIDs();
59111       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
59112         context.enter(modeSelect(context, [_areaID]));
59113       }
59114       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59115       timeout2(function() {
59116         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59117         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
59118         reveal(
59119           ".preset-search-input",
59120           helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
59121         );
59122       }, 400);
59123       context.on("enter.intro", function(mode) {
59124         if (!_areaID || !context.hasEntity(_areaID)) {
59125           return continueTo(addArea);
59126         }
59127         var ids2 = context.selectedIDs();
59128         if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) {
59129           context.enter(modeSelect(context, [_areaID]));
59130           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59131           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59132           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
59133           reveal(
59134             ".preset-search-input",
59135             helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
59136           );
59137           context.history().on("change.intro", null);
59138         }
59139       });
59140       function checkPresetSearch() {
59141         var first = context.container().select(".preset-list-item:first-child");
59142         if (first.classed("preset-leisure-playground")) {
59143           reveal(
59144             first.select(".preset-list-button").node(),
59145             helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }),
59146             { duration: 300 }
59147           );
59148           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
59149           context.history().on("change.intro", function() {
59150             continueTo(clickAddField);
59151           });
59152         }
59153       }
59154       function continueTo(nextStep) {
59155         context.container().select(".inspector-wrap").on("wheel.intro", null);
59156         context.on("enter.intro", null);
59157         context.history().on("change.intro", null);
59158         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
59159         nextStep();
59160       }
59161     }
59162     function clickAddField() {
59163       if (!_areaID || !context.hasEntity(_areaID)) {
59164         return addArea();
59165       }
59166       var ids = context.selectedIDs();
59167       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
59168         return searchPresets();
59169       }
59170       if (!context.container().select(".form-field-description").empty()) {
59171         return continueTo(describePlayground);
59172       }
59173       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59174       timeout2(function() {
59175         context.container().select(".inspector-wrap .panewrap").style("right", "0%");
59176         var entity = context.entity(_areaID);
59177         if (entity.tags.description) {
59178           return continueTo(play);
59179         }
59180         var box = context.container().select(".more-fields").node().getBoundingClientRect();
59181         if (box.top > 300) {
59182           var pane = context.container().select(".entity-editor-pane .inspector-body");
59183           var start2 = pane.node().scrollTop;
59184           var end = start2 + (box.top - 300);
59185           pane.transition().duration(250).tween("scroll.inspector", function() {
59186             var node = this;
59187             var i3 = number_default(start2, end);
59188             return function(t2) {
59189               node.scrollTop = i3(t2);
59190             };
59191           });
59192         }
59193         timeout2(function() {
59194           reveal(
59195             ".more-fields .combobox-input",
59196             helpHtml("intro.areas.add_field", {
59197               name: nameField.title(),
59198               description: descriptionField.title()
59199             }),
59200             { duration: 300 }
59201           );
59202           context.container().select(".more-fields .combobox-input").on("click.intro", function() {
59203             var watcher;
59204             watcher = window.setInterval(function() {
59205               if (!context.container().select("div.combobox").empty()) {
59206                 window.clearInterval(watcher);
59207                 continueTo(chooseDescriptionField);
59208               }
59209             }, 300);
59210           });
59211         }, 300);
59212       }, 400);
59213       context.on("exit.intro", function() {
59214         return continueTo(searchPresets);
59215       });
59216       function continueTo(nextStep) {
59217         context.container().select(".inspector-wrap").on("wheel.intro", null);
59218         context.container().select(".more-fields .combobox-input").on("click.intro", null);
59219         context.on("exit.intro", null);
59220         nextStep();
59221       }
59222     }
59223     function chooseDescriptionField() {
59224       if (!_areaID || !context.hasEntity(_areaID)) {
59225         return addArea();
59226       }
59227       var ids = context.selectedIDs();
59228       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
59229         return searchPresets();
59230       }
59231       if (!context.container().select(".form-field-description").empty()) {
59232         return continueTo(describePlayground);
59233       }
59234       if (context.container().select("div.combobox").empty()) {
59235         return continueTo(clickAddField);
59236       }
59237       var watcher;
59238       watcher = window.setInterval(function() {
59239         if (context.container().select("div.combobox").empty()) {
59240           window.clearInterval(watcher);
59241           timeout2(function() {
59242             if (context.container().select(".form-field-description").empty()) {
59243               continueTo(retryChooseDescription);
59244             } else {
59245               continueTo(describePlayground);
59246             }
59247           }, 300);
59248         }
59249       }, 300);
59250       reveal(
59251         "div.combobox",
59252         helpHtml("intro.areas.choose_field", { field: descriptionField.title() }),
59253         { duration: 300 }
59254       );
59255       context.on("exit.intro", function() {
59256         return continueTo(searchPresets);
59257       });
59258       function continueTo(nextStep) {
59259         if (watcher) window.clearInterval(watcher);
59260         context.on("exit.intro", null);
59261         nextStep();
59262       }
59263     }
59264     function describePlayground() {
59265       if (!_areaID || !context.hasEntity(_areaID)) {
59266         return addArea();
59267       }
59268       var ids = context.selectedIDs();
59269       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
59270         return searchPresets();
59271       }
59272       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
59273       if (context.container().select(".form-field-description").empty()) {
59274         return continueTo(retryChooseDescription);
59275       }
59276       context.on("exit.intro", function() {
59277         continueTo(play);
59278       });
59279       reveal(
59280         ".entity-editor-pane",
59281         helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }),
59282         { duration: 300 }
59283       );
59284       function continueTo(nextStep) {
59285         context.on("exit.intro", null);
59286         nextStep();
59287       }
59288     }
59289     function retryChooseDescription() {
59290       if (!_areaID || !context.hasEntity(_areaID)) {
59291         return addArea();
59292       }
59293       var ids = context.selectedIDs();
59294       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
59295         return searchPresets();
59296       }
59297       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
59298       reveal(
59299         ".entity-editor-pane",
59300         helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }),
59301         {
59302           buttonText: _t.html("intro.ok"),
59303           buttonCallback: function() {
59304             continueTo(clickAddField);
59305           }
59306         }
59307       );
59308       context.on("exit.intro", function() {
59309         return continueTo(searchPresets);
59310       });
59311       function continueTo(nextStep) {
59312         context.on("exit.intro", null);
59313         nextStep();
59314       }
59315     }
59316     function play() {
59317       dispatch14.call("done");
59318       reveal(
59319         ".ideditor",
59320         helpHtml("intro.areas.play", { next: _t("intro.lines.title") }),
59321         {
59322           tooltipBox: ".intro-nav-wrap .chapter-line",
59323           buttonText: _t.html("intro.ok"),
59324           buttonCallback: function() {
59325             reveal(".ideditor");
59326           }
59327         }
59328       );
59329     }
59330     chapter.enter = function() {
59331       addArea();
59332     };
59333     chapter.exit = function() {
59334       timeouts.forEach(window.clearTimeout);
59335       context.on("enter.intro exit.intro", null);
59336       context.map().on("move.intro drawn.intro", null);
59337       context.history().on("change.intro", null);
59338       context.container().select(".inspector-wrap").on("wheel.intro", null);
59339       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
59340       context.container().select(".more-fields .combobox-input").on("click.intro", null);
59341     };
59342     chapter.restart = function() {
59343       chapter.exit();
59344       chapter.enter();
59345     };
59346     return utilRebind(chapter, dispatch14, "on");
59347   }
59348
59349   // modules/ui/intro/line.js
59350   function uiIntroLine(context, reveal) {
59351     var dispatch14 = dispatch_default("done");
59352     var timeouts = [];
59353     var _tulipRoadID = null;
59354     var flowerRoadID = "w646";
59355     var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
59356     var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
59357     var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
59358     var roadCategory = _mainPresetIndex.item("category-road_minor");
59359     var residentialPreset = _mainPresetIndex.item("highway/residential");
59360     var woodRoadID = "w525";
59361     var woodRoadEndID = "n2862";
59362     var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
59363     var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
59364     var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
59365     var washingtonStreetID = "w522";
59366     var twelfthAvenueID = "w1";
59367     var eleventhAvenueEndID = "n3550";
59368     var twelfthAvenueEndID = "n5";
59369     var _washingtonSegmentID = null;
59370     var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
59371     var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
59372     var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
59373     var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
59374     var chapter = {
59375       title: "intro.lines.title"
59376     };
59377     function timeout2(f2, t2) {
59378       timeouts.push(window.setTimeout(f2, t2));
59379     }
59380     function eventCancel(d3_event) {
59381       d3_event.stopPropagation();
59382       d3_event.preventDefault();
59383     }
59384     function addLine() {
59385       context.enter(modeBrowse(context));
59386       context.history().reset("initial");
59387       var msec = transitionTime(tulipRoadStart, context.map().center());
59388       if (msec) {
59389         reveal(null, null, { duration: 0 });
59390       }
59391       context.map().centerZoomEase(tulipRoadStart, 18.5, msec);
59392       timeout2(function() {
59393         var tooltip = reveal(
59394           "button.add-line",
59395           helpHtml("intro.lines.add_line")
59396         );
59397         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines");
59398         context.on("enter.intro", function(mode) {
59399           if (mode.id !== "add-line") return;
59400           continueTo(startLine);
59401         });
59402       }, msec + 100);
59403       function continueTo(nextStep) {
59404         context.on("enter.intro", null);
59405         nextStep();
59406       }
59407     }
59408     function startLine() {
59409       if (context.mode().id !== "add-line") return chapter.restart();
59410       _tulipRoadID = null;
59411       var padding = 70 * Math.pow(2, context.map().zoom() - 18);
59412       var box = pad(tulipRoadStart, padding, context);
59413       box.height = box.height + 100;
59414       var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap";
59415       var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId);
59416       reveal(box, startLineString);
59417       context.map().on("move.intro drawn.intro", function() {
59418         padding = 70 * Math.pow(2, context.map().zoom() - 18);
59419         box = pad(tulipRoadStart, padding, context);
59420         box.height = box.height + 100;
59421         reveal(box, startLineString, { duration: 0 });
59422       });
59423       context.on("enter.intro", function(mode) {
59424         if (mode.id !== "draw-line") return chapter.restart();
59425         continueTo(drawLine);
59426       });
59427       function continueTo(nextStep) {
59428         context.map().on("move.intro drawn.intro", null);
59429         context.on("enter.intro", null);
59430         nextStep();
59431       }
59432     }
59433     function drawLine() {
59434       if (context.mode().id !== "draw-line") return chapter.restart();
59435       _tulipRoadID = context.mode().selectedIDs()[0];
59436       context.map().centerEase(tulipRoadMidpoint, 500);
59437       timeout2(function() {
59438         var padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
59439         var box = pad(tulipRoadMidpoint, padding, context);
59440         box.height = box.height * 2;
59441         reveal(
59442           box,
59443           helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") })
59444         );
59445         context.map().on("move.intro drawn.intro", function() {
59446           padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
59447           box = pad(tulipRoadMidpoint, padding, context);
59448           box.height = box.height * 2;
59449           reveal(
59450             box,
59451             helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }),
59452             { duration: 0 }
59453           );
59454         });
59455       }, 550);
59456       context.history().on("change.intro", function() {
59457         if (isLineConnected()) {
59458           continueTo(continueLine);
59459         }
59460       });
59461       context.on("enter.intro", function(mode) {
59462         if (mode.id === "draw-line") {
59463           return;
59464         } else if (mode.id === "select") {
59465           continueTo(retryIntersect);
59466           return;
59467         } else {
59468           return chapter.restart();
59469         }
59470       });
59471       function continueTo(nextStep) {
59472         context.map().on("move.intro drawn.intro", null);
59473         context.history().on("change.intro", null);
59474         context.on("enter.intro", null);
59475         nextStep();
59476       }
59477     }
59478     function isLineConnected() {
59479       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
59480       if (!entity) return false;
59481       var drawNodes = context.graph().childNodes(entity);
59482       return drawNodes.some(function(node) {
59483         return context.graph().parentWays(node).some(function(parent) {
59484           return parent.id === flowerRoadID;
59485         });
59486       });
59487     }
59488     function retryIntersect() {
59489       select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true);
59490       var box = pad(tulipRoadIntersection, 80, context);
59491       reveal(
59492         box,
59493         helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") })
59494       );
59495       timeout2(chapter.restart, 3e3);
59496     }
59497     function continueLine() {
59498       if (context.mode().id !== "draw-line") return chapter.restart();
59499       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
59500       if (!entity) return chapter.restart();
59501       context.map().centerEase(tulipRoadIntersection, 500);
59502       var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road");
59503       reveal(".main-map .surface", continueLineText);
59504       context.on("enter.intro", function(mode) {
59505         if (mode.id === "draw-line") {
59506           return;
59507         } else if (mode.id === "select") {
59508           return continueTo(chooseCategoryRoad);
59509         } else {
59510           return chapter.restart();
59511         }
59512       });
59513       function continueTo(nextStep) {
59514         context.on("enter.intro", null);
59515         nextStep();
59516       }
59517     }
59518     function chooseCategoryRoad() {
59519       if (context.mode().id !== "select") return chapter.restart();
59520       context.on("exit.intro", function() {
59521         return chapter.restart();
59522       });
59523       var button = context.container().select(".preset-category-road_minor .preset-list-button");
59524       if (button.empty()) return chapter.restart();
59525       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59526       timeout2(function() {
59527         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59528         reveal(
59529           button.node(),
59530           helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() })
59531         );
59532         button.on("click.intro", function() {
59533           continueTo(choosePresetResidential);
59534         });
59535       }, 400);
59536       function continueTo(nextStep) {
59537         context.container().select(".inspector-wrap").on("wheel.intro", null);
59538         context.container().select(".preset-list-button").on("click.intro", null);
59539         context.on("exit.intro", null);
59540         nextStep();
59541       }
59542     }
59543     function choosePresetResidential() {
59544       if (context.mode().id !== "select") return chapter.restart();
59545       context.on("exit.intro", function() {
59546         return chapter.restart();
59547       });
59548       var subgrid = context.container().select(".preset-category-road_minor .subgrid");
59549       if (subgrid.empty()) return chapter.restart();
59550       subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() {
59551         continueTo(retryPresetResidential);
59552       });
59553       subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() {
59554         continueTo(nameRoad);
59555       });
59556       timeout2(function() {
59557         reveal(
59558           subgrid.node(),
59559           helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }),
59560           { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 }
59561         );
59562       }, 300);
59563       function continueTo(nextStep) {
59564         context.container().select(".preset-list-button").on("click.intro", null);
59565         context.on("exit.intro", null);
59566         nextStep();
59567       }
59568     }
59569     function retryPresetResidential() {
59570       if (context.mode().id !== "select") return chapter.restart();
59571       context.on("exit.intro", function() {
59572         return chapter.restart();
59573       });
59574       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59575       timeout2(function() {
59576         var button = context.container().select(".entity-editor-pane .preset-list-button");
59577         reveal(
59578           button.node(),
59579           helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() })
59580         );
59581         button.on("click.intro", function() {
59582           continueTo(chooseCategoryRoad);
59583         });
59584       }, 500);
59585       function continueTo(nextStep) {
59586         context.container().select(".inspector-wrap").on("wheel.intro", null);
59587         context.container().select(".preset-list-button").on("click.intro", null);
59588         context.on("exit.intro", null);
59589         nextStep();
59590       }
59591     }
59592     function nameRoad() {
59593       context.on("exit.intro", function() {
59594         continueTo(didNameRoad);
59595       });
59596       timeout2(function() {
59597         reveal(
59598           ".entity-editor-pane",
59599           helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }),
59600           { tooltipClass: "intro-lines-name_road" }
59601         );
59602       }, 500);
59603       function continueTo(nextStep) {
59604         context.on("exit.intro", null);
59605         nextStep();
59606       }
59607     }
59608     function didNameRoad() {
59609       context.history().checkpoint("doneAddLine");
59610       timeout2(function() {
59611         reveal(".main-map .surface", helpHtml("intro.lines.did_name_road"), {
59612           buttonText: _t.html("intro.ok"),
59613           buttonCallback: function() {
59614             continueTo(updateLine);
59615           }
59616         });
59617       }, 500);
59618       function continueTo(nextStep) {
59619         nextStep();
59620       }
59621     }
59622     function updateLine() {
59623       context.history().reset("doneAddLine");
59624       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59625         return chapter.restart();
59626       }
59627       var msec = transitionTime(woodRoadDragMidpoint, context.map().center());
59628       if (msec) {
59629         reveal(null, null, { duration: 0 });
59630       }
59631       context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec);
59632       timeout2(function() {
59633         var padding = 250 * Math.pow(2, context.map().zoom() - 19);
59634         var box = pad(woodRoadDragMidpoint, padding, context);
59635         var advance = function() {
59636           continueTo(addNode);
59637         };
59638         reveal(
59639           box,
59640           helpHtml("intro.lines.update_line"),
59641           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59642         );
59643         context.map().on("move.intro drawn.intro", function() {
59644           var padding2 = 250 * Math.pow(2, context.map().zoom() - 19);
59645           var box2 = pad(woodRoadDragMidpoint, padding2, context);
59646           reveal(
59647             box2,
59648             helpHtml("intro.lines.update_line"),
59649             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59650           );
59651         });
59652       }, msec + 100);
59653       function continueTo(nextStep) {
59654         context.map().on("move.intro drawn.intro", null);
59655         nextStep();
59656       }
59657     }
59658     function addNode() {
59659       context.history().reset("doneAddLine");
59660       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59661         return chapter.restart();
59662       }
59663       var padding = 40 * Math.pow(2, context.map().zoom() - 19);
59664       var box = pad(woodRoadAddNode, padding, context);
59665       var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
59666       reveal(box, addNodeString);
59667       context.map().on("move.intro drawn.intro", function() {
59668         var padding2 = 40 * Math.pow(2, context.map().zoom() - 19);
59669         var box2 = pad(woodRoadAddNode, padding2, context);
59670         reveal(box2, addNodeString, { duration: 0 });
59671       });
59672       context.history().on("change.intro", function(changed) {
59673         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59674           return continueTo(updateLine);
59675         }
59676         if (changed.created().length === 1) {
59677           timeout2(function() {
59678             continueTo(startDragEndpoint);
59679           }, 500);
59680         }
59681       });
59682       context.on("enter.intro", function(mode) {
59683         if (mode.id !== "select") {
59684           continueTo(updateLine);
59685         }
59686       });
59687       function continueTo(nextStep) {
59688         context.map().on("move.intro drawn.intro", null);
59689         context.history().on("change.intro", null);
59690         context.on("enter.intro", null);
59691         nextStep();
59692       }
59693     }
59694     function startDragEndpoint() {
59695       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59696         return continueTo(updateLine);
59697       }
59698       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59699       var box = pad(woodRoadDragEndpoint, padding, context);
59700       var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection");
59701       reveal(box, startDragString);
59702       context.map().on("move.intro drawn.intro", function() {
59703         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59704           return continueTo(updateLine);
59705         }
59706         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59707         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59708         reveal(box2, startDragString, { duration: 0 });
59709         var entity = context.entity(woodRoadEndID);
59710         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
59711           continueTo(finishDragEndpoint);
59712         }
59713       });
59714       function continueTo(nextStep) {
59715         context.map().on("move.intro drawn.intro", null);
59716         nextStep();
59717       }
59718     }
59719     function finishDragEndpoint() {
59720       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59721         return continueTo(updateLine);
59722       }
59723       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59724       var box = pad(woodRoadDragEndpoint, padding, context);
59725       var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
59726       reveal(box, finishDragString);
59727       context.map().on("move.intro drawn.intro", function() {
59728         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59729           return continueTo(updateLine);
59730         }
59731         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59732         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59733         reveal(box2, finishDragString, { duration: 0 });
59734         var entity = context.entity(woodRoadEndID);
59735         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
59736           continueTo(startDragEndpoint);
59737         }
59738       });
59739       context.on("enter.intro", function() {
59740         continueTo(startDragMidpoint);
59741       });
59742       function continueTo(nextStep) {
59743         context.map().on("move.intro drawn.intro", null);
59744         context.on("enter.intro", null);
59745         nextStep();
59746       }
59747     }
59748     function startDragMidpoint() {
59749       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59750         return continueTo(updateLine);
59751       }
59752       if (context.selectedIDs().indexOf(woodRoadID) === -1) {
59753         context.enter(modeSelect(context, [woodRoadID]));
59754       }
59755       var padding = 80 * Math.pow(2, context.map().zoom() - 19);
59756       var box = pad(woodRoadDragMidpoint, padding, context);
59757       reveal(box, helpHtml("intro.lines.start_drag_midpoint"));
59758       context.map().on("move.intro drawn.intro", function() {
59759         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59760           return continueTo(updateLine);
59761         }
59762         var padding2 = 80 * Math.pow(2, context.map().zoom() - 19);
59763         var box2 = pad(woodRoadDragMidpoint, padding2, context);
59764         reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 });
59765       });
59766       context.history().on("change.intro", function(changed) {
59767         if (changed.created().length === 1) {
59768           continueTo(continueDragMidpoint);
59769         }
59770       });
59771       context.on("enter.intro", function(mode) {
59772         if (mode.id !== "select") {
59773           context.enter(modeSelect(context, [woodRoadID]));
59774         }
59775       });
59776       function continueTo(nextStep) {
59777         context.map().on("move.intro drawn.intro", null);
59778         context.history().on("change.intro", null);
59779         context.on("enter.intro", null);
59780         nextStep();
59781       }
59782     }
59783     function continueDragMidpoint() {
59784       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59785         return continueTo(updateLine);
59786       }
59787       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59788       var box = pad(woodRoadDragEndpoint, padding, context);
59789       box.height += 400;
59790       var advance = function() {
59791         context.history().checkpoint("doneUpdateLine");
59792         continueTo(deleteLines);
59793       };
59794       reveal(
59795         box,
59796         helpHtml("intro.lines.continue_drag_midpoint"),
59797         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59798       );
59799       context.map().on("move.intro drawn.intro", function() {
59800         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59801           return continueTo(updateLine);
59802         }
59803         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59804         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59805         box2.height += 400;
59806         reveal(
59807           box2,
59808           helpHtml("intro.lines.continue_drag_midpoint"),
59809           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59810         );
59811       });
59812       function continueTo(nextStep) {
59813         context.map().on("move.intro drawn.intro", null);
59814         nextStep();
59815       }
59816     }
59817     function deleteLines() {
59818       context.history().reset("doneUpdateLine");
59819       context.enter(modeBrowse(context));
59820       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59821         return chapter.restart();
59822       }
59823       var msec = transitionTime(deleteLinesLoc, context.map().center());
59824       if (msec) {
59825         reveal(null, null, { duration: 0 });
59826       }
59827       context.map().centerZoomEase(deleteLinesLoc, 18, msec);
59828       timeout2(function() {
59829         var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59830         var box = pad(deleteLinesLoc, padding, context);
59831         box.top -= 200;
59832         box.height += 400;
59833         var advance = function() {
59834           continueTo(rightClickIntersection);
59835         };
59836         reveal(
59837           box,
59838           helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
59839           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59840         );
59841         context.map().on("move.intro drawn.intro", function() {
59842           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
59843           var box2 = pad(deleteLinesLoc, padding2, context);
59844           box2.top -= 200;
59845           box2.height += 400;
59846           reveal(
59847             box2,
59848             helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
59849             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59850           );
59851         });
59852         context.history().on("change.intro", function() {
59853           timeout2(function() {
59854             continueTo(deleteLines);
59855           }, 500);
59856         });
59857       }, msec + 100);
59858       function continueTo(nextStep) {
59859         context.map().on("move.intro drawn.intro", null);
59860         context.history().on("change.intro", null);
59861         nextStep();
59862       }
59863     }
59864     function rightClickIntersection() {
59865       context.history().reset("doneUpdateLine");
59866       context.enter(modeBrowse(context));
59867       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
59868       var rightClickString = helpHtml("intro.lines.split_street", {
59869         street1: _t("intro.graph.name.11th-avenue"),
59870         street2: _t("intro.graph.name.washington-street")
59871       }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch"));
59872       timeout2(function() {
59873         var padding = 60 * Math.pow(2, context.map().zoom() - 18);
59874         var box = pad(eleventhAvenueEnd, padding, context);
59875         reveal(box, rightClickString);
59876         context.map().on("move.intro drawn.intro", function() {
59877           var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
59878           var box2 = pad(eleventhAvenueEnd, padding2, context);
59879           reveal(
59880             box2,
59881             rightClickString,
59882             { duration: 0 }
59883           );
59884         });
59885         context.on("enter.intro", function(mode) {
59886           if (mode.id !== "select") return;
59887           var ids = context.selectedIDs();
59888           if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID) return;
59889           timeout2(function() {
59890             var node = selectMenuItem(context, "split").node();
59891             if (!node) return;
59892             continueTo(splitIntersection);
59893           }, 50);
59894         });
59895         context.history().on("change.intro", function() {
59896           timeout2(function() {
59897             continueTo(deleteLines);
59898           }, 300);
59899         });
59900       }, 600);
59901       function continueTo(nextStep) {
59902         context.map().on("move.intro drawn.intro", null);
59903         context.on("enter.intro", null);
59904         context.history().on("change.intro", null);
59905         nextStep();
59906       }
59907     }
59908     function splitIntersection() {
59909       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59910         return continueTo(deleteLines);
59911       }
59912       var node = selectMenuItem(context, "split").node();
59913       if (!node) {
59914         return continueTo(rightClickIntersection);
59915       }
59916       var wasChanged = false;
59917       _washingtonSegmentID = null;
59918       reveal(
59919         ".edit-menu",
59920         helpHtml(
59921           "intro.lines.split_intersection",
59922           { street: _t("intro.graph.name.washington-street") }
59923         ),
59924         { padding: 50 }
59925       );
59926       context.map().on("move.intro drawn.intro", function() {
59927         var node2 = selectMenuItem(context, "split").node();
59928         if (!wasChanged && !node2) {
59929           return continueTo(rightClickIntersection);
59930         }
59931         reveal(
59932           ".edit-menu",
59933           helpHtml(
59934             "intro.lines.split_intersection",
59935             { street: _t("intro.graph.name.washington-street") }
59936           ),
59937           { duration: 0, padding: 50 }
59938         );
59939       });
59940       context.history().on("change.intro", function(changed) {
59941         wasChanged = true;
59942         timeout2(function() {
59943           if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) {
59944             _washingtonSegmentID = changed.created()[0].id;
59945             continueTo(didSplit);
59946           } else {
59947             _washingtonSegmentID = null;
59948             continueTo(retrySplit);
59949           }
59950         }, 300);
59951       });
59952       function continueTo(nextStep) {
59953         context.map().on("move.intro drawn.intro", null);
59954         context.history().on("change.intro", null);
59955         nextStep();
59956       }
59957     }
59958     function retrySplit() {
59959       context.enter(modeBrowse(context));
59960       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
59961       var advance = function() {
59962         continueTo(rightClickIntersection);
59963       };
59964       var padding = 60 * Math.pow(2, context.map().zoom() - 18);
59965       var box = pad(eleventhAvenueEnd, padding, context);
59966       reveal(
59967         box,
59968         helpHtml("intro.lines.retry_split"),
59969         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59970       );
59971       context.map().on("move.intro drawn.intro", function() {
59972         var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
59973         var box2 = pad(eleventhAvenueEnd, padding2, context);
59974         reveal(
59975           box2,
59976           helpHtml("intro.lines.retry_split"),
59977           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59978         );
59979       });
59980       function continueTo(nextStep) {
59981         context.map().on("move.intro drawn.intro", null);
59982         nextStep();
59983       }
59984     }
59985     function didSplit() {
59986       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59987         return continueTo(rightClickIntersection);
59988       }
59989       var ids = context.selectedIDs();
59990       var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single");
59991       var street = _t("intro.graph.name.washington-street");
59992       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59993       var box = pad(twelfthAvenue, padding, context);
59994       box.width = box.width / 2;
59995       reveal(
59996         box,
59997         helpHtml(string, { street1: street, street2: street }),
59998         { duration: 500 }
59999       );
60000       timeout2(function() {
60001         context.map().centerZoomEase(twelfthAvenue, 18, 500);
60002         context.map().on("move.intro drawn.intro", function() {
60003           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
60004           var box2 = pad(twelfthAvenue, padding2, context);
60005           box2.width = box2.width / 2;
60006           reveal(
60007             box2,
60008             helpHtml(string, { street1: street, street2: street }),
60009             { duration: 0 }
60010           );
60011         });
60012       }, 600);
60013       context.on("enter.intro", function() {
60014         var ids2 = context.selectedIDs();
60015         if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) {
60016           continueTo(multiSelect2);
60017         }
60018       });
60019       context.history().on("change.intro", function() {
60020         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60021           return continueTo(rightClickIntersection);
60022         }
60023       });
60024       function continueTo(nextStep) {
60025         context.map().on("move.intro drawn.intro", null);
60026         context.on("enter.intro", null);
60027         context.history().on("change.intro", null);
60028         nextStep();
60029       }
60030     }
60031     function multiSelect2() {
60032       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60033         return continueTo(rightClickIntersection);
60034       }
60035       var ids = context.selectedIDs();
60036       var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
60037       var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
60038       if (hasWashington && hasTwelfth) {
60039         return continueTo(multiRightClick);
60040       } else if (!hasWashington && !hasTwelfth) {
60041         return continueTo(didSplit);
60042       }
60043       context.map().centerZoomEase(twelfthAvenue, 18, 500);
60044       timeout2(function() {
60045         var selected, other2, padding, box;
60046         if (hasWashington) {
60047           selected = _t("intro.graph.name.washington-street");
60048           other2 = _t("intro.graph.name.12th-avenue");
60049           padding = 60 * Math.pow(2, context.map().zoom() - 18);
60050           box = pad(twelfthAvenueEnd, padding, context);
60051           box.width *= 3;
60052         } else {
60053           selected = _t("intro.graph.name.12th-avenue");
60054           other2 = _t("intro.graph.name.washington-street");
60055           padding = 200 * Math.pow(2, context.map().zoom() - 18);
60056           box = pad(twelfthAvenue, padding, context);
60057           box.width /= 2;
60058         }
60059         reveal(
60060           box,
60061           helpHtml(
60062             "intro.lines.multi_select",
60063             { selected, other1: other2 }
60064           ) + " " + helpHtml(
60065             "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
60066             { selected, other2 }
60067           )
60068         );
60069         context.map().on("move.intro drawn.intro", function() {
60070           if (hasWashington) {
60071             selected = _t("intro.graph.name.washington-street");
60072             other2 = _t("intro.graph.name.12th-avenue");
60073             padding = 60 * Math.pow(2, context.map().zoom() - 18);
60074             box = pad(twelfthAvenueEnd, padding, context);
60075             box.width *= 3;
60076           } else {
60077             selected = _t("intro.graph.name.12th-avenue");
60078             other2 = _t("intro.graph.name.washington-street");
60079             padding = 200 * Math.pow(2, context.map().zoom() - 18);
60080             box = pad(twelfthAvenue, padding, context);
60081             box.width /= 2;
60082           }
60083           reveal(
60084             box,
60085             helpHtml(
60086               "intro.lines.multi_select",
60087               { selected, other1: other2 }
60088             ) + " " + helpHtml(
60089               "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
60090               { selected, other2 }
60091             ),
60092             { duration: 0 }
60093           );
60094         });
60095         context.on("enter.intro", function() {
60096           continueTo(multiSelect2);
60097         });
60098         context.history().on("change.intro", function() {
60099           if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60100             return continueTo(rightClickIntersection);
60101           }
60102         });
60103       }, 600);
60104       function continueTo(nextStep) {
60105         context.map().on("move.intro drawn.intro", null);
60106         context.on("enter.intro", null);
60107         context.history().on("change.intro", null);
60108         nextStep();
60109       }
60110     }
60111     function multiRightClick() {
60112       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60113         return continueTo(rightClickIntersection);
60114       }
60115       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
60116       var box = pad(twelfthAvenue, padding, context);
60117       var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"));
60118       reveal(box, rightClickString);
60119       context.map().on("move.intro drawn.intro", function() {
60120         var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
60121         var box2 = pad(twelfthAvenue, padding2, context);
60122         reveal(box2, rightClickString, { duration: 0 });
60123       });
60124       context.ui().editMenu().on("toggled.intro", function(open) {
60125         if (!open) return;
60126         timeout2(function() {
60127           var ids = context.selectedIDs();
60128           if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) {
60129             var node = selectMenuItem(context, "delete").node();
60130             if (!node) return;
60131             continueTo(multiDelete);
60132           } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) {
60133             return continueTo(multiSelect2);
60134           } else {
60135             return continueTo(didSplit);
60136           }
60137         }, 300);
60138       });
60139       context.history().on("change.intro", function() {
60140         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60141           return continueTo(rightClickIntersection);
60142         }
60143       });
60144       function continueTo(nextStep) {
60145         context.map().on("move.intro drawn.intro", null);
60146         context.ui().editMenu().on("toggled.intro", null);
60147         context.history().on("change.intro", null);
60148         nextStep();
60149       }
60150     }
60151     function multiDelete() {
60152       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
60153         return continueTo(rightClickIntersection);
60154       }
60155       var node = selectMenuItem(context, "delete").node();
60156       if (!node) return continueTo(multiRightClick);
60157       reveal(
60158         ".edit-menu",
60159         helpHtml("intro.lines.multi_delete"),
60160         { padding: 50 }
60161       );
60162       context.map().on("move.intro drawn.intro", function() {
60163         reveal(
60164           ".edit-menu",
60165           helpHtml("intro.lines.multi_delete"),
60166           { duration: 0, padding: 50 }
60167         );
60168       });
60169       context.on("exit.intro", function() {
60170         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
60171           return continueTo(multiSelect2);
60172         }
60173       });
60174       context.history().on("change.intro", function() {
60175         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
60176           continueTo(retryDelete);
60177         } else {
60178           continueTo(play);
60179         }
60180       });
60181       function continueTo(nextStep) {
60182         context.map().on("move.intro drawn.intro", null);
60183         context.on("exit.intro", null);
60184         context.history().on("change.intro", null);
60185         nextStep();
60186       }
60187     }
60188     function retryDelete() {
60189       context.enter(modeBrowse(context));
60190       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
60191       var box = pad(twelfthAvenue, padding, context);
60192       reveal(box, helpHtml("intro.lines.retry_delete"), {
60193         buttonText: _t.html("intro.ok"),
60194         buttonCallback: function() {
60195           continueTo(multiSelect2);
60196         }
60197       });
60198       function continueTo(nextStep) {
60199         nextStep();
60200       }
60201     }
60202     function play() {
60203       dispatch14.call("done");
60204       reveal(
60205         ".ideditor",
60206         helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }),
60207         {
60208           tooltipBox: ".intro-nav-wrap .chapter-building",
60209           buttonText: _t.html("intro.ok"),
60210           buttonCallback: function() {
60211             reveal(".ideditor");
60212           }
60213         }
60214       );
60215     }
60216     chapter.enter = function() {
60217       addLine();
60218     };
60219     chapter.exit = function() {
60220       timeouts.forEach(window.clearTimeout);
60221       select_default2(window).on("pointerdown.intro mousedown.intro", null, true);
60222       context.on("enter.intro exit.intro", null);
60223       context.map().on("move.intro drawn.intro", null);
60224       context.history().on("change.intro", null);
60225       context.container().select(".inspector-wrap").on("wheel.intro", null);
60226       context.container().select(".preset-list-button").on("click.intro", null);
60227     };
60228     chapter.restart = function() {
60229       chapter.exit();
60230       chapter.enter();
60231     };
60232     return utilRebind(chapter, dispatch14, "on");
60233   }
60234
60235   // modules/ui/intro/building.js
60236   function uiIntroBuilding(context, reveal) {
60237     var dispatch14 = dispatch_default("done");
60238     var house = [-85.62815, 41.95638];
60239     var tank = [-85.62732, 41.95347];
60240     var buildingCatetory = _mainPresetIndex.item("category-building");
60241     var housePreset = _mainPresetIndex.item("building/house");
60242     var tankPreset = _mainPresetIndex.item("man_made/storage_tank");
60243     var timeouts = [];
60244     var _houseID = null;
60245     var _tankID = null;
60246     var chapter = {
60247       title: "intro.buildings.title"
60248     };
60249     function timeout2(f2, t2) {
60250       timeouts.push(window.setTimeout(f2, t2));
60251     }
60252     function eventCancel(d3_event) {
60253       d3_event.stopPropagation();
60254       d3_event.preventDefault();
60255     }
60256     function revealHouse(center, text, options2) {
60257       var padding = 160 * Math.pow(2, context.map().zoom() - 20);
60258       var box = pad(center, padding, context);
60259       reveal(box, text, options2);
60260     }
60261     function revealTank(center, text, options2) {
60262       var padding = 190 * Math.pow(2, context.map().zoom() - 19.5);
60263       var box = pad(center, padding, context);
60264       reveal(box, text, options2);
60265     }
60266     function addHouse() {
60267       context.enter(modeBrowse(context));
60268       context.history().reset("initial");
60269       _houseID = null;
60270       var msec = transitionTime(house, context.map().center());
60271       if (msec) {
60272         reveal(null, null, { duration: 0 });
60273       }
60274       context.map().centerZoomEase(house, 19, msec);
60275       timeout2(function() {
60276         var tooltip = reveal(
60277           "button.add-area",
60278           helpHtml("intro.buildings.add_building")
60279         );
60280         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings");
60281         context.on("enter.intro", function(mode) {
60282           if (mode.id !== "add-area") return;
60283           continueTo(startHouse);
60284         });
60285       }, msec + 100);
60286       function continueTo(nextStep) {
60287         context.on("enter.intro", null);
60288         nextStep();
60289       }
60290     }
60291     function startHouse() {
60292       if (context.mode().id !== "add-area") {
60293         return continueTo(addHouse);
60294       }
60295       _houseID = null;
60296       context.map().zoomEase(20, 500);
60297       timeout2(function() {
60298         var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
60299         revealHouse(house, startString);
60300         context.map().on("move.intro drawn.intro", function() {
60301           revealHouse(house, startString, { duration: 0 });
60302         });
60303         context.on("enter.intro", function(mode) {
60304           if (mode.id !== "draw-area") return chapter.restart();
60305           continueTo(continueHouse);
60306         });
60307       }, 550);
60308       function continueTo(nextStep) {
60309         context.map().on("move.intro drawn.intro", null);
60310         context.on("enter.intro", null);
60311         nextStep();
60312       }
60313     }
60314     function continueHouse() {
60315       if (context.mode().id !== "draw-area") {
60316         return continueTo(addHouse);
60317       }
60318       _houseID = null;
60319       var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building");
60320       revealHouse(house, continueString);
60321       context.map().on("move.intro drawn.intro", function() {
60322         revealHouse(house, continueString, { duration: 0 });
60323       });
60324       context.on("enter.intro", function(mode) {
60325         if (mode.id === "draw-area") {
60326           return;
60327         } else if (mode.id === "select") {
60328           var graph = context.graph();
60329           var way = context.entity(context.selectedIDs()[0]);
60330           var nodes = graph.childNodes(way);
60331           var points = utilArrayUniq(nodes).map(function(n3) {
60332             return context.projection(n3.loc);
60333           });
60334           if (isMostlySquare(points)) {
60335             _houseID = way.id;
60336             return continueTo(chooseCategoryBuilding);
60337           } else {
60338             return continueTo(retryHouse);
60339           }
60340         } else {
60341           return chapter.restart();
60342         }
60343       });
60344       function continueTo(nextStep) {
60345         context.map().on("move.intro drawn.intro", null);
60346         context.on("enter.intro", null);
60347         nextStep();
60348       }
60349     }
60350     function retryHouse() {
60351       var onClick = function() {
60352         continueTo(addHouse);
60353       };
60354       revealHouse(
60355         house,
60356         helpHtml("intro.buildings.retry_building"),
60357         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60358       );
60359       context.map().on("move.intro drawn.intro", function() {
60360         revealHouse(
60361           house,
60362           helpHtml("intro.buildings.retry_building"),
60363           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60364         );
60365       });
60366       function continueTo(nextStep) {
60367         context.map().on("move.intro drawn.intro", null);
60368         nextStep();
60369       }
60370     }
60371     function chooseCategoryBuilding() {
60372       if (!_houseID || !context.hasEntity(_houseID)) {
60373         return addHouse();
60374       }
60375       var ids = context.selectedIDs();
60376       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
60377         context.enter(modeSelect(context, [_houseID]));
60378       }
60379       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60380       timeout2(function() {
60381         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
60382         var button = context.container().select(".preset-category-building .preset-list-button");
60383         reveal(
60384           button.node(),
60385           helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() })
60386         );
60387         button.on("click.intro", function() {
60388           button.on("click.intro", null);
60389           continueTo(choosePresetHouse);
60390         });
60391       }, 400);
60392       context.on("enter.intro", function(mode) {
60393         if (!_houseID || !context.hasEntity(_houseID)) {
60394           return continueTo(addHouse);
60395         }
60396         var ids2 = context.selectedIDs();
60397         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
60398           return continueTo(chooseCategoryBuilding);
60399         }
60400       });
60401       function continueTo(nextStep) {
60402         context.container().select(".inspector-wrap").on("wheel.intro", null);
60403         context.container().select(".preset-list-button").on("click.intro", null);
60404         context.on("enter.intro", null);
60405         nextStep();
60406       }
60407     }
60408     function choosePresetHouse() {
60409       if (!_houseID || !context.hasEntity(_houseID)) {
60410         return addHouse();
60411       }
60412       var ids = context.selectedIDs();
60413       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
60414         context.enter(modeSelect(context, [_houseID]));
60415       }
60416       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60417       timeout2(function() {
60418         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
60419         var button = context.container().select(".preset-building-house .preset-list-button");
60420         reveal(
60421           button.node(),
60422           helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }),
60423           { duration: 300 }
60424         );
60425         button.on("click.intro", function() {
60426           button.on("click.intro", null);
60427           continueTo(closeEditorHouse);
60428         });
60429       }, 400);
60430       context.on("enter.intro", function(mode) {
60431         if (!_houseID || !context.hasEntity(_houseID)) {
60432           return continueTo(addHouse);
60433         }
60434         var ids2 = context.selectedIDs();
60435         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
60436           return continueTo(chooseCategoryBuilding);
60437         }
60438       });
60439       function continueTo(nextStep) {
60440         context.container().select(".inspector-wrap").on("wheel.intro", null);
60441         context.container().select(".preset-list-button").on("click.intro", null);
60442         context.on("enter.intro", null);
60443         nextStep();
60444       }
60445     }
60446     function closeEditorHouse() {
60447       if (!_houseID || !context.hasEntity(_houseID)) {
60448         return addHouse();
60449       }
60450       var ids = context.selectedIDs();
60451       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
60452         context.enter(modeSelect(context, [_houseID]));
60453       }
60454       context.history().checkpoint("hasHouse");
60455       context.on("exit.intro", function() {
60456         continueTo(rightClickHouse);
60457       });
60458       timeout2(function() {
60459         reveal(
60460           ".entity-editor-pane",
60461           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
60462         );
60463       }, 500);
60464       function continueTo(nextStep) {
60465         context.on("exit.intro", null);
60466         nextStep();
60467       }
60468     }
60469     function rightClickHouse() {
60470       if (!_houseID) return chapter.restart();
60471       context.enter(modeBrowse(context));
60472       context.history().reset("hasHouse");
60473       var zoom = context.map().zoom();
60474       if (zoom < 20) {
60475         zoom = 20;
60476       }
60477       context.map().centerZoomEase(house, zoom, 500);
60478       context.on("enter.intro", function(mode) {
60479         if (mode.id !== "select") return;
60480         var ids = context.selectedIDs();
60481         if (ids.length !== 1 || ids[0] !== _houseID) return;
60482         timeout2(function() {
60483           var node = selectMenuItem(context, "orthogonalize").node();
60484           if (!node) return;
60485           continueTo(clickSquare);
60486         }, 50);
60487       });
60488       context.map().on("move.intro drawn.intro", function() {
60489         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch"));
60490         revealHouse(house, rightclickString, { duration: 0 });
60491       });
60492       context.history().on("change.intro", function() {
60493         continueTo(rightClickHouse);
60494       });
60495       function continueTo(nextStep) {
60496         context.on("enter.intro", null);
60497         context.map().on("move.intro drawn.intro", null);
60498         context.history().on("change.intro", null);
60499         nextStep();
60500       }
60501     }
60502     function clickSquare() {
60503       if (!_houseID) return chapter.restart();
60504       var entity = context.hasEntity(_houseID);
60505       if (!entity) return continueTo(rightClickHouse);
60506       var node = selectMenuItem(context, "orthogonalize").node();
60507       if (!node) {
60508         return continueTo(rightClickHouse);
60509       }
60510       var wasChanged = false;
60511       reveal(
60512         ".edit-menu",
60513         helpHtml("intro.buildings.square_building"),
60514         { padding: 50 }
60515       );
60516       context.on("enter.intro", function(mode) {
60517         if (mode.id === "browse") {
60518           continueTo(rightClickHouse);
60519         } else if (mode.id === "move" || mode.id === "rotate") {
60520           continueTo(retryClickSquare);
60521         }
60522       });
60523       context.map().on("move.intro", function() {
60524         var node2 = selectMenuItem(context, "orthogonalize").node();
60525         if (!wasChanged && !node2) {
60526           return continueTo(rightClickHouse);
60527         }
60528         reveal(
60529           ".edit-menu",
60530           helpHtml("intro.buildings.square_building"),
60531           { duration: 0, padding: 50 }
60532         );
60533       });
60534       context.history().on("change.intro", function() {
60535         wasChanged = true;
60536         context.history().on("change.intro", null);
60537         timeout2(function() {
60538           if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) {
60539             continueTo(doneSquare);
60540           } else {
60541             continueTo(retryClickSquare);
60542           }
60543         }, 500);
60544       });
60545       function continueTo(nextStep) {
60546         context.on("enter.intro", null);
60547         context.map().on("move.intro", null);
60548         context.history().on("change.intro", null);
60549         nextStep();
60550       }
60551     }
60552     function retryClickSquare() {
60553       context.enter(modeBrowse(context));
60554       revealHouse(house, helpHtml("intro.buildings.retry_square"), {
60555         buttonText: _t.html("intro.ok"),
60556         buttonCallback: function() {
60557           continueTo(rightClickHouse);
60558         }
60559       });
60560       function continueTo(nextStep) {
60561         nextStep();
60562       }
60563     }
60564     function doneSquare() {
60565       context.history().checkpoint("doneSquare");
60566       revealHouse(house, helpHtml("intro.buildings.done_square"), {
60567         buttonText: _t.html("intro.ok"),
60568         buttonCallback: function() {
60569           continueTo(addTank);
60570         }
60571       });
60572       function continueTo(nextStep) {
60573         nextStep();
60574       }
60575     }
60576     function addTank() {
60577       context.enter(modeBrowse(context));
60578       context.history().reset("doneSquare");
60579       _tankID = null;
60580       var msec = transitionTime(tank, context.map().center());
60581       if (msec) {
60582         reveal(null, null, { duration: 0 });
60583       }
60584       context.map().centerZoomEase(tank, 19.5, msec);
60585       timeout2(function() {
60586         reveal(
60587           "button.add-area",
60588           helpHtml("intro.buildings.add_tank")
60589         );
60590         context.on("enter.intro", function(mode) {
60591           if (mode.id !== "add-area") return;
60592           continueTo(startTank);
60593         });
60594       }, msec + 100);
60595       function continueTo(nextStep) {
60596         context.on("enter.intro", null);
60597         nextStep();
60598       }
60599     }
60600     function startTank() {
60601       if (context.mode().id !== "add-area") {
60602         return continueTo(addTank);
60603       }
60604       _tankID = null;
60605       timeout2(function() {
60606         var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
60607         revealTank(tank, startString);
60608         context.map().on("move.intro drawn.intro", function() {
60609           revealTank(tank, startString, { duration: 0 });
60610         });
60611         context.on("enter.intro", function(mode) {
60612           if (mode.id !== "draw-area") return chapter.restart();
60613           continueTo(continueTank);
60614         });
60615       }, 550);
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 continueTank() {
60623       if (context.mode().id !== "draw-area") {
60624         return continueTo(addTank);
60625       }
60626       _tankID = null;
60627       var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank");
60628       revealTank(tank, continueString);
60629       context.map().on("move.intro drawn.intro", function() {
60630         revealTank(tank, continueString, { duration: 0 });
60631       });
60632       context.on("enter.intro", function(mode) {
60633         if (mode.id === "draw-area") {
60634           return;
60635         } else if (mode.id === "select") {
60636           _tankID = context.selectedIDs()[0];
60637           return continueTo(searchPresetTank);
60638         } else {
60639           return continueTo(addTank);
60640         }
60641       });
60642       function continueTo(nextStep) {
60643         context.map().on("move.intro drawn.intro", null);
60644         context.on("enter.intro", null);
60645         nextStep();
60646       }
60647     }
60648     function searchPresetTank() {
60649       if (!_tankID || !context.hasEntity(_tankID)) {
60650         return addTank();
60651       }
60652       var ids = context.selectedIDs();
60653       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
60654         context.enter(modeSelect(context, [_tankID]));
60655       }
60656       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60657       timeout2(function() {
60658         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
60659         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60660         reveal(
60661           ".preset-search-input",
60662           helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
60663         );
60664       }, 400);
60665       context.on("enter.intro", function(mode) {
60666         if (!_tankID || !context.hasEntity(_tankID)) {
60667           return continueTo(addTank);
60668         }
60669         var ids2 = context.selectedIDs();
60670         if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) {
60671           context.enter(modeSelect(context, [_tankID]));
60672           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
60673           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60674           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60675           reveal(
60676             ".preset-search-input",
60677             helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
60678           );
60679           context.history().on("change.intro", null);
60680         }
60681       });
60682       function checkPresetSearch() {
60683         var first = context.container().select(".preset-list-item:first-child");
60684         if (first.classed("preset-man_made-storage_tank")) {
60685           reveal(
60686             first.select(".preset-list-button").node(),
60687             helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }),
60688             { duration: 300 }
60689           );
60690           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60691           context.history().on("change.intro", function() {
60692             continueTo(closeEditorTank);
60693           });
60694         }
60695       }
60696       function continueTo(nextStep) {
60697         context.container().select(".inspector-wrap").on("wheel.intro", null);
60698         context.on("enter.intro", null);
60699         context.history().on("change.intro", null);
60700         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60701         nextStep();
60702       }
60703     }
60704     function closeEditorTank() {
60705       if (!_tankID || !context.hasEntity(_tankID)) {
60706         return addTank();
60707       }
60708       var ids = context.selectedIDs();
60709       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
60710         context.enter(modeSelect(context, [_tankID]));
60711       }
60712       context.history().checkpoint("hasTank");
60713       context.on("exit.intro", function() {
60714         continueTo(rightClickTank);
60715       });
60716       timeout2(function() {
60717         reveal(
60718           ".entity-editor-pane",
60719           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
60720         );
60721       }, 500);
60722       function continueTo(nextStep) {
60723         context.on("exit.intro", null);
60724         nextStep();
60725       }
60726     }
60727     function rightClickTank() {
60728       if (!_tankID) return continueTo(addTank);
60729       context.enter(modeBrowse(context));
60730       context.history().reset("hasTank");
60731       context.map().centerEase(tank, 500);
60732       timeout2(function() {
60733         context.on("enter.intro", function(mode) {
60734           if (mode.id !== "select") return;
60735           var ids = context.selectedIDs();
60736           if (ids.length !== 1 || ids[0] !== _tankID) return;
60737           timeout2(function() {
60738             var node = selectMenuItem(context, "circularize").node();
60739             if (!node) return;
60740             continueTo(clickCircle);
60741           }, 50);
60742         });
60743         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch"));
60744         revealTank(tank, rightclickString);
60745         context.map().on("move.intro drawn.intro", function() {
60746           revealTank(tank, rightclickString, { duration: 0 });
60747         });
60748         context.history().on("change.intro", function() {
60749           continueTo(rightClickTank);
60750         });
60751       }, 600);
60752       function continueTo(nextStep) {
60753         context.on("enter.intro", null);
60754         context.map().on("move.intro drawn.intro", null);
60755         context.history().on("change.intro", null);
60756         nextStep();
60757       }
60758     }
60759     function clickCircle() {
60760       if (!_tankID) return chapter.restart();
60761       var entity = context.hasEntity(_tankID);
60762       if (!entity) return continueTo(rightClickTank);
60763       var node = selectMenuItem(context, "circularize").node();
60764       if (!node) {
60765         return continueTo(rightClickTank);
60766       }
60767       var wasChanged = false;
60768       reveal(
60769         ".edit-menu",
60770         helpHtml("intro.buildings.circle_tank"),
60771         { padding: 50 }
60772       );
60773       context.on("enter.intro", function(mode) {
60774         if (mode.id === "browse") {
60775           continueTo(rightClickTank);
60776         } else if (mode.id === "move" || mode.id === "rotate") {
60777           continueTo(retryClickCircle);
60778         }
60779       });
60780       context.map().on("move.intro", function() {
60781         var node2 = selectMenuItem(context, "circularize").node();
60782         if (!wasChanged && !node2) {
60783           return continueTo(rightClickTank);
60784         }
60785         reveal(
60786           ".edit-menu",
60787           helpHtml("intro.buildings.circle_tank"),
60788           { duration: 0, padding: 50 }
60789         );
60790       });
60791       context.history().on("change.intro", function() {
60792         wasChanged = true;
60793         context.history().on("change.intro", null);
60794         timeout2(function() {
60795           if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) {
60796             continueTo(play);
60797           } else {
60798             continueTo(retryClickCircle);
60799           }
60800         }, 500);
60801       });
60802       function continueTo(nextStep) {
60803         context.on("enter.intro", null);
60804         context.map().on("move.intro", null);
60805         context.history().on("change.intro", null);
60806         nextStep();
60807       }
60808     }
60809     function retryClickCircle() {
60810       context.enter(modeBrowse(context));
60811       revealTank(tank, helpHtml("intro.buildings.retry_circle"), {
60812         buttonText: _t.html("intro.ok"),
60813         buttonCallback: function() {
60814           continueTo(rightClickTank);
60815         }
60816       });
60817       function continueTo(nextStep) {
60818         nextStep();
60819       }
60820     }
60821     function play() {
60822       dispatch14.call("done");
60823       reveal(
60824         ".ideditor",
60825         helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }),
60826         {
60827           tooltipBox: ".intro-nav-wrap .chapter-startEditing",
60828           buttonText: _t.html("intro.ok"),
60829           buttonCallback: function() {
60830             reveal(".ideditor");
60831           }
60832         }
60833       );
60834     }
60835     chapter.enter = function() {
60836       addHouse();
60837     };
60838     chapter.exit = function() {
60839       timeouts.forEach(window.clearTimeout);
60840       context.on("enter.intro exit.intro", null);
60841       context.map().on("move.intro drawn.intro", null);
60842       context.history().on("change.intro", null);
60843       context.container().select(".inspector-wrap").on("wheel.intro", null);
60844       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60845       context.container().select(".more-fields .combobox-input").on("click.intro", null);
60846     };
60847     chapter.restart = function() {
60848       chapter.exit();
60849       chapter.enter();
60850     };
60851     return utilRebind(chapter, dispatch14, "on");
60852   }
60853
60854   // modules/ui/intro/start_editing.js
60855   function uiIntroStartEditing(context, reveal) {
60856     var dispatch14 = dispatch_default("done", "startEditing");
60857     var modalSelection = select_default2(null);
60858     var chapter = {
60859       title: "intro.startediting.title"
60860     };
60861     function showHelp() {
60862       reveal(
60863         ".map-control.help-control",
60864         helpHtml("intro.startediting.help"),
60865         {
60866           buttonText: _t.html("intro.ok"),
60867           buttonCallback: function() {
60868             shortcuts();
60869           }
60870         }
60871       );
60872     }
60873     function shortcuts() {
60874       reveal(
60875         ".map-control.help-control",
60876         helpHtml("intro.startediting.shortcuts"),
60877         {
60878           buttonText: _t.html("intro.ok"),
60879           buttonCallback: function() {
60880             showSave();
60881           }
60882         }
60883       );
60884     }
60885     function showSave() {
60886       context.container().selectAll(".shaded").remove();
60887       reveal(
60888         ".top-toolbar button.save",
60889         helpHtml("intro.startediting.save"),
60890         {
60891           buttonText: _t.html("intro.ok"),
60892           buttonCallback: function() {
60893             showStart();
60894           }
60895         }
60896       );
60897     }
60898     function showStart() {
60899       context.container().selectAll(".shaded").remove();
60900       modalSelection = uiModal(context.container());
60901       modalSelection.select(".modal").attr("class", "modal-splash modal");
60902       modalSelection.selectAll(".close").remove();
60903       var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() {
60904         modalSelection.remove();
60905       });
60906       startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough");
60907       startbutton.append("h2").call(_t.append("intro.startediting.start"));
60908       dispatch14.call("startEditing");
60909     }
60910     chapter.enter = function() {
60911       showHelp();
60912     };
60913     chapter.exit = function() {
60914       modalSelection.remove();
60915       context.container().selectAll(".shaded").remove();
60916     };
60917     return utilRebind(chapter, dispatch14, "on");
60918   }
60919
60920   // modules/ui/intro/intro.js
60921   var chapterUi = {
60922     welcome: uiIntroWelcome,
60923     navigation: uiIntroNavigation,
60924     point: uiIntroPoint,
60925     area: uiIntroArea,
60926     line: uiIntroLine,
60927     building: uiIntroBuilding,
60928     startEditing: uiIntroStartEditing
60929   };
60930   var chapterFlow = [
60931     "welcome",
60932     "navigation",
60933     "point",
60934     "area",
60935     "line",
60936     "building",
60937     "startEditing"
60938   ];
60939   function uiIntro(context) {
60940     const INTRO_IMAGERY = "EsriWorldImageryClarity";
60941     let _introGraph = {};
60942     let _currChapter;
60943     function intro(selection2) {
60944       _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => {
60945         for (let id2 in dataIntroGraph) {
60946           if (!_introGraph[id2]) {
60947             _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2]));
60948           }
60949         }
60950         selection2.call(startIntro);
60951       }).catch(function() {
60952       });
60953     }
60954     function startIntro(selection2) {
60955       context.enter(modeBrowse(context));
60956       let osm = context.connection();
60957       let history = context.history().toJSON();
60958       let hash2 = window.location.hash;
60959       let center = context.map().center();
60960       let zoom = context.map().zoom();
60961       let background = context.background().baseLayerSource();
60962       let overlays = context.background().overlayLayerSources();
60963       let opacity = context.container().selectAll(".main-map .layer-background").style("opacity");
60964       let caches = osm && osm.caches();
60965       let baseEntities = context.history().graph().base().entities;
60966       context.ui().sidebar.expand();
60967       context.container().selectAll("button.sidebar-toggle").classed("disabled", true);
60968       context.inIntro(true);
60969       if (osm) {
60970         osm.toggle(false).reset();
60971       }
60972       context.history().reset();
60973       context.history().merge(Object.values(coreGraph().load(_introGraph).entities));
60974       context.history().checkpoint("initial");
60975       let imagery = context.background().findSource(INTRO_IMAGERY);
60976       if (imagery) {
60977         context.background().baseLayerSource(imagery);
60978       } else {
60979         context.background().bing();
60980       }
60981       overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
60982       let layers = context.layers();
60983       layers.all().forEach((item) => {
60984         if (typeof item.layer.enabled === "function") {
60985           item.layer.enabled(item.id === "osm");
60986         }
60987       });
60988       context.container().selectAll(".main-map .layer-background").style("opacity", 1);
60989       let curtain = uiCurtain(context.container().node());
60990       selection2.call(curtain);
60991       corePreferences("walkthrough_started", "yes");
60992       let storedProgress = corePreferences("walkthrough_progress") || "";
60993       let progress = storedProgress.split(";").filter(Boolean);
60994       let chapters = chapterFlow.map((chapter, i3) => {
60995         let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => {
60996           buttons.filter((d2) => d2.title === s2.title).classed("finished", true);
60997           if (i3 < chapterFlow.length - 1) {
60998             const next = chapterFlow[i3 + 1];
60999             context.container().select("button.chapter-".concat(next)).classed("next", true);
61000           }
61001           progress.push(chapter);
61002           corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
61003         });
61004         return s2;
61005       });
61006       chapters[chapters.length - 1].on("startEditing", () => {
61007         progress.push("startEditing");
61008         corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
61009         let incomplete = utilArrayDifference(chapterFlow, progress);
61010         if (!incomplete.length) {
61011           corePreferences("walkthrough_completed", "yes");
61012         }
61013         curtain.remove();
61014         navwrap.remove();
61015         context.container().selectAll(".main-map .layer-background").style("opacity", opacity);
61016         context.container().selectAll("button.sidebar-toggle").classed("disabled", false);
61017         if (osm) {
61018           osm.toggle(true).reset().caches(caches);
61019         }
61020         context.history().reset().merge(Object.values(baseEntities));
61021         context.background().baseLayerSource(background);
61022         overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
61023         if (history) {
61024           context.history().fromJSON(history, false);
61025         }
61026         context.map().centerZoom(center, zoom);
61027         window.location.replace(hash2);
61028         context.inIntro(false);
61029       });
61030       let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD");
61031       navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough");
61032       let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter");
61033       let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter);
61034       buttons.append("span").html((d2) => _t.html(d2.title));
61035       buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
61036       enterChapter(null, chapters[0]);
61037       function enterChapter(d3_event, newChapter) {
61038         if (_currChapter) {
61039           _currChapter.exit();
61040         }
61041         context.enter(modeBrowse(context));
61042         _currChapter = newChapter;
61043         _currChapter.enter();
61044         buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title);
61045       }
61046     }
61047     return intro;
61048   }
61049
61050   // modules/ui/issues_info.js
61051   function uiIssuesInfo(context) {
61052     var warningsItem = {
61053       id: "warnings",
61054       count: 0,
61055       iconID: "iD-icon-alert",
61056       descriptionID: "issues.warnings_and_errors"
61057     };
61058     var resolvedItem = {
61059       id: "resolved",
61060       count: 0,
61061       iconID: "iD-icon-apply",
61062       descriptionID: "issues.user_resolved_issues"
61063     };
61064     function update(selection2) {
61065       var shownItems = [];
61066       var liveIssues = context.validator().getIssues({
61067         what: corePreferences("validate-what") || "edited",
61068         where: corePreferences("validate-where") || "all"
61069       });
61070       if (liveIssues.length) {
61071         warningsItem.count = liveIssues.length;
61072         shownItems.push(warningsItem);
61073       }
61074       if (corePreferences("validate-what") === "all") {
61075         var resolvedIssues = context.validator().getResolvedIssues();
61076         if (resolvedIssues.length) {
61077           resolvedItem.count = resolvedIssues.length;
61078           shownItems.push(resolvedItem);
61079         }
61080       }
61081       var chips = selection2.selectAll(".chip").data(shownItems, function(d2) {
61082         return d2.id;
61083       });
61084       chips.exit().remove();
61085       var enter = chips.enter().append("a").attr("class", function(d2) {
61086         return "chip " + d2.id + "-count";
61087       }).attr("href", "#").each(function(d2) {
61088         var chipSelection = select_default2(this);
61089         var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID));
61090         chipSelection.call(tooltipBehavior).on("click", function(d3_event) {
61091           d3_event.preventDefault();
61092           tooltipBehavior.hide(select_default2(this));
61093           context.ui().togglePanes(context.container().select(".map-panes .issues-pane"));
61094         });
61095         chipSelection.call(svgIcon("#" + d2.iconID));
61096       });
61097       enter.append("span").attr("class", "count");
61098       enter.merge(chips).selectAll("span.count").text(function(d2) {
61099         return d2.count.toString();
61100       });
61101     }
61102     return function(selection2) {
61103       update(selection2);
61104       context.validator().on("validated.infobox", function() {
61105         update(selection2);
61106       });
61107     };
61108   }
61109
61110   // modules/renderer/background_source.js
61111   var import_lodash4 = __toESM(require_lodash());
61112
61113   // modules/util/IntervalTasksQueue.js
61114   var IntervalTasksQueue = class {
61115     /**
61116      * Interval in milliseconds inside which only 1 task can execute.
61117      * e.g. if interval is 200ms, and 5 async tasks are unqueued,
61118      * they will complete in ~1s if not cleared
61119      * @param {number} intervalInMs
61120      */
61121     constructor(intervalInMs) {
61122       this.intervalInMs = intervalInMs;
61123       this.pendingHandles = [];
61124       this.time = 0;
61125     }
61126     enqueue(task) {
61127       let taskTimeout = this.time;
61128       this.time += this.intervalInMs;
61129       this.pendingHandles.push(setTimeout(() => {
61130         this.time -= this.intervalInMs;
61131         task();
61132       }, taskTimeout));
61133     }
61134     clear() {
61135       this.pendingHandles.forEach((timeoutHandle) => {
61136         clearTimeout(timeoutHandle);
61137       });
61138       this.pendingHandles = [];
61139       this.time = 0;
61140     }
61141   };
61142
61143   // modules/renderer/background_source.js
61144   var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
61145   var _a3;
61146   (_a3 = window.matchMedia) == null ? void 0 : _a3.call(window, "\n        (-webkit-min-device-pixel-ratio: 2), /* Safari */\n        (min-resolution: 2dppx),             /* standard */\n        (min-resolution: 192dpi)             /* fallback */\n    ").addListener(function() {
61147     isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
61148   });
61149   function localeDateString(s2) {
61150     if (!s2) return null;
61151     var options2 = { day: "numeric", month: "short", year: "numeric" };
61152     var d2 = new Date(s2);
61153     if (isNaN(d2.getTime())) return null;
61154     return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
61155   }
61156   function vintageRange(vintage) {
61157     var s2;
61158     if (vintage.start || vintage.end) {
61159       s2 = vintage.start || "?";
61160       if (vintage.start !== vintage.end) {
61161         s2 += " - " + (vintage.end || "?");
61162       }
61163     }
61164     return s2;
61165   }
61166   function rendererBackgroundSource(data) {
61167     var source = Object.assign({}, data);
61168     var _offset = [0, 0];
61169     var _name = source.name;
61170     var _description = source.description;
61171     var _best = !!source.best;
61172     var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template;
61173     source.tileSize = data.tileSize || 256;
61174     source.zoomExtent = data.zoomExtent || [0, 22];
61175     source.overzoom = data.overzoom !== false;
61176     source.offset = function(val) {
61177       if (!arguments.length) return _offset;
61178       _offset = val;
61179       return source;
61180     };
61181     source.nudge = function(val, zoomlevel) {
61182       _offset[0] += val[0] / Math.pow(2, zoomlevel);
61183       _offset[1] += val[1] / Math.pow(2, zoomlevel);
61184       return source;
61185     };
61186     source.name = function() {
61187       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
61188       return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
61189     };
61190     source.label = function() {
61191       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
61192       return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
61193     };
61194     source.hasDescription = function() {
61195       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
61196       var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text;
61197       return descriptionText !== "";
61198     };
61199     source.description = function() {
61200       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
61201       return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) });
61202     };
61203     source.best = function() {
61204       return _best;
61205     };
61206     source.area = function() {
61207       if (!data.polygon) return Number.MAX_VALUE;
61208       var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] });
61209       return isNaN(area) ? 0 : area;
61210     };
61211     source.imageryUsed = function() {
61212       return _name || source.id;
61213     };
61214     source.template = function(val) {
61215       if (!arguments.length) return _template;
61216       if (source.id === "custom" || source.id === "Bing") {
61217         _template = val;
61218       }
61219       return source;
61220     };
61221     source.url = function(coord2) {
61222       var result = _template.replace(new RegExp("#[\\s\\S]*", "u"), "");
61223       if (result === "") return result;
61224       if (!source.type || source.id === "custom") {
61225         if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
61226           source.type = "wms";
61227           source.projection = "EPSG:3857";
61228         } else if (/\{(x|y)\}/.test(result)) {
61229           source.type = "tms";
61230         } else if (/\{u\}/.test(result)) {
61231           source.type = "bing";
61232         }
61233       }
61234       if (source.type === "wms") {
61235         var tileToProjectedCoords = function(x2, y2, z2) {
61236           var zoomSize = Math.pow(2, z2);
61237           var lon = x2 / zoomSize * Math.PI * 2 - Math.PI;
61238           var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize)));
61239           switch (source.projection) {
61240             case "EPSG:4326":
61241               return {
61242                 x: lon * 180 / Math.PI,
61243                 y: lat * 180 / Math.PI
61244               };
61245             default:
61246               var mercCoords = mercatorRaw(lon, lat);
61247               return {
61248                 x: 2003750834e-2 / Math.PI * mercCoords[0],
61249                 y: 2003750834e-2 / Math.PI * mercCoords[1]
61250               };
61251           }
61252         };
61253         var tileSize = source.tileSize;
61254         var projection2 = source.projection;
61255         var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]);
61256         var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]);
61257         result = result.replace(/\{(\w+)\}/g, function(token, key) {
61258           switch (key) {
61259             case "width":
61260             case "height":
61261               return tileSize;
61262             case "proj":
61263               return projection2;
61264             case "wkid":
61265               return projection2.replace(/^EPSG:/, "");
61266             case "bbox":
61267               if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS)
61268               /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) {
61269                 return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x;
61270               } else {
61271                 return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y;
61272               }
61273             case "w":
61274               return minXmaxY.x;
61275             case "s":
61276               return maxXminY.y;
61277             case "n":
61278               return maxXminY.x;
61279             case "e":
61280               return minXmaxY.y;
61281             default:
61282               return token;
61283           }
61284         });
61285       } else if (source.type === "tms") {
61286         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" : "");
61287       } else if (source.type === "bing") {
61288         result = result.replace("{u}", function() {
61289           var u2 = "";
61290           for (var zoom = coord2[2]; zoom > 0; zoom--) {
61291             var b2 = 0;
61292             var mask = 1 << zoom - 1;
61293             if ((coord2[0] & mask) !== 0) b2++;
61294             if ((coord2[1] & mask) !== 0) b2 += 2;
61295             u2 += b2.toString();
61296           }
61297           return u2;
61298         });
61299       }
61300       result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) {
61301         var subdomains = r2.split(",");
61302         return subdomains[(coord2[0] + coord2[1]) % subdomains.length];
61303       });
61304       return result;
61305     };
61306     source.validZoom = function(z2, underzoom) {
61307       if (underzoom === void 0) underzoom = 0;
61308       return source.zoomExtent[0] - underzoom <= z2 && (source.overzoom || source.zoomExtent[1] > z2);
61309     };
61310     source.isLocatorOverlay = function() {
61311       return source.id === "mapbox_locator_overlay";
61312     };
61313     source.isHidden = function() {
61314       return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage";
61315     };
61316     source.copyrightNotices = function() {
61317     };
61318     source.getMetadata = function(center, tileCoord, callback) {
61319       var vintage = {
61320         start: localeDateString(source.startDate),
61321         end: localeDateString(source.endDate)
61322       };
61323       vintage.range = vintageRange(vintage);
61324       var metadata = { vintage };
61325       callback(null, metadata);
61326     };
61327     return source;
61328   }
61329   rendererBackgroundSource.Bing = function(data, dispatch14) {
61330     data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z";
61331     var bing = rendererBackgroundSource(data);
61332     var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
61333     const strictParam = "n";
61334     var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key;
61335     var cache = {};
61336     var inflight = {};
61337     var providers = [];
61338     var taskQueue = new IntervalTasksQueue(250);
61339     var metadataLastZoom = -1;
61340     json_default(url).then(function(json) {
61341       let imageryResource = json.resourceSets[0].resources[0];
61342       let template = imageryResource.imageUrl;
61343       let subDomains = imageryResource.imageUrlSubdomains;
61344       let subDomainNumbers = subDomains.map((subDomain) => {
61345         return subDomain.substring(1);
61346       }).join(",");
61347       template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}");
61348       if (!new URLSearchParams(template).has(strictParam)) {
61349         template += "&".concat(strictParam, "=z");
61350       }
61351       bing.template(template);
61352       providers = imageryResource.imageryProviders.map(function(provider) {
61353         return {
61354           attribution: provider.attribution,
61355           areas: provider.coverageAreas.map(function(area) {
61356             return {
61357               zoom: [area.zoomMin, area.zoomMax],
61358               extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
61359             };
61360           })
61361         };
61362       });
61363       dispatch14.call("change");
61364     }).catch(function() {
61365     });
61366     bing.copyrightNotices = function(zoom, extent) {
61367       zoom = Math.min(zoom, 21);
61368       return providers.filter(function(provider) {
61369         return provider.areas.some(function(area) {
61370           return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom;
61371         });
61372       }).map(function(provider) {
61373         return provider.attribution;
61374       }).join(", ");
61375     };
61376     bing.getMetadata = function(center, tileCoord, callback) {
61377       var tileID = tileCoord.slice(0, 3).join("/");
61378       var zoom = Math.min(tileCoord[2], 21);
61379       var centerPoint = center[1] + "," + center[0];
61380       var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key;
61381       if (inflight[tileID]) return;
61382       if (!cache[tileID]) {
61383         cache[tileID] = {};
61384       }
61385       if (cache[tileID] && cache[tileID].metadata) {
61386         return callback(null, cache[tileID].metadata);
61387       }
61388       inflight[tileID] = true;
61389       if (metadataLastZoom !== tileCoord[2]) {
61390         metadataLastZoom = tileCoord[2];
61391         taskQueue.clear();
61392       }
61393       taskQueue.enqueue(() => {
61394         json_default(url2).then(function(result) {
61395           delete inflight[tileID];
61396           if (!result) {
61397             throw new Error("Unknown Error");
61398           }
61399           var vintage = {
61400             start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
61401             end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
61402           };
61403           vintage.range = vintageRange(vintage);
61404           var metadata = { vintage };
61405           cache[tileID].metadata = metadata;
61406           if (callback) callback(null, metadata);
61407         }).catch(function(err) {
61408           delete inflight[tileID];
61409           if (callback) callback(err.message);
61410         });
61411       });
61412     };
61413     bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details";
61414     return bing;
61415   };
61416   rendererBackgroundSource.Esri = function(data) {
61417     if (data.template.match(/blankTile/) === null) {
61418       data.template = data.template + "?blankTile=false";
61419     }
61420     var esri = rendererBackgroundSource(data);
61421     var cache = {};
61422     var inflight = {};
61423     var _prevCenter;
61424     esri.fetchTilemap = function(center) {
61425       if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3) return;
61426       _prevCenter = center;
61427       var z2 = 20;
61428       var dummyUrl = esri.url([1, 2, 3]);
61429       var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2));
61430       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));
61431       var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8";
61432       json_default(tilemapUrl).then(function(tilemap) {
61433         if (!tilemap) {
61434           throw new Error("Unknown Error");
61435         }
61436         var hasTiles = true;
61437         for (var i3 = 0; i3 < tilemap.data.length; i3++) {
61438           if (!tilemap.data[i3]) {
61439             hasTiles = false;
61440             break;
61441           }
61442         }
61443         esri.zoomExtent[1] = hasTiles ? 22 : 19;
61444       }).catch(function() {
61445       });
61446     };
61447     esri.getMetadata = function(center, tileCoord, callback) {
61448       if (esri.id !== "EsriWorldImagery") {
61449         return callback(null, {});
61450       }
61451       var tileID = tileCoord.slice(0, 3).join("/");
61452       var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]);
61453       var centerPoint = center[0] + "," + center[1];
61454       var unknown = _t("info_panels.background.unknown");
61455       var vintage = {};
61456       var metadata = {};
61457       if (inflight[tileID]) return;
61458       var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query";
61459       url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json";
61460       if (!cache[tileID]) {
61461         cache[tileID] = {};
61462       }
61463       if (cache[tileID] && cache[tileID].metadata) {
61464         return callback(null, cache[tileID].metadata);
61465       }
61466       inflight[tileID] = true;
61467       json_default(url).then(function(result) {
61468         delete inflight[tileID];
61469         result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0];
61470         if (!result) {
61471           throw new Error("Unknown Error");
61472         } else if (result.features && result.features.length < 1) {
61473           throw new Error("No Results");
61474         } else if (result.error && result.error.message) {
61475           throw new Error(result.error.message);
61476         }
61477         var captureDate = localeDateString(result.SRC_DATE2);
61478         vintage = {
61479           start: captureDate,
61480           end: captureDate,
61481           range: captureDate
61482         };
61483         metadata = {
61484           vintage,
61485           source: clean2(result.NICE_NAME),
61486           description: clean2(result.NICE_DESC),
61487           resolution: clean2(+Number(result.SRC_RES).toFixed(4)),
61488           accuracy: clean2(+Number(result.SRC_ACC).toFixed(4))
61489         };
61490         if (isFinite(metadata.resolution)) {
61491           metadata.resolution += " m";
61492         }
61493         if (isFinite(metadata.accuracy)) {
61494           metadata.accuracy += " m";
61495         }
61496         cache[tileID].metadata = metadata;
61497         if (callback) callback(null, metadata);
61498       }).catch(function(err) {
61499         delete inflight[tileID];
61500         if (callback) callback(err.message);
61501       });
61502       function clean2(val) {
61503         return String(val).trim() || unknown;
61504       }
61505     };
61506     return esri;
61507   };
61508   rendererBackgroundSource.None = function() {
61509     var source = rendererBackgroundSource({ id: "none", template: "" });
61510     source.name = function() {
61511       return _t("background.none");
61512     };
61513     source.label = function() {
61514       return _t.append("background.none");
61515     };
61516     source.imageryUsed = function() {
61517       return null;
61518     };
61519     source.area = function() {
61520       return -1;
61521     };
61522     return source;
61523   };
61524   rendererBackgroundSource.Custom = function(template) {
61525     var source = rendererBackgroundSource({ id: "custom", template });
61526     source.name = function() {
61527       return _t("background.custom");
61528     };
61529     source.label = function() {
61530       return _t.append("background.custom");
61531     };
61532     source.imageryUsed = function() {
61533       var cleaned = source.template();
61534       if (cleaned.indexOf("?") !== -1) {
61535         var parts = cleaned.split("?", 2);
61536         var qs = utilStringQs(parts[1]);
61537         ["access_token", "connectId", "token", "Signature"].forEach(function(param) {
61538           if (qs[param]) {
61539             qs[param] = "{apikey}";
61540           }
61541         });
61542         cleaned = parts[0] + "?" + utilQsString(qs, true);
61543       }
61544       cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}");
61545       return "Custom (" + cleaned + " )";
61546     };
61547     source.area = function() {
61548       return -2;
61549     };
61550     return source;
61551   };
61552
61553   // node_modules/@turf/helpers/dist/esm/index.js
61554   var earthRadius = 63710088e-1;
61555   var factors = {
61556     centimeters: earthRadius * 100,
61557     centimetres: earthRadius * 100,
61558     degrees: 360 / (2 * Math.PI),
61559     feet: earthRadius * 3.28084,
61560     inches: earthRadius * 39.37,
61561     kilometers: earthRadius / 1e3,
61562     kilometres: earthRadius / 1e3,
61563     meters: earthRadius,
61564     metres: earthRadius,
61565     miles: earthRadius / 1609.344,
61566     millimeters: earthRadius * 1e3,
61567     millimetres: earthRadius * 1e3,
61568     nauticalmiles: earthRadius / 1852,
61569     radians: 1,
61570     yards: earthRadius * 1.0936
61571   };
61572   function feature2(geom, properties, options2 = {}) {
61573     const feat = { type: "Feature" };
61574     if (options2.id === 0 || options2.id) {
61575       feat.id = options2.id;
61576     }
61577     if (options2.bbox) {
61578       feat.bbox = options2.bbox;
61579     }
61580     feat.properties = properties || {};
61581     feat.geometry = geom;
61582     return feat;
61583   }
61584   function polygon(coordinates, properties, options2 = {}) {
61585     for (const ring of coordinates) {
61586       if (ring.length < 4) {
61587         throw new Error(
61588           "Each LinearRing of a Polygon must have 4 or more Positions."
61589         );
61590       }
61591       if (ring[ring.length - 1].length !== ring[0].length) {
61592         throw new Error("First and last Position are not equivalent.");
61593       }
61594       for (let j2 = 0; j2 < ring[ring.length - 1].length; j2++) {
61595         if (ring[ring.length - 1][j2] !== ring[0][j2]) {
61596           throw new Error("First and last Position are not equivalent.");
61597         }
61598       }
61599     }
61600     const geom = {
61601       type: "Polygon",
61602       coordinates
61603     };
61604     return feature2(geom, properties, options2);
61605   }
61606   function lineString(coordinates, properties, options2 = {}) {
61607     if (coordinates.length < 2) {
61608       throw new Error("coordinates must be an array of two or more positions");
61609     }
61610     const geom = {
61611       type: "LineString",
61612       coordinates
61613     };
61614     return feature2(geom, properties, options2);
61615   }
61616   function multiLineString(coordinates, properties, options2 = {}) {
61617     const geom = {
61618       type: "MultiLineString",
61619       coordinates
61620     };
61621     return feature2(geom, properties, options2);
61622   }
61623   function multiPolygon(coordinates, properties, options2 = {}) {
61624     const geom = {
61625       type: "MultiPolygon",
61626       coordinates
61627     };
61628     return feature2(geom, properties, options2);
61629   }
61630
61631   // node_modules/@turf/invariant/dist/esm/index.js
61632   function getGeom(geojson) {
61633     if (geojson.type === "Feature") {
61634       return geojson.geometry;
61635     }
61636     return geojson;
61637   }
61638
61639   // node_modules/@turf/bbox-clip/dist/esm/index.js
61640   function lineclip(points, bbox2, result) {
61641     var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode;
61642     let a2;
61643     let b2;
61644     if (!result) result = [];
61645     for (i3 = 1; i3 < len; i3++) {
61646       a2 = points[i3 - 1];
61647       b2 = points[i3];
61648       codeB = lastCode = bitCode(b2, bbox2);
61649       while (true) {
61650         if (!(codeA | codeB)) {
61651           part.push(a2);
61652           if (codeB !== lastCode) {
61653             part.push(b2);
61654             if (i3 < len - 1) {
61655               result.push(part);
61656               part = [];
61657             }
61658           } else if (i3 === len - 1) {
61659             part.push(b2);
61660           }
61661           break;
61662         } else if (codeA & codeB) {
61663           break;
61664         } else if (codeA) {
61665           a2 = intersect(a2, b2, codeA, bbox2);
61666           codeA = bitCode(a2, bbox2);
61667         } else {
61668           b2 = intersect(a2, b2, codeB, bbox2);
61669           codeB = bitCode(b2, bbox2);
61670         }
61671       }
61672       codeA = lastCode;
61673     }
61674     if (part.length) result.push(part);
61675     return result;
61676   }
61677   function polygonclip(points, bbox2) {
61678     var result, edge, prev, prevInside, i3, p2, inside;
61679     for (edge = 1; edge <= 8; edge *= 2) {
61680       result = [];
61681       prev = points[points.length - 1];
61682       prevInside = !(bitCode(prev, bbox2) & edge);
61683       for (i3 = 0; i3 < points.length; i3++) {
61684         p2 = points[i3];
61685         inside = !(bitCode(p2, bbox2) & edge);
61686         if (inside !== prevInside) result.push(intersect(prev, p2, edge, bbox2));
61687         if (inside) result.push(p2);
61688         prev = p2;
61689         prevInside = inside;
61690       }
61691       points = result;
61692       if (!points.length) break;
61693     }
61694     return result;
61695   }
61696   function intersect(a2, b2, edge, bbox2) {
61697     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;
61698   }
61699   function bitCode(p2, bbox2) {
61700     var code = 0;
61701     if (p2[0] < bbox2[0]) code |= 1;
61702     else if (p2[0] > bbox2[2]) code |= 2;
61703     if (p2[1] < bbox2[1]) code |= 4;
61704     else if (p2[1] > bbox2[3]) code |= 8;
61705     return code;
61706   }
61707   function bboxClip(feature3, bbox2) {
61708     const geom = getGeom(feature3);
61709     const type2 = geom.type;
61710     const properties = feature3.type === "Feature" ? feature3.properties : {};
61711     let coords = geom.coordinates;
61712     switch (type2) {
61713       case "LineString":
61714       case "MultiLineString": {
61715         const lines = [];
61716         if (type2 === "LineString") {
61717           coords = [coords];
61718         }
61719         coords.forEach((line) => {
61720           lineclip(line, bbox2, lines);
61721         });
61722         if (lines.length === 1) {
61723           return lineString(lines[0], properties);
61724         }
61725         return multiLineString(lines, properties);
61726       }
61727       case "Polygon":
61728         return polygon(clipPolygon(coords, bbox2), properties);
61729       case "MultiPolygon":
61730         return multiPolygon(
61731           coords.map((poly) => {
61732             return clipPolygon(poly, bbox2);
61733           }),
61734           properties
61735         );
61736       default:
61737         throw new Error("geometry " + type2 + " not supported");
61738     }
61739   }
61740   function clipPolygon(rings, bbox2) {
61741     const outRings = [];
61742     for (const ring of rings) {
61743       const clipped = polygonclip(ring, bbox2);
61744       if (clipped.length > 0) {
61745         if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
61746           clipped.push(clipped[0]);
61747         }
61748         if (clipped.length >= 4) {
61749           outRings.push(clipped);
61750         }
61751       }
61752     }
61753     return outRings;
61754   }
61755   var turf_bbox_clip_default = bboxClip;
61756
61757   // node_modules/@turf/meta/dist/esm/index.js
61758   function coordEach(geojson, callback, excludeWrapCoord) {
61759     if (geojson === null) return;
61760     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;
61761     for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
61762       geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
61763       isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
61764       stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
61765       for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
61766         var multiFeatureIndex = 0;
61767         var geometryIndex = 0;
61768         geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
61769         if (geometry === null) continue;
61770         coords = geometry.coordinates;
61771         var geomType = geometry.type;
61772         wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
61773         switch (geomType) {
61774           case null:
61775             break;
61776           case "Point":
61777             if (callback(
61778               coords,
61779               coordIndex,
61780               featureIndex,
61781               multiFeatureIndex,
61782               geometryIndex
61783             ) === false)
61784               return false;
61785             coordIndex++;
61786             multiFeatureIndex++;
61787             break;
61788           case "LineString":
61789           case "MultiPoint":
61790             for (j2 = 0; j2 < coords.length; j2++) {
61791               if (callback(
61792                 coords[j2],
61793                 coordIndex,
61794                 featureIndex,
61795                 multiFeatureIndex,
61796                 geometryIndex
61797               ) === false)
61798                 return false;
61799               coordIndex++;
61800               if (geomType === "MultiPoint") multiFeatureIndex++;
61801             }
61802             if (geomType === "LineString") multiFeatureIndex++;
61803             break;
61804           case "Polygon":
61805           case "MultiLineString":
61806             for (j2 = 0; j2 < coords.length; j2++) {
61807               for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) {
61808                 if (callback(
61809                   coords[j2][k2],
61810                   coordIndex,
61811                   featureIndex,
61812                   multiFeatureIndex,
61813                   geometryIndex
61814                 ) === false)
61815                   return false;
61816                 coordIndex++;
61817               }
61818               if (geomType === "MultiLineString") multiFeatureIndex++;
61819               if (geomType === "Polygon") geometryIndex++;
61820             }
61821             if (geomType === "Polygon") multiFeatureIndex++;
61822             break;
61823           case "MultiPolygon":
61824             for (j2 = 0; j2 < coords.length; j2++) {
61825               geometryIndex = 0;
61826               for (k2 = 0; k2 < coords[j2].length; k2++) {
61827                 for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) {
61828                   if (callback(
61829                     coords[j2][k2][l2],
61830                     coordIndex,
61831                     featureIndex,
61832                     multiFeatureIndex,
61833                     geometryIndex
61834                   ) === false)
61835                     return false;
61836                   coordIndex++;
61837                 }
61838                 geometryIndex++;
61839               }
61840               multiFeatureIndex++;
61841             }
61842             break;
61843           case "GeometryCollection":
61844             for (j2 = 0; j2 < geometry.geometries.length; j2++)
61845               if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false)
61846                 return false;
61847             break;
61848           default:
61849             throw new Error("Unknown Geometry Type");
61850         }
61851       }
61852     }
61853   }
61854
61855   // node_modules/@turf/bbox/dist/esm/index.js
61856   function bbox(geojson, options2 = {}) {
61857     if (geojson.bbox != null && true !== options2.recompute) {
61858       return geojson.bbox;
61859     }
61860     const result = [Infinity, Infinity, -Infinity, -Infinity];
61861     coordEach(geojson, (coord2) => {
61862       if (result[0] > coord2[0]) {
61863         result[0] = coord2[0];
61864       }
61865       if (result[1] > coord2[1]) {
61866         result[1] = coord2[1];
61867       }
61868       if (result[2] < coord2[0]) {
61869         result[2] = coord2[0];
61870       }
61871       if (result[3] < coord2[1]) {
61872         result[3] = coord2[1];
61873       }
61874     });
61875     return result;
61876   }
61877   var turf_bbox_default = bbox;
61878
61879   // modules/renderer/background.js
61880   var import_which_polygon3 = __toESM(require_which_polygon());
61881
61882   // modules/renderer/tile_layer.js
61883   function rendererTileLayer(context) {
61884     var transformProp = utilPrefixCSSProperty("Transform");
61885     var tiler8 = utilTiler();
61886     var _tileSize = 256;
61887     var _projection;
61888     var _cache5 = {};
61889     var _tileOrigin;
61890     var _zoom;
61891     var _source;
61892     var _underzoom = 0;
61893     function tileSizeAtZoom(d2, z2) {
61894       return d2.tileSize * Math.pow(2, z2 - d2[2]) / d2.tileSize;
61895     }
61896     function atZoom(t2, distance) {
61897       var power = Math.pow(2, distance);
61898       return [
61899         Math.floor(t2[0] * power),
61900         Math.floor(t2[1] * power),
61901         t2[2] + distance
61902       ];
61903     }
61904     function lookUp(d2) {
61905       for (var up = -1; up > -d2[2]; up--) {
61906         var tile = atZoom(d2, up);
61907         if (_cache5[_source.url(tile)] !== false) {
61908           return tile;
61909         }
61910       }
61911     }
61912     function uniqueBy(a2, n3) {
61913       var o2 = [];
61914       var seen = {};
61915       for (var i3 = 0; i3 < a2.length; i3++) {
61916         if (seen[a2[i3][n3]] === void 0) {
61917           o2.push(a2[i3]);
61918           seen[a2[i3][n3]] = true;
61919         }
61920       }
61921       return o2;
61922     }
61923     function addSource(d2) {
61924       d2.url = _source.url(d2);
61925       d2.tileSize = _tileSize;
61926       d2.source = _source;
61927       return d2;
61928     }
61929     function background(selection2) {
61930       _zoom = geoScaleToZoom(_projection.scale(), _tileSize);
61931       var pixelOffset;
61932       if (_source) {
61933         pixelOffset = [
61934           _source.offset()[0] * Math.pow(2, _zoom),
61935           _source.offset()[1] * Math.pow(2, _zoom)
61936         ];
61937       } else {
61938         pixelOffset = [0, 0];
61939       }
61940       tiler8.scale(_projection.scale() * 2 * Math.PI).translate([
61941         _projection.translate()[0] + pixelOffset[0],
61942         _projection.translate()[1] + pixelOffset[1]
61943       ]);
61944       _tileOrigin = [
61945         _projection.scale() * Math.PI - _projection.translate()[0],
61946         _projection.scale() * Math.PI - _projection.translate()[1]
61947       ];
61948       render(selection2);
61949     }
61950     function render(selection2) {
61951       if (!_source) return;
61952       var requests = [];
61953       var showDebug = context.getDebug("tile") && !_source.overlay;
61954       if (_source.validZoom(_zoom, _underzoom)) {
61955         tiler8.skipNullIsland(!!_source.overlay);
61956         tiler8().forEach(function(d2) {
61957           addSource(d2);
61958           if (d2.url === "") return;
61959           if (typeof d2.url !== "string") return;
61960           requests.push(d2);
61961           if (_cache5[d2.url] === false && lookUp(d2)) {
61962             requests.push(addSource(lookUp(d2)));
61963           }
61964         });
61965         requests = uniqueBy(requests, "url").filter(function(r2) {
61966           return _cache5[r2.url] !== false;
61967         });
61968       }
61969       function load(d3_event, d2) {
61970         _cache5[d2.url] = true;
61971         select_default2(this).on("error", null).on("load", null);
61972         render(selection2);
61973       }
61974       function error(d3_event, d2) {
61975         _cache5[d2.url] = false;
61976         select_default2(this).on("error", null).on("load", null).remove();
61977         render(selection2);
61978       }
61979       function imageTransform(d2) {
61980         var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]);
61981         var scale = tileSizeAtZoom(d2, _zoom);
61982         return "translate(" + ((d2[0] * ts + d2.source.offset()[0] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[0]) + "px," + ((d2[1] * ts + d2.source.offset()[1] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[1]) + "px) scale(" + scale * _tileSize / d2.tileSize + "," + scale * _tileSize / d2.tileSize + ")";
61983       }
61984       function tileCenter(d2) {
61985         var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]);
61986         return [
61987           d2[0] * ts - _tileOrigin[0] + ts / 2,
61988           d2[1] * ts - _tileOrigin[1] + ts / 2
61989         ];
61990       }
61991       function debugTransform(d2) {
61992         var coord2 = tileCenter(d2);
61993         return "translate(" + coord2[0] + "px," + coord2[1] + "px)";
61994       }
61995       var dims = tiler8.size();
61996       var mapCenter = [dims[0] / 2, dims[1] / 2];
61997       var minDist = Math.max(dims[0], dims[1]);
61998       var nearCenter;
61999       requests.forEach(function(d2) {
62000         var c2 = tileCenter(d2);
62001         var dist = geoVecLength(c2, mapCenter);
62002         if (dist < minDist) {
62003           minDist = dist;
62004           nearCenter = d2;
62005         }
62006       });
62007       var image = selection2.selectAll("img").data(requests, function(d2) {
62008         return d2.url;
62009       });
62010       image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).on("transitionend", function() {
62011         const tile = select_default2(this);
62012         if (tile.classed("tile-removing")) {
62013           tile.remove();
62014         }
62015       });
62016       image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) {
62017         return d2.url;
62018       }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) {
62019         return d2 === nearCenter;
62020       }).sort((a2, b2) => a2[2] - b2[2]);
62021       var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) {
62022         return d2.url;
62023       });
62024       debug2.exit().remove();
62025       if (showDebug) {
62026         var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug");
62027         debugEnter.append("div").attr("class", "tile-label-debug-coord");
62028         debugEnter.append("div").attr("class", "tile-label-debug-vintage");
62029         debug2 = debug2.merge(debugEnter);
62030         debug2.style(transformProp, debugTransform);
62031         debug2.selectAll(".tile-label-debug-coord").text(function(d2) {
62032           return d2[2] + " / " + d2[0] + " / " + d2[1];
62033         });
62034         debug2.selectAll(".tile-label-debug-vintage").each(function(d2) {
62035           var span = select_default2(this);
62036           var center = context.projection.invert(tileCenter(d2));
62037           _source.getMetadata(center, d2, function(err, result) {
62038             if (result && result.vintage && result.vintage.range) {
62039               span.text(result.vintage.range);
62040             } else {
62041               span.text("");
62042               span.call(_t.append("info_panels.background.vintage"));
62043               span.append("span").text(": ");
62044               span.call(_t.append("info_panels.background.unknown"));
62045             }
62046           });
62047         });
62048       }
62049     }
62050     background.projection = function(val) {
62051       if (!arguments.length) return _projection;
62052       _projection = val;
62053       return background;
62054     };
62055     background.dimensions = function(val) {
62056       if (!arguments.length) return tiler8.size();
62057       tiler8.size(val);
62058       return background;
62059     };
62060     background.source = function(val) {
62061       if (!arguments.length) return _source;
62062       _source = val;
62063       _tileSize = _source.tileSize;
62064       _cache5 = {};
62065       tiler8.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
62066       return background;
62067     };
62068     background.underzoom = function(amount) {
62069       if (!arguments.length) return _underzoom;
62070       _underzoom = amount;
62071       return background;
62072     };
62073     return background;
62074   }
62075
62076   // modules/renderer/background.js
62077   var _imageryIndex = null;
62078   function rendererBackground(context) {
62079     const dispatch14 = dispatch_default("change");
62080     const baseLayer = rendererTileLayer(context).projection(context.projection);
62081     let _checkedBlocklists = [];
62082     let _isValid = true;
62083     let _overlayLayers = [];
62084     let _brightness = 1;
62085     let _contrast = 1;
62086     let _saturation = 1;
62087     let _sharpness = 1;
62088     function ensureImageryIndex() {
62089       return _mainFileFetcher.get("imagery").then((sources) => {
62090         if (_imageryIndex) return _imageryIndex;
62091         _imageryIndex = {
62092           imagery: sources,
62093           features: {}
62094         };
62095         const features = sources.map((source) => {
62096           if (!source.polygon) return null;
62097           const rings = source.polygon.map((ring) => [ring]);
62098           const feature3 = {
62099             type: "Feature",
62100             properties: { id: source.id },
62101             geometry: { type: "MultiPolygon", coordinates: rings }
62102           };
62103           _imageryIndex.features[source.id] = feature3;
62104           return feature3;
62105         }).filter(Boolean);
62106         _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features });
62107         _imageryIndex.backgrounds = sources.map((source) => {
62108           if (source.type === "bing") {
62109             return rendererBackgroundSource.Bing(source, dispatch14);
62110           } else if (/^EsriWorldImagery/.test(source.id)) {
62111             return rendererBackgroundSource.Esri(source);
62112           } else {
62113             return rendererBackgroundSource(source);
62114           }
62115         });
62116         _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None());
62117         let template = corePreferences("background-custom-template") || "";
62118         const custom = rendererBackgroundSource.Custom(template);
62119         _imageryIndex.backgrounds.unshift(custom);
62120         return _imageryIndex;
62121       });
62122     }
62123     function background(selection2) {
62124       const currSource = baseLayer.source();
62125       if (context.map().zoom() > 18) {
62126         if (currSource && /^EsriWorldImagery/.test(currSource.id)) {
62127           const center = context.map().center();
62128           currSource.fetchTilemap(center);
62129         }
62130       }
62131       const sources = background.sources(context.map().extent());
62132       const wasValid = _isValid;
62133       _isValid = !!sources.filter((d2) => d2 === currSource).length;
62134       if (wasValid !== _isValid) {
62135         background.updateImagery();
62136       }
62137       let baseFilter = "";
62138       if (_brightness !== 1) {
62139         baseFilter += " brightness(".concat(_brightness, ")");
62140       }
62141       if (_contrast !== 1) {
62142         baseFilter += " contrast(".concat(_contrast, ")");
62143       }
62144       if (_saturation !== 1) {
62145         baseFilter += " saturate(".concat(_saturation, ")");
62146       }
62147       if (_sharpness < 1) {
62148         const blur = number_default(0.5, 5)(1 - _sharpness);
62149         baseFilter += " blur(".concat(blur, "px)");
62150       }
62151       let base = selection2.selectAll(".layer-background").data([0]);
62152       base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base);
62153       base.style("filter", baseFilter || null);
62154       let imagery = base.selectAll(".layer-imagery").data([0]);
62155       imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer);
62156       let maskFilter = "";
62157       let mixBlendMode = "";
62158       if (_sharpness > 1) {
62159         mixBlendMode = "overlay";
62160         maskFilter = "saturate(0) blur(3px) invert(1)";
62161         let contrast = _sharpness - 1;
62162         maskFilter += " contrast(".concat(contrast, ")");
62163         let brightness = number_default(1, 0.85)(_sharpness - 1);
62164         maskFilter += " brightness(".concat(brightness, ")");
62165       }
62166       let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []);
62167       mask.exit().remove();
62168       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);
62169       let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name());
62170       overlays.exit().remove();
62171       overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer));
62172     }
62173     background.updateImagery = function() {
62174       let currSource = baseLayer.source();
62175       if (context.inIntro() || !currSource) return;
62176       let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(",");
62177       const meters = geoOffsetToMeters(currSource.offset());
62178       const EPSILON = 0.01;
62179       const x2 = +meters[0].toFixed(2);
62180       const y2 = +meters[1].toFixed(2);
62181       let hash2 = utilStringQs(window.location.hash);
62182       let id2 = currSource.id;
62183       if (id2 === "custom") {
62184         id2 = "custom:".concat(currSource.template());
62185       }
62186       if (id2) {
62187         hash2.background = id2;
62188       } else {
62189         delete hash2.background;
62190       }
62191       if (o2) {
62192         hash2.overlays = o2;
62193       } else {
62194         delete hash2.overlays;
62195       }
62196       if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) {
62197         hash2.offset = "".concat(x2, ",").concat(y2);
62198       } else {
62199         delete hash2.offset;
62200       }
62201       if (!window.mocha) {
62202         window.location.replace("#" + utilQsString(hash2, true));
62203       }
62204       let imageryUsed = [];
62205       let photoOverlaysUsed = [];
62206       const currUsed = currSource.imageryUsed();
62207       if (currUsed && _isValid) {
62208         imageryUsed.push(currUsed);
62209       }
62210       _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed()));
62211       const dataLayer = context.layers().layer("data");
62212       if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) {
62213         imageryUsed.push(dataLayer.getSrc());
62214       }
62215       const photoOverlayLayers = {
62216         streetside: "Bing Streetside",
62217         mapillary: "Mapillary Images",
62218         "mapillary-map-features": "Mapillary Map Features",
62219         "mapillary-signs": "Mapillary Signs",
62220         kartaview: "KartaView Images",
62221         vegbilder: "Norwegian Road Administration Images",
62222         mapilio: "Mapilio Images",
62223         panoramax: "Panoramax Images"
62224       };
62225       for (let layerID in photoOverlayLayers) {
62226         const layer = context.layers().layer(layerID);
62227         if (layer && layer.enabled()) {
62228           photoOverlaysUsed.push(layerID);
62229           imageryUsed.push(photoOverlayLayers[layerID]);
62230         }
62231       }
62232       context.history().imageryUsed(imageryUsed);
62233       context.history().photoOverlaysUsed(photoOverlaysUsed);
62234     };
62235     background.sources = (extent, zoom, includeCurrent) => {
62236       if (!_imageryIndex) return [];
62237       let visible = {};
62238       (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true);
62239       const currSource = baseLayer.source();
62240       const osm = context.connection();
62241       const blocklists = osm && osm.imageryBlocklists() || [];
62242       const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]);
62243       if (blocklistChanged) {
62244         _imageryIndex.backgrounds.forEach((source) => {
62245           source.isBlocked = blocklists.some((regex) => regex.test(source.template()));
62246         });
62247         _checkedBlocklists = blocklists.map((regex) => String(regex));
62248       }
62249       return _imageryIndex.backgrounds.filter((source) => {
62250         if (includeCurrent && currSource === source) return true;
62251         if (source.isBlocked) return false;
62252         if (!source.polygon) return true;
62253         if (zoom && zoom < 6) return false;
62254         return visible[source.id];
62255       });
62256     };
62257     background.dimensions = (val) => {
62258       if (!val) return;
62259       baseLayer.dimensions(val);
62260       _overlayLayers.forEach((layer) => layer.dimensions(val));
62261     };
62262     background.baseLayerSource = function(d2) {
62263       if (!arguments.length) return baseLayer.source();
62264       const osm = context.connection();
62265       if (!osm) return background;
62266       const blocklists = osm.imageryBlocklists();
62267       const template = d2.template();
62268       let fail = false;
62269       let tested = 0;
62270       let regex;
62271       for (let i3 = 0; i3 < blocklists.length; i3++) {
62272         regex = blocklists[i3];
62273         fail = regex.test(template);
62274         tested++;
62275         if (fail) break;
62276       }
62277       if (!tested) {
62278         regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
62279         fail = regex.test(template);
62280       }
62281       baseLayer.source(!fail ? d2 : background.findSource("none"));
62282       dispatch14.call("change");
62283       background.updateImagery();
62284       return background;
62285     };
62286     background.findSource = (id2) => {
62287       if (!id2 || !_imageryIndex) return null;
62288       return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2);
62289     };
62290     background.bing = () => {
62291       background.baseLayerSource(background.findSource("Bing"));
62292     };
62293     background.showsLayer = (d2) => {
62294       const currSource = baseLayer.source();
62295       if (!d2 || !currSource) return false;
62296       return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id);
62297     };
62298     background.overlayLayerSources = () => {
62299       return _overlayLayers.map((layer) => layer.source());
62300     };
62301     background.toggleOverlayLayer = (d2) => {
62302       let layer;
62303       for (let i3 = 0; i3 < _overlayLayers.length; i3++) {
62304         layer = _overlayLayers[i3];
62305         if (layer.source() === d2) {
62306           _overlayLayers.splice(i3, 1);
62307           dispatch14.call("change");
62308           background.updateImagery();
62309           return;
62310         }
62311       }
62312       layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions(
62313         baseLayer.dimensions()
62314       );
62315       _overlayLayers.push(layer);
62316       dispatch14.call("change");
62317       background.updateImagery();
62318     };
62319     background.nudge = (d2, zoom) => {
62320       const currSource = baseLayer.source();
62321       if (currSource) {
62322         currSource.nudge(d2, zoom);
62323         dispatch14.call("change");
62324         background.updateImagery();
62325       }
62326       return background;
62327     };
62328     background.offset = function(d2) {
62329       const currSource = baseLayer.source();
62330       if (!arguments.length) {
62331         return currSource && currSource.offset() || [0, 0];
62332       }
62333       if (currSource) {
62334         currSource.offset(d2);
62335         dispatch14.call("change");
62336         background.updateImagery();
62337       }
62338       return background;
62339     };
62340     background.brightness = function(d2) {
62341       if (!arguments.length) return _brightness;
62342       _brightness = d2;
62343       if (context.mode()) dispatch14.call("change");
62344       return background;
62345     };
62346     background.contrast = function(d2) {
62347       if (!arguments.length) return _contrast;
62348       _contrast = d2;
62349       if (context.mode()) dispatch14.call("change");
62350       return background;
62351     };
62352     background.saturation = function(d2) {
62353       if (!arguments.length) return _saturation;
62354       _saturation = d2;
62355       if (context.mode()) dispatch14.call("change");
62356       return background;
62357     };
62358     background.sharpness = function(d2) {
62359       if (!arguments.length) return _sharpness;
62360       _sharpness = d2;
62361       if (context.mode()) dispatch14.call("change");
62362       return background;
62363     };
62364     let _loadPromise;
62365     background.ensureLoaded = () => {
62366       if (_loadPromise) return _loadPromise;
62367       return _loadPromise = ensureImageryIndex();
62368     };
62369     background.init = () => {
62370       const loadPromise = background.ensureLoaded();
62371       const hash2 = utilStringQs(window.location.hash);
62372       const requestedBackground = hash2.background || hash2.layer;
62373       const lastUsedBackground = corePreferences("background-last-used");
62374       return loadPromise.then((imageryIndex) => {
62375         const extent = context.map().extent();
62376         const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom");
62377         const first = validBackgrounds.length && validBackgrounds[0];
62378         const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground);
62379         let best;
62380         if (!requestedBackground && extent) {
62381           const viewArea = extent.area();
62382           best = validBackgrounds.find((s2) => {
62383             if (!s2.best() || s2.overlay) return false;
62384             let bbox2 = turf_bbox_default(turf_bbox_clip_default(
62385               { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] },
62386               extent.rectangle()
62387             ));
62388             let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area();
62389             return area / viewArea > 0.5;
62390           });
62391         }
62392         if (requestedBackground && requestedBackground.indexOf("custom:") === 0) {
62393           const template = requestedBackground.replace(/^custom:/, "");
62394           const custom = background.findSource("custom");
62395           background.baseLayerSource(custom.template(template));
62396           corePreferences("background-custom-template", template);
62397         } else {
62398           background.baseLayerSource(
62399             background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none")
62400           );
62401         }
62402         const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default);
62403         if (locator) {
62404           background.toggleOverlayLayer(locator);
62405         }
62406         const overlays = (hash2.overlays || "").split(",");
62407         overlays.forEach((overlay) => {
62408           overlay = background.findSource(overlay);
62409           if (overlay) {
62410             background.toggleOverlayLayer(overlay);
62411           }
62412         });
62413         if (hash2.gpx) {
62414           const gpx2 = context.layers().layer("data");
62415           if (gpx2) {
62416             gpx2.url(hash2.gpx, ".gpx");
62417           }
62418         }
62419         if (hash2.offset) {
62420           const offset = hash2.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3);
62421           if (offset.length === 2) {
62422             background.offset(geoMetersToOffset(offset));
62423           }
62424         }
62425       }).catch((err) => {
62426         console.error(err);
62427       });
62428     };
62429     return utilRebind(background, dispatch14, "on");
62430   }
62431
62432   // modules/renderer/features.js
62433   function rendererFeatures(context) {
62434     var dispatch14 = dispatch_default("change", "redraw");
62435     const features = {};
62436     var _deferred2 = /* @__PURE__ */ new Set();
62437     var traffic_roads = {
62438       "motorway": true,
62439       "motorway_link": true,
62440       "trunk": true,
62441       "trunk_link": true,
62442       "primary": true,
62443       "primary_link": true,
62444       "secondary": true,
62445       "secondary_link": true,
62446       "tertiary": true,
62447       "tertiary_link": true,
62448       "residential": true,
62449       "unclassified": true,
62450       "living_street": true,
62451       "busway": true
62452     };
62453     var service_roads = {
62454       "service": true,
62455       "road": true,
62456       "track": true
62457     };
62458     var paths = {
62459       "path": true,
62460       "footway": true,
62461       "cycleway": true,
62462       "bridleway": true,
62463       "steps": true,
62464       "ladder": true,
62465       "pedestrian": true
62466     };
62467     var _cullFactor = 1;
62468     var _cache5 = {};
62469     var _rules = {};
62470     var _stats = {};
62471     var _keys = [];
62472     var _hidden = [];
62473     var _forceVisible = {};
62474     function update() {
62475       if (!window.mocha) {
62476         var hash2 = utilStringQs(window.location.hash);
62477         var disabled = features.disabled();
62478         if (disabled.length) {
62479           hash2.disable_features = disabled.join(",");
62480         } else {
62481           delete hash2.disable_features;
62482         }
62483         window.location.replace("#" + utilQsString(hash2, true));
62484         corePreferences("disabled-features", disabled.join(","));
62485       }
62486       _hidden = features.hidden();
62487       dispatch14.call("change");
62488       dispatch14.call("redraw");
62489     }
62490     function defineRule(k2, filter2, max3) {
62491       var isEnabled = true;
62492       _keys.push(k2);
62493       _rules[k2] = {
62494         filter: filter2,
62495         enabled: isEnabled,
62496         // whether the user wants it enabled..
62497         count: 0,
62498         currentMax: max3 || Infinity,
62499         defaultMax: max3 || Infinity,
62500         enable: function() {
62501           this.enabled = true;
62502           this.currentMax = this.defaultMax;
62503         },
62504         disable: function() {
62505           this.enabled = false;
62506           this.currentMax = 0;
62507         },
62508         hidden: function() {
62509           return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor;
62510         },
62511         autoHidden: function() {
62512           return this.hidden() && this.currentMax > 0;
62513         }
62514       };
62515     }
62516     defineRule("points", function isPoint(tags, geometry) {
62517       return geometry === "point";
62518     }, 200);
62519     defineRule("traffic_roads", function isTrafficRoad(tags) {
62520       return traffic_roads[tags.highway];
62521     });
62522     defineRule("service_roads", function isServiceRoad(tags) {
62523       return service_roads[tags.highway];
62524     });
62525     defineRule("paths", function isPath(tags) {
62526       return paths[tags.highway];
62527     });
62528     defineRule("buildings", function isBuilding(tags) {
62529       return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes";
62530     }, 250);
62531     defineRule("building_parts", function isBuildingPart(tags) {
62532       return !!tags["building:part"];
62533     });
62534     defineRule("indoor", function isIndoor(tags) {
62535       return !!tags.indoor && tags.indoor !== "no" || !!tags.indoormark && tags.indoormark !== "no";
62536     });
62537     defineRule("landuse", function isLanduse(tags, geometry) {
62538       return geometry === "area" && (!!tags.landuse || !!tags.natural || !!tags.leisure || !!tags.amenity) && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags);
62539     });
62540     defineRule("boundaries", function isBoundary(tags, geometry) {
62541       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);
62542     });
62543     defineRule("water", function isWater(tags) {
62544       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";
62545     });
62546     defineRule("rail", function isRail(tags) {
62547       return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]);
62548     });
62549     defineRule("pistes", function isPiste(tags) {
62550       return tags["piste:type"];
62551     });
62552     defineRule("aerialways", function isAerialways(tags) {
62553       return !!(tags == null ? void 0 : tags.aerialway) && tags.aerialway !== "yes" && tags.aerialway !== "station";
62554     });
62555     defineRule("power", function isPower(tags) {
62556       return !!tags.power;
62557     });
62558     defineRule("past_future", function isPastFuture(tags) {
62559       if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) {
62560         return false;
62561       }
62562       const keys2 = Object.keys(tags);
62563       for (let i3 = 0; i3 < keys2.length; i3++) {
62564         const key = keys2[i3];
62565         const s2 = key.split(":")[0];
62566         if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[key]]) return true;
62567       }
62568       return false;
62569     });
62570     defineRule("others", function isOther(tags, geometry) {
62571       return geometry === "line" || geometry === "area";
62572     });
62573     features.features = function() {
62574       return _rules;
62575     };
62576     features.keys = function() {
62577       return _keys;
62578     };
62579     features.enabled = function(k2) {
62580       if (!arguments.length) {
62581         return _keys.filter(function(k3) {
62582           return _rules[k3].enabled;
62583         });
62584       }
62585       return _rules[k2] && _rules[k2].enabled;
62586     };
62587     features.disabled = function(k2) {
62588       if (!arguments.length) {
62589         return _keys.filter(function(k3) {
62590           return !_rules[k3].enabled;
62591         });
62592       }
62593       return _rules[k2] && !_rules[k2].enabled;
62594     };
62595     features.hidden = function(k2) {
62596       var _a4;
62597       if (!arguments.length) {
62598         return _keys.filter(function(k3) {
62599           return _rules[k3].hidden();
62600         });
62601       }
62602       return (_a4 = _rules[k2]) == null ? void 0 : _a4.hidden();
62603     };
62604     features.autoHidden = function(k2) {
62605       if (!arguments.length) {
62606         return _keys.filter(function(k3) {
62607           return _rules[k3].autoHidden();
62608         });
62609       }
62610       return _rules[k2] && _rules[k2].autoHidden();
62611     };
62612     features.enable = function(k2) {
62613       if (_rules[k2] && !_rules[k2].enabled) {
62614         _rules[k2].enable();
62615         update();
62616       }
62617     };
62618     features.enableAll = function() {
62619       var didEnable = false;
62620       for (var k2 in _rules) {
62621         if (!_rules[k2].enabled) {
62622           didEnable = true;
62623           _rules[k2].enable();
62624         }
62625       }
62626       if (didEnable) update();
62627     };
62628     features.disable = function(k2) {
62629       if (_rules[k2] && _rules[k2].enabled) {
62630         _rules[k2].disable();
62631         update();
62632       }
62633     };
62634     features.disableAll = function() {
62635       var didDisable = false;
62636       for (var k2 in _rules) {
62637         if (_rules[k2].enabled) {
62638           didDisable = true;
62639           _rules[k2].disable();
62640         }
62641       }
62642       if (didDisable) update();
62643     };
62644     features.toggle = function(k2) {
62645       if (_rules[k2]) {
62646         (function(f2) {
62647           return f2.enabled ? f2.disable() : f2.enable();
62648         })(_rules[k2]);
62649         update();
62650       }
62651     };
62652     features.resetStats = function() {
62653       for (var i3 = 0; i3 < _keys.length; i3++) {
62654         _rules[_keys[i3]].count = 0;
62655       }
62656       dispatch14.call("change");
62657     };
62658     features.gatherStats = function(d2, resolver, dimensions) {
62659       var needsRedraw = false;
62660       var types = utilArrayGroupBy(d2, "type");
62661       var entities = [].concat(types.relation || [], types.way || [], types.node || []);
62662       var currHidden, geometry, matches, i3, j2;
62663       for (i3 = 0; i3 < _keys.length; i3++) {
62664         _rules[_keys[i3]].count = 0;
62665       }
62666       _cullFactor = dimensions[0] * dimensions[1] / 1e6;
62667       for (i3 = 0; i3 < entities.length; i3++) {
62668         geometry = entities[i3].geometry(resolver);
62669         matches = Object.keys(features.getMatches(entities[i3], resolver, geometry));
62670         for (j2 = 0; j2 < matches.length; j2++) {
62671           _rules[matches[j2]].count++;
62672         }
62673       }
62674       currHidden = features.hidden();
62675       if (currHidden !== _hidden) {
62676         _hidden = currHidden;
62677         needsRedraw = true;
62678         dispatch14.call("change");
62679       }
62680       return needsRedraw;
62681     };
62682     features.stats = function() {
62683       for (var i3 = 0; i3 < _keys.length; i3++) {
62684         _stats[_keys[i3]] = _rules[_keys[i3]].count;
62685       }
62686       return _stats;
62687     };
62688     features.clear = function(d2) {
62689       for (var i3 = 0; i3 < d2.length; i3++) {
62690         features.clearEntity(d2[i3]);
62691       }
62692     };
62693     features.clearEntity = function(entity) {
62694       delete _cache5[osmEntity.key(entity)];
62695     };
62696     features.reset = function() {
62697       Array.from(_deferred2).forEach(function(handle) {
62698         window.cancelIdleCallback(handle);
62699         _deferred2.delete(handle);
62700       });
62701       _cache5 = {};
62702     };
62703     function relationShouldBeChecked(relation) {
62704       return relation.tags.type === "boundary";
62705     }
62706     features.getMatches = function(entity, resolver, geometry) {
62707       if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity)) return {};
62708       var ent = osmEntity.key(entity);
62709       if (!_cache5[ent]) {
62710         _cache5[ent] = {};
62711       }
62712       if (!_cache5[ent].matches) {
62713         var matches = {};
62714         var hasMatch = false;
62715         for (var i3 = 0; i3 < _keys.length; i3++) {
62716           if (_keys[i3] === "others") {
62717             if (hasMatch) continue;
62718             if (entity.type === "way") {
62719               var parents = features.getParents(entity, resolver, geometry);
62720               if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations
62721               parents.length > 0 && parents.every(function(parent) {
62722                 return parent.tags.type === "boundary";
62723               })) {
62724                 var pkey = osmEntity.key(parents[0]);
62725                 if (_cache5[pkey] && _cache5[pkey].matches) {
62726                   matches = Object.assign({}, _cache5[pkey].matches);
62727                   continue;
62728                 }
62729               }
62730             }
62731           }
62732           if (_rules[_keys[i3]].filter(entity.tags, geometry)) {
62733             matches[_keys[i3]] = hasMatch = true;
62734           }
62735         }
62736         _cache5[ent].matches = matches;
62737       }
62738       return _cache5[ent].matches;
62739     };
62740     features.getParents = function(entity, resolver, geometry) {
62741       if (geometry === "point") return [];
62742       var ent = osmEntity.key(entity);
62743       if (!_cache5[ent]) {
62744         _cache5[ent] = {};
62745       }
62746       if (!_cache5[ent].parents) {
62747         var parents = [];
62748         if (geometry === "vertex") {
62749           parents = resolver.parentWays(entity);
62750         } else {
62751           parents = resolver.parentRelations(entity);
62752         }
62753         _cache5[ent].parents = parents;
62754       }
62755       return _cache5[ent].parents;
62756     };
62757     features.isHiddenPreset = function(preset, geometry) {
62758       if (!_hidden.length) return false;
62759       if (!preset.tags) return false;
62760       var test = preset.setTags({}, geometry);
62761       for (var key in _rules) {
62762         if (_rules[key].filter(test, geometry)) {
62763           if (_hidden.indexOf(key) !== -1) {
62764             return key;
62765           }
62766           return false;
62767         }
62768       }
62769       return false;
62770     };
62771     features.isHiddenFeature = function(entity, resolver, geometry) {
62772       if (!_hidden.length) return false;
62773       if (!entity.version) return false;
62774       if (_forceVisible[entity.id]) return false;
62775       var matches = Object.keys(features.getMatches(entity, resolver, geometry));
62776       return matches.length && matches.every(function(k2) {
62777         return features.hidden(k2);
62778       });
62779     };
62780     features.isHiddenChild = function(entity, resolver, geometry) {
62781       if (!_hidden.length) return false;
62782       if (!entity.version || geometry === "point") return false;
62783       if (_forceVisible[entity.id]) return false;
62784       var parents = features.getParents(entity, resolver, geometry);
62785       if (!parents.length) return false;
62786       for (var i3 = 0; i3 < parents.length; i3++) {
62787         if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) {
62788           return false;
62789         }
62790       }
62791       return true;
62792     };
62793     features.hasHiddenConnections = function(entity, resolver) {
62794       if (!_hidden.length) return false;
62795       var childNodes, connections;
62796       if (entity.type === "midpoint") {
62797         childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
62798         connections = [];
62799       } else {
62800         childNodes = entity.nodes ? resolver.childNodes(entity) : [];
62801         connections = features.getParents(entity, resolver, entity.geometry(resolver));
62802       }
62803       connections = childNodes.reduce(function(result, e3) {
62804         return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result;
62805       }, connections);
62806       return connections.some(function(e3) {
62807         return features.isHidden(e3, resolver, e3.geometry(resolver));
62808       });
62809     };
62810     features.isHidden = function(entity, resolver, geometry) {
62811       if (!_hidden.length) return false;
62812       if (!entity.version) return false;
62813       var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature;
62814       return fn(entity, resolver, geometry);
62815     };
62816     features.filter = function(d2, resolver) {
62817       if (!_hidden.length) return d2;
62818       var result = [];
62819       for (var i3 = 0; i3 < d2.length; i3++) {
62820         var entity = d2[i3];
62821         if (!features.isHidden(entity, resolver, entity.geometry(resolver))) {
62822           result.push(entity);
62823         }
62824       }
62825       return result;
62826     };
62827     features.forceVisible = function(entityIDs) {
62828       if (!arguments.length) return Object.keys(_forceVisible);
62829       _forceVisible = {};
62830       for (var i3 = 0; i3 < entityIDs.length; i3++) {
62831         _forceVisible[entityIDs[i3]] = true;
62832         var entity = context.hasEntity(entityIDs[i3]);
62833         if (entity && entity.type === "relation") {
62834           for (var j2 in entity.members) {
62835             _forceVisible[entity.members[j2].id] = true;
62836           }
62837         }
62838       }
62839       return features;
62840     };
62841     features.init = function() {
62842       var storage = corePreferences("disabled-features");
62843       if (storage) {
62844         var storageDisabled = storage.replace(/;/g, ",").split(",");
62845         storageDisabled.forEach(features.disable);
62846       }
62847       var hash2 = utilStringQs(window.location.hash);
62848       if (hash2.disable_features) {
62849         var hashDisabled = hash2.disable_features.replace(/;/g, ",").split(",");
62850         hashDisabled.forEach(features.disable);
62851       }
62852     };
62853     context.history().on("merge.features", function(newEntities) {
62854       if (!newEntities) return;
62855       var handle = window.requestIdleCallback(function() {
62856         var graph = context.graph();
62857         var types = utilArrayGroupBy(newEntities, "type");
62858         var entities = [].concat(types.relation || [], types.way || [], types.node || []);
62859         for (var i3 = 0; i3 < entities.length; i3++) {
62860           var geometry = entities[i3].geometry(graph);
62861           features.getMatches(entities[i3], graph, geometry);
62862         }
62863       });
62864       _deferred2.add(handle);
62865     });
62866     return utilRebind(features, dispatch14, "on");
62867   }
62868
62869   // modules/util/bind_once.js
62870   function utilBindOnce(target, type2, listener, capture) {
62871     var typeOnce = type2 + ".once";
62872     function one2() {
62873       target.on(typeOnce, null);
62874       listener.apply(this, arguments);
62875     }
62876     target.on(typeOnce, one2, capture);
62877     return this;
62878   }
62879
62880   // modules/util/zoom_pan.js
62881   function defaultFilter3(d3_event) {
62882     return !d3_event.ctrlKey && !d3_event.button;
62883   }
62884   function defaultExtent2() {
62885     var e3 = this;
62886     if (e3 instanceof SVGElement) {
62887       e3 = e3.ownerSVGElement || e3;
62888       if (e3.hasAttribute("viewBox")) {
62889         e3 = e3.viewBox.baseVal;
62890         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
62891       }
62892       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
62893     }
62894     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
62895   }
62896   function defaultWheelDelta2(d3_event) {
62897     return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3);
62898   }
62899   function defaultConstrain2(transform2, extent, translateExtent) {
62900     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];
62901     return transform2.translate(
62902       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
62903       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
62904     );
62905   }
62906   function utilZoomPan() {
62907     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;
62908     function zoom(selection2) {
62909       selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
62910       select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup);
62911     }
62912     zoom.transform = function(collection, transform2, point) {
62913       var selection2 = collection.selection ? collection.selection() : collection;
62914       if (collection !== selection2) {
62915         schedule(collection, transform2, point);
62916       } else {
62917         selection2.interrupt().each(function() {
62918           gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null);
62919         });
62920       }
62921     };
62922     zoom.scaleBy = function(selection2, k2, p2) {
62923       zoom.scaleTo(selection2, function() {
62924         var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
62925         return k0 * k1;
62926       }, p2);
62927     };
62928     zoom.scaleTo = function(selection2, k2, p2) {
62929       zoom.transform(selection2, function() {
62930         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;
62931         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
62932       }, p2);
62933     };
62934     zoom.translateBy = function(selection2, x2, y2) {
62935       zoom.transform(selection2, function() {
62936         return constrain(_transform.translate(
62937           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
62938           typeof y2 === "function" ? y2.apply(this, arguments) : y2
62939         ), extent.apply(this, arguments), translateExtent);
62940       });
62941     };
62942     zoom.translateTo = function(selection2, x2, y2, p2) {
62943       zoom.transform(selection2, function() {
62944         var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
62945         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
62946           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
62947           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
62948         ), e3, translateExtent);
62949       }, p2);
62950     };
62951     function scale(transform2, k2) {
62952       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
62953       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
62954     }
62955     function translate(transform2, p02, p1) {
62956       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
62957       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
62958     }
62959     function centroid(extent2) {
62960       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
62961     }
62962     function schedule(transition2, transform2, point) {
62963       transition2.on("start.zoom", function() {
62964         gesture(this, arguments).start(null);
62965       }).on("interrupt.zoom end.zoom", function() {
62966         gesture(this, arguments).end(null);
62967       }).tween("zoom", function() {
62968         var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, 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));
62969         return function(t2) {
62970           if (t2 === 1) {
62971             t2 = b2;
62972           } else {
62973             var l2 = i3(t2);
62974             var k2 = w2 / l2[2];
62975             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
62976           }
62977           g3.zoom(null, null, t2);
62978         };
62979       });
62980     }
62981     function gesture(that, args, clean2) {
62982       return !clean2 && _activeGesture || new Gesture(that, args);
62983     }
62984     function Gesture(that, args) {
62985       this.that = that;
62986       this.args = args;
62987       this.active = 0;
62988       this.extent = extent.apply(that, args);
62989     }
62990     Gesture.prototype = {
62991       start: function(d3_event) {
62992         if (++this.active === 1) {
62993           _activeGesture = this;
62994           dispatch14.call("start", this, d3_event);
62995         }
62996         return this;
62997       },
62998       zoom: function(d3_event, key, transform2) {
62999         if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]);
63000         if (this.pointer0 && key !== "touch") this.pointer0[1] = transform2.invert(this.pointer0[0]);
63001         if (this.pointer1 && key !== "touch") this.pointer1[1] = transform2.invert(this.pointer1[0]);
63002         _transform = transform2;
63003         dispatch14.call("zoom", this, d3_event, key, transform2);
63004         return this;
63005       },
63006       end: function(d3_event) {
63007         if (--this.active === 0) {
63008           _activeGesture = null;
63009           dispatch14.call("end", this, d3_event);
63010         }
63011         return this;
63012       }
63013     };
63014     function wheeled(d3_event) {
63015       if (!filter2.apply(this, arguments)) return;
63016       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);
63017       if (g3.wheel) {
63018         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
63019           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
63020         }
63021         clearTimeout(g3.wheel);
63022       } else {
63023         g3.mouse = [p2, t2.invert(p2)];
63024         interrupt_default(this);
63025         g3.start(d3_event);
63026       }
63027       d3_event.preventDefault();
63028       d3_event.stopImmediatePropagation();
63029       g3.wheel = setTimeout(wheelidled, _wheelDelay);
63030       g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
63031       function wheelidled() {
63032         g3.wheel = null;
63033         g3.end(d3_event);
63034       }
63035     }
63036     var _downPointerIDs = /* @__PURE__ */ new Set();
63037     var _pointerLocGetter;
63038     function pointerdown(d3_event) {
63039       _downPointerIDs.add(d3_event.pointerId);
63040       if (!filter2.apply(this, arguments)) return;
63041       var g3 = gesture(this, arguments, _downPointerIDs.size === 1);
63042       var started;
63043       d3_event.stopImmediatePropagation();
63044       _pointerLocGetter = utilFastMouse(this);
63045       var loc = _pointerLocGetter(d3_event);
63046       var p2 = [loc, _transform.invert(loc), d3_event.pointerId];
63047       if (!g3.pointer0) {
63048         g3.pointer0 = p2;
63049         started = true;
63050       } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) {
63051         g3.pointer1 = p2;
63052       }
63053       if (started) {
63054         interrupt_default(this);
63055         g3.start(d3_event);
63056       }
63057     }
63058     function pointermove(d3_event) {
63059       if (!_downPointerIDs.has(d3_event.pointerId)) return;
63060       if (!_activeGesture || !_pointerLocGetter) return;
63061       var g3 = gesture(this, arguments);
63062       var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId;
63063       var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId;
63064       if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) {
63065         if (g3.pointer0) _downPointerIDs.delete(g3.pointer0[2]);
63066         if (g3.pointer1) _downPointerIDs.delete(g3.pointer1[2]);
63067         g3.end(d3_event);
63068         return;
63069       }
63070       d3_event.preventDefault();
63071       d3_event.stopImmediatePropagation();
63072       var loc = _pointerLocGetter(d3_event);
63073       var t2, p2, l2;
63074       if (isPointer0) g3.pointer0[0] = loc;
63075       else if (isPointer1) g3.pointer1[0] = loc;
63076       t2 = _transform;
63077       if (g3.pointer1) {
63078         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;
63079         t2 = scale(t2, Math.sqrt(dp / dl));
63080         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
63081         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
63082       } else if (g3.pointer0) {
63083         p2 = g3.pointer0[0];
63084         l2 = g3.pointer0[1];
63085       } else {
63086         return;
63087       }
63088       g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
63089     }
63090     function pointerup(d3_event) {
63091       if (!_downPointerIDs.has(d3_event.pointerId)) return;
63092       _downPointerIDs.delete(d3_event.pointerId);
63093       if (!_activeGesture) return;
63094       var g3 = gesture(this, arguments);
63095       d3_event.stopImmediatePropagation();
63096       if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId) delete g3.pointer0;
63097       else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId) delete g3.pointer1;
63098       if (g3.pointer1 && !g3.pointer0) {
63099         g3.pointer0 = g3.pointer1;
63100         delete g3.pointer1;
63101       }
63102       if (g3.pointer0) {
63103         g3.pointer0[1] = _transform.invert(g3.pointer0[0]);
63104       } else {
63105         g3.end(d3_event);
63106       }
63107     }
63108     zoom.wheelDelta = function(_2) {
63109       return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta;
63110     };
63111     zoom.filter = function(_2) {
63112       return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2;
63113     };
63114     zoom.extent = function(_2) {
63115       return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
63116     };
63117     zoom.scaleExtent = function(_2) {
63118       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
63119     };
63120     zoom.translateExtent = function(_2) {
63121       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]]];
63122     };
63123     zoom.constrain = function(_2) {
63124       return arguments.length ? (constrain = _2, zoom) : constrain;
63125     };
63126     zoom.interpolate = function(_2) {
63127       return arguments.length ? (interpolate = _2, zoom) : interpolate;
63128     };
63129     zoom._transform = function(_2) {
63130       return arguments.length ? (_transform = _2, zoom) : _transform;
63131     };
63132     return utilRebind(zoom, dispatch14, "on");
63133   }
63134
63135   // modules/util/double_up.js
63136   function utilDoubleUp() {
63137     var dispatch14 = dispatch_default("doubleUp");
63138     var _maxTimespan = 500;
63139     var _maxDistance = 20;
63140     var _pointer;
63141     function pointerIsValidFor(loc) {
63142       return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown
63143       geoVecLength(_pointer.startLoc, loc) <= _maxDistance;
63144     }
63145     function pointerdown(d3_event) {
63146       if (d3_event.ctrlKey || d3_event.button === 2) return;
63147       var loc = [d3_event.clientX, d3_event.clientY];
63148       if (_pointer && !pointerIsValidFor(loc)) {
63149         _pointer = void 0;
63150       }
63151       if (!_pointer) {
63152         _pointer = {
63153           startLoc: loc,
63154           startTime: (/* @__PURE__ */ new Date()).getTime(),
63155           upCount: 0,
63156           pointerId: d3_event.pointerId
63157         };
63158       } else {
63159         _pointer.pointerId = d3_event.pointerId;
63160       }
63161     }
63162     function pointerup(d3_event) {
63163       if (d3_event.ctrlKey || d3_event.button === 2) return;
63164       if (!_pointer || _pointer.pointerId !== d3_event.pointerId) return;
63165       _pointer.upCount += 1;
63166       if (_pointer.upCount === 2) {
63167         var loc = [d3_event.clientX, d3_event.clientY];
63168         if (pointerIsValidFor(loc)) {
63169           var locInThis = utilFastMouse(this)(d3_event);
63170           dispatch14.call("doubleUp", this, d3_event, locInThis);
63171         }
63172         _pointer = void 0;
63173       }
63174     }
63175     function doubleUp(selection2) {
63176       if ("PointerEvent" in window) {
63177         selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup);
63178       } else {
63179         selection2.on("dblclick.doubleUp", function(d3_event) {
63180           dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event));
63181         });
63182       }
63183     }
63184     doubleUp.off = function(selection2) {
63185       selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null);
63186     };
63187     return utilRebind(doubleUp, dispatch14, "on");
63188   }
63189
63190   // modules/renderer/map.js
63191   var TILESIZE = 256;
63192   var minZoom2 = 2;
63193   var maxZoom = 24;
63194   var kMin = geoZoomToScale(minZoom2, TILESIZE);
63195   var kMax = geoZoomToScale(maxZoom, TILESIZE);
63196   function clamp2(num, min3, max3) {
63197     return Math.max(min3, Math.min(num, max3));
63198   }
63199   function rendererMap(context) {
63200     var dispatch14 = dispatch_default(
63201       "move",
63202       "drawn",
63203       "crossEditableZoom",
63204       "hitMinZoom",
63205       "changeHighlighting",
63206       "changeAreaFill"
63207     );
63208     var projection2 = context.projection;
63209     var curtainProjection = context.curtainProjection;
63210     var drawLayers;
63211     var drawPoints;
63212     var drawVertices;
63213     var drawLines;
63214     var drawAreas;
63215     var drawMidpoints;
63216     var drawLabels;
63217     var _selection = select_default2(null);
63218     var supersurface = select_default2(null);
63219     var wrapper = select_default2(null);
63220     var surface = select_default2(null);
63221     var _dimensions = [1, 1];
63222     var _dblClickZoomEnabled = true;
63223     var _redrawEnabled = true;
63224     var _gestureTransformStart;
63225     var _transformStart = projection2.transform();
63226     var _transformLast;
63227     var _isTransformed = false;
63228     var _minzoom = 0;
63229     var _getMouseCoords;
63230     var _lastPointerEvent;
63231     var _lastWithinEditableZoom;
63232     var _pointerDown = false;
63233     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
63234     var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2;
63235     var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) {
63236       _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown");
63237     }).on("end.map", function() {
63238       _pointerDown = false;
63239     });
63240     var _doubleUpHandler = utilDoubleUp();
63241     var scheduleRedraw = throttle_default(redraw, 750);
63242     function cancelPendingRedraw() {
63243       scheduleRedraw.cancel();
63244     }
63245     function map2(selection2) {
63246       _selection = selection2;
63247       context.on("change.map", immediateRedraw);
63248       var osm = context.connection();
63249       if (osm) {
63250         osm.on("change.map", immediateRedraw);
63251       }
63252       function didUndoOrRedo(targetTransform) {
63253         var mode = context.mode().id;
63254         if (mode !== "browse" && mode !== "select") return;
63255         if (targetTransform) {
63256           map2.transformEase(targetTransform);
63257         }
63258       }
63259       context.history().on("merge.map", function() {
63260         scheduleRedraw();
63261       }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) {
63262         didUndoOrRedo(fromStack.transform);
63263       }).on("redone.map", function(stack) {
63264         didUndoOrRedo(stack.transform);
63265       });
63266       context.background().on("change.map", immediateRedraw);
63267       context.features().on("redraw.map", immediateRedraw);
63268       drawLayers.on("change.map", function() {
63269         context.background().updateImagery();
63270         immediateRedraw();
63271       });
63272       selection2.on("wheel.map mousewheel.map", function(d3_event) {
63273         d3_event.preventDefault();
63274       }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null);
63275       map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0);
63276       wrapper = supersurface.append("div").attr("class", "layer layer-data");
63277       map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface");
63278       surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) {
63279         _lastPointerEvent = d3_event;
63280         if (d3_event.button === 2) {
63281           d3_event.stopPropagation();
63282         }
63283       }, true).on(_pointerPrefix + "up.zoom", function(d3_event) {
63284         _lastPointerEvent = d3_event;
63285         if (resetTransform()) {
63286           immediateRedraw();
63287         }
63288       }).on(_pointerPrefix + "move.map", function(d3_event) {
63289         _lastPointerEvent = d3_event;
63290       }).on(_pointerPrefix + "over.vertices", function(d3_event) {
63291         if (map2.editableDataEnabled() && !_isTransformed) {
63292           var hover = d3_event.target.__data__;
63293           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
63294           dispatch14.call("drawn", this, { full: false });
63295         }
63296       }).on(_pointerPrefix + "out.vertices", function(d3_event) {
63297         if (map2.editableDataEnabled() && !_isTransformed) {
63298           var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
63299           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
63300           dispatch14.call("drawn", this, { full: false });
63301         }
63302       });
63303       var detected = utilDetect();
63304       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
63305       // but we only need to do this on desktop Safari anyway. – #7694
63306       !detected.isMobileWebKit) {
63307         surface.on("gesturestart.surface", function(d3_event) {
63308           d3_event.preventDefault();
63309           _gestureTransformStart = projection2.transform();
63310         }).on("gesturechange.surface", gestureChange);
63311       }
63312       updateAreaFill();
63313       _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) {
63314         if (!_dblClickZoomEnabled) return;
63315         if (typeof d3_event.target.__data__ === "object" && // or area fills
63316         !select_default2(d3_event.target).classed("fill")) return;
63317         var zoomOut2 = d3_event.shiftKey;
63318         var t2 = projection2.transform();
63319         var p1 = t2.invert(p02);
63320         t2 = t2.scale(zoomOut2 ? 0.5 : 2);
63321         t2.x = p02[0] - p1[0] * t2.k;
63322         t2.y = p02[1] - p1[1] * t2.k;
63323         map2.transformEase(t2);
63324       });
63325       context.on("enter.map", function() {
63326         if (!map2.editableDataEnabled(
63327           true
63328           /* skip zoom check */
63329         )) return;
63330         if (_isTransformed) return;
63331         var graph = context.graph();
63332         var selectedAndParents = {};
63333         context.selectedIDs().forEach(function(id2) {
63334           var entity = graph.hasEntity(id2);
63335           if (entity) {
63336             selectedAndParents[entity.id] = entity;
63337             if (entity.type === "node") {
63338               graph.parentWays(entity).forEach(function(parent) {
63339                 selectedAndParents[parent.id] = parent;
63340               });
63341             }
63342           }
63343         });
63344         var data = Object.values(selectedAndParents);
63345         var filter2 = function(d2) {
63346           return d2.id in selectedAndParents;
63347         };
63348         data = context.features().filter(data, graph);
63349         surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent());
63350         dispatch14.call("drawn", this, { full: false });
63351         scheduleRedraw();
63352       });
63353       map2.dimensions(utilGetDimensions(selection2));
63354     }
63355     function zoomEventFilter(d3_event) {
63356       if (d3_event.type === "mousedown") {
63357         var hasOrphan = false;
63358         var listeners = window.__on;
63359         for (var i3 = 0; i3 < listeners.length; i3++) {
63360           var listener = listeners[i3];
63361           if (listener.name === "zoom" && listener.type === "mouseup") {
63362             hasOrphan = true;
63363             break;
63364           }
63365         }
63366         if (hasOrphan) {
63367           var event = window.CustomEvent;
63368           if (event) {
63369             event = new event("mouseup");
63370           } else {
63371             event = window.document.createEvent("Event");
63372             event.initEvent("mouseup", false, false);
63373           }
63374           event.view = window;
63375           window.dispatchEvent(event);
63376         }
63377       }
63378       return d3_event.button !== 2;
63379     }
63380     function pxCenter() {
63381       return [_dimensions[0] / 2, _dimensions[1] / 2];
63382     }
63383     function drawEditable(difference2, extent) {
63384       var mode = context.mode();
63385       var graph = context.graph();
63386       var features = context.features();
63387       var all = context.history().intersects(map2.extent());
63388       var fullRedraw = false;
63389       var data;
63390       var set4;
63391       var filter2;
63392       var applyFeatureLayerFilters = true;
63393       if (map2.isInWideSelection()) {
63394         data = [];
63395         utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) {
63396           var entity = context.hasEntity(id2);
63397           if (entity) data.push(entity);
63398         });
63399         fullRedraw = true;
63400         filter2 = utilFunctor(true);
63401         applyFeatureLayerFilters = false;
63402       } else if (difference2) {
63403         var complete = difference2.complete(map2.extent());
63404         data = Object.values(complete).filter(Boolean);
63405         set4 = new Set(Object.keys(complete));
63406         filter2 = function(d2) {
63407           return set4.has(d2.id);
63408         };
63409         features.clear(data);
63410       } else {
63411         if (features.gatherStats(all, graph, _dimensions)) {
63412           extent = void 0;
63413         }
63414         if (extent) {
63415           data = context.history().intersects(map2.extent().intersection(extent));
63416           set4 = new Set(data.map(function(entity) {
63417             return entity.id;
63418           }));
63419           filter2 = function(d2) {
63420             return set4.has(d2.id);
63421           };
63422         } else {
63423           data = all;
63424           fullRedraw = true;
63425           filter2 = utilFunctor(true);
63426         }
63427       }
63428       if (applyFeatureLayerFilters) {
63429         data = features.filter(data, graph);
63430       } else {
63431         context.features().resetStats();
63432       }
63433       if (mode && mode.id === "select") {
63434         surface.call(drawVertices.drawSelected, graph, map2.extent());
63435       }
63436       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);
63437       dispatch14.call("drawn", this, { full: true });
63438     }
63439     map2.init = function() {
63440       drawLayers = svgLayers(projection2, context);
63441       drawPoints = svgPoints(projection2, context);
63442       drawVertices = svgVertices(projection2, context);
63443       drawLines = svgLines(projection2, context);
63444       drawAreas = svgAreas(projection2, context);
63445       drawMidpoints = svgMidpoints(projection2, context);
63446       drawLabels = svgLabels(projection2, context);
63447     };
63448     function editOff() {
63449       context.features().resetStats();
63450       surface.selectAll(".layer-osm *").remove();
63451       surface.selectAll(".layer-touch:not(.markers) *").remove();
63452       var allowed = {
63453         "browse": true,
63454         "save": true,
63455         "select-note": true,
63456         "select-data": true,
63457         "select-error": true
63458       };
63459       var mode = context.mode();
63460       if (mode && !allowed[mode.id]) {
63461         context.enter(modeBrowse(context));
63462       }
63463       dispatch14.call("drawn", this, { full: true });
63464     }
63465     function gestureChange(d3_event) {
63466       var e3 = d3_event;
63467       e3.preventDefault();
63468       var props = {
63469         deltaMode: 0,
63470         // dummy values to ignore in zoomPan
63471         deltaY: 1,
63472         // dummy values to ignore in zoomPan
63473         clientX: e3.clientX,
63474         clientY: e3.clientY,
63475         screenX: e3.screenX,
63476         screenY: e3.screenY,
63477         x: e3.x,
63478         y: e3.y
63479       };
63480       var e22 = new WheelEvent("wheel", props);
63481       e22._scale = e3.scale;
63482       e22._rotation = e3.rotation;
63483       _selection.node().dispatchEvent(e22);
63484     }
63485     function zoomPan2(event, key, transform2) {
63486       var source = event && event.sourceEvent || event;
63487       var eventTransform = transform2 || event && event.transform;
63488       var x2 = eventTransform.x;
63489       var y2 = eventTransform.y;
63490       var k2 = eventTransform.k;
63491       if (source && source.type === "wheel") {
63492         if (_pointerDown) return;
63493         var detected = utilDetect();
63494         var dX = source.deltaX;
63495         var dY = source.deltaY;
63496         var x22 = x2;
63497         var y22 = y2;
63498         var k22 = k2;
63499         var t0, p02, p1;
63500         if (source.deltaMode === 1) {
63501           var lines = Math.abs(source.deltaY);
63502           var sign2 = source.deltaY > 0 ? 1 : -1;
63503           dY = sign2 * clamp2(
63504             lines * 18.001,
63505             4.000244140625,
63506             // min
63507             350.000244140625
63508             // max
63509           );
63510           t0 = _isTransformed ? _transformLast : _transformStart;
63511           p02 = _getMouseCoords(source);
63512           p1 = t0.invert(p02);
63513           k22 = t0.k * Math.pow(2, -dY / 500);
63514           k22 = clamp2(k22, kMin, kMax);
63515           x22 = p02[0] - p1[0] * k22;
63516           y22 = p02[1] - p1[1] * k22;
63517         } else if (source._scale) {
63518           t0 = _gestureTransformStart;
63519           p02 = _getMouseCoords(source);
63520           p1 = t0.invert(p02);
63521           k22 = t0.k * source._scale;
63522           k22 = clamp2(k22, kMin, kMax);
63523           x22 = p02[0] - p1[0] * k22;
63524           y22 = p02[1] - p1[1] * k22;
63525         } else if (source.ctrlKey && !isInteger(dY)) {
63526           dY *= 6;
63527           t0 = _isTransformed ? _transformLast : _transformStart;
63528           p02 = _getMouseCoords(source);
63529           p1 = t0.invert(p02);
63530           k22 = t0.k * Math.pow(2, -dY / 500);
63531           k22 = clamp2(k22, kMin, kMax);
63532           x22 = p02[0] - p1[0] * k22;
63533           y22 = p02[1] - p1[1] * k22;
63534         } else if ((source.altKey || source.shiftKey) && isInteger(dY)) {
63535           t0 = _isTransformed ? _transformLast : _transformStart;
63536           p02 = _getMouseCoords(source);
63537           p1 = t0.invert(p02);
63538           k22 = t0.k * Math.pow(2, -dY / 500);
63539           k22 = clamp2(k22, kMin, kMax);
63540           x22 = p02[0] - p1[0] * k22;
63541           y22 = p02[1] - p1[1] * k22;
63542         } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) {
63543           p1 = projection2.translate();
63544           x22 = p1[0] - dX;
63545           y22 = p1[1] - dY;
63546           k22 = projection2.scale();
63547           k22 = clamp2(k22, kMin, kMax);
63548         }
63549         if (x22 !== x2 || y22 !== y2 || k22 !== k2) {
63550           x2 = x22;
63551           y2 = y22;
63552           k2 = k22;
63553           eventTransform = identity2.translate(x22, y22).scale(k22);
63554           if (_zoomerPanner._transform) {
63555             _zoomerPanner._transform(eventTransform);
63556           } else {
63557             _selection.node().__zoom = eventTransform;
63558           }
63559         }
63560       }
63561       if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) {
63562         return;
63563       }
63564       if (geoScaleToZoom(k2, TILESIZE) < _minzoom) {
63565         surface.interrupt();
63566         dispatch14.call("hitMinZoom", this, map2);
63567         setCenterZoom(map2.center(), context.minEditableZoom(), 0, true);
63568         scheduleRedraw();
63569         dispatch14.call("move", this, map2);
63570         return;
63571       }
63572       projection2.transform(eventTransform);
63573       var withinEditableZoom = map2.withinEditableZoom();
63574       if (_lastWithinEditableZoom !== withinEditableZoom) {
63575         if (_lastWithinEditableZoom !== void 0) {
63576           dispatch14.call("crossEditableZoom", this, withinEditableZoom);
63577         }
63578         _lastWithinEditableZoom = withinEditableZoom;
63579       }
63580       var scale = k2 / _transformStart.k;
63581       var tX = (x2 / scale - _transformStart.x) * scale;
63582       var tY = (y2 / scale - _transformStart.y) * scale;
63583       if (context.inIntro()) {
63584         curtainProjection.transform({
63585           x: x2 - tX,
63586           y: y2 - tY,
63587           k: k2
63588         });
63589       }
63590       if (source) {
63591         _lastPointerEvent = event;
63592       }
63593       _isTransformed = true;
63594       _transformLast = eventTransform;
63595       utilSetTransform(supersurface, tX, tY, scale);
63596       scheduleRedraw();
63597       dispatch14.call("move", this, map2);
63598       function isInteger(val) {
63599         return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
63600       }
63601     }
63602     function resetTransform() {
63603       if (!_isTransformed) return false;
63604       utilSetTransform(supersurface, 0, 0);
63605       _isTransformed = false;
63606       if (context.inIntro()) {
63607         curtainProjection.transform(projection2.transform());
63608       }
63609       return true;
63610     }
63611     function redraw(difference2, extent) {
63612       if (typeof window === "undefined") return;
63613       if (surface.empty() || !_redrawEnabled) return;
63614       if (resetTransform()) {
63615         difference2 = extent = void 0;
63616       }
63617       var zoom = map2.zoom();
63618       var z2 = String(~~zoom);
63619       if (surface.attr("data-zoom") !== z2) {
63620         surface.attr("data-zoom", z2);
63621       }
63622       var lat = map2.center()[1];
63623       var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true);
63624       surface.classed("low-zoom", zoom <= lowzoom(lat));
63625       if (!difference2) {
63626         supersurface.call(context.background());
63627         wrapper.call(drawLayers);
63628       }
63629       if (map2.editableDataEnabled() || map2.isInWideSelection()) {
63630         context.loadTiles(projection2);
63631         drawEditable(difference2, extent);
63632       } else {
63633         editOff();
63634       }
63635       _transformStart = projection2.transform();
63636       return map2;
63637     }
63638     var immediateRedraw = function(difference2, extent) {
63639       if (!difference2 && !extent) cancelPendingRedraw();
63640       redraw(difference2, extent);
63641     };
63642     map2.lastPointerEvent = function() {
63643       return _lastPointerEvent;
63644     };
63645     map2.mouse = function(d3_event) {
63646       var event = d3_event || _lastPointerEvent;
63647       if (event) {
63648         var s2;
63649         while (s2 = event.sourceEvent) {
63650           event = s2;
63651         }
63652         return _getMouseCoords(event);
63653       }
63654       return null;
63655     };
63656     map2.mouseCoordinates = function() {
63657       var coord2 = map2.mouse() || pxCenter();
63658       return projection2.invert(coord2);
63659     };
63660     map2.dblclickZoomEnable = function(val) {
63661       if (!arguments.length) return _dblClickZoomEnabled;
63662       _dblClickZoomEnabled = val;
63663       return map2;
63664     };
63665     map2.redrawEnable = function(val) {
63666       if (!arguments.length) return _redrawEnabled;
63667       _redrawEnabled = val;
63668       return map2;
63669     };
63670     map2.isTransformed = function() {
63671       return _isTransformed;
63672     };
63673     function setTransform(t2, duration, force) {
63674       var t3 = projection2.transform();
63675       if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y) return false;
63676       if (duration) {
63677         _selection.transition().duration(duration).on("start", function() {
63678           map2.startEase();
63679         }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k));
63680       } else {
63681         projection2.transform(t2);
63682         _transformStart = t2;
63683         _selection.call(_zoomerPanner.transform, _transformStart);
63684       }
63685       return true;
63686     }
63687     function setCenterZoom(loc2, z2, duration, force) {
63688       var c2 = map2.center();
63689       var z3 = map2.zoom();
63690       if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force) return false;
63691       var proj = geoRawMercator().transform(projection2.transform());
63692       var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax);
63693       proj.scale(k2);
63694       var t2 = proj.translate();
63695       var point = proj(loc2);
63696       var center = pxCenter();
63697       t2[0] += center[0] - point[0];
63698       t2[1] += center[1] - point[1];
63699       return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force);
63700     }
63701     map2.pan = function(delta, duration) {
63702       var t2 = projection2.translate();
63703       var k2 = projection2.scale();
63704       t2[0] += delta[0];
63705       t2[1] += delta[1];
63706       if (duration) {
63707         _selection.transition().duration(duration).on("start", function() {
63708           map2.startEase();
63709         }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2));
63710       } else {
63711         projection2.translate(t2);
63712         _transformStart = projection2.transform();
63713         _selection.call(_zoomerPanner.transform, _transformStart);
63714         dispatch14.call("move", this, map2);
63715         immediateRedraw();
63716       }
63717       return map2;
63718     };
63719     map2.dimensions = function(val) {
63720       if (!arguments.length) return _dimensions;
63721       _dimensions = val;
63722       drawLayers.dimensions(_dimensions);
63723       context.background().dimensions(_dimensions);
63724       projection2.clipExtent([[0, 0], _dimensions]);
63725       _getMouseCoords = utilFastMouse(supersurface.node());
63726       scheduleRedraw();
63727       return map2;
63728     };
63729     function zoomIn(delta) {
63730       setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true);
63731     }
63732     function zoomOut(delta) {
63733       setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true);
63734     }
63735     map2.zoomIn = function() {
63736       zoomIn(1);
63737     };
63738     map2.zoomInFurther = function() {
63739       zoomIn(4);
63740     };
63741     map2.canZoomIn = function() {
63742       return map2.zoom() < maxZoom;
63743     };
63744     map2.zoomOut = function() {
63745       zoomOut(1);
63746     };
63747     map2.zoomOutFurther = function() {
63748       zoomOut(4);
63749     };
63750     map2.canZoomOut = function() {
63751       return map2.zoom() > minZoom2;
63752     };
63753     map2.center = function(loc2) {
63754       if (!arguments.length) {
63755         return projection2.invert(pxCenter());
63756       }
63757       if (setCenterZoom(loc2, map2.zoom())) {
63758         dispatch14.call("move", this, map2);
63759       }
63760       scheduleRedraw();
63761       return map2;
63762     };
63763     map2.unobscuredCenterZoomEase = function(loc, zoom) {
63764       var offset = map2.unobscuredOffsetPx();
63765       var proj = geoRawMercator().transform(projection2.transform());
63766       proj.scale(geoZoomToScale(zoom, TILESIZE));
63767       var locPx = proj(loc);
63768       var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
63769       var offsetLoc = proj.invert(offsetLocPx);
63770       map2.centerZoomEase(offsetLoc, zoom);
63771     };
63772     map2.unobscuredOffsetPx = function() {
63773       var openPane = context.container().select(".map-panes .map-pane.shown");
63774       if (!openPane.empty()) {
63775         return [openPane.node().offsetWidth / 2, 0];
63776       }
63777       return [0, 0];
63778     };
63779     map2.zoom = function(z2) {
63780       if (!arguments.length) {
63781         return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0);
63782       }
63783       if (z2 < _minzoom) {
63784         surface.interrupt();
63785         dispatch14.call("hitMinZoom", this, map2);
63786         z2 = context.minEditableZoom();
63787       }
63788       if (setCenterZoom(map2.center(), z2)) {
63789         dispatch14.call("move", this, map2);
63790       }
63791       scheduleRedraw();
63792       return map2;
63793     };
63794     map2.centerZoom = function(loc2, z2) {
63795       if (setCenterZoom(loc2, z2)) {
63796         dispatch14.call("move", this, map2);
63797       }
63798       scheduleRedraw();
63799       return map2;
63800     };
63801     map2.zoomTo = function(entities) {
63802       if (!isArray_default(entities)) {
63803         entities = [entities];
63804       }
63805       if (entities.length === 0) return map2;
63806       var extent = entities.map((entity) => entity.extent(context.graph())).reduce((a2, b2) => a2.extend(b2));
63807       if (!isFinite(extent.area())) return map2;
63808       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
63809       return map2.centerZoom(extent.center(), z2);
63810     };
63811     map2.centerEase = function(loc2, duration) {
63812       duration = duration || 250;
63813       setCenterZoom(loc2, map2.zoom(), duration);
63814       return map2;
63815     };
63816     map2.zoomEase = function(z2, duration) {
63817       duration = duration || 250;
63818       setCenterZoom(map2.center(), z2, duration, false);
63819       return map2;
63820     };
63821     map2.centerZoomEase = function(loc2, z2, duration) {
63822       duration = duration || 250;
63823       setCenterZoom(loc2, z2, duration, false);
63824       return map2;
63825     };
63826     map2.transformEase = function(t2, duration) {
63827       duration = duration || 250;
63828       setTransform(
63829         t2,
63830         duration,
63831         false
63832         /* don't force */
63833       );
63834       return map2;
63835     };
63836     map2.zoomToEase = function(obj, duration) {
63837       var extent;
63838       if (Array.isArray(obj)) {
63839         obj.forEach(function(entity) {
63840           var entityExtent = entity.extent(context.graph());
63841           if (!extent) {
63842             extent = entityExtent;
63843           } else {
63844             extent = extent.extend(entityExtent);
63845           }
63846         });
63847       } else {
63848         extent = obj.extent(context.graph());
63849       }
63850       if (!isFinite(extent.area())) return map2;
63851       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
63852       return map2.centerZoomEase(extent.center(), z2, duration);
63853     };
63854     map2.startEase = function() {
63855       utilBindOnce(surface, _pointerPrefix + "down.ease", function() {
63856         map2.cancelEase();
63857       });
63858       return map2;
63859     };
63860     map2.cancelEase = function() {
63861       _selection.interrupt();
63862       return map2;
63863     };
63864     map2.extent = function(val) {
63865       if (!arguments.length) {
63866         return new geoExtent(
63867           projection2.invert([0, _dimensions[1]]),
63868           projection2.invert([_dimensions[0], 0])
63869         );
63870       } else {
63871         var extent = geoExtent(val);
63872         map2.centerZoom(extent.center(), map2.extentZoom(extent));
63873       }
63874     };
63875     map2.trimmedExtent = function(val) {
63876       if (!arguments.length) {
63877         var headerY = 71;
63878         var footerY = 30;
63879         var pad2 = 10;
63880         return new geoExtent(
63881           projection2.invert([pad2, _dimensions[1] - footerY - pad2]),
63882           projection2.invert([_dimensions[0] - pad2, headerY + pad2])
63883         );
63884       } else {
63885         var extent = geoExtent(val);
63886         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
63887       }
63888     };
63889     function calcExtentZoom(extent, dim) {
63890       var tl = projection2([extent[0][0], extent[1][1]]);
63891       var br2 = projection2([extent[1][0], extent[0][1]]);
63892       var hFactor = (br2[0] - tl[0]) / dim[0];
63893       var vFactor = (br2[1] - tl[1]) / dim[1];
63894       var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
63895       var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
63896       var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff);
63897       return newZoom;
63898     }
63899     map2.extentZoom = function(val) {
63900       return calcExtentZoom(geoExtent(val), _dimensions);
63901     };
63902     map2.trimmedExtentZoom = function(val) {
63903       var trimY = 120;
63904       var trimX = 40;
63905       var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY];
63906       return calcExtentZoom(geoExtent(val), trimmed);
63907     };
63908     map2.withinEditableZoom = function() {
63909       return map2.zoom() >= context.minEditableZoom();
63910     };
63911     map2.isInWideSelection = function() {
63912       return !map2.withinEditableZoom() && context.selectedIDs().length;
63913     };
63914     map2.editableDataEnabled = function(skipZoomCheck) {
63915       var layer = context.layers().layer("osm");
63916       if (!layer || !layer.enabled()) return false;
63917       return skipZoomCheck || map2.withinEditableZoom();
63918     };
63919     map2.notesEditable = function() {
63920       var layer = context.layers().layer("notes");
63921       if (!layer || !layer.enabled()) return false;
63922       return map2.withinEditableZoom();
63923     };
63924     map2.minzoom = function(val) {
63925       if (!arguments.length) return _minzoom;
63926       _minzoom = val;
63927       return map2;
63928     };
63929     map2.toggleHighlightEdited = function() {
63930       surface.classed("highlight-edited", !surface.classed("highlight-edited"));
63931       map2.pan([0, 0]);
63932       dispatch14.call("changeHighlighting", this);
63933     };
63934     map2.areaFillOptions = ["wireframe", "partial", "full"];
63935     map2.activeAreaFill = function(val) {
63936       if (!arguments.length) return corePreferences("area-fill") || "partial";
63937       corePreferences("area-fill", val);
63938       if (val !== "wireframe") {
63939         corePreferences("area-fill-toggle", val);
63940       }
63941       updateAreaFill();
63942       map2.pan([0, 0]);
63943       dispatch14.call("changeAreaFill", this);
63944       return map2;
63945     };
63946     map2.toggleWireframe = function() {
63947       var activeFill = map2.activeAreaFill();
63948       if (activeFill === "wireframe") {
63949         activeFill = corePreferences("area-fill-toggle") || "partial";
63950       } else {
63951         activeFill = "wireframe";
63952       }
63953       map2.activeAreaFill(activeFill);
63954     };
63955     function updateAreaFill() {
63956       var activeFill = map2.activeAreaFill();
63957       map2.areaFillOptions.forEach(function(opt) {
63958         surface.classed("fill-" + opt, Boolean(opt === activeFill));
63959       });
63960     }
63961     map2.layers = () => drawLayers;
63962     map2.doubleUpHandler = function() {
63963       return _doubleUpHandler;
63964     };
63965     return utilRebind(map2, dispatch14, "on");
63966   }
63967
63968   // modules/renderer/photos.js
63969   function rendererPhotos(context) {
63970     var dispatch14 = dispatch_default("change");
63971     var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder", "panoramax"];
63972     var _allPhotoTypes = ["flat", "panoramic"];
63973     var _shownPhotoTypes = _allPhotoTypes.slice();
63974     var _dateFilters = ["fromDate", "toDate"];
63975     var _fromDate;
63976     var _toDate;
63977     var _usernames;
63978     function photos() {
63979     }
63980     function updateStorage() {
63981       if (window.mocha) return;
63982       var hash2 = utilStringQs(window.location.hash);
63983       var enabled = context.layers().all().filter(function(d2) {
63984         return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled();
63985       }).map(function(d2) {
63986         return d2.id;
63987       });
63988       if (enabled.length) {
63989         hash2.photo_overlay = enabled.join(",");
63990       } else {
63991         delete hash2.photo_overlay;
63992       }
63993       window.location.replace("#" + utilQsString(hash2, true));
63994     }
63995     photos.overlayLayerIDs = function() {
63996       return _layerIDs;
63997     };
63998     photos.allPhotoTypes = function() {
63999       return _allPhotoTypes;
64000     };
64001     photos.dateFilters = function() {
64002       return _dateFilters;
64003     };
64004     photos.dateFilterValue = function(val) {
64005       return val === _dateFilters[0] ? _fromDate : _toDate;
64006     };
64007     photos.setDateFilter = function(type2, val, updateUrl) {
64008       var date = val && new Date(val);
64009       if (date && !isNaN(date)) {
64010         val = date.toISOString().slice(0, 10);
64011       } else {
64012         val = null;
64013       }
64014       if (type2 === _dateFilters[0]) {
64015         _fromDate = val;
64016         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
64017           _toDate = _fromDate;
64018         }
64019       }
64020       if (type2 === _dateFilters[1]) {
64021         _toDate = val;
64022         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
64023           _fromDate = _toDate;
64024         }
64025       }
64026       dispatch14.call("change", this);
64027       if (updateUrl) {
64028         var rangeString;
64029         if (_fromDate || _toDate) {
64030           rangeString = (_fromDate || "") + "_" + (_toDate || "");
64031         }
64032         setUrlFilterValue("photo_dates", rangeString);
64033       }
64034     };
64035     photos.setUsernameFilter = function(val, updateUrl) {
64036       if (val && typeof val === "string") val = val.replace(/;/g, ",").split(",");
64037       if (val) {
64038         val = val.map((d2) => d2.trim()).filter(Boolean);
64039         if (!val.length) {
64040           val = null;
64041         }
64042       }
64043       _usernames = val;
64044       dispatch14.call("change", this);
64045       if (updateUrl) {
64046         var hashString;
64047         if (_usernames) {
64048           hashString = _usernames.join(",");
64049         }
64050         setUrlFilterValue("photo_username", hashString);
64051       }
64052     };
64053     function setUrlFilterValue(property, val) {
64054       if (!window.mocha) {
64055         var hash2 = utilStringQs(window.location.hash);
64056         if (val) {
64057           if (hash2[property] === val) return;
64058           hash2[property] = val;
64059         } else {
64060           if (!(property in hash2)) return;
64061           delete hash2[property];
64062         }
64063         window.location.replace("#" + utilQsString(hash2, true));
64064       }
64065     }
64066     function showsLayer(id2) {
64067       var layer = context.layers().layer(id2);
64068       return layer && layer.supported() && layer.enabled();
64069     }
64070     photos.shouldFilterByDate = function() {
64071       return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder") || showsLayer("panoramax");
64072     };
64073     photos.shouldFilterByPhotoType = function() {
64074       return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder") || showsLayer("panoramax");
64075     };
64076     photos.shouldFilterByUsername = function() {
64077       return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside") || showsLayer("panoramax");
64078     };
64079     photos.showsPhotoType = function(val) {
64080       if (!photos.shouldFilterByPhotoType()) return true;
64081       return _shownPhotoTypes.indexOf(val) !== -1;
64082     };
64083     photos.showsFlat = function() {
64084       return photos.showsPhotoType("flat");
64085     };
64086     photos.showsPanoramic = function() {
64087       return photos.showsPhotoType("panoramic");
64088     };
64089     photos.fromDate = function() {
64090       return _fromDate;
64091     };
64092     photos.toDate = function() {
64093       return _toDate;
64094     };
64095     photos.togglePhotoType = function(val) {
64096       var index = _shownPhotoTypes.indexOf(val);
64097       if (index !== -1) {
64098         _shownPhotoTypes.splice(index, 1);
64099       } else {
64100         _shownPhotoTypes.push(val);
64101       }
64102       dispatch14.call("change", this);
64103       return photos;
64104     };
64105     photos.usernames = function() {
64106       return _usernames;
64107     };
64108     photos.init = function() {
64109       var hash2 = utilStringQs(window.location.hash);
64110       if (hash2.photo_dates) {
64111         var parts = /^(.*)[–_](.*)$/g.exec(hash2.photo_dates.trim());
64112         this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false);
64113         this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false);
64114       }
64115       if (hash2.photo_username) {
64116         this.setUsernameFilter(hash2.photo_username, false);
64117       }
64118       if (hash2.photo_overlay) {
64119         var hashOverlayIDs = hash2.photo_overlay.replace(/;/g, ",").split(",");
64120         hashOverlayIDs.forEach(function(id2) {
64121           if (id2 === "openstreetcam") id2 = "kartaview";
64122           var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2);
64123           if (layer2 && !layer2.enabled()) layer2.enabled(true);
64124         });
64125       }
64126       if (hash2.photo) {
64127         var photoIds = hash2.photo.replace(/;/g, ",").split(",");
64128         var photoId = photoIds.length && photoIds[0].trim();
64129         var results = /(.*)\/(.*)/g.exec(photoId);
64130         if (results && results.length >= 3) {
64131           var serviceId = results[1];
64132           if (serviceId === "openstreetcam") serviceId = "kartaview";
64133           var photoKey = results[2];
64134           var service = services[serviceId];
64135           if (service && service.ensureViewerLoaded) {
64136             var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId);
64137             if (layer && !layer.enabled()) layer.enabled(true);
64138             var baselineTime = Date.now();
64139             service.on("loadedImages.rendererPhotos", function() {
64140               if (Date.now() - baselineTime > 45e3) {
64141                 service.on("loadedImages.rendererPhotos", null);
64142                 return;
64143               }
64144               if (!service.cachedImage(photoKey)) return;
64145               service.on("loadedImages.rendererPhotos", null);
64146               service.ensureViewerLoaded(context).then(function() {
64147                 service.selectImage(context, photoKey).showViewer(context);
64148               });
64149             });
64150           }
64151         }
64152       }
64153       context.layers().on("change.rendererPhotos", updateStorage);
64154     };
64155     return utilRebind(photos, dispatch14, "on");
64156   }
64157
64158   // modules/ui/map_in_map.js
64159   function uiMapInMap(context) {
64160     function mapInMap(selection2) {
64161       var backgroundLayer = rendererTileLayer(context).underzoom(2);
64162       var overlayLayers = {};
64163       var projection2 = geoRawMercator();
64164       var dataLayer = svgData(projection2, context).showLabels(false);
64165       var debugLayer = svgDebug(projection2, context);
64166       var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded);
64167       var wrap2 = select_default2(null);
64168       var tiles = select_default2(null);
64169       var viewport = select_default2(null);
64170       var _isTransformed = false;
64171       var _isHidden = true;
64172       var _skipEvents = false;
64173       var _gesture = null;
64174       var _zDiff = 6;
64175       var _dMini;
64176       var _cMini;
64177       var _tStart;
64178       var _tCurr;
64179       var _timeoutID;
64180       function zoomStarted() {
64181         if (_skipEvents) return;
64182         _tStart = _tCurr = projection2.transform();
64183         _gesture = null;
64184       }
64185       function zoomed(d3_event) {
64186         if (_skipEvents) return;
64187         var x2 = d3_event.transform.x;
64188         var y2 = d3_event.transform.y;
64189         var k2 = d3_event.transform.k;
64190         var isZooming = k2 !== _tStart.k;
64191         var isPanning = x2 !== _tStart.x || y2 !== _tStart.y;
64192         if (!isZooming && !isPanning) {
64193           return;
64194         }
64195         if (!_gesture) {
64196           _gesture = isZooming ? "zoom" : "pan";
64197         }
64198         var tMini = projection2.transform();
64199         var tX, tY, scale;
64200         if (_gesture === "zoom") {
64201           scale = k2 / tMini.k;
64202           tX = (_cMini[0] / scale - _cMini[0]) * scale;
64203           tY = (_cMini[1] / scale - _cMini[1]) * scale;
64204         } else {
64205           k2 = tMini.k;
64206           scale = 1;
64207           tX = x2 - tMini.x;
64208           tY = y2 - tMini.y;
64209         }
64210         utilSetTransform(tiles, tX, tY, scale);
64211         utilSetTransform(viewport, 0, 0, scale);
64212         _isTransformed = true;
64213         _tCurr = identity2.translate(x2, y2).scale(k2);
64214         var zMain = geoScaleToZoom(context.projection.scale());
64215         var zMini = geoScaleToZoom(k2);
64216         _zDiff = zMain - zMini;
64217         queueRedraw();
64218       }
64219       function zoomEnded() {
64220         if (_skipEvents) return;
64221         if (_gesture !== "pan") return;
64222         updateProjection();
64223         _gesture = null;
64224         context.map().center(projection2.invert(_cMini));
64225       }
64226       function updateProjection() {
64227         var loc = context.map().center();
64228         var tMain = context.projection.transform();
64229         var zMain = geoScaleToZoom(tMain.k);
64230         var zMini = Math.max(zMain - _zDiff, 0.5);
64231         var kMini = geoZoomToScale(zMini);
64232         projection2.translate([tMain.x, tMain.y]).scale(kMini);
64233         var point = projection2(loc);
64234         var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0];
64235         var xMini = _cMini[0] - point[0] + tMain.x + mouse[0];
64236         var yMini = _cMini[1] - point[1] + tMain.y + mouse[1];
64237         projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]);
64238         _tCurr = projection2.transform();
64239         if (_isTransformed) {
64240           utilSetTransform(tiles, 0, 0);
64241           utilSetTransform(viewport, 0, 0);
64242           _isTransformed = false;
64243         }
64244         zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]);
64245         _skipEvents = true;
64246         wrap2.call(zoom.transform, _tCurr);
64247         _skipEvents = false;
64248       }
64249       function redraw() {
64250         clearTimeout(_timeoutID);
64251         if (_isHidden) return;
64252         updateProjection();
64253         var zMini = geoScaleToZoom(projection2.scale());
64254         tiles = wrap2.selectAll(".map-in-map-tiles").data([0]);
64255         tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles);
64256         backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini);
64257         var background = tiles.selectAll(".map-in-map-background").data([0]);
64258         background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer);
64259         var overlaySources = context.background().overlayLayerSources();
64260         var activeOverlayLayers = [];
64261         for (var i3 = 0; i3 < overlaySources.length; i3++) {
64262           if (overlaySources[i3].validZoom(zMini)) {
64263             if (!overlayLayers[i3]) overlayLayers[i3] = rendererTileLayer(context);
64264             activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini));
64265           }
64266         }
64267         var overlay = tiles.selectAll(".map-in-map-overlay").data([0]);
64268         overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay);
64269         var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) {
64270           return d2.source().name();
64271         });
64272         overlays.exit().remove();
64273         overlays = overlays.enter().append("div").merge(overlays).each(function(layer) {
64274           select_default2(this).call(layer);
64275         });
64276         var dataLayers = tiles.selectAll(".map-in-map-data").data([0]);
64277         dataLayers.exit().remove();
64278         dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer);
64279         if (_gesture !== "pan") {
64280           var getPath = path_default(projection2);
64281           var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] };
64282           viewport = wrap2.selectAll(".map-in-map-viewport").data([0]);
64283           viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport);
64284           var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]);
64285           path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) {
64286             return getPath.area(d2) < 30;
64287           });
64288         }
64289       }
64290       function queueRedraw() {
64291         clearTimeout(_timeoutID);
64292         _timeoutID = setTimeout(function() {
64293           redraw();
64294         }, 750);
64295       }
64296       function toggle(d3_event) {
64297         if (d3_event) d3_event.preventDefault();
64298         _isHidden = !_isHidden;
64299         context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden);
64300         if (_isHidden) {
64301           wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() {
64302             selection2.selectAll(".map-in-map").style("display", "none");
64303           });
64304         } else {
64305           wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() {
64306             redraw();
64307           });
64308         }
64309       }
64310       uiMapInMap.toggle = toggle;
64311       wrap2 = selection2.selectAll(".map-in-map").data([0]);
64312       wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2);
64313       _dMini = [200, 150];
64314       _cMini = geoVecScale(_dMini, 0.5);
64315       context.map().on("drawn.map-in-map", function(drawn) {
64316         if (drawn.full === true) {
64317           redraw();
64318         }
64319       });
64320       redraw();
64321       context.keybinding().on(_t("background.minimap.key"), toggle);
64322     }
64323     return mapInMap;
64324   }
64325
64326   // modules/ui/notice.js
64327   function uiNotice(context) {
64328     return function(selection2) {
64329       var div = selection2.append("div").attr("class", "notice");
64330       var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() {
64331         context.map().zoomEase(context.minEditableZoom());
64332       }).on("wheel", function(d3_event) {
64333         var e22 = new WheelEvent(d3_event.type, d3_event);
64334         context.surface().node().dispatchEvent(e22);
64335       });
64336       button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit"));
64337       function disableTooHigh() {
64338         var canEdit = context.map().zoom() >= context.minEditableZoom();
64339         div.style("display", canEdit ? "none" : "block");
64340       }
64341       context.map().on("move.notice", debounce_default(disableTooHigh, 500));
64342       disableTooHigh();
64343     };
64344   }
64345
64346   // modules/ui/photoviewer.js
64347   function uiPhotoviewer(context) {
64348     var dispatch14 = dispatch_default("resize");
64349     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
64350     function photoviewer(selection2) {
64351       selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() {
64352         if (services.streetside) {
64353           services.streetside.hideViewer(context);
64354         }
64355         if (services.mapillary) {
64356           services.mapillary.hideViewer(context);
64357         }
64358         if (services.kartaview) {
64359           services.kartaview.hideViewer(context);
64360         }
64361         if (services.mapilio) {
64362           services.mapilio.hideViewer(context);
64363         }
64364         if (services.panoramax) {
64365           services.panoramax.hideViewer(context);
64366         }
64367         if (services.vegbilder) {
64368           services.vegbilder.hideViewer(context);
64369         }
64370       }).append("div").call(svgIcon("#iD-icon-close"));
64371       function preventDefault(d3_event) {
64372         d3_event.preventDefault();
64373       }
64374       selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on(
64375         _pointerPrefix + "down",
64376         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true })
64377       );
64378       selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on(
64379         _pointerPrefix + "down",
64380         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true })
64381       );
64382       selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on(
64383         _pointerPrefix + "down",
64384         buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true })
64385       );
64386       context.features().on("change.setPhotoFromViewer", function() {
64387         setPhotoFromViewerButton();
64388       });
64389       context.history().on("change.setPhotoFromViewer", function() {
64390         setPhotoFromViewerButton();
64391       });
64392       function setPhotoFromViewerButton() {
64393         if (services.mapillary.isViewerOpen()) {
64394           let setMapillaryPhotoId2 = function() {
64395             const service = services.mapillary;
64396             const image = service.getActiveImage();
64397             const action = (graph) => context.selectedIDs().reduce((graph2, entityID) => {
64398               const tags = graph2.entity(entityID).tags;
64399               const action2 = actionChangeTags(entityID, __spreadProps(__spreadValues({}, tags), { mapillary: image.id }));
64400               return action2(graph2);
64401             }, graph);
64402             const annotation = _t("operations.change_tags.annotation");
64403             context.perform(action, annotation);
64404           };
64405           var setMapillaryPhotoId = setMapillaryPhotoId2;
64406           if (context.mode().id !== "select" || !(layerStatus("mapillary") && getServiceId() === "mapillary")) {
64407             buttonRemove();
64408           } else {
64409             if (selection2.select(".set-photo-from-viewer").empty()) {
64410               const button = buttonCreate();
64411               button.on("click", function(e3) {
64412                 e3.preventDefault();
64413                 e3.stopPropagation();
64414                 setMapillaryPhotoId2();
64415                 buttonDisable("already_set");
64416               });
64417             }
64418             buttonShowHide();
64419           }
64420         }
64421         function layerStatus(which) {
64422           const layers = context.layers();
64423           const layer = layers.layer(which);
64424           return layer.enabled();
64425         }
64426         function getServiceId() {
64427           const hash2 = utilStringQs(window.location.hash);
64428           let serviceId;
64429           if (hash2.photo) {
64430             let result = hash2.photo.split("/");
64431             serviceId = result[0];
64432           }
64433           return serviceId;
64434         }
64435         function buttonCreate() {
64436           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
64437           const buttonEnter = button.enter().append("button").attr("class", "set-photo-from-viewer").call(svgIcon("#iD-icon-plus")).call(
64438             uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right")
64439           );
64440           buttonEnter.select(".tooltip").classed("dark", true).style("width", "300px");
64441           return buttonEnter;
64442         }
64443         function buttonRemove() {
64444           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
64445           button.remove();
64446         }
64447         function buttonShowHide() {
64448           const activeImage = services.mapillary.getActiveImage();
64449           const graph = context.graph();
64450           const entities = context.selectedIDs().map((id2) => graph.entity(id2));
64451           if (entities.map((entity) => entity.tags.mapillary).every((value) => value === (activeImage == null ? void 0 : activeImage.id))) {
64452             buttonDisable("already_set");
64453           } else if (activeImage && entities.map((entity) => entity.extent(context.graph()).center()).every((loc) => geoSphericalDistance(loc, activeImage.loc) > 100)) {
64454             buttonDisable("too_far");
64455           } else {
64456             buttonDisable(false);
64457           }
64458         }
64459         function buttonDisable(reason) {
64460           const disabled = reason !== false;
64461           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
64462           button.attr("disabled", disabled ? "true" : null);
64463           button.classed("disabled", disabled);
64464           button.call(uiTooltip().destroyAny);
64465           if (disabled) {
64466             button.call(
64467               uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.disable.".concat(reason))).placement("right")
64468             );
64469           } else {
64470             button.call(
64471               uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right")
64472             );
64473           }
64474           button.select(".tooltip").classed("dark", true).style("width", "300px");
64475         }
64476       }
64477       function buildResizeListener(target, eventName, dispatch15, options2) {
64478         var resizeOnX = !!options2.resizeOnX;
64479         var resizeOnY = !!options2.resizeOnY;
64480         var minHeight = options2.minHeight || 240;
64481         var minWidth = options2.minWidth || 320;
64482         var pointerId;
64483         var startX;
64484         var startY;
64485         var startWidth;
64486         var startHeight;
64487         function startResize(d3_event) {
64488           if (pointerId !== (d3_event.pointerId || "mouse")) return;
64489           d3_event.preventDefault();
64490           d3_event.stopPropagation();
64491           var mapSize = context.map().dimensions();
64492           if (resizeOnX) {
64493             var mapWidth = mapSize[0];
64494             const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-left"), 10);
64495             var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, mapWidth - viewerMargin * 2);
64496             target.style("width", newWidth + "px");
64497           }
64498           if (resizeOnY) {
64499             const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1];
64500             const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10);
64501             var maxHeight = mapSize[1] - menuHeight - viewerMargin * 2;
64502             var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight);
64503             target.style("height", newHeight + "px");
64504           }
64505           dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target));
64506         }
64507         function clamp3(num, min3, max3) {
64508           return Math.max(min3, Math.min(num, max3));
64509         }
64510         function stopResize(d3_event) {
64511           if (pointerId !== (d3_event.pointerId || "mouse")) return;
64512           d3_event.preventDefault();
64513           d3_event.stopPropagation();
64514           select_default2(window).on("." + eventName, null);
64515         }
64516         return function initResize(d3_event) {
64517           d3_event.preventDefault();
64518           d3_event.stopPropagation();
64519           pointerId = d3_event.pointerId || "mouse";
64520           startX = d3_event.clientX;
64521           startY = d3_event.clientY;
64522           var targetRect = target.node().getBoundingClientRect();
64523           startWidth = targetRect.width;
64524           startHeight = targetRect.height;
64525           select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false);
64526           if (_pointerPrefix === "pointer") {
64527             select_default2(window).on("pointercancel." + eventName, stopResize, false);
64528           }
64529         };
64530       }
64531     }
64532     photoviewer.onMapResize = function() {
64533       var photoviewer2 = context.container().select(".photoviewer");
64534       var content = context.container().select(".main-content");
64535       var mapDimensions = utilGetDimensions(content, true);
64536       const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1];
64537       const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10);
64538       var photoDimensions = utilGetDimensions(photoviewer2, true);
64539       if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - menuHeight - viewerMargin * 2) {
64540         var setPhotoDimensions = [
64541           Math.min(photoDimensions[0], mapDimensions[0]),
64542           Math.min(photoDimensions[1], mapDimensions[1] - menuHeight - viewerMargin * 2)
64543         ];
64544         photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px");
64545         dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2));
64546       }
64547     };
64548     function subtractPadding(dimensions, selection2) {
64549       return [
64550         dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")),
64551         dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom"))
64552       ];
64553     }
64554     return utilRebind(photoviewer, dispatch14, "on");
64555   }
64556
64557   // modules/ui/restore.js
64558   function uiRestore(context) {
64559     return function(selection2) {
64560       if (!context.history().hasRestorableChanges()) return;
64561       let modalSelection = uiModal(selection2, true);
64562       modalSelection.select(".modal").attr("class", "modal fillL");
64563       let introModal = modalSelection.select(".content");
64564       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading"));
64565       introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description"));
64566       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
64567       let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => {
64568         context.history().restore();
64569         modalSelection.remove();
64570       });
64571       restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore");
64572       restore.append("div").call(_t.append("restore.restore"));
64573       let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => {
64574         context.history().clearSaved();
64575         modalSelection.remove();
64576       });
64577       reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset");
64578       reset.append("div").call(_t.append("restore.reset"));
64579       restore.node().focus();
64580     };
64581   }
64582
64583   // modules/ui/scale.js
64584   function uiScale(context) {
64585     var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8;
64586     function scaleDefs(loc1, loc2) {
64587       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;
64588       if (isImperial) {
64589         buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1];
64590       } else {
64591         buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1];
64592       }
64593       for (i3 = 0; i3 < buckets.length; i3++) {
64594         val = buckets[i3];
64595         if (dist >= val) {
64596           scale.dist = Math.floor(dist / val) * val;
64597           break;
64598         } else {
64599           scale.dist = +dist.toFixed(2);
64600         }
64601       }
64602       dLon = geoMetersToLon(scale.dist / conversion, lat);
64603       scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]);
64604       scale.text = displayLength(scale.dist / conversion, isImperial);
64605       return scale;
64606     }
64607     function update(selection2) {
64608       var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2);
64609       selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight);
64610       selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text);
64611     }
64612     return function(selection2) {
64613       function switchUnits() {
64614         isImperial = !isImperial;
64615         selection2.call(update);
64616       }
64617       var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)");
64618       scalegroup.append("path").attr("class", "scale-path");
64619       selection2.append("div").attr("class", "scale-text");
64620       selection2.call(update);
64621       context.map().on("move.scale", function() {
64622         update(selection2);
64623       });
64624     };
64625   }
64626
64627   // modules/ui/shortcuts.js
64628   function uiShortcuts(context) {
64629     var detected = utilDetect();
64630     var _activeTab = 0;
64631     var _modalSelection;
64632     var _selection = select_default2(null);
64633     var _dataShortcuts;
64634     function shortcutsModal(_modalSelection2) {
64635       _modalSelection2.select(".modal").classed("modal-shortcuts", true);
64636       var content = _modalSelection2.select(".content");
64637       content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title"));
64638       _mainFileFetcher.get("shortcuts").then(function(data) {
64639         _dataShortcuts = data;
64640         content.call(render);
64641       }).catch(function() {
64642       });
64643     }
64644     function render(selection2) {
64645       if (!_dataShortcuts) return;
64646       var wrapper = selection2.selectAll(".wrapper").data([0]);
64647       var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section");
64648       var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar");
64649       var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list");
64650       wrapper = wrapper.merge(wrapperEnter);
64651       var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts);
64652       var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) {
64653         d3_event.preventDefault();
64654         var i3 = _dataShortcuts.indexOf(d2);
64655         _activeTab = i3;
64656         render(selection2);
64657       });
64658       tabsEnter.append("span").html(function(d2) {
64659         return _t.html(d2.text);
64660       });
64661       wrapper.selectAll(".tab").classed("active", function(d2, i3) {
64662         return i3 === _activeTab;
64663       });
64664       var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts);
64665       var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) {
64666         return "shortcut-tab shortcut-tab-" + d2.tab;
64667       });
64668       var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) {
64669         return d2.columns;
64670       }).enter().append("table").attr("class", "shortcut-column");
64671       var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) {
64672         return d2.rows;
64673       }).enter().append("tr").attr("class", "shortcut-row");
64674       var sectionRows = rowsEnter.filter(function(d2) {
64675         return !d2.shortcuts;
64676       });
64677       sectionRows.append("td");
64678       sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) {
64679         return _t.html(d2.text);
64680       });
64681       var shortcutRows = rowsEnter.filter(function(d2) {
64682         return d2.shortcuts;
64683       });
64684       var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys");
64685       var modifierKeys = shortcutKeys.filter(function(d2) {
64686         return d2.modifiers;
64687       });
64688       modifierKeys.selectAll("kbd.modifier").data(function(d2) {
64689         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
64690           return ["\u2318"];
64691         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
64692           return [];
64693         } else {
64694           return d2.modifiers;
64695         }
64696       }).enter().each(function() {
64697         var selection3 = select_default2(this);
64698         selection3.append("kbd").attr("class", "modifier").text(function(d2) {
64699           return uiCmd.display(d2);
64700         });
64701         selection3.append("span").text("+");
64702       });
64703       shortcutKeys.selectAll("kbd.shortcut").data(function(d2) {
64704         var arr = d2.shortcuts;
64705         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
64706           arr = ["Y"];
64707         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
64708           arr = ["F11"];
64709         }
64710         arr = arr.map(function(s2) {
64711           return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2);
64712         });
64713         return utilArrayUniq(arr).map(function(s2) {
64714           return {
64715             shortcut: s2,
64716             separator: d2.separator,
64717             suffix: d2.suffix
64718           };
64719         });
64720       }).enter().each(function(d2, i3, nodes) {
64721         var selection3 = select_default2(this);
64722         var click = d2.shortcut.toLowerCase().match(/(.*).click/);
64723         if (click && click[1]) {
64724           selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation"));
64725         } else if (d2.shortcut.toLowerCase() === "long-press") {
64726           selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation"));
64727         } else if (d2.shortcut.toLowerCase() === "tap") {
64728           selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation"));
64729         } else {
64730           selection3.append("kbd").attr("class", "shortcut").text(function(d4) {
64731             return d4.shortcut;
64732           });
64733         }
64734         if (i3 < nodes.length - 1) {
64735           selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0");
64736         } else if (i3 === nodes.length - 1 && d2.suffix) {
64737           selection3.append("span").text(d2.suffix);
64738         }
64739       });
64740       shortcutKeys.filter(function(d2) {
64741         return d2.gesture;
64742       }).each(function() {
64743         var selection3 = select_default2(this);
64744         selection3.append("span").text("+");
64745         selection3.append("span").attr("class", "gesture").html(function(d2) {
64746           return _t.html(d2.gesture);
64747         });
64748       });
64749       shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) {
64750         return d2.text ? _t.html(d2.text) : "\xA0";
64751       });
64752       wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) {
64753         return i3 === _activeTab ? "flex" : "none";
64754       });
64755     }
64756     return function(selection2, show) {
64757       _selection = selection2;
64758       if (show) {
64759         _modalSelection = uiModal(selection2);
64760         _modalSelection.call(shortcutsModal);
64761       } else {
64762         context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() {
64763           if (context.container().selectAll(".modal-shortcuts").size()) {
64764             if (_modalSelection) {
64765               _modalSelection.close();
64766               _modalSelection = null;
64767             }
64768           } else {
64769             _modalSelection = uiModal(_selection);
64770             _modalSelection.call(shortcutsModal);
64771           }
64772         });
64773       }
64774     };
64775   }
64776
64777   // modules/ui/data_header.js
64778   function uiDataHeader() {
64779     var _datum;
64780     function dataHeader(selection2) {
64781       var header = selection2.selectAll(".data-header").data(
64782         _datum ? [_datum] : [],
64783         function(d2) {
64784           return d2.__featurehash__;
64785         }
64786       );
64787       header.exit().remove();
64788       var headerEnter = header.enter().append("div").attr("class", "data-header");
64789       var iconEnter = headerEnter.append("div").attr("class", "data-header-icon");
64790       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill"));
64791       headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title"));
64792     }
64793     dataHeader.datum = function(val) {
64794       if (!arguments.length) return _datum;
64795       _datum = val;
64796       return this;
64797     };
64798     return dataHeader;
64799   }
64800
64801   // modules/ui/disclosure.js
64802   function uiDisclosure(context, key, expandedDefault) {
64803     var dispatch14 = dispatch_default("toggled");
64804     var _expanded;
64805     var _label = utilFunctor("");
64806     var _updatePreference = true;
64807     var _content = function() {
64808     };
64809     var disclosure = function(selection2) {
64810       if (_expanded === void 0 || _expanded === null) {
64811         var preference = corePreferences("disclosure." + key + ".expanded");
64812         _expanded = preference === null ? !!expandedDefault : preference === "true";
64813       }
64814       var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]);
64815       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"));
64816       hideToggleEnter.append("span").attr("class", "hide-toggle-text");
64817       hideToggle = hideToggleEnter.merge(hideToggle);
64818       hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded);
64819       const label = _label();
64820       const labelSelection = hideToggle.selectAll(".hide-toggle-text");
64821       if (typeof label !== "function") {
64822         labelSelection.text(_label());
64823       } else {
64824         labelSelection.text("").call(label);
64825       }
64826       hideToggle.selectAll(".hide-toggle-icon").attr(
64827         "xlink:href",
64828         _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64829       );
64830       var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]);
64831       wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded);
64832       if (_expanded) {
64833         wrap2.call(_content);
64834       }
64835       function toggle(d3_event) {
64836         d3_event.preventDefault();
64837         _expanded = !_expanded;
64838         if (_updatePreference) {
64839           corePreferences("disclosure." + key + ".expanded", _expanded);
64840         }
64841         hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand")));
64842         hideToggle.selectAll(".hide-toggle-icon").attr(
64843           "xlink:href",
64844           _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64845         );
64846         wrap2.call(uiToggle(_expanded));
64847         if (_expanded) {
64848           wrap2.call(_content);
64849         }
64850         dispatch14.call("toggled", this, _expanded);
64851       }
64852     };
64853     disclosure.label = function(val) {
64854       if (!arguments.length) return _label;
64855       _label = utilFunctor(val);
64856       return disclosure;
64857     };
64858     disclosure.expanded = function(val) {
64859       if (!arguments.length) return _expanded;
64860       _expanded = val;
64861       return disclosure;
64862     };
64863     disclosure.updatePreference = function(val) {
64864       if (!arguments.length) return _updatePreference;
64865       _updatePreference = val;
64866       return disclosure;
64867     };
64868     disclosure.content = function(val) {
64869       if (!arguments.length) return _content;
64870       _content = val;
64871       return disclosure;
64872     };
64873     return utilRebind(disclosure, dispatch14, "on");
64874   }
64875
64876   // modules/ui/section.js
64877   function uiSection(id2, context) {
64878     var _classes = utilFunctor("");
64879     var _shouldDisplay;
64880     var _content;
64881     var _disclosure;
64882     var _label;
64883     var _expandedByDefault = utilFunctor(true);
64884     var _disclosureContent;
64885     var _disclosureExpanded;
64886     var _containerSelection = select_default2(null);
64887     var section = {
64888       id: id2
64889     };
64890     section.classes = function(val) {
64891       if (!arguments.length) return _classes;
64892       _classes = utilFunctor(val);
64893       return section;
64894     };
64895     section.label = function(val) {
64896       if (!arguments.length) return _label;
64897       _label = utilFunctor(val);
64898       return section;
64899     };
64900     section.expandedByDefault = function(val) {
64901       if (!arguments.length) return _expandedByDefault;
64902       _expandedByDefault = utilFunctor(val);
64903       return section;
64904     };
64905     section.shouldDisplay = function(val) {
64906       if (!arguments.length) return _shouldDisplay;
64907       _shouldDisplay = utilFunctor(val);
64908       return section;
64909     };
64910     section.content = function(val) {
64911       if (!arguments.length) return _content;
64912       _content = val;
64913       return section;
64914     };
64915     section.disclosureContent = function(val) {
64916       if (!arguments.length) return _disclosureContent;
64917       _disclosureContent = val;
64918       return section;
64919     };
64920     section.disclosureExpanded = function(val) {
64921       if (!arguments.length) return _disclosureExpanded;
64922       _disclosureExpanded = val;
64923       return section;
64924     };
64925     section.render = function(selection2) {
64926       _containerSelection = selection2.selectAll(".section-" + id2).data([0]);
64927       var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || ""));
64928       _containerSelection = sectionEnter.merge(_containerSelection);
64929       _containerSelection.call(renderContent);
64930     };
64931     section.reRender = function() {
64932       _containerSelection.call(renderContent);
64933     };
64934     section.selection = function() {
64935       return _containerSelection;
64936     };
64937     section.disclosure = function() {
64938       return _disclosure;
64939     };
64940     function renderContent(selection2) {
64941       if (_shouldDisplay) {
64942         var shouldDisplay = _shouldDisplay();
64943         selection2.classed("hide", !shouldDisplay);
64944         if (!shouldDisplay) {
64945           selection2.html("");
64946           return;
64947         }
64948       }
64949       if (_disclosureContent) {
64950         if (!_disclosure) {
64951           _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent);
64952         }
64953         if (_disclosureExpanded !== void 0) {
64954           _disclosure.expanded(_disclosureExpanded);
64955           _disclosureExpanded = void 0;
64956         }
64957         selection2.call(_disclosure);
64958         return;
64959       }
64960       if (_content) {
64961         selection2.call(_content);
64962       }
64963     }
64964     return section;
64965   }
64966
64967   // modules/ui/tag_reference.js
64968   function uiTagReference(what) {
64969     var wikibase = what.qid ? services.wikidata : services.osmWikibase;
64970     var tagReference = {};
64971     var _button = select_default2(null);
64972     var _body = select_default2(null);
64973     var _loaded;
64974     var _showing;
64975     function load() {
64976       if (!wikibase) return;
64977       _button.classed("tag-reference-loading", true);
64978       wikibase.getDocs(what, gotDocs);
64979     }
64980     function gotDocs(err, docs) {
64981       _body.html("");
64982       if (!docs || !docs.title) {
64983         _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key"));
64984         done();
64985         return;
64986       }
64987       if (docs.imageURL) {
64988         _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.title).attr("src", docs.imageURL).on("load", function() {
64989           done();
64990         }).on("error", function() {
64991           select_default2(this).remove();
64992           done();
64993         });
64994       } else {
64995         done();
64996       }
64997       var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span");
64998       if (docs.description) {
64999         tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").call(docs.description);
65000       } else {
65001         tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key"));
65002       }
65003       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"));
65004       if (docs.wiki) {
65005         _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));
65006       }
65007       if (what.key === "comment") {
65008         _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"));
65009       }
65010     }
65011     function done() {
65012       _loaded = true;
65013       _button.classed("tag-reference-loading", false);
65014       _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1");
65015       _showing = true;
65016       _button.selectAll("svg.icon use").each(function() {
65017         var iconUse = select_default2(this);
65018         if (iconUse.attr("href") === "#iD-icon-info") {
65019           iconUse.attr("href", "#iD-icon-info-filled");
65020         }
65021       });
65022     }
65023     function hide() {
65024       _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
65025         _body.classed("expanded", false);
65026       });
65027       _showing = false;
65028       _button.selectAll("svg.icon use").each(function() {
65029         var iconUse = select_default2(this);
65030         if (iconUse.attr("href") === "#iD-icon-info-filled") {
65031           iconUse.attr("href", "#iD-icon-info");
65032         }
65033       });
65034     }
65035     tagReference.button = function(selection2, klass, iconName) {
65036       _button = selection2.selectAll(".tag-reference-button").data([0]);
65037       _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button);
65038       _button.on("click", function(d3_event) {
65039         d3_event.stopPropagation();
65040         d3_event.preventDefault();
65041         this.blur();
65042         if (_showing) {
65043           hide();
65044         } else if (_loaded) {
65045           done();
65046         } else {
65047           load();
65048         }
65049       });
65050     };
65051     tagReference.body = function(selection2) {
65052       var itemID = what.qid || what.key + "-" + (what.value || "");
65053       _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) {
65054         return d2;
65055       });
65056       _body.exit().remove();
65057       _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body);
65058       if (_showing === false) {
65059         hide();
65060       }
65061     };
65062     tagReference.showing = function(val) {
65063       if (!arguments.length) return _showing;
65064       _showing = val;
65065       return tagReference;
65066     };
65067     return tagReference;
65068   }
65069
65070   // modules/ui/sections/raw_tag_editor.js
65071   function uiSectionRawTagEditor(id2, context) {
65072     var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
65073       var count = Object.keys(_tags).filter(function(d2) {
65074         return d2;
65075       }).length;
65076       return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
65077     }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
65078     var taginfo = services.taginfo;
65079     var dispatch14 = dispatch_default("change");
65080     var availableViews = [
65081       { id: "list", icon: "#fas-th-list" },
65082       { id: "text", icon: "#fas-i-cursor" }
65083     ];
65084     let _discardTags = {};
65085     _mainFileFetcher.get("discarded").then((d2) => {
65086       _discardTags = d2;
65087     }).catch(() => {
65088     });
65089     var _tagView = corePreferences("raw-tag-editor-view") || "list";
65090     var _readOnlyTags = [];
65091     var _orderedKeys = [];
65092     var _showBlank = false;
65093     var _pendingChange = null;
65094     var _state;
65095     var _presets;
65096     var _tags;
65097     var _entityIDs;
65098     var _didInteract = false;
65099     function interacted() {
65100       _didInteract = true;
65101     }
65102     function renderDisclosureContent(wrap2) {
65103       _orderedKeys = _orderedKeys.filter(function(key) {
65104         return _tags[key] !== void 0;
65105       });
65106       var all = Object.keys(_tags).sort();
65107       var missingKeys = utilArrayDifference(all, _orderedKeys);
65108       for (var i3 in missingKeys) {
65109         _orderedKeys.push(missingKeys[i3]);
65110       }
65111       var rowData = _orderedKeys.map(function(key, i4) {
65112         return { index: i4, key, value: _tags[key] };
65113       });
65114       if (!rowData.length || _showBlank) {
65115         _showBlank = false;
65116         rowData.push({ index: rowData.length, key: "", value: "" });
65117       }
65118       var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
65119       options2.exit().remove();
65120       var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
65121       var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
65122         return d2.id;
65123       }).enter();
65124       optionEnter.append("button").attr("class", function(d2) {
65125         return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
65126       }).attr("aria-selected", function(d2) {
65127         return _tagView === d2.id;
65128       }).attr("role", "tab").attr("title", function(d2) {
65129         return _t("icons." + d2.id);
65130       }).on("click", function(d3_event, d2) {
65131         _tagView = d2.id;
65132         corePreferences("raw-tag-editor-view", d2.id);
65133         wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
65134           return datum2 === d2;
65135         }).attr("aria-selected", function(datum2) {
65136           return datum2 === d2;
65137         });
65138         wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
65139         wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
65140       }).each(function(d2) {
65141         select_default2(this).call(svgIcon(d2.icon));
65142       });
65143       var textData = rowsToText(rowData);
65144       var textarea = wrap2.selectAll(".tag-text").data([0]);
65145       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);
65146       textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
65147       var list2 = wrap2.selectAll(".tag-list").data([0]);
65148       list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
65149       var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
65150       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);
65151       addRowEnter.append("div").attr("class", "space-value");
65152       addRowEnter.append("div").attr("class", "space-buttons");
65153       var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
65154         return d2.key;
65155       });
65156       items.exit().each(unbind).remove();
65157       var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
65158       var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
65159       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);
65160       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);
65161       innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
65162       items = items.merge(itemsEnter).sort(function(a2, b2) {
65163         return a2.index - b2.index;
65164       });
65165       items.each(function(d2) {
65166         var row = select_default2(this);
65167         var key = row.select("input.key");
65168         var value = row.select("input.value");
65169         if (_entityIDs && taginfo && _state !== "hover") {
65170           bindTypeahead(key, value);
65171         }
65172         var referenceOptions = { key: d2.key };
65173         if (typeof d2.value === "string") {
65174           referenceOptions.value = d2.value;
65175         }
65176         var reference = uiTagReference(referenceOptions, context);
65177         if (_state === "hover") {
65178           reference.showing(false);
65179         }
65180         row.select(".inner-wrap").call(reference.button);
65181         row.call(reference.body);
65182         row.select("button.remove");
65183       });
65184       items.selectAll("input.key").attr("title", function(d2) {
65185         return d2.key;
65186       }).call(utilGetSetValue, function(d2) {
65187         return d2.key;
65188       }).attr("readonly", function(d2) {
65189         return isReadOnly(d2) || null;
65190       });
65191       items.selectAll("input.value").attr("title", function(d2) {
65192         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
65193       }).classed("mixed", function(d2) {
65194         return Array.isArray(d2.value);
65195       }).attr("placeholder", function(d2) {
65196         return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
65197       }).call(utilGetSetValue, function(d2) {
65198         return typeof d2.value === "string" ? d2.value : "";
65199       }).attr("readonly", function(d2) {
65200         return isReadOnly(d2) || null;
65201       });
65202       items.selectAll("button.remove").on(
65203         ("PointerEvent" in window ? "pointer" : "mouse") + "down",
65204         // 'click' fires too late - #5878
65205         (d3_event, d2) => {
65206           if (d3_event.button !== 0) return;
65207           removeTag(d3_event, d2);
65208         }
65209       );
65210     }
65211     function isReadOnly(d2) {
65212       for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
65213         if (d2.key.match(_readOnlyTags[i3]) !== null) {
65214           return true;
65215         }
65216       }
65217       return false;
65218     }
65219     function setTextareaHeight() {
65220       if (_tagView !== "text") return;
65221       var selection2 = select_default2(this);
65222       var matches = selection2.node().value.match(/\n/g);
65223       var lineCount = 2 + Number(matches && matches.length);
65224       var lineHeight = 20;
65225       selection2.style("height", lineCount * lineHeight + "px");
65226     }
65227     function stringify3(s2) {
65228       const stringified = JSON.stringify(s2).slice(1, -1);
65229       if (stringified !== s2) {
65230         return '"'.concat(stringified, '"');
65231       } else {
65232         return s2;
65233       }
65234     }
65235     function unstringify(s2) {
65236       const isQuoted = s2.length > 1 && s2.charAt(0) === '"' && s2.charAt(s2.length - 1) === '"';
65237       if (isQuoted) {
65238         try {
65239           return JSON.parse(s2);
65240         } catch (e3) {
65241           return s2;
65242         }
65243       } else {
65244         return s2;
65245       }
65246     }
65247     function rowsToText(rows) {
65248       var str = rows.filter(function(row) {
65249         return row.key && row.key.trim() !== "";
65250       }).map(function(row) {
65251         var rawVal = row.value;
65252         if (typeof rawVal !== "string") rawVal = "*";
65253         var val = rawVal ? stringify3(rawVal) : "";
65254         return stringify3(row.key) + "=" + val;
65255       }).join("\n");
65256       if (_state !== "hover" && str.length) {
65257         return str + "\n";
65258       }
65259       return str;
65260     }
65261     function textChanged() {
65262       var newText = this.value.trim();
65263       var newTags = {};
65264       newText.split("\n").forEach(function(row) {
65265         var m2 = row.match(/^\s*([^=]+)=(.*)$/);
65266         if (m2 !== null) {
65267           var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
65268           var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
65269           newTags[k2] = v2;
65270         }
65271       });
65272       var tagDiff = utilTagDiff(_tags, newTags);
65273       _pendingChange = _pendingChange || {};
65274       tagDiff.forEach(function(change) {
65275         if (isReadOnly({ key: change.key })) return;
65276         if (change.newVal === "*" && typeof change.oldVal !== "string") return;
65277         if (change.type === "-") {
65278           _pendingChange[change.key] = void 0;
65279         } else if (change.type === "+") {
65280           _pendingChange[change.key] = change.newVal || "";
65281         }
65282       });
65283       if (Object.keys(_pendingChange).length === 0) {
65284         _pendingChange = null;
65285         section.reRender();
65286         return;
65287       }
65288       scheduleChange();
65289     }
65290     function pushMore(d3_event) {
65291       if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
65292         addTag();
65293       }
65294     }
65295     function bindTypeahead(key, value) {
65296       if (isReadOnly(key.datum())) return;
65297       if (Array.isArray(value.datum().value)) {
65298         value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
65299           var keyString = utilGetSetValue(key);
65300           if (!_tags[keyString]) return;
65301           var data = _tags[keyString].map(function(tagValue) {
65302             if (!tagValue) {
65303               return {
65304                 value: " ",
65305                 title: _t("inspector.empty"),
65306                 display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
65307               };
65308             }
65309             return {
65310               value: tagValue,
65311               title: tagValue
65312             };
65313           });
65314           callback(data);
65315         }));
65316         return;
65317       }
65318       var geometry = context.graph().geometry(_entityIDs[0]);
65319       key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
65320         taginfo.keys({
65321           debounce: true,
65322           geometry,
65323           query: value2
65324         }, function(err, data) {
65325           if (!err) {
65326             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()));
65327             callback(sort(value2, filtered));
65328           }
65329         });
65330       }));
65331       value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
65332         taginfo.values({
65333           debounce: true,
65334           key: utilGetSetValue(key),
65335           geometry,
65336           query: value2
65337         }, function(err, data) {
65338           if (!err) {
65339             const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
65340             callback(sort(value2, filtered));
65341           }
65342         });
65343       }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
65344       function sort(value2, data) {
65345         var sameletter = [];
65346         var other2 = [];
65347         for (var i3 = 0; i3 < data.length; i3++) {
65348           if (data[i3].value.substring(0, value2.length) === value2) {
65349             sameletter.push(data[i3]);
65350           } else {
65351             other2.push(data[i3]);
65352           }
65353         }
65354         return sameletter.concat(other2);
65355       }
65356     }
65357     function unbind() {
65358       var row = select_default2(this);
65359       row.selectAll("input.key").call(uiCombobox.off, context);
65360       row.selectAll("input.value").call(uiCombobox.off, context);
65361     }
65362     function keyChange(d3_event, d2) {
65363       if (select_default2(this).attr("readonly")) return;
65364       var kOld = d2.key;
65365       if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0) return;
65366       var kNew = context.cleanTagKey(this.value.trim());
65367       if (isReadOnly({ key: kNew })) {
65368         this.value = kOld;
65369         return;
65370       }
65371       if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
65372         this.value = kOld;
65373         section.selection().selectAll(".tag-list input.value").each(function(d4) {
65374           if (d4.key === kNew) {
65375             var input = select_default2(this).node();
65376             input.focus();
65377             input.select();
65378           }
65379         });
65380         return;
65381       }
65382       _pendingChange = _pendingChange || {};
65383       if (kOld) {
65384         if (kOld === kNew) return;
65385         _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
65386         _pendingChange[kOld] = void 0;
65387       } else {
65388         let row = this.parentNode.parentNode;
65389         let inputVal = select_default2(row).selectAll("input.value");
65390         let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
65391         _pendingChange[kNew] = vNew;
65392         utilGetSetValue(inputVal, vNew);
65393       }
65394       var existingKeyIndex = _orderedKeys.indexOf(kOld);
65395       if (existingKeyIndex !== -1) _orderedKeys[existingKeyIndex] = kNew;
65396       d2.key = kNew;
65397       this.value = kNew;
65398       scheduleChange();
65399     }
65400     function valueChange(d3_event, d2) {
65401       if (isReadOnly(d2)) return;
65402       if (typeof d2.value !== "string" && !this.value) return;
65403       if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0) return;
65404       _pendingChange = _pendingChange || {};
65405       _pendingChange[d2.key] = context.cleanTagValue(this.value);
65406       scheduleChange();
65407     }
65408     function removeTag(d3_event, d2) {
65409       if (isReadOnly(d2)) return;
65410       if (d2.key === "") {
65411         _showBlank = false;
65412         section.reRender();
65413       } else {
65414         _orderedKeys = _orderedKeys.filter(function(key) {
65415           return key !== d2.key;
65416         });
65417         _pendingChange = _pendingChange || {};
65418         _pendingChange[d2.key] = void 0;
65419         scheduleChange();
65420       }
65421     }
65422     function addTag() {
65423       window.setTimeout(function() {
65424         _showBlank = true;
65425         section.reRender();
65426         section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
65427       }, 20);
65428     }
65429     function scheduleChange() {
65430       var entityIDs = _entityIDs;
65431       window.setTimeout(function() {
65432         if (!_pendingChange) return;
65433         dispatch14.call("change", this, entityIDs, _pendingChange);
65434         _pendingChange = null;
65435       }, 10);
65436     }
65437     section.state = function(val) {
65438       if (!arguments.length) return _state;
65439       if (_state !== val) {
65440         _orderedKeys = [];
65441         _state = val;
65442       }
65443       return section;
65444     };
65445     section.presets = function(val) {
65446       if (!arguments.length) return _presets;
65447       _presets = val;
65448       if (_presets && _presets.length && _presets[0].isFallback()) {
65449         section.disclosureExpanded(true);
65450       } else if (!_didInteract) {
65451         section.disclosureExpanded(null);
65452       }
65453       return section;
65454     };
65455     section.tags = function(val) {
65456       if (!arguments.length) return _tags;
65457       _tags = val;
65458       return section;
65459     };
65460     section.entityIDs = function(val) {
65461       if (!arguments.length) return _entityIDs;
65462       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
65463         _entityIDs = val;
65464         _orderedKeys = [];
65465       }
65466       return section;
65467     };
65468     section.readOnlyTags = function(val) {
65469       if (!arguments.length) return _readOnlyTags;
65470       _readOnlyTags = val;
65471       return section;
65472     };
65473     return utilRebind(section, dispatch14, "on");
65474   }
65475
65476   // modules/ui/data_editor.js
65477   function uiDataEditor(context) {
65478     var dataHeader = uiDataHeader();
65479     var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
65480     var _datum;
65481     function dataEditor(selection2) {
65482       var header = selection2.selectAll(".header").data([0]);
65483       var headerEnter = header.enter().append("div").attr("class", "header fillL");
65484       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
65485         context.enter(modeBrowse(context));
65486       }).call(svgIcon("#iD-icon-close"));
65487       headerEnter.append("h2").call(_t.append("map_data.title"));
65488       var body = selection2.selectAll(".body").data([0]);
65489       body = body.enter().append("div").attr("class", "body").merge(body);
65490       var editor = body.selectAll(".data-editor").data([0]);
65491       editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
65492       var rte = body.selectAll(".raw-tag-editor").data([0]);
65493       rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
65494         rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
65495       ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
65496     }
65497     dataEditor.datum = function(val) {
65498       if (!arguments.length) return _datum;
65499       _datum = val;
65500       return this;
65501     };
65502     return dataEditor;
65503   }
65504
65505   // modules/ui/feature_list.js
65506   var sexagesimal = __toESM(require_sexagesimal());
65507   function uiFeatureList(context) {
65508     var _geocodeResults;
65509     function featureList(selection2) {
65510       var header = selection2.append("div").attr("class", "header fillL");
65511       header.append("h2").call(_t.append("inspector.feature_list"));
65512       var searchWrap = selection2.append("div").attr("class", "search-header");
65513       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
65514       var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
65515       var listWrap = selection2.append("div").attr("class", "inspector-body");
65516       var list2 = listWrap.append("div").attr("class", "feature-list");
65517       context.on("exit.feature-list", clearSearch);
65518       context.map().on("drawn.feature-list", mapDrawn);
65519       context.keybinding().on(uiCmd("\u2318F"), focusSearch);
65520       function focusSearch(d3_event) {
65521         var mode = context.mode() && context.mode().id;
65522         if (mode !== "browse") return;
65523         d3_event.preventDefault();
65524         search.node().focus();
65525       }
65526       function keydown(d3_event) {
65527         if (d3_event.keyCode === 27) {
65528           search.node().blur();
65529         }
65530       }
65531       function keypress(d3_event) {
65532         var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
65533         if (d3_event.keyCode === 13 && // ↩ Return
65534         q2.length && items.size()) {
65535           click(d3_event, items.datum());
65536         }
65537       }
65538       function inputevent() {
65539         _geocodeResults = void 0;
65540         drawList();
65541       }
65542       function clearSearch() {
65543         search.property("value", "");
65544         drawList();
65545       }
65546       function mapDrawn(e3) {
65547         if (e3.full) {
65548           drawList();
65549         }
65550       }
65551       function features() {
65552         var result = [];
65553         var graph = context.graph();
65554         var visibleCenter = context.map().extent().center();
65555         var q2 = search.property("value").toLowerCase();
65556         if (!q2) return result;
65557         var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
65558         if (locationMatch) {
65559           const latLon = [Number(locationMatch[0]), Number(locationMatch[1])];
65560           const lonLat = [latLon[1], latLon[0]];
65561           const isLatLonValid = latLon[0] >= -90 && latLon[0] <= 90 && latLon[1] >= -180 && latLon[1] <= 180;
65562           let isLonLatValid = lonLat[0] >= -90 && lonLat[0] <= 90 && lonLat[1] >= -180 && lonLat[1] <= 180;
65563           isLonLatValid && (isLonLatValid = !q2.match(/[NSEW]/i));
65564           isLonLatValid && (isLonLatValid = lonLat[0] !== lonLat[1]);
65565           if (isLatLonValid) {
65566             result.push({
65567               id: latLon[0] + "/" + latLon[1],
65568               geometry: "point",
65569               type: _t("inspector.location"),
65570               name: dmsCoordinatePair([latLon[1], latLon[0]]),
65571               location: latLon
65572             });
65573           }
65574           if (isLonLatValid) {
65575             result.push({
65576               id: lonLat[0] + "/" + lonLat[1],
65577               geometry: "point",
65578               type: _t("inspector.location"),
65579               name: dmsCoordinatePair([lonLat[1], lonLat[0]]),
65580               location: lonLat
65581             });
65582           }
65583         }
65584         var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
65585         if (idMatch) {
65586           var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
65587           var elemId = idMatch[2];
65588           result.push({
65589             id: elemType + elemId,
65590             geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
65591             type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
65592             name: elemId
65593           });
65594         }
65595         var allEntities = graph.entities;
65596         var localResults = [];
65597         for (var id2 in allEntities) {
65598           var entity = allEntities[id2];
65599           if (!entity) continue;
65600           var name = utilDisplayName(entity) || "";
65601           if (name.toLowerCase().indexOf(q2) < 0) continue;
65602           var matched = _mainPresetIndex.match(entity, graph);
65603           var type2 = matched && matched.name() || utilDisplayType(entity.id);
65604           var extent = entity.extent(graph);
65605           var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
65606           localResults.push({
65607             id: entity.id,
65608             entity,
65609             geometry: entity.geometry(graph),
65610             type: type2,
65611             name,
65612             distance
65613           });
65614           if (localResults.length > 100) break;
65615         }
65616         localResults = localResults.sort(function byDistance(a2, b2) {
65617           return a2.distance - b2.distance;
65618         });
65619         result = result.concat(localResults);
65620         (_geocodeResults || []).forEach(function(d2) {
65621           if (d2.osm_type && d2.osm_id) {
65622             var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
65623             var tags = {};
65624             tags[d2.class] = d2.type;
65625             var attrs = { id: id3, type: d2.osm_type, tags };
65626             if (d2.osm_type === "way") {
65627               attrs.nodes = ["a", "a"];
65628             }
65629             var tempEntity = osmEntity(attrs);
65630             var tempGraph = coreGraph([tempEntity]);
65631             var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
65632             var type3 = matched2 && matched2.name() || utilDisplayType(id3);
65633             result.push({
65634               id: tempEntity.id,
65635               geometry: tempEntity.geometry(tempGraph),
65636               type: type3,
65637               name: d2.display_name,
65638               extent: new geoExtent(
65639                 [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
65640                 [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
65641               )
65642             });
65643           }
65644         });
65645         if (q2.match(/^[0-9]+$/)) {
65646           result.push({
65647             id: "n" + q2,
65648             geometry: "point",
65649             type: _t("inspector.node"),
65650             name: q2
65651           });
65652           result.push({
65653             id: "w" + q2,
65654             geometry: "line",
65655             type: _t("inspector.way"),
65656             name: q2
65657           });
65658           result.push({
65659             id: "r" + q2,
65660             geometry: "relation",
65661             type: _t("inspector.relation"),
65662             name: q2
65663           });
65664           result.push({
65665             id: "note" + q2,
65666             geometry: "note",
65667             type: _t("note.note"),
65668             name: q2
65669           });
65670         }
65671         return result;
65672       }
65673       function drawList() {
65674         var value = search.property("value");
65675         var results = features();
65676         list2.classed("filtered", value.length);
65677         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"));
65678         resultsIndicator.append("span").attr("class", "entity-name");
65679         list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
65680         if (services.geocoder) {
65681           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"));
65682         }
65683         list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
65684         list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
65685         var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
65686           return d2.id;
65687         });
65688         var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("pointerenter", mouseover).on("pointerleave", mouseout).on("focus", mouseover).on("blur", mouseout).on("click", click);
65689         var label = enter.append("div").attr("class", "label");
65690         label.each(function(d2) {
65691           select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
65692         });
65693         label.append("span").attr("class", "entity-type").text(function(d2) {
65694           return d2.type;
65695         });
65696         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) {
65697           return d2.name;
65698         });
65699         enter.style("opacity", 0).transition().style("opacity", 1);
65700         items.exit().each((d2) => mouseout(void 0, d2)).remove();
65701         items.merge(enter).order();
65702       }
65703       function mouseover(d3_event, d2) {
65704         if (d2.location !== void 0) return;
65705         utilHighlightEntities([d2.id], true, context);
65706       }
65707       function mouseout(d3_event, d2) {
65708         if (d2.location !== void 0) return;
65709         utilHighlightEntities([d2.id], false, context);
65710       }
65711       function click(d3_event, d2) {
65712         d3_event.preventDefault();
65713         if (d2.location) {
65714           context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
65715         } else if (d2.entity) {
65716           utilHighlightEntities([d2.id], false, context);
65717           context.enter(modeSelect(context, [d2.entity.id]));
65718           context.map().zoomToEase(d2.entity);
65719         } else if (d2.geometry === "note") {
65720           const noteId = d2.id.replace(/\D/g, "");
65721           context.moveToNote(noteId);
65722         } else {
65723           context.zoomToEntity(d2.id);
65724         }
65725       }
65726       function geocoderSearch() {
65727         services.geocoder.search(search.property("value"), function(err, resp) {
65728           _geocodeResults = resp || [];
65729           drawList();
65730         });
65731       }
65732     }
65733     return featureList;
65734   }
65735
65736   // modules/ui/entity_editor.js
65737   var import_fast_deep_equal9 = __toESM(require_fast_deep_equal());
65738
65739   // modules/ui/sections/entity_issues.js
65740   function uiSectionEntityIssues(context) {
65741     var preference = corePreferences("entity-issues.reference.expanded");
65742     var _expanded = preference === null ? true : preference === "true";
65743     var _entityIDs = [];
65744     var _issues = [];
65745     var _activeIssueID;
65746     var section = uiSection("entity-issues", context).shouldDisplay(function() {
65747       return _issues.length > 0;
65748     }).label(function() {
65749       return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length });
65750     }).disclosureContent(renderDisclosureContent);
65751     context.validator().on("validated.entity_issues", function() {
65752       reloadIssues();
65753       section.reRender();
65754     }).on("focusedIssue.entity_issues", function(issue) {
65755       makeActiveIssue(issue.id);
65756     });
65757     function reloadIssues() {
65758       _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true });
65759     }
65760     function makeActiveIssue(issueID) {
65761       _activeIssueID = issueID;
65762       section.selection().selectAll(".issue-container").classed("active", function(d2) {
65763         return d2.id === _activeIssueID;
65764       });
65765     }
65766     function renderDisclosureContent(selection2) {
65767       selection2.classed("grouped-items-area", true);
65768       _activeIssueID = _issues.length > 0 ? _issues[0].id : null;
65769       var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) {
65770         return d2.key;
65771       });
65772       containers.exit().remove();
65773       var containersEnter = containers.enter().append("div").attr("class", "issue-container");
65774       var itemsEnter = containersEnter.append("div").attr("class", function(d2) {
65775         return "issue severity-" + d2.severity;
65776       }).on("mouseover.highlight", function(d3_event, d2) {
65777         var ids = d2.entityIds.filter(function(e3) {
65778           return _entityIDs.indexOf(e3) === -1;
65779         });
65780         utilHighlightEntities(ids, true, context);
65781       }).on("mouseout.highlight", function(d3_event, d2) {
65782         var ids = d2.entityIds.filter(function(e3) {
65783           return _entityIDs.indexOf(e3) === -1;
65784         });
65785         utilHighlightEntities(ids, false, context);
65786       });
65787       var labelsEnter = itemsEnter.append("div").attr("class", "issue-label");
65788       var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) {
65789         makeActiveIssue(d2.id);
65790         var extent = d2.extent(context.graph());
65791         if (extent) {
65792           var setZoom = Math.max(context.map().zoom(), 19);
65793           context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
65794         }
65795       });
65796       textEnter.each(function(d2) {
65797         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
65798         select_default2(this).call(svgIcon(iconName, "issue-icon"));
65799       });
65800       textEnter.append("span").attr("class", "issue-message");
65801       var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect"));
65802       infoButton.on("click", function(d3_event) {
65803         d3_event.stopPropagation();
65804         d3_event.preventDefault();
65805         this.blur();
65806         var container = select_default2(this.parentNode.parentNode.parentNode);
65807         var info = container.selectAll(".issue-info");
65808         var isExpanded = info.classed("expanded");
65809         _expanded = !isExpanded;
65810         corePreferences("entity-issues.reference.expanded", _expanded);
65811         if (isExpanded) {
65812           info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
65813             info.classed("expanded", false);
65814           });
65815         } else {
65816           info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() {
65817             info.style("max-height", null);
65818           });
65819         }
65820       });
65821       itemsEnter.append("ul").attr("class", "issue-fix-list");
65822       containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) {
65823         if (typeof d2.reference === "function") {
65824           select_default2(this).call(d2.reference);
65825         } else {
65826           select_default2(this).call(_t.append("inspector.no_documentation_key"));
65827         }
65828       });
65829       containers = containers.merge(containersEnter).classed("active", function(d2) {
65830         return d2.id === _activeIssueID;
65831       });
65832       containers.selectAll(".issue-message").text("").each(function(d2) {
65833         return d2.message(context)(select_default2(this));
65834       });
65835       var fixLists = containers.selectAll(".issue-fix-list");
65836       var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) {
65837         return d2.fixes ? d2.fixes(context) : [];
65838       }, function(fix) {
65839         return fix.id;
65840       });
65841       fixes.exit().remove();
65842       var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item");
65843       var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) {
65844         if (select_default2(this).attr("disabled") || !d2.onClick) return;
65845         if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3) return;
65846         d2.issue.dateLastRanFix = /* @__PURE__ */ new Date();
65847         utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context);
65848         new Promise(function(resolve, reject) {
65849           d2.onClick(context, resolve, reject);
65850           if (d2.onClick.length <= 1) {
65851             resolve();
65852           }
65853         }).then(function() {
65854           context.validator().validate();
65855         });
65856       }).on("mouseover.highlight", function(d3_event, d2) {
65857         utilHighlightEntities(d2.entityIds, true, context);
65858       }).on("mouseout.highlight", function(d3_event, d2) {
65859         utilHighlightEntities(d2.entityIds, false, context);
65860       });
65861       buttons.each(function(d2) {
65862         var iconName = d2.icon || "iD-icon-wrench";
65863         if (iconName.startsWith("maki")) {
65864           iconName += "-15";
65865         }
65866         select_default2(this).call(svgIcon("#" + iconName, "fix-icon"));
65867       });
65868       buttons.append("span").attr("class", "fix-message").each(function(d2) {
65869         return d2.title(select_default2(this));
65870       });
65871       fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) {
65872         return d2.onClick;
65873       }).attr("disabled", function(d2) {
65874         return d2.onClick ? null : "true";
65875       }).attr("title", function(d2) {
65876         if (d2.disabledReason) {
65877           return d2.disabledReason;
65878         }
65879         return null;
65880       });
65881     }
65882     section.entityIDs = function(val) {
65883       if (!arguments.length) return _entityIDs;
65884       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
65885         _entityIDs = val;
65886         _activeIssueID = null;
65887         reloadIssues();
65888       }
65889       return section;
65890     };
65891     return section;
65892   }
65893
65894   // modules/ui/preset_icon.js
65895   function uiPresetIcon() {
65896     let _preset;
65897     let _geometry;
65898     function presetIcon(selection2) {
65899       selection2.each(render);
65900     }
65901     function getIcon(p2, geom) {
65902       if (p2.isFallback && p2.isFallback()) return geom === "vertex" ? "" : "iD-icon-" + p2.id;
65903       if (p2.icon) return p2.icon;
65904       if (geom === "line") return "iD-other-line";
65905       if (geom === "vertex") return "temaki-vertex";
65906       return "maki-marker-stroked";
65907     }
65908     function renderPointBorder(container, drawPoint) {
65909       let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []);
65910       pointBorder.exit().remove();
65911       let pointBorderEnter = pointBorder.enter();
65912       const w2 = 40;
65913       const h2 = 40;
65914       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");
65915       pointBorder = pointBorderEnter.merge(pointBorder);
65916     }
65917     function renderCategoryBorder(container, category) {
65918       let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []);
65919       categoryBorder.exit().remove();
65920       let categoryBorderEnter = categoryBorder.enter();
65921       const d2 = 60;
65922       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));
65923       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");
65924       categoryBorder = categoryBorderEnter.merge(categoryBorder);
65925       if (category) {
65926         categoryBorder.selectAll("path").attr("class", "area ".concat(category.id));
65927       }
65928     }
65929     function renderCircleFill(container, drawVertex) {
65930       let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []);
65931       vertexFill.exit().remove();
65932       let vertexFillEnter = vertexFill.enter();
65933       const w2 = 60;
65934       const h2 = 60;
65935       const d2 = 40;
65936       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);
65937       vertexFill = vertexFillEnter.merge(vertexFill);
65938     }
65939     function renderSquareFill(container, drawArea, tagClasses) {
65940       let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []);
65941       fill.exit().remove();
65942       let fillEnter = fill.enter();
65943       const d2 = 60;
65944       const w2 = d2;
65945       const h2 = d2;
65946       const l2 = d2 * 2 / 3;
65947       const c1 = (w2 - l2) / 2;
65948       const c2 = c1 + l2;
65949       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));
65950       ["fill", "stroke"].forEach((klass) => {
65951         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));
65952       });
65953       const rVertex = 2.5;
65954       [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point) => {
65955         fillEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", rVertex);
65956       });
65957       const rMidpoint = 1.25;
65958       [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point) => {
65959         fillEnter.append("circle").attr("class", "midpoint").attr("cx", point[0]).attr("cy", point[1]).attr("r", rMidpoint);
65960       });
65961       fill = fillEnter.merge(fill);
65962       fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses));
65963       fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses));
65964     }
65965     function renderLine(container, drawLine, tagClasses) {
65966       let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []);
65967       line.exit().remove();
65968       let lineEnter = line.enter();
65969       const d2 = 60;
65970       const w2 = d2;
65971       const h2 = d2;
65972       const y2 = Math.round(d2 * 0.72);
65973       const l2 = Math.round(d2 * 0.6);
65974       const r2 = 2.5;
65975       const x12 = (w2 - l2) / 2;
65976       const x2 = x12 + l2;
65977       lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
65978       ["casing", "stroke"].forEach((klass) => {
65979         lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass));
65980       });
65981       [[x12 - 1, y2], [x2 + 1, y2]].forEach((point) => {
65982         lineEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2);
65983       });
65984       line = lineEnter.merge(line);
65985       line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses));
65986       line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses));
65987     }
65988     function renderRoute(container, drawRoute, p2) {
65989       let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []);
65990       route.exit().remove();
65991       let routeEnter = route.enter();
65992       const d2 = 60;
65993       const w2 = d2;
65994       const h2 = d2;
65995       const y12 = Math.round(d2 * 0.8);
65996       const y2 = Math.round(d2 * 0.68);
65997       const l2 = Math.round(d2 * 0.6);
65998       const r2 = 2;
65999       const x12 = (w2 - l2) / 2;
66000       const x2 = x12 + l2 / 3;
66001       const x3 = x2 + l2 / 3;
66002       const x4 = x3 + l2 / 3;
66003       routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
66004       ["casing", "stroke"].forEach((klass) => {
66005         routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass));
66006         routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass));
66007         routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass));
66008       });
66009       [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point) => {
66010         routeEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2);
66011       });
66012       route = routeEnter.merge(route);
66013       if (drawRoute) {
66014         let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route;
66015         const segmentPresetIDs = routeSegments[routeType];
66016         for (let i3 in segmentPresetIDs) {
66017           const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]);
66018           const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, "");
66019           route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses));
66020           route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses));
66021         }
66022       }
66023     }
66024     function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) {
66025       const isMaki = picon && /^maki-/.test(picon);
66026       const isTemaki = picon && /^temaki-/.test(picon);
66027       const isFa = picon && /^fa[srb]-/.test(picon);
66028       const isR\u00F6ntgen = picon && /^roentgen-/.test(picon);
66029       const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen);
66030       let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []);
66031       icon2.exit().remove();
66032       icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2);
66033       icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon);
66034       icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses));
66035       icon2.selectAll("use").attr("href", "#" + picon);
66036     }
66037     function renderImageIcon(container, imageURL) {
66038       let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []);
66039       imageIcon.exit().remove();
66040       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);
66041       imageIcon.attr("src", imageURL);
66042     }
66043     const routeSegments = {
66044       bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"],
66045       bus: ["highway/unclassified", "highway/secondary", "highway/primary"],
66046       trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"],
66047       detour: ["highway/tertiary", "highway/residential", "highway/unclassified"],
66048       ferry: ["route/ferry", "route/ferry", "route/ferry"],
66049       foot: ["highway/footway", "highway/footway", "highway/footway"],
66050       hiking: ["highway/path", "highway/path", "highway/path"],
66051       horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"],
66052       light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"],
66053       monorail: ["railway/monorail", "railway/monorail", "railway/monorail"],
66054       mtb: ["highway/path", "highway/track", "highway/bridleway"],
66055       pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"],
66056       piste: ["piste/downhill", "piste/hike", "piste/nordic"],
66057       power: ["power/line", "power/line", "power/line"],
66058       road: ["highway/secondary", "highway/primary", "highway/trunk"],
66059       subway: ["railway/subway", "railway/subway", "railway/subway"],
66060       train: ["railway/rail", "railway/rail", "railway/rail"],
66061       tram: ["railway/tram", "railway/tram", "railway/tram"],
66062       railway: ["railway/rail", "railway/rail", "railway/rail"],
66063       waterway: ["waterway/stream", "waterway/stream", "waterway/stream"]
66064     };
66065     function render() {
66066       let p2 = _preset.apply(this, arguments);
66067       let geom = _geometry ? _geometry.apply(this, arguments) : null;
66068       if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) {
66069         geom = "route";
66070       }
66071       const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
66072       const isFallback = p2.isFallback && p2.isFallback();
66073       const imageURL = showThirdPartyIcons === "true" && p2.imageURL;
66074       const picon = getIcon(p2, geom);
66075       const isCategory = !p2.setTags;
66076       const drawPoint = false;
66077       const drawVertex = picon !== null && geom === "vertex";
66078       const drawLine = picon && geom === "line" && !isFallback && !isCategory;
66079       const drawArea = picon && geom === "area" && !isFallback && !isCategory;
66080       const drawRoute = picon && geom === "route";
66081       const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory;
66082       let tags = !isCategory ? p2.setTags({}, geom) : {};
66083       for (let k2 in tags) {
66084         if (tags[k2] === "*") {
66085           tags[k2] = "yes";
66086         }
66087       }
66088       let tagClasses = svgTagClasses().getClassesString(tags, "");
66089       let selection2 = select_default2(this);
66090       let container = selection2.selectAll(".preset-icon-container").data([0]);
66091       container = container.enter().append("div").attr("class", "preset-icon-container").merge(container);
66092       container.classed("showing-img", !!imageURL).classed("fallback", isFallback);
66093       renderCategoryBorder(container, isCategory && p2);
66094       renderPointBorder(container, drawPoint);
66095       renderCircleFill(container, drawVertex);
66096       renderSquareFill(container, drawArea, tagClasses);
66097       renderLine(container, drawLine, tagClasses);
66098       renderRoute(container, drawRoute, p2);
66099       renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses);
66100       renderImageIcon(container, imageURL);
66101     }
66102     presetIcon.preset = function(val) {
66103       if (!arguments.length) return _preset;
66104       _preset = utilFunctor(val);
66105       return presetIcon;
66106     };
66107     presetIcon.geometry = function(val) {
66108       if (!arguments.length) return _geometry;
66109       _geometry = utilFunctor(val);
66110       return presetIcon;
66111     };
66112     return presetIcon;
66113   }
66114
66115   // modules/ui/sections/feature_type.js
66116   function uiSectionFeatureType(context) {
66117     var dispatch14 = dispatch_default("choose");
66118     var _entityIDs = [];
66119     var _presets = [];
66120     var _tagReference;
66121     var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent);
66122     function renderDisclosureContent(selection2) {
66123       selection2.classed("preset-list-item", true);
66124       selection2.classed("mixed-types", _presets.length > 1);
66125       var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap");
66126       var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call(
66127         uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom")
66128       );
66129       presetButton.append("div").attr("class", "preset-icon-container");
66130       presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner");
66131       presetButtonWrap.append("div").attr("class", "accessory-buttons");
66132       var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]);
66133       tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap);
66134       if (_tagReference) {
66135         selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button);
66136         tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body);
66137       }
66138       selection2.selectAll(".preset-reset").on("click", function() {
66139         dispatch14.call("choose", this, _presets);
66140       }).on("pointerdown pointerup mousedown mouseup", function(d3_event) {
66141         d3_event.preventDefault();
66142         d3_event.stopPropagation();
66143       });
66144       var geometries = entityGeometries();
66145       selection2.select(".preset-list-item button").call(
66146         uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point"))
66147       );
66148       var names = _presets.length === 1 ? [
66149         _presets[0].nameLabel(),
66150         _presets[0].subtitleLabel()
66151       ].filter(Boolean) : [_t.append("inspector.multiple_types")];
66152       var label = selection2.select(".label-inner");
66153       var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId);
66154       nameparts.exit().remove();
66155       nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) {
66156         d2(select_default2(this));
66157       });
66158     }
66159     section.entityIDs = function(val) {
66160       if (!arguments.length) return _entityIDs;
66161       _entityIDs = val;
66162       return section;
66163     };
66164     section.presets = function(val) {
66165       if (!arguments.length) return _presets;
66166       if (!utilArrayIdentical(val, _presets)) {
66167         _presets = val;
66168         if (_presets.length === 1) {
66169           _tagReference = uiTagReference(_presets[0].reference(), context).showing(false);
66170         }
66171       }
66172       return section;
66173     };
66174     function entityGeometries() {
66175       var counts = {};
66176       for (var i3 in _entityIDs) {
66177         var geometry = context.graph().geometry(_entityIDs[i3]);
66178         if (!counts[geometry]) counts[geometry] = 0;
66179         counts[geometry] += 1;
66180       }
66181       return Object.keys(counts).sort(function(geom1, geom2) {
66182         return counts[geom2] - counts[geom1];
66183       });
66184     }
66185     return utilRebind(section, dispatch14, "on");
66186   }
66187
66188   // modules/ui/form_fields.js
66189   function uiFormFields(context) {
66190     var moreCombo = uiCombobox(context, "more-fields").minItems(1);
66191     var _fieldsArr = [];
66192     var _lastPlaceholder = "";
66193     var _state = "";
66194     var _klass = "";
66195     function formFields(selection2) {
66196       var allowedFields = _fieldsArr.filter(function(field) {
66197         return field.isAllowed();
66198       });
66199       var shown = allowedFields.filter(function(field) {
66200         return field.isShown();
66201       });
66202       var notShown = allowedFields.filter(function(field) {
66203         return !field.isShown();
66204       }).sort(function(a2, b2) {
66205         return a2.universal === b2.universal ? 0 : a2.universal ? 1 : -1;
66206       });
66207       var container = selection2.selectAll(".form-fields-container").data([0]);
66208       container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container);
66209       var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) {
66210         return d2.id + (d2.entityIDs ? d2.entityIDs.join() : "");
66211       });
66212       fields.exit().remove();
66213       var enter = fields.enter().append("div").attr("class", function(d2) {
66214         return "wrap-form-field wrap-form-field-" + d2.safeid;
66215       });
66216       fields = fields.merge(enter);
66217       fields.order().each(function(d2) {
66218         select_default2(this).call(d2.render);
66219       });
66220       var titles = [];
66221       var moreFields = notShown.map(function(field) {
66222         var title = field.title();
66223         titles.push(title);
66224         var terms = field.terms();
66225         if (field.key) terms.push(field.key);
66226         if (field.keys) terms = terms.concat(field.keys);
66227         return {
66228           display: field.label(),
66229           value: title,
66230           title,
66231           field,
66232           terms
66233         };
66234       });
66235       var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : "");
66236       var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]);
66237       more.exit().remove();
66238       var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label");
66239       moreEnter.append("span").call(_t.append("inspector.add_fields"));
66240       more = moreEnter.merge(more);
66241       var input = more.selectAll(".value").data([0]);
66242       input.exit().remove();
66243       input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input);
66244       input.call(utilGetSetValue, "").call(
66245         moreCombo.data(moreFields).on("accept", function(d2) {
66246           if (!d2) return;
66247           var field = d2.field;
66248           field.show();
66249           selection2.call(formFields);
66250           field.focus();
66251         })
66252       );
66253       if (_lastPlaceholder !== placeholder) {
66254         input.attr("placeholder", placeholder);
66255         _lastPlaceholder = placeholder;
66256       }
66257     }
66258     formFields.fieldsArr = function(val) {
66259       if (!arguments.length) return _fieldsArr;
66260       _fieldsArr = val || [];
66261       return formFields;
66262     };
66263     formFields.state = function(val) {
66264       if (!arguments.length) return _state;
66265       _state = val;
66266       return formFields;
66267     };
66268     formFields.klass = function(val) {
66269       if (!arguments.length) return _klass;
66270       _klass = val;
66271       return formFields;
66272     };
66273     return formFields;
66274   }
66275
66276   // modules/ui/sections/preset_fields.js
66277   function uiSectionPresetFields(context) {
66278     var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
66279     var dispatch14 = dispatch_default("change", "revert");
66280     var formFields = uiFormFields(context);
66281     var _state;
66282     var _fieldsArr;
66283     var _presets = [];
66284     var _tags;
66285     var _entityIDs;
66286     function renderDisclosureContent(selection2) {
66287       if (!_fieldsArr) {
66288         var graph = context.graph();
66289         var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
66290           geoms[graph.entity(entityID).geometry(graph)] = true;
66291           return geoms;
66292         }, {}));
66293         const loc = _entityIDs.reduce(function(extent, entityID) {
66294           var entity = context.graph().entity(entityID);
66295           return extent.extend(entity.extent(context.graph()));
66296         }, geoExtent()).center();
66297         var presetsManager = _mainPresetIndex;
66298         var allFields = [];
66299         var allMoreFields = [];
66300         var sharedTotalFields;
66301         _presets.forEach(function(preset) {
66302           var fields = preset.fields(loc);
66303           var moreFields = preset.moreFields(loc);
66304           allFields = utilArrayUnion(allFields, fields);
66305           allMoreFields = utilArrayUnion(allMoreFields, moreFields);
66306           if (!sharedTotalFields) {
66307             sharedTotalFields = utilArrayUnion(fields, moreFields);
66308           } else {
66309             sharedTotalFields = sharedTotalFields.filter(function(field) {
66310               return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
66311             });
66312           }
66313         });
66314         var sharedFields = allFields.filter(function(field) {
66315           return sharedTotalFields.indexOf(field) !== -1;
66316         });
66317         var sharedMoreFields = allMoreFields.filter(function(field) {
66318           return sharedTotalFields.indexOf(field) !== -1;
66319         });
66320         _fieldsArr = [];
66321         sharedFields.forEach(function(field) {
66322           if (field.matchAllGeometry(geometries)) {
66323             _fieldsArr.push(
66324               uiField(context, field, _entityIDs)
66325             );
66326           }
66327         });
66328         var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
66329         if (singularEntity && singularEntity.type === "node" && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
66330           _fieldsArr.push(
66331             uiField(context, presetsManager.field("restrictions"), _entityIDs)
66332           );
66333         }
66334         var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
66335         additionalFields.sort(function(field1, field2) {
66336           return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
66337         });
66338         additionalFields.forEach(function(field) {
66339           if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
66340             _fieldsArr.push(
66341               uiField(context, field, _entityIDs, { show: false })
66342             );
66343           }
66344         });
66345         _fieldsArr.forEach(function(field) {
66346           field.on("change", function(t2, onInput) {
66347             dispatch14.call("change", field, _entityIDs, t2, onInput);
66348           }).on("revert", function(keys2) {
66349             dispatch14.call("revert", field, keys2);
66350           });
66351         });
66352       }
66353       _fieldsArr.forEach(function(field) {
66354         field.state(_state).tags(_tags);
66355       });
66356       selection2.call(
66357         formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
66358       );
66359     }
66360     section.presets = function(val) {
66361       if (!arguments.length) return _presets;
66362       if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
66363         _presets = val;
66364         _fieldsArr = null;
66365       }
66366       return section;
66367     };
66368     section.state = function(val) {
66369       if (!arguments.length) return _state;
66370       _state = val;
66371       return section;
66372     };
66373     section.tags = function(val) {
66374       if (!arguments.length) return _tags;
66375       _tags = val;
66376       return section;
66377     };
66378     section.entityIDs = function(val) {
66379       if (!arguments.length) return _entityIDs;
66380       if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
66381         _entityIDs = val;
66382         _fieldsArr = null;
66383       }
66384       return section;
66385     };
66386     return utilRebind(section, dispatch14, "on");
66387   }
66388
66389   // modules/ui/sections/raw_member_editor.js
66390   function uiSectionRawMemberEditor(context) {
66391     var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
66392       if (!_entityIDs || _entityIDs.length !== 1) return false;
66393       var entity = context.hasEntity(_entityIDs[0]);
66394       return entity && entity.type === "relation";
66395     }).label(function() {
66396       var entity = context.hasEntity(_entityIDs[0]);
66397       if (!entity) return "";
66398       var gt2 = entity.members.length > _maxMembers ? ">" : "";
66399       var count = gt2 + entity.members.slice(0, _maxMembers).length;
66400       return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
66401     }).disclosureContent(renderDisclosureContent);
66402     var taginfo = services.taginfo;
66403     var _entityIDs;
66404     var _maxMembers = 1e3;
66405     function downloadMember(d3_event, d2) {
66406       d3_event.preventDefault();
66407       select_default2(this).classed("loading", true);
66408       context.loadEntity(d2.id, function() {
66409         section.reRender();
66410       });
66411     }
66412     function zoomToMember(d3_event, d2) {
66413       d3_event.preventDefault();
66414       var entity = context.entity(d2.id);
66415       context.map().zoomToEase(entity);
66416       utilHighlightEntities([d2.id], true, context);
66417     }
66418     function selectMember(d3_event, d2) {
66419       d3_event.preventDefault();
66420       utilHighlightEntities([d2.id], false, context);
66421       var entity = context.entity(d2.id);
66422       var mapExtent = context.map().extent();
66423       if (!entity.intersects(mapExtent, context.graph())) {
66424         context.map().zoomToEase(entity);
66425       }
66426       context.enter(modeSelect(context, [d2.id]));
66427     }
66428     function changeRole(d3_event, d2) {
66429       var oldRole = d2.role;
66430       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
66431       if (oldRole !== newRole) {
66432         var member = { id: d2.id, type: d2.type, role: newRole };
66433         context.perform(
66434           actionChangeMember(d2.relation.id, member, d2.index),
66435           _t("operations.change_role.annotation", {
66436             n: 1
66437           })
66438         );
66439         context.validator().validate();
66440       }
66441     }
66442     function deleteMember(d3_event, d2) {
66443       utilHighlightEntities([d2.id], false, context);
66444       context.perform(
66445         actionDeleteMember(d2.relation.id, d2.index),
66446         _t("operations.delete_member.annotation", {
66447           n: 1
66448         })
66449       );
66450       if (!context.hasEntity(d2.relation.id)) {
66451         context.enter(modeBrowse(context));
66452       } else {
66453         context.validator().validate();
66454       }
66455     }
66456     function renderDisclosureContent(selection2) {
66457       var entityID = _entityIDs[0];
66458       var memberships = [];
66459       var entity = context.entity(entityID);
66460       entity.members.slice(0, _maxMembers).forEach(function(member, index) {
66461         memberships.push({
66462           index,
66463           id: member.id,
66464           type: member.type,
66465           role: member.role,
66466           relation: entity,
66467           member: context.hasEntity(member.id),
66468           domId: utilUniqueDomId(entityID + "-member-" + index)
66469         });
66470       });
66471       var list2 = selection2.selectAll(".member-list").data([0]);
66472       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
66473       var items = list2.selectAll("li").data(memberships, function(d2) {
66474         return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
66475       });
66476       items.exit().each(unbind).remove();
66477       var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
66478         return !d2.member;
66479       });
66480       itemsEnter.each(function(d2) {
66481         var item = select_default2(this);
66482         var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
66483         if (d2.member) {
66484           item.on("mouseover", function() {
66485             utilHighlightEntities([d2.id], true, context);
66486           }).on("mouseout", function() {
66487             utilHighlightEntities([d2.id], false, context);
66488           });
66489           var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
66490           labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
66491             var matched = _mainPresetIndex.match(d4.member, context.graph());
66492             return matched && matched.name() || utilDisplayType(d4.member.id);
66493           });
66494           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) {
66495             return utilDisplayName(d4.member);
66496           });
66497           label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
66498           label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
66499         } else {
66500           var labelText = label.append("span").attr("class", "label-text");
66501           labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
66502           labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
66503           label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
66504         }
66505       });
66506       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
66507       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
66508         return d2.domId;
66509       }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
66510       if (taginfo) {
66511         wrapEnter.each(bindTypeahead);
66512       }
66513       items = items.merge(itemsEnter).order();
66514       items.select("input.member-role").property("value", function(d2) {
66515         return d2.role;
66516       }).on("blur", changeRole).on("change", changeRole);
66517       items.select("button.member-delete").on("click", deleteMember);
66518       var dragOrigin, targetIndex;
66519       items.call(
66520         drag_default().on("start", function(d3_event) {
66521           dragOrigin = {
66522             x: d3_event.x,
66523             y: d3_event.y
66524           };
66525           targetIndex = null;
66526         }).on("drag", function(d3_event) {
66527           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
66528           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
66529           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) return;
66530           var index = items.nodes().indexOf(this);
66531           select_default2(this).classed("dragging", true);
66532           targetIndex = null;
66533           selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
66534             var node = select_default2(this).node();
66535             if (index === index2) {
66536               return "translate(" + x2 + "px, " + y2 + "px)";
66537             } else if (index2 > index && d3_event.y > node.offsetTop) {
66538               if (targetIndex === null || index2 > targetIndex) {
66539                 targetIndex = index2;
66540               }
66541               return "translateY(-100%)";
66542             } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
66543               if (targetIndex === null || index2 < targetIndex) {
66544                 targetIndex = index2;
66545               }
66546               return "translateY(100%)";
66547             }
66548             return null;
66549           });
66550         }).on("end", function(d3_event, d2) {
66551           if (!select_default2(this).classed("dragging")) return;
66552           var index = items.nodes().indexOf(this);
66553           select_default2(this).classed("dragging", false);
66554           selection2.selectAll("li.member-row").style("transform", null);
66555           if (targetIndex !== null) {
66556             context.perform(
66557               actionMoveMember(d2.relation.id, index, targetIndex),
66558               _t("operations.reorder_members.annotation")
66559             );
66560             context.validator().validate();
66561           }
66562         })
66563       );
66564       function bindTypeahead(d2) {
66565         var row = select_default2(this);
66566         var role = row.selectAll("input.member-role");
66567         var origValue = role.property("value");
66568         function sort(value, data) {
66569           var sameletter = [];
66570           var other2 = [];
66571           for (var i3 = 0; i3 < data.length; i3++) {
66572             if (data[i3].value.substring(0, value.length) === value) {
66573               sameletter.push(data[i3]);
66574             } else {
66575               other2.push(data[i3]);
66576             }
66577           }
66578           return sameletter.concat(other2);
66579         }
66580         role.call(
66581           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
66582             var geometry;
66583             if (d2.member) {
66584               geometry = context.graph().geometry(d2.member.id);
66585             } else if (d2.type === "relation") {
66586               geometry = "relation";
66587             } else if (d2.type === "way") {
66588               geometry = "line";
66589             } else {
66590               geometry = "point";
66591             }
66592             var rtype = entity.tags.type;
66593             taginfo.roles({
66594               debounce: true,
66595               rtype: rtype || "",
66596               geometry,
66597               query: role2
66598             }, function(err, data) {
66599               if (!err) callback(sort(role2, data));
66600             });
66601           }).on("cancel", function() {
66602             role.property("value", origValue);
66603           })
66604         );
66605       }
66606       function unbind() {
66607         var row = select_default2(this);
66608         row.selectAll("input.member-role").call(uiCombobox.off, context);
66609       }
66610     }
66611     section.entityIDs = function(val) {
66612       if (!arguments.length) return _entityIDs;
66613       _entityIDs = val;
66614       return section;
66615     };
66616     return section;
66617   }
66618
66619   // modules/actions/delete_members.js
66620   function actionDeleteMembers(relationId, memberIndexes) {
66621     return function(graph) {
66622       memberIndexes.sort((a2, b2) => b2 - a2);
66623       for (var i3 in memberIndexes) {
66624         graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
66625       }
66626       return graph;
66627     };
66628   }
66629
66630   // modules/ui/sections/raw_membership_editor.js
66631   function uiSectionRawMembershipEditor(context) {
66632     var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
66633       return _entityIDs && _entityIDs.length;
66634     }).label(function() {
66635       var parents = getSharedParentRelations();
66636       var gt2 = parents.length > _maxMemberships ? ">" : "";
66637       var count = gt2 + parents.slice(0, _maxMemberships).length;
66638       return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
66639     }).disclosureContent(renderDisclosureContent);
66640     var taginfo = services.taginfo;
66641     var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
66642       if (d2.relation) utilHighlightEntities([d2.relation.id], true, context);
66643     }).itemsMouseLeave(function(d3_event, d2) {
66644       if (d2.relation) utilHighlightEntities([d2.relation.id], false, context);
66645     });
66646     var _inChange = false;
66647     var _entityIDs = [];
66648     var _showBlank;
66649     var _maxMemberships = 1e3;
66650     const recentlyAdded = /* @__PURE__ */ new Set();
66651     function getSharedParentRelations() {
66652       var parents = [];
66653       for (var i3 = 0; i3 < _entityIDs.length; i3++) {
66654         var entity = context.graph().hasEntity(_entityIDs[i3]);
66655         if (!entity) continue;
66656         if (i3 === 0) {
66657           parents = context.graph().parentRelations(entity);
66658         } else {
66659           parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
66660         }
66661         if (!parents.length) break;
66662       }
66663       return parents;
66664     }
66665     function getMemberships() {
66666       var memberships = [];
66667       var relations = getSharedParentRelations().slice(0, _maxMemberships);
66668       var isMultiselect = _entityIDs.length > 1;
66669       var i3, relation, membership, index, member, indexedMember;
66670       for (i3 = 0; i3 < relations.length; i3++) {
66671         relation = relations[i3];
66672         membership = {
66673           relation,
66674           members: [],
66675           hash: osmEntity.key(relation)
66676         };
66677         for (index = 0; index < relation.members.length; index++) {
66678           member = relation.members[index];
66679           if (_entityIDs.indexOf(member.id) !== -1) {
66680             indexedMember = Object.assign({}, member, { index });
66681             membership.members.push(indexedMember);
66682             membership.hash += "," + index.toString();
66683             if (!isMultiselect) {
66684               memberships.push(membership);
66685               membership = {
66686                 relation,
66687                 members: [],
66688                 hash: osmEntity.key(relation)
66689               };
66690             }
66691           }
66692         }
66693         if (membership.members.length) memberships.push(membership);
66694       }
66695       memberships.forEach(function(membership2) {
66696         membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
66697         var roles = [];
66698         membership2.members.forEach(function(member2) {
66699           if (roles.indexOf(member2.role) === -1) roles.push(member2.role);
66700         });
66701         membership2.role = roles.length === 1 ? roles[0] : roles;
66702       });
66703       const existingRelations = memberships.filter((membership2) => !recentlyAdded.has(membership2.relation.id)).map((membership2) => __spreadProps(__spreadValues({}, membership2), {
66704         // We only sort relations that were not added just now.
66705         // Sorting uses the same label as shown in the UI.
66706         // If the label is not unique, the relation ID ensures
66707         // that the sort order is still stable.
66708         _sortKey: [
66709           baseDisplayValue(membership2.relation),
66710           membership2.relation.id
66711         ].join("-")
66712       })).sort((a2, b2) => {
66713         return a2._sortKey.localeCompare(
66714           b2._sortKey,
66715           _mainLocalizer.localeCodes(),
66716           { numeric: true }
66717         );
66718       });
66719       const newlyAddedRelations = memberships.filter((membership2) => recentlyAdded.has(membership2.relation.id));
66720       return [
66721         // the sorted relations come first
66722         ...existingRelations,
66723         // then the ones that were just added from this panel
66724         ...newlyAddedRelations
66725       ];
66726     }
66727     function selectRelation(d3_event, d2) {
66728       d3_event.preventDefault();
66729       utilHighlightEntities([d2.relation.id], false, context);
66730       context.enter(modeSelect(context, [d2.relation.id]));
66731     }
66732     function zoomToRelation(d3_event, d2) {
66733       d3_event.preventDefault();
66734       var entity = context.entity(d2.relation.id);
66735       context.map().zoomToEase(entity);
66736       utilHighlightEntities([d2.relation.id], true, context);
66737     }
66738     function changeRole(d3_event, d2) {
66739       if (d2 === 0) return;
66740       if (_inChange) return;
66741       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
66742       if (!newRole.trim() && typeof d2.role !== "string") return;
66743       var membersToUpdate = d2.members.filter(function(member) {
66744         return member.role !== newRole;
66745       });
66746       if (membersToUpdate.length) {
66747         _inChange = true;
66748         context.perform(
66749           function actionChangeMemberRoles(graph) {
66750             membersToUpdate.forEach(function(member) {
66751               var newMember = Object.assign({}, member, { role: newRole });
66752               delete newMember.index;
66753               graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
66754             });
66755             return graph;
66756           },
66757           _t("operations.change_role.annotation", {
66758             n: membersToUpdate.length
66759           })
66760         );
66761         context.validator().validate();
66762       }
66763       _inChange = false;
66764     }
66765     function addMembership(d2, role) {
66766       _showBlank = false;
66767       function actionAddMembers(relationId, ids, role2) {
66768         return function(graph) {
66769           for (var i3 in ids) {
66770             var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
66771             graph = actionAddMember(relationId, member)(graph);
66772           }
66773           return graph;
66774         };
66775       }
66776       if (d2.relation) {
66777         recentlyAdded.add(d2.relation.id);
66778         context.perform(
66779           actionAddMembers(d2.relation.id, _entityIDs, role),
66780           _t("operations.add_member.annotation", {
66781             n: _entityIDs.length
66782           })
66783         );
66784         context.validator().validate();
66785       } else {
66786         var relation = osmRelation();
66787         context.perform(
66788           actionAddEntity(relation),
66789           actionAddMembers(relation.id, _entityIDs, role),
66790           _t("operations.add.annotation.relation")
66791         );
66792         context.enter(modeSelect(context, [relation.id]).newFeature(true));
66793       }
66794     }
66795     function downloadMembers(d3_event, d2) {
66796       d3_event.preventDefault();
66797       const button = select_default2(this);
66798       button.classed("loading", true);
66799       context.loadEntity(d2.relation.id, function() {
66800         section.reRender();
66801       });
66802     }
66803     function deleteMembership(d3_event, d2) {
66804       this.blur();
66805       if (d2 === 0) return;
66806       utilHighlightEntities([d2.relation.id], false, context);
66807       var indexes = d2.members.map(function(member) {
66808         return member.index;
66809       });
66810       context.perform(
66811         actionDeleteMembers(d2.relation.id, indexes),
66812         _t("operations.delete_member.annotation", {
66813           n: _entityIDs.length
66814         })
66815       );
66816       context.validator().validate();
66817     }
66818     function fetchNearbyRelations(q2, callback) {
66819       var newRelation = {
66820         relation: null,
66821         value: _t("inspector.new_relation"),
66822         display: _t.append("inspector.new_relation")
66823       };
66824       var entityID = _entityIDs[0];
66825       var result = [];
66826       var graph = context.graph();
66827       function baseDisplayLabel(entity) {
66828         var matched = _mainPresetIndex.match(entity, graph);
66829         var presetName = matched && matched.name() || _t("inspector.relation");
66830         var entityName = utilDisplayName(entity) || "";
66831         return (selection2) => {
66832           selection2.append("b").text(presetName + " ");
66833           selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
66834         };
66835       }
66836       var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
66837       if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
66838         result.push({
66839           relation: explicitRelation,
66840           value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
66841           display: baseDisplayLabel(explicitRelation)
66842         });
66843       } else {
66844         context.history().intersects(context.map().extent()).forEach(function(entity) {
66845           if (entity.type !== "relation" || entity.id === entityID) return;
66846           var value = baseDisplayValue(entity);
66847           if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1) return;
66848           result.push({
66849             relation: entity,
66850             value,
66851             display: baseDisplayLabel(entity)
66852           });
66853         });
66854         result.sort(function(a2, b2) {
66855           return osmRelation.creationOrder(a2.relation, b2.relation);
66856         });
66857         var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
66858           return v2.length > 1;
66859         });
66860         dupeGroups.forEach(function(group) {
66861           group.forEach(function(obj) {
66862             obj.value += " " + obj.relation.id;
66863           });
66864         });
66865       }
66866       result.forEach(function(obj) {
66867         obj.title = obj.value;
66868       });
66869       result.unshift(newRelation);
66870       callback(result);
66871     }
66872     function baseDisplayValue(entity) {
66873       const graph = context.graph();
66874       var matched = _mainPresetIndex.match(entity, graph);
66875       var presetName = matched && matched.name() || _t("inspector.relation");
66876       var entityName = utilDisplayName(entity) || "";
66877       return presetName + " " + entityName;
66878     }
66879     function renderDisclosureContent(selection2) {
66880       var memberships = getMemberships();
66881       var list2 = selection2.selectAll(".member-list").data([0]);
66882       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
66883       var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
66884         return d2.hash;
66885       });
66886       items.exit().each(unbind).remove();
66887       var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
66888       itemsEnter.on("mouseover", function(d3_event, d2) {
66889         utilHighlightEntities([d2.relation.id], true, context);
66890       }).on("mouseout", function(d3_event, d2) {
66891         utilHighlightEntities([d2.relation.id], false, context);
66892       });
66893       var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
66894         return d2.domId;
66895       });
66896       var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
66897       labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
66898         var matched = _mainPresetIndex.match(d2.relation, context.graph());
66899         return matched && matched.name() || _t.html("inspector.relation");
66900       });
66901       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).html(function(d2) {
66902         const matched = _mainPresetIndex.match(d2.relation, context.graph());
66903         return utilDisplayName(d2.relation, matched.suggestion);
66904       });
66905       labelEnter.append("button").attr("class", "members-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMembers);
66906       labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
66907       labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
66908       items = items.merge(itemsEnter);
66909       items.selectAll("button.members-download").classed("hide", (d2) => {
66910         const graph = context.graph();
66911         return d2.relation.members.every((m2) => graph.hasEntity(m2.id));
66912       });
66913       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
66914       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
66915         return d2.domId;
66916       }).property("type", "text").property("value", function(d2) {
66917         return typeof d2.role === "string" ? d2.role : "";
66918       }).attr("title", function(d2) {
66919         return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
66920       }).attr("placeholder", function(d2) {
66921         return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
66922       }).classed("mixed", function(d2) {
66923         return Array.isArray(d2.role);
66924       }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
66925       if (taginfo) {
66926         wrapEnter.each(bindTypeahead);
66927       }
66928       var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
66929       newMembership.exit().remove();
66930       var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
66931       var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
66932       newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
66933       newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
66934         list2.selectAll(".member-row-new").remove();
66935       });
66936       var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
66937       newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
66938       newMembership = newMembership.merge(newMembershipEnter);
66939       newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
66940         nearbyCombo.on("accept", function(d2) {
66941           this.blur();
66942           acceptEntity.call(this, d2);
66943         }).on("cancel", cancelEntity)
66944       );
66945       var addRow = selection2.selectAll(".add-row").data([0]);
66946       var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
66947       var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
66948       addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
66949       addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
66950       addRowEnter.append("div").attr("class", "space-value");
66951       addRowEnter.append("div").attr("class", "space-buttons");
66952       addRow = addRow.merge(addRowEnter);
66953       addRow.select(".add-relation").on("click", function() {
66954         _showBlank = true;
66955         section.reRender();
66956         list2.selectAll(".member-entity-input").node().focus();
66957       });
66958       function acceptEntity(d2) {
66959         if (!d2) {
66960           cancelEntity();
66961           return;
66962         }
66963         if (d2.relation) utilHighlightEntities([d2.relation.id], false, context);
66964         var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
66965         addMembership(d2, role);
66966       }
66967       function cancelEntity() {
66968         var input = newMembership.selectAll(".member-entity-input");
66969         input.property("value", "");
66970         context.surface().selectAll(".highlighted").classed("highlighted", false);
66971       }
66972       function bindTypeahead(d2) {
66973         var row = select_default2(this);
66974         var role = row.selectAll("input.member-role");
66975         var origValue = role.property("value");
66976         function sort(value, data) {
66977           var sameletter = [];
66978           var other2 = [];
66979           for (var i3 = 0; i3 < data.length; i3++) {
66980             if (data[i3].value.substring(0, value.length) === value) {
66981               sameletter.push(data[i3]);
66982             } else {
66983               other2.push(data[i3]);
66984             }
66985           }
66986           return sameletter.concat(other2);
66987         }
66988         role.call(
66989           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
66990             var rtype = d2.relation.tags.type;
66991             taginfo.roles({
66992               debounce: true,
66993               rtype: rtype || "",
66994               geometry: context.graph().geometry(_entityIDs[0]),
66995               query: role2
66996             }, function(err, data) {
66997               if (!err) callback(sort(role2, data));
66998             });
66999           }).on("cancel", function() {
67000             role.property("value", origValue);
67001           })
67002         );
67003       }
67004       function unbind() {
67005         var row = select_default2(this);
67006         row.selectAll("input.member-role").call(uiCombobox.off, context);
67007       }
67008     }
67009     section.entityIDs = function(val) {
67010       if (!arguments.length) return _entityIDs;
67011       const didChange = _entityIDs.join(",") !== val.join(",");
67012       _entityIDs = val;
67013       _showBlank = false;
67014       if (didChange) {
67015         recentlyAdded.clear();
67016       }
67017       return section;
67018     };
67019     return section;
67020   }
67021
67022   // modules/ui/sections/selection_list.js
67023   function uiSectionSelectionList(context) {
67024     var _selectedIDs = [];
67025     var section = uiSection("selected-features", context).shouldDisplay(function() {
67026       return _selectedIDs.length > 1;
67027     }).label(function() {
67028       return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
67029     }).disclosureContent(renderDisclosureContent);
67030     context.history().on("change.selectionList", function(difference2) {
67031       if (difference2) {
67032         section.reRender();
67033       }
67034     });
67035     section.entityIDs = function(val) {
67036       if (!arguments.length) return _selectedIDs;
67037       _selectedIDs = val;
67038       return section;
67039     };
67040     function selectEntity(d3_event, entity) {
67041       context.enter(modeSelect(context, [entity.id]));
67042     }
67043     function deselectEntity(d3_event, entity) {
67044       var selectedIDs = _selectedIDs.slice();
67045       var index = selectedIDs.indexOf(entity.id);
67046       if (index > -1) {
67047         selectedIDs.splice(index, 1);
67048         context.enter(modeSelect(context, selectedIDs));
67049       }
67050     }
67051     function renderDisclosureContent(selection2) {
67052       var list2 = selection2.selectAll(".feature-list").data([0]);
67053       list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
67054       var entities = _selectedIDs.map(function(id2) {
67055         return context.hasEntity(id2);
67056       }).filter(Boolean);
67057       var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
67058       items.exit().remove();
67059       var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
67060         select_default2(this).on("mouseover", function() {
67061           utilHighlightEntities([d2.id], true, context);
67062         }).on("mouseout", function() {
67063           utilHighlightEntities([d2.id], false, context);
67064         });
67065       });
67066       var label = enter.append("button").attr("class", "label").on("click", selectEntity);
67067       label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
67068       label.append("span").attr("class", "entity-type");
67069       label.append("span").attr("class", "entity-name");
67070       enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
67071       items = items.merge(enter);
67072       items.selectAll(".entity-geom-icon use").attr("href", function() {
67073         var entity = this.parentNode.parentNode.__data__;
67074         return "#iD-icon-" + entity.geometry(context.graph());
67075       });
67076       items.selectAll(".entity-type").text(function(entity) {
67077         return _mainPresetIndex.match(entity, context.graph()).name();
67078       });
67079       items.selectAll(".entity-name").text(function(d2) {
67080         var entity = context.entity(d2.id);
67081         return utilDisplayName(entity);
67082       });
67083     }
67084     return section;
67085   }
67086
67087   // modules/ui/entity_editor.js
67088   function uiEntityEditor(context) {
67089     var dispatch14 = dispatch_default("choose");
67090     var _state = "select";
67091     var _coalesceChanges = false;
67092     var _modified = false;
67093     var _base;
67094     var _entityIDs;
67095     var _activePresets = [];
67096     var _newFeature;
67097     var _sections;
67098     function entityEditor(selection2) {
67099       var combinedTags = utilCombinedTags(_entityIDs, context.graph());
67100       var header = selection2.selectAll(".header").data([0]);
67101       var headerEnter = header.enter().append("div").attr("class", "header fillL");
67102       var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
67103       headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
67104       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
67105         context.enter(modeBrowse(context));
67106       }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
67107       headerEnter.append("h2");
67108       header = header.merge(headerEnter);
67109       header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
67110       header.selectAll(".preset-reset").on("click", function() {
67111         dispatch14.call("choose", this, _activePresets);
67112       });
67113       var body = selection2.selectAll(".inspector-body").data([0]);
67114       var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
67115       body = body.merge(bodyEnter);
67116       if (!_sections) {
67117         _sections = [
67118           uiSectionSelectionList(context),
67119           uiSectionFeatureType(context).on("choose", function(presets) {
67120             dispatch14.call("choose", this, presets);
67121           }),
67122           uiSectionEntityIssues(context),
67123           uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
67124           uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
67125           uiSectionRawMemberEditor(context),
67126           uiSectionRawMembershipEditor(context)
67127         ];
67128       }
67129       _sections.forEach(function(section) {
67130         if (section.entityIDs) {
67131           section.entityIDs(_entityIDs);
67132         }
67133         if (section.presets) {
67134           section.presets(_activePresets);
67135         }
67136         if (section.tags) {
67137           section.tags(combinedTags);
67138         }
67139         if (section.state) {
67140           section.state(_state);
67141         }
67142         body.call(section.render);
67143       });
67144       context.history().on("change.entity-editor", historyChanged);
67145       function historyChanged(difference2) {
67146         if (selection2.selectAll(".entity-editor").empty()) return;
67147         if (_state === "hide") return;
67148         var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
67149         if (!significant) return;
67150         _entityIDs = _entityIDs.filter(context.hasEntity);
67151         if (!_entityIDs.length) return;
67152         var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
67153         loadActivePresets();
67154         var graph = context.graph();
67155         entityEditor.modified(_base !== graph);
67156         entityEditor(selection2);
67157         if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
67158           context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
67159         }
67160       }
67161     }
67162     function changeTags(entityIDs, changed, onInput) {
67163       var actions = [];
67164       for (var i3 in entityIDs) {
67165         var entityID = entityIDs[i3];
67166         var entity = context.entity(entityID);
67167         var tags = Object.assign({}, entity.tags);
67168         if (typeof changed === "function") {
67169           tags = changed(tags);
67170         } else {
67171           for (var k2 in changed) {
67172             if (!k2) continue;
67173             var v2 = changed[k2];
67174             if (typeof v2 === "object") {
67175               tags[k2] = tags[v2.oldKey];
67176             } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
67177               tags[k2] = v2;
67178             }
67179           }
67180         }
67181         if (!onInput) {
67182           tags = utilCleanTags(tags);
67183         }
67184         if (!(0, import_fast_deep_equal9.default)(entity.tags, tags)) {
67185           actions.push(actionChangeTags(entityID, tags));
67186         }
67187       }
67188       if (actions.length) {
67189         var combinedAction = function(graph) {
67190           actions.forEach(function(action) {
67191             graph = action(graph);
67192           });
67193           return graph;
67194         };
67195         var annotation = _t("operations.change_tags.annotation");
67196         if (_coalesceChanges) {
67197           context.overwrite(combinedAction, annotation);
67198         } else {
67199           context.perform(combinedAction, annotation);
67200           _coalesceChanges = !!onInput;
67201         }
67202       }
67203       if (!onInput) {
67204         context.validator().validate();
67205       }
67206     }
67207     function revertTags(keys2) {
67208       var actions = [];
67209       for (var i3 in _entityIDs) {
67210         var entityID = _entityIDs[i3];
67211         var original = context.graph().base().entities[entityID];
67212         var changed = {};
67213         for (var j2 in keys2) {
67214           var key = keys2[j2];
67215           changed[key] = original ? original.tags[key] : void 0;
67216         }
67217         var entity = context.entity(entityID);
67218         var tags = Object.assign({}, entity.tags);
67219         for (var k2 in changed) {
67220           if (!k2) continue;
67221           var v2 = changed[k2];
67222           if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
67223             tags[k2] = v2;
67224           }
67225         }
67226         tags = utilCleanTags(tags);
67227         if (!(0, import_fast_deep_equal9.default)(entity.tags, tags)) {
67228           actions.push(actionChangeTags(entityID, tags));
67229         }
67230       }
67231       if (actions.length) {
67232         var combinedAction = function(graph) {
67233           actions.forEach(function(action) {
67234             graph = action(graph);
67235           });
67236           return graph;
67237         };
67238         var annotation = _t("operations.change_tags.annotation");
67239         if (_coalesceChanges) {
67240           context.overwrite(combinedAction, annotation);
67241         } else {
67242           context.perform(combinedAction, annotation);
67243           _coalesceChanges = false;
67244         }
67245       }
67246       context.validator().validate();
67247     }
67248     entityEditor.modified = function(val) {
67249       if (!arguments.length) return _modified;
67250       _modified = val;
67251       return entityEditor;
67252     };
67253     entityEditor.state = function(val) {
67254       if (!arguments.length) return _state;
67255       _state = val;
67256       return entityEditor;
67257     };
67258     entityEditor.entityIDs = function(val) {
67259       if (!arguments.length) return _entityIDs;
67260       _base = context.graph();
67261       _coalesceChanges = false;
67262       if (val && _entityIDs && utilArrayIdentical(_entityIDs, val)) return entityEditor;
67263       _entityIDs = val;
67264       loadActivePresets(true);
67265       return entityEditor.modified(false);
67266     };
67267     entityEditor.newFeature = function(val) {
67268       if (!arguments.length) return _newFeature;
67269       _newFeature = val;
67270       return entityEditor;
67271     };
67272     function loadActivePresets(isForNewSelection) {
67273       var graph = context.graph();
67274       var counts = {};
67275       for (var i3 in _entityIDs) {
67276         var entity = graph.hasEntity(_entityIDs[i3]);
67277         if (!entity) return;
67278         var match = _mainPresetIndex.match(entity, graph);
67279         if (!counts[match.id]) counts[match.id] = 0;
67280         counts[match.id] += 1;
67281       }
67282       var matches = Object.keys(counts).sort(function(p1, p2) {
67283         return counts[p2] - counts[p1];
67284       }).map(function(pID) {
67285         return _mainPresetIndex.item(pID);
67286       });
67287       if (!isForNewSelection) {
67288         var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
67289         if (weakPreset && matches.length === 1 && matches[0].isFallback()) return;
67290       }
67291       entityEditor.presets(matches);
67292     }
67293     entityEditor.presets = function(val) {
67294       if (!arguments.length) return _activePresets;
67295       if (!utilArrayIdentical(val, _activePresets)) {
67296         _activePresets = val;
67297       }
67298       return entityEditor;
67299     };
67300     return utilRebind(entityEditor, dispatch14, "on");
67301   }
67302
67303   // modules/ui/preset_list.js
67304   function uiPresetList(context) {
67305     var dispatch14 = dispatch_default("cancel", "choose");
67306     var _entityIDs;
67307     var _currLoc;
67308     var _currentPresets;
67309     var _autofocus = false;
67310     function presetList(selection2) {
67311       if (!_entityIDs) return;
67312       var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
67313       selection2.html("");
67314       var messagewrap = selection2.append("div").attr("class", "header fillL");
67315       var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
67316       messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
67317         dispatch14.call("cancel", this);
67318       }).call(svgIcon("#iD-icon-close"));
67319       function initialKeydown(d3_event) {
67320         if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
67321           d3_event.preventDefault();
67322           d3_event.stopPropagation();
67323           operationDelete(context, _entityIDs)();
67324         } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
67325           d3_event.preventDefault();
67326           d3_event.stopPropagation();
67327           context.undo();
67328         } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
67329           select_default2(this).on("keydown", keydown);
67330           keydown.call(this, d3_event);
67331         }
67332       }
67333       function keydown(d3_event) {
67334         if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
67335         search.node().selectionStart === search.property("value").length) {
67336           d3_event.preventDefault();
67337           d3_event.stopPropagation();
67338           var buttons = list2.selectAll(".preset-list-button");
67339           if (!buttons.empty()) buttons.nodes()[0].focus();
67340         }
67341       }
67342       function keypress(d3_event) {
67343         var value = search.property("value");
67344         if (d3_event.keyCode === 13 && // ↩ Return
67345         value.length) {
67346           list2.selectAll(".preset-list-item:first-child").each(function(d2) {
67347             d2.choose.call(this);
67348           });
67349         }
67350       }
67351       function inputevent() {
67352         var value = search.property("value");
67353         list2.classed("filtered", value.length);
67354         var results, messageText;
67355         if (value.length) {
67356           results = presets.search(value, entityGeometries()[0], _currLoc);
67357           messageText = _t.html("inspector.results", {
67358             n: results.collection.length,
67359             search: value
67360           });
67361         } else {
67362           var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
67363           results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
67364           messageText = _t.html("inspector.choose");
67365         }
67366         list2.call(drawList, results);
67367         message.html(messageText);
67368       }
67369       var searchWrap = selection2.append("div").attr("class", "search-header");
67370       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
67371       var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search_feature_type")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent));
67372       if (_autofocus) {
67373         search.node().focus();
67374         setTimeout(function() {
67375           search.node().focus();
67376         }, 0);
67377       }
67378       var listWrap = selection2.append("div").attr("class", "inspector-body");
67379       var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
67380       var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
67381       context.features().on("change.preset-list", updateForFeatureHiddenState);
67382     }
67383     function drawList(list2, presets) {
67384       presets = presets.matchAllGeometry(entityGeometries());
67385       var collection = presets.collection.reduce(function(collection2, preset) {
67386         if (!preset) return collection2;
67387         if (preset.members) {
67388           if (preset.members.collection.filter(function(preset2) {
67389             return preset2.addable();
67390           }).length > 1) {
67391             collection2.push(CategoryItem(preset));
67392           }
67393         } else if (preset.addable()) {
67394           collection2.push(PresetItem(preset));
67395         }
67396         return collection2;
67397       }, []);
67398       var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
67399         return d2.preset.id;
67400       });
67401       items.order();
67402       items.exit().remove();
67403       items.enter().append("div").attr("class", function(item) {
67404         return "preset-list-item preset-" + item.preset.id.replace("/", "-");
67405       }).classed("current", function(item) {
67406         return _currentPresets.indexOf(item.preset) !== -1;
67407       }).each(function(item) {
67408         select_default2(this).call(item);
67409       }).style("opacity", 0).transition().style("opacity", 1);
67410       updateForFeatureHiddenState();
67411     }
67412     function itemKeydown(d3_event) {
67413       var item = select_default2(this.closest(".preset-list-item"));
67414       var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
67415       if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
67416         d3_event.preventDefault();
67417         d3_event.stopPropagation();
67418         var nextItem = select_default2(item.node().nextElementSibling);
67419         if (nextItem.empty()) {
67420           if (!parentItem.empty()) {
67421             nextItem = select_default2(parentItem.node().nextElementSibling);
67422           }
67423         } else if (select_default2(this).classed("expanded")) {
67424           nextItem = item.select(".subgrid .preset-list-item:first-child");
67425         }
67426         if (!nextItem.empty()) {
67427           nextItem.select(".preset-list-button").node().focus();
67428         }
67429       } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
67430         d3_event.preventDefault();
67431         d3_event.stopPropagation();
67432         var previousItem = select_default2(item.node().previousElementSibling);
67433         if (previousItem.empty()) {
67434           if (!parentItem.empty()) {
67435             previousItem = parentItem;
67436           }
67437         } else if (previousItem.select(".preset-list-button").classed("expanded")) {
67438           previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
67439         }
67440         if (!previousItem.empty()) {
67441           previousItem.select(".preset-list-button").node().focus();
67442         } else {
67443           var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
67444           search.node().focus();
67445         }
67446       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
67447         d3_event.preventDefault();
67448         d3_event.stopPropagation();
67449         if (!parentItem.empty()) {
67450           parentItem.select(".preset-list-button").node().focus();
67451         }
67452       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
67453         d3_event.preventDefault();
67454         d3_event.stopPropagation();
67455         item.datum().choose.call(select_default2(this).node());
67456       }
67457     }
67458     function CategoryItem(preset) {
67459       var box, sublist, shown = false;
67460       function item(selection2) {
67461         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
67462         function click() {
67463           var isExpanded = select_default2(this).classed("expanded");
67464           var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
67465           select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
67466           select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
67467           item.choose();
67468         }
67469         var geometries = entityGeometries();
67470         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) {
67471           if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
67472             d3_event.preventDefault();
67473             d3_event.stopPropagation();
67474             if (!select_default2(this).classed("expanded")) {
67475               click.call(this, d3_event);
67476             }
67477           } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
67478             d3_event.preventDefault();
67479             d3_event.stopPropagation();
67480             if (select_default2(this).classed("expanded")) {
67481               click.call(this, d3_event);
67482             }
67483           } else {
67484             itemKeydown.call(this, d3_event);
67485           }
67486         });
67487         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
67488         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");
67489         box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
67490         box.append("div").attr("class", "arrow");
67491         sublist = box.append("div").attr("class", "preset-list fillL3");
67492       }
67493       item.choose = function() {
67494         if (!box || !sublist) return;
67495         if (shown) {
67496           shown = false;
67497           box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
67498         } else {
67499           shown = true;
67500           var members = preset.members.matchAllGeometry(entityGeometries());
67501           sublist.call(drawList, members);
67502           box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
67503         }
67504       };
67505       item.preset = preset;
67506       return item;
67507     }
67508     function PresetItem(preset) {
67509       function item(selection2) {
67510         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
67511         var geometries = entityGeometries();
67512         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);
67513         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
67514         var nameparts = [
67515           preset.nameLabel(),
67516           preset.subtitleLabel()
67517         ].filter(Boolean);
67518         label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
67519           d2(select_default2(this));
67520         });
67521         wrap2.call(item.reference.button);
67522         selection2.call(item.reference.body);
67523       }
67524       item.choose = function() {
67525         if (select_default2(this).classed("disabled")) return;
67526         if (!context.inIntro()) {
67527           _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
67528         }
67529         context.perform(
67530           function(graph) {
67531             for (var i3 in _entityIDs) {
67532               var entityID = _entityIDs[i3];
67533               var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
67534               graph = actionChangePreset(entityID, oldPreset, preset)(graph);
67535             }
67536             return graph;
67537           },
67538           _t("operations.change_tags.annotation")
67539         );
67540         context.validator().validate();
67541         dispatch14.call("choose", this, preset);
67542       };
67543       item.help = function(d3_event) {
67544         d3_event.stopPropagation();
67545         item.reference.toggle();
67546       };
67547       item.preset = preset;
67548       item.reference = uiTagReference(preset.reference(), context);
67549       return item;
67550     }
67551     function updateForFeatureHiddenState() {
67552       if (!_entityIDs.every(context.hasEntity)) return;
67553       var geometries = entityGeometries();
67554       var button = context.container().selectAll(".preset-list .preset-list-button");
67555       button.call(uiTooltip().destroyAny);
67556       button.each(function(item, index) {
67557         var hiddenPresetFeaturesId;
67558         for (var i3 in geometries) {
67559           hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
67560           if (hiddenPresetFeaturesId) break;
67561         }
67562         var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
67563         select_default2(this).classed("disabled", isHiddenPreset);
67564         if (isHiddenPreset) {
67565           var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
67566           select_default2(this).call(
67567             uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
67568               features: _t("feature." + hiddenPresetFeaturesId + ".description")
67569             })).placement(index < 2 ? "bottom" : "top")
67570           );
67571         }
67572       });
67573     }
67574     presetList.autofocus = function(val) {
67575       if (!arguments.length) return _autofocus;
67576       _autofocus = val;
67577       return presetList;
67578     };
67579     presetList.entityIDs = function(val) {
67580       if (!arguments.length) return _entityIDs;
67581       _entityIDs = val;
67582       _currLoc = null;
67583       if (_entityIDs && _entityIDs.length) {
67584         const extent = _entityIDs.reduce(function(extent2, entityID) {
67585           var entity = context.graph().entity(entityID);
67586           return extent2.extend(entity.extent(context.graph()));
67587         }, geoExtent());
67588         _currLoc = extent.center();
67589         var presets = _entityIDs.map(function(entityID) {
67590           return _mainPresetIndex.match(context.entity(entityID), context.graph());
67591         });
67592         presetList.presets(presets);
67593       }
67594       return presetList;
67595     };
67596     presetList.presets = function(val) {
67597       if (!arguments.length) return _currentPresets;
67598       _currentPresets = val;
67599       return presetList;
67600     };
67601     function entityGeometries() {
67602       var counts = {};
67603       for (var i3 in _entityIDs) {
67604         var entityID = _entityIDs[i3];
67605         var entity = context.entity(entityID);
67606         var geometry = entity.geometry(context.graph());
67607         if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
67608           geometry = "point";
67609         }
67610         if (!counts[geometry]) counts[geometry] = 0;
67611         counts[geometry] += 1;
67612       }
67613       return Object.keys(counts).sort(function(geom1, geom2) {
67614         return counts[geom2] - counts[geom1];
67615       });
67616     }
67617     return utilRebind(presetList, dispatch14, "on");
67618   }
67619
67620   // modules/ui/inspector.js
67621   function uiInspector(context) {
67622     var presetList = uiPresetList(context);
67623     var entityEditor = uiEntityEditor(context);
67624     var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
67625     var _state = "select";
67626     var _entityIDs;
67627     var _newFeature = false;
67628     function inspector(selection2) {
67629       presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
67630         inspector.setPreset();
67631       });
67632       entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
67633       wrap2 = selection2.selectAll(".panewrap").data([0]);
67634       var enter = wrap2.enter().append("div").attr("class", "panewrap");
67635       enter.append("div").attr("class", "preset-list-pane pane");
67636       enter.append("div").attr("class", "entity-editor-pane pane");
67637       wrap2 = wrap2.merge(enter);
67638       presetPane = wrap2.selectAll(".preset-list-pane");
67639       editorPane = wrap2.selectAll(".entity-editor-pane");
67640       function shouldDefaultToPresetList() {
67641         if (_state !== "select") return false;
67642         if (_entityIDs.length !== 1) return false;
67643         var entityID = _entityIDs[0];
67644         var entity = context.hasEntity(entityID);
67645         if (!entity) return false;
67646         if (entity.hasNonGeometryTags()) return false;
67647         if (_newFeature) return true;
67648         if (entity.geometry(context.graph()) !== "vertex") return false;
67649         if (context.graph().parentRelations(entity).length) return false;
67650         if (context.validator().getEntityIssues(entityID).length) return false;
67651         if (entity.type === "node" && entity.isHighwayIntersection(context.graph())) return false;
67652         return true;
67653       }
67654       if (shouldDefaultToPresetList()) {
67655         wrap2.style("right", "-100%");
67656         editorPane.classed("hide", true);
67657         presetPane.classed("hide", false).call(presetList);
67658       } else {
67659         wrap2.style("right", "0%");
67660         presetPane.classed("hide", true);
67661         editorPane.classed("hide", false).call(entityEditor);
67662       }
67663       var footer = selection2.selectAll(".footer").data([0]);
67664       footer = footer.enter().append("div").attr("class", "footer").merge(footer);
67665       footer.call(
67666         uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
67667       );
67668     }
67669     inspector.showList = function(presets) {
67670       presetPane.classed("hide", false);
67671       wrap2.transition().styleTween("right", function() {
67672         return value_default("0%", "-100%");
67673       }).on("end", function() {
67674         editorPane.classed("hide", true);
67675       });
67676       if (presets) {
67677         presetList.presets(presets);
67678       }
67679       presetPane.call(presetList.autofocus(true));
67680     };
67681     inspector.setPreset = function(preset) {
67682       if (preset && preset.id === "type/multipolygon") {
67683         presetPane.call(presetList.autofocus(true));
67684       } else {
67685         editorPane.classed("hide", false);
67686         wrap2.transition().styleTween("right", function() {
67687           return value_default("-100%", "0%");
67688         }).on("end", function() {
67689           presetPane.classed("hide", true);
67690         });
67691         if (preset) {
67692           entityEditor.presets([preset]);
67693         }
67694         editorPane.call(entityEditor);
67695       }
67696     };
67697     inspector.state = function(val) {
67698       if (!arguments.length) return _state;
67699       _state = val;
67700       entityEditor.state(_state);
67701       context.container().selectAll(".field-help-body").remove();
67702       return inspector;
67703     };
67704     inspector.entityIDs = function(val) {
67705       if (!arguments.length) return _entityIDs;
67706       _entityIDs = val;
67707       return inspector;
67708     };
67709     inspector.newFeature = function(val) {
67710       if (!arguments.length) return _newFeature;
67711       _newFeature = val;
67712       return inspector;
67713     };
67714     return inspector;
67715   }
67716
67717   // modules/ui/keepRight_details.js
67718   function uiKeepRightDetails(context) {
67719     let _qaItem;
67720     function issueDetail(d2) {
67721       const { itemType, parentIssueType } = d2;
67722       const unknown = { html: _t.html("inspector.unknown") };
67723       let replacements = d2.replacements || {};
67724       replacements.default = unknown;
67725       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
67726         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
67727       } else {
67728         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
67729       }
67730     }
67731     function keepRightDetails(selection2) {
67732       const details = selection2.selectAll(".error-details").data(
67733         _qaItem ? [_qaItem] : [],
67734         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67735       );
67736       details.exit().remove();
67737       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
67738       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
67739       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
67740       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
67741       let relatedEntities = [];
67742       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
67743         const link3 = select_default2(this);
67744         const isObjectLink = link3.classed("error_object_link");
67745         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
67746         const entity = context.hasEntity(entityID);
67747         relatedEntities.push(entityID);
67748         link3.on("mouseenter", () => {
67749           utilHighlightEntities([entityID], true, context);
67750         }).on("mouseleave", () => {
67751           utilHighlightEntities([entityID], false, context);
67752         }).on("click", (d3_event) => {
67753           d3_event.preventDefault();
67754           utilHighlightEntities([entityID], false, context);
67755           const osmlayer = context.layers().layer("osm");
67756           if (!osmlayer.enabled()) {
67757             osmlayer.enabled(true);
67758           }
67759           context.map().centerZoomEase(_qaItem.loc, 20);
67760           if (entity) {
67761             context.enter(modeSelect(context, [entityID]));
67762           } else {
67763             context.loadEntity(entityID, (err, result) => {
67764               if (err) return;
67765               const entity2 = result.data.find((e3) => e3.id === entityID);
67766               if (entity2) context.enter(modeSelect(context, [entityID]));
67767             });
67768           }
67769         });
67770         if (entity) {
67771           let name = utilDisplayName(entity);
67772           if (!name && !isObjectLink) {
67773             const preset = _mainPresetIndex.match(entity, context.graph());
67774             name = preset && !preset.isFallback() && preset.name();
67775           }
67776           if (name) {
67777             this.innerText = name;
67778           }
67779         }
67780       });
67781       context.features().forceVisible(relatedEntities);
67782       context.map().pan([0, 0]);
67783     }
67784     keepRightDetails.issue = function(val) {
67785       if (!arguments.length) return _qaItem;
67786       _qaItem = val;
67787       return keepRightDetails;
67788     };
67789     return keepRightDetails;
67790   }
67791
67792   // modules/ui/keepRight_header.js
67793   function uiKeepRightHeader() {
67794     let _qaItem;
67795     function issueTitle(d2) {
67796       const { itemType, parentIssueType } = d2;
67797       const unknown = _t.html("inspector.unknown");
67798       let replacements = d2.replacements || {};
67799       replacements.default = { html: unknown };
67800       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
67801         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
67802       } else {
67803         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
67804       }
67805     }
67806     function keepRightHeader(selection2) {
67807       const header = selection2.selectAll(".qa-header").data(
67808         _qaItem ? [_qaItem] : [],
67809         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67810       );
67811       header.exit().remove();
67812       const headerEnter = header.enter().append("div").attr("class", "qa-header");
67813       const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
67814       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"));
67815       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
67816     }
67817     keepRightHeader.issue = function(val) {
67818       if (!arguments.length) return _qaItem;
67819       _qaItem = val;
67820       return keepRightHeader;
67821     };
67822     return keepRightHeader;
67823   }
67824
67825   // modules/ui/view_on_keepRight.js
67826   function uiViewOnKeepRight() {
67827     let _qaItem;
67828     function viewOnKeepRight(selection2) {
67829       let url;
67830       if (services.keepRight && _qaItem instanceof QAItem) {
67831         url = services.keepRight.issueURL(_qaItem);
67832       }
67833       const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
67834       link3.exit().remove();
67835       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"));
67836       linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
67837     }
67838     viewOnKeepRight.what = function(val) {
67839       if (!arguments.length) return _qaItem;
67840       _qaItem = val;
67841       return viewOnKeepRight;
67842     };
67843     return viewOnKeepRight;
67844   }
67845
67846   // modules/ui/keepRight_editor.js
67847   function uiKeepRightEditor(context) {
67848     const dispatch14 = dispatch_default("change");
67849     const qaDetails = uiKeepRightDetails(context);
67850     const qaHeader = uiKeepRightHeader(context);
67851     let _qaItem;
67852     function keepRightEditor(selection2) {
67853       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
67854       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
67855       headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
67856       let body = selection2.selectAll(".body").data([0]);
67857       body = body.enter().append("div").attr("class", "body").merge(body);
67858       const editor = body.selectAll(".qa-editor").data([0]);
67859       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
67860       const footer = selection2.selectAll(".footer").data([0]);
67861       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
67862     }
67863     function keepRightSaveSection(selection2) {
67864       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67865       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
67866       let saveSection = selection2.selectAll(".qa-save").data(
67867         isShown ? [_qaItem] : [],
67868         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67869       );
67870       saveSection.exit().remove();
67871       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
67872       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
67873       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);
67874       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
67875       function changeInput() {
67876         const input = select_default2(this);
67877         let val = input.property("value").trim();
67878         if (val === _qaItem.comment) {
67879           val = void 0;
67880         }
67881         _qaItem = _qaItem.update({ newComment: val });
67882         const qaService = services.keepRight;
67883         if (qaService) {
67884           qaService.replaceItem(_qaItem);
67885         }
67886         saveSection.call(qaSaveButtons);
67887       }
67888     }
67889     function qaSaveButtons(selection2) {
67890       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67891       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
67892       buttonSection.exit().remove();
67893       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
67894       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
67895       buttonEnter.append("button").attr("class", "button close-button action");
67896       buttonEnter.append("button").attr("class", "button ignore-button action");
67897       buttonSection = buttonSection.merge(buttonEnter);
67898       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
67899         this.blur();
67900         const qaService = services.keepRight;
67901         if (qaService) {
67902           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67903         }
67904       });
67905       buttonSection.select(".close-button").html((d2) => {
67906         const andComment = d2.newComment ? "_comment" : "";
67907         return _t.html("QA.keepRight.close".concat(andComment));
67908       }).on("click.close", function(d3_event, d2) {
67909         this.blur();
67910         const qaService = services.keepRight;
67911         if (qaService) {
67912           d2.newStatus = "ignore_t";
67913           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67914         }
67915       });
67916       buttonSection.select(".ignore-button").html((d2) => {
67917         const andComment = d2.newComment ? "_comment" : "";
67918         return _t.html("QA.keepRight.ignore".concat(andComment));
67919       }).on("click.ignore", function(d3_event, d2) {
67920         this.blur();
67921         const qaService = services.keepRight;
67922         if (qaService) {
67923           d2.newStatus = "ignore";
67924           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67925         }
67926       });
67927     }
67928     keepRightEditor.error = function(val) {
67929       if (!arguments.length) return _qaItem;
67930       _qaItem = val;
67931       return keepRightEditor;
67932     };
67933     return utilRebind(keepRightEditor, dispatch14, "on");
67934   }
67935
67936   // modules/ui/osmose_details.js
67937   function uiOsmoseDetails(context) {
67938     let _qaItem;
67939     function issueString(d2, type2) {
67940       if (!d2) return "";
67941       const s2 = services.osmose.getStrings(d2.itemType);
67942       return type2 in s2 ? s2[type2] : "";
67943     }
67944     function osmoseDetails(selection2) {
67945       const details = selection2.selectAll(".error-details").data(
67946         _qaItem ? [_qaItem] : [],
67947         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67948       );
67949       details.exit().remove();
67950       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
67951       if (issueString(_qaItem, "detail")) {
67952         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67953         div.append("h4").call(_t.append("QA.keepRight.detail_description"));
67954         div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67955       }
67956       const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
67957       const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
67958       if (issueString(_qaItem, "fix")) {
67959         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67960         div.append("h4").call(_t.append("QA.osmose.fix_title"));
67961         div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67962       }
67963       if (issueString(_qaItem, "trap")) {
67964         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67965         div.append("h4").call(_t.append("QA.osmose.trap_title"));
67966         div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67967       }
67968       const thisItem = _qaItem;
67969       services.osmose.loadIssueDetail(_qaItem).then((d2) => {
67970         if (!d2.elems || d2.elems.length === 0) return;
67971         if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty()) return;
67972         if (d2.detail) {
67973           detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
67974           detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67975         }
67976         elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
67977         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() {
67978           const link3 = select_default2(this);
67979           const entityID = this.textContent;
67980           const entity = context.hasEntity(entityID);
67981           link3.on("mouseenter", () => {
67982             utilHighlightEntities([entityID], true, context);
67983           }).on("mouseleave", () => {
67984             utilHighlightEntities([entityID], false, context);
67985           }).on("click", (d3_event) => {
67986             d3_event.preventDefault();
67987             utilHighlightEntities([entityID], false, context);
67988             const osmlayer = context.layers().layer("osm");
67989             if (!osmlayer.enabled()) {
67990               osmlayer.enabled(true);
67991             }
67992             context.map().centerZoom(d2.loc, 20);
67993             if (entity) {
67994               context.enter(modeSelect(context, [entityID]));
67995             } else {
67996               context.loadEntity(entityID, (err, result) => {
67997                 if (err) return;
67998                 const entity2 = result.data.find((e3) => e3.id === entityID);
67999                 if (entity2) context.enter(modeSelect(context, [entityID]));
68000               });
68001             }
68002           });
68003           if (entity) {
68004             let name = utilDisplayName(entity);
68005             if (!name) {
68006               const preset = _mainPresetIndex.match(entity, context.graph());
68007               name = preset && !preset.isFallback() && preset.name();
68008             }
68009             if (name) {
68010               this.innerText = name;
68011             }
68012           }
68013         });
68014         context.features().forceVisible(d2.elems);
68015         context.map().pan([0, 0]);
68016       }).catch((err) => {
68017         console.log(err);
68018       });
68019     }
68020     osmoseDetails.issue = function(val) {
68021       if (!arguments.length) return _qaItem;
68022       _qaItem = val;
68023       return osmoseDetails;
68024     };
68025     return osmoseDetails;
68026   }
68027
68028   // modules/ui/osmose_header.js
68029   function uiOsmoseHeader() {
68030     let _qaItem;
68031     function issueTitle(d2) {
68032       const unknown = _t("inspector.unknown");
68033       if (!d2) return unknown;
68034       const s2 = services.osmose.getStrings(d2.itemType);
68035       return "title" in s2 ? s2.title : unknown;
68036     }
68037     function osmoseHeader(selection2) {
68038       const header = selection2.selectAll(".qa-header").data(
68039         _qaItem ? [_qaItem] : [],
68040         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
68041       );
68042       header.exit().remove();
68043       const headerEnter = header.enter().append("div").attr("class", "qa-header");
68044       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));
68045       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");
68046       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 : "");
68047       headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
68048     }
68049     osmoseHeader.issue = function(val) {
68050       if (!arguments.length) return _qaItem;
68051       _qaItem = val;
68052       return osmoseHeader;
68053     };
68054     return osmoseHeader;
68055   }
68056
68057   // modules/ui/view_on_osmose.js
68058   function uiViewOnOsmose() {
68059     let _qaItem;
68060     function viewOnOsmose(selection2) {
68061       let url;
68062       if (services.osmose && _qaItem instanceof QAItem) {
68063         url = services.osmose.itemURL(_qaItem);
68064       }
68065       const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
68066       link3.exit().remove();
68067       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"));
68068       linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
68069     }
68070     viewOnOsmose.what = function(val) {
68071       if (!arguments.length) return _qaItem;
68072       _qaItem = val;
68073       return viewOnOsmose;
68074     };
68075     return viewOnOsmose;
68076   }
68077
68078   // modules/ui/osmose_editor.js
68079   function uiOsmoseEditor(context) {
68080     const dispatch14 = dispatch_default("change");
68081     const qaDetails = uiOsmoseDetails(context);
68082     const qaHeader = uiOsmoseHeader(context);
68083     let _qaItem;
68084     function osmoseEditor(selection2) {
68085       const header = selection2.selectAll(".header").data([0]);
68086       const headerEnter = header.enter().append("div").attr("class", "header fillL");
68087       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
68088       headerEnter.append("h2").call(_t.append("QA.osmose.title"));
68089       let body = selection2.selectAll(".body").data([0]);
68090       body = body.enter().append("div").attr("class", "body").merge(body);
68091       let editor = body.selectAll(".qa-editor").data([0]);
68092       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
68093       const footer = selection2.selectAll(".footer").data([0]);
68094       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
68095     }
68096     function osmoseSaveSection(selection2) {
68097       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
68098       const isShown = _qaItem && isSelected;
68099       let saveSection = selection2.selectAll(".qa-save").data(
68100         isShown ? [_qaItem] : [],
68101         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
68102       );
68103       saveSection.exit().remove();
68104       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
68105       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
68106     }
68107     function qaSaveButtons(selection2) {
68108       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
68109       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
68110       buttonSection.exit().remove();
68111       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
68112       buttonEnter.append("button").attr("class", "button close-button action");
68113       buttonEnter.append("button").attr("class", "button ignore-button action");
68114       buttonSection = buttonSection.merge(buttonEnter);
68115       buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
68116         this.blur();
68117         const qaService = services.osmose;
68118         if (qaService) {
68119           d2.newStatus = "done";
68120           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
68121         }
68122       });
68123       buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
68124         this.blur();
68125         const qaService = services.osmose;
68126         if (qaService) {
68127           d2.newStatus = "false";
68128           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
68129         }
68130       });
68131     }
68132     osmoseEditor.error = function(val) {
68133       if (!arguments.length) return _qaItem;
68134       _qaItem = val;
68135       return osmoseEditor;
68136     };
68137     return utilRebind(osmoseEditor, dispatch14, "on");
68138   }
68139
68140   // modules/ui/sidebar.js
68141   function uiSidebar(context) {
68142     var inspector = uiInspector(context);
68143     var dataEditor = uiDataEditor(context);
68144     var noteEditor = uiNoteEditor(context);
68145     var keepRightEditor = uiKeepRightEditor(context);
68146     var osmoseEditor = uiOsmoseEditor(context);
68147     var _current;
68148     var _wasData = false;
68149     var _wasNote = false;
68150     var _wasQaItem = false;
68151     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
68152     function sidebar(selection2) {
68153       var container = context.container();
68154       var minWidth = 240;
68155       var sidebarWidth;
68156       var containerWidth;
68157       var dragOffset;
68158       selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
68159       var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
68160       var downPointerId, lastClientX, containerLocGetter;
68161       function pointerdown(d3_event) {
68162         if (downPointerId) return;
68163         if ("button" in d3_event && d3_event.button !== 0) return;
68164         downPointerId = d3_event.pointerId || "mouse";
68165         lastClientX = d3_event.clientX;
68166         containerLocGetter = utilFastMouse(container.node());
68167         dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
68168         sidebarWidth = selection2.node().getBoundingClientRect().width;
68169         containerWidth = container.node().getBoundingClientRect().width;
68170         var widthPct = sidebarWidth / containerWidth * 100;
68171         selection2.style("width", widthPct + "%").style("max-width", "85%");
68172         resizer.classed("dragging", true);
68173         select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
68174           d3_event2.preventDefault();
68175         }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
68176       }
68177       function pointermove(d3_event) {
68178         if (downPointerId !== (d3_event.pointerId || "mouse")) return;
68179         d3_event.preventDefault();
68180         var dx = d3_event.clientX - lastClientX;
68181         lastClientX = d3_event.clientX;
68182         var isRTL = _mainLocalizer.textDirection() === "rtl";
68183         var scaleX = isRTL ? 0 : 1;
68184         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
68185         var x2 = containerLocGetter(d3_event)[0] - dragOffset;
68186         sidebarWidth = isRTL ? containerWidth - x2 : x2;
68187         var isCollapsed = selection2.classed("collapsed");
68188         var shouldCollapse = sidebarWidth < minWidth;
68189         selection2.classed("collapsed", shouldCollapse);
68190         if (shouldCollapse) {
68191           if (!isCollapsed) {
68192             selection2.style(xMarginProperty, "-400px").style("width", "400px");
68193             context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
68194           }
68195         } else {
68196           var widthPct = sidebarWidth / containerWidth * 100;
68197           selection2.style(xMarginProperty, null).style("width", widthPct + "%");
68198           if (isCollapsed) {
68199             context.ui().onResize([-sidebarWidth * scaleX, 0]);
68200           } else {
68201             context.ui().onResize([-dx * scaleX, 0]);
68202           }
68203         }
68204       }
68205       function pointerup(d3_event) {
68206         if (downPointerId !== (d3_event.pointerId || "mouse")) return;
68207         downPointerId = null;
68208         resizer.classed("dragging", false);
68209         select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
68210       }
68211       var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
68212       var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
68213       var hoverModeSelect = function(targets) {
68214         context.container().selectAll(".feature-list-item button").classed("hover", false);
68215         if (context.selectedIDs().length > 1 && targets && targets.length) {
68216           var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
68217             return targets.indexOf(node) !== -1;
68218           });
68219           if (!elements.empty()) {
68220             elements.classed("hover", true);
68221           }
68222         }
68223       };
68224       sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
68225       function hover(targets) {
68226         var datum2 = targets && targets.length && targets[0];
68227         if (datum2 && datum2.__featurehash__) {
68228           _wasData = true;
68229           sidebar.show(dataEditor.datum(datum2));
68230           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
68231         } else if (datum2 instanceof osmNote) {
68232           if (context.mode().id === "drag-note") return;
68233           _wasNote = true;
68234           var osm = services.osm;
68235           if (osm) {
68236             datum2 = osm.getNote(datum2.id);
68237           }
68238           sidebar.show(noteEditor.note(datum2));
68239           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
68240         } else if (datum2 instanceof QAItem) {
68241           _wasQaItem = true;
68242           var errService = services[datum2.service];
68243           if (errService) {
68244             datum2 = errService.getError(datum2.id);
68245           }
68246           var errEditor;
68247           if (datum2.service === "keepRight") {
68248             errEditor = keepRightEditor;
68249           } else {
68250             errEditor = osmoseEditor;
68251           }
68252           context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
68253             return d2.id === datum2.id;
68254           });
68255           sidebar.show(errEditor.error(datum2));
68256           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
68257         } else if (!_current && datum2 instanceof osmEntity) {
68258           featureListWrap.classed("inspector-hidden", true);
68259           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
68260           if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
68261             inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
68262             inspectorWrap.call(inspector);
68263           }
68264         } else if (!_current) {
68265           featureListWrap.classed("inspector-hidden", false);
68266           inspectorWrap.classed("inspector-hidden", true);
68267           inspector.state("hide");
68268         } else if (_wasData || _wasNote || _wasQaItem) {
68269           _wasNote = false;
68270           _wasData = false;
68271           _wasQaItem = false;
68272           context.container().selectAll(".note").classed("hover", false);
68273           context.container().selectAll(".qaItem").classed("hover", false);
68274           sidebar.hide();
68275         }
68276       }
68277       sidebar.hover = throttle_default(hover, 200);
68278       sidebar.intersects = function(extent) {
68279         var rect = selection2.node().getBoundingClientRect();
68280         return extent.intersects([
68281           context.projection.invert([0, rect.height]),
68282           context.projection.invert([rect.width, 0])
68283         ]);
68284       };
68285       sidebar.select = function(ids, newFeature) {
68286         sidebar.hide();
68287         if (ids && ids.length) {
68288           var entity = ids.length === 1 && context.entity(ids[0]);
68289           if (entity && newFeature && selection2.classed("collapsed")) {
68290             var extent = entity.extent(context.graph());
68291             sidebar.expand(sidebar.intersects(extent));
68292           }
68293           featureListWrap.classed("inspector-hidden", true);
68294           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
68295           inspector.state("select").entityIDs(ids).newFeature(newFeature);
68296           inspectorWrap.call(inspector);
68297         } else {
68298           inspector.state("hide");
68299         }
68300       };
68301       sidebar.showPresetList = function() {
68302         inspector.showList();
68303       };
68304       sidebar.show = function(component, element) {
68305         featureListWrap.classed("inspector-hidden", true);
68306         inspectorWrap.classed("inspector-hidden", true);
68307         if (_current) _current.remove();
68308         _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
68309       };
68310       sidebar.hide = function() {
68311         featureListWrap.classed("inspector-hidden", false);
68312         inspectorWrap.classed("inspector-hidden", true);
68313         if (_current) _current.remove();
68314         _current = null;
68315       };
68316       sidebar.expand = function(moveMap) {
68317         if (selection2.classed("collapsed")) {
68318           sidebar.toggle(moveMap);
68319         }
68320       };
68321       sidebar.collapse = function(moveMap) {
68322         if (!selection2.classed("collapsed")) {
68323           sidebar.toggle(moveMap);
68324         }
68325       };
68326       sidebar.toggle = function(moveMap) {
68327         if (context.inIntro()) return;
68328         var isCollapsed = selection2.classed("collapsed");
68329         var isCollapsing = !isCollapsed;
68330         var isRTL = _mainLocalizer.textDirection() === "rtl";
68331         var scaleX = isRTL ? 0 : 1;
68332         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
68333         sidebarWidth = selection2.node().getBoundingClientRect().width;
68334         selection2.style("width", sidebarWidth + "px");
68335         var startMargin, endMargin, lastMargin;
68336         if (isCollapsing) {
68337           startMargin = lastMargin = 0;
68338           endMargin = -sidebarWidth;
68339         } else {
68340           startMargin = lastMargin = -sidebarWidth;
68341           endMargin = 0;
68342         }
68343         if (!isCollapsing) {
68344           selection2.classed("collapsed", isCollapsing);
68345         }
68346         selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
68347           var i3 = number_default(startMargin, endMargin);
68348           return function(t2) {
68349             var dx = lastMargin - Math.round(i3(t2));
68350             lastMargin = lastMargin - dx;
68351             context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
68352           };
68353         }).on("end", function() {
68354           if (isCollapsing) {
68355             selection2.classed("collapsed", isCollapsing);
68356           }
68357           if (!isCollapsing) {
68358             var containerWidth2 = container.node().getBoundingClientRect().width;
68359             var widthPct = sidebarWidth / containerWidth2 * 100;
68360             selection2.style(xMarginProperty, null).style("width", widthPct + "%");
68361           }
68362         });
68363       };
68364       resizer.on("dblclick", function(d3_event) {
68365         d3_event.preventDefault();
68366         if (d3_event.sourceEvent) {
68367           d3_event.sourceEvent.preventDefault();
68368         }
68369         sidebar.toggle();
68370       });
68371       context.map().on("crossEditableZoom.sidebar", function(within) {
68372         if (!within && !selection2.select(".inspector-hover").empty()) {
68373           hover([]);
68374         }
68375       });
68376     }
68377     sidebar.showPresetList = function() {
68378     };
68379     sidebar.hover = function() {
68380     };
68381     sidebar.hover.cancel = function() {
68382     };
68383     sidebar.intersects = function() {
68384     };
68385     sidebar.select = function() {
68386     };
68387     sidebar.show = function() {
68388     };
68389     sidebar.hide = function() {
68390     };
68391     sidebar.expand = function() {
68392     };
68393     sidebar.collapse = function() {
68394     };
68395     sidebar.toggle = function() {
68396     };
68397     return sidebar;
68398   }
68399
68400   // modules/ui/source_switch.js
68401   function uiSourceSwitch(context) {
68402     var keys2;
68403     function click(d3_event) {
68404       d3_event.preventDefault();
68405       var osm = context.connection();
68406       if (!osm) return;
68407       if (context.inIntro()) return;
68408       if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes"))) return;
68409       var isLive = select_default2(this).classed("live");
68410       isLive = !isLive;
68411       context.enter(modeBrowse(context));
68412       context.history().clearSaved();
68413       context.flush();
68414       select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
68415       osm.switch(isLive ? keys2[0] : keys2[1]);
68416     }
68417     var sourceSwitch = function(selection2) {
68418       selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
68419     };
68420     sourceSwitch.keys = function(_2) {
68421       if (!arguments.length) return keys2;
68422       keys2 = _2;
68423       return sourceSwitch;
68424     };
68425     return sourceSwitch;
68426   }
68427
68428   // modules/ui/spinner.js
68429   function uiSpinner(context) {
68430     var osm = context.connection();
68431     return function(selection2) {
68432       var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
68433       if (osm) {
68434         osm.on("loading.spinner", function() {
68435           img.transition().style("opacity", 1);
68436         }).on("loaded.spinner", function() {
68437           img.transition().style("opacity", 0);
68438         });
68439       }
68440     };
68441   }
68442
68443   // modules/ui/sections/privacy.js
68444   function uiSectionPrivacy(context) {
68445     let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
68446     function renderDisclosureContent(selection2) {
68447       selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
68448       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(
68449         uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
68450       );
68451       thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
68452         d3_event.preventDefault();
68453         corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
68454       });
68455       thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
68456       selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
68457       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"));
68458     }
68459     corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
68460     return section;
68461   }
68462
68463   // modules/ui/splash.js
68464   function uiSplash(context) {
68465     return (selection2) => {
68466       if (context.history().hasRestorableChanges()) return;
68467       let updateMessage = "";
68468       const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
68469       let showSplash = !corePreferences("sawSplash");
68470       if (sawPrivacyVersion !== context.privacyVersion) {
68471         updateMessage = _t("splash.privacy_update");
68472         showSplash = true;
68473       }
68474       if (!showSplash) return;
68475       corePreferences("sawSplash", true);
68476       corePreferences("sawPrivacyVersion", context.privacyVersion);
68477       _mainFileFetcher.get("intro_graph");
68478       let modalSelection = uiModal(selection2);
68479       modalSelection.select(".modal").attr("class", "modal-splash modal");
68480       let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
68481       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
68482       let modalSection = introModal.append("div").attr("class", "modal-section");
68483       modalSection.append("p").html(_t.html("splash.text", {
68484         version: context.version,
68485         website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
68486         github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
68487       }));
68488       modalSection.append("p").html(_t.html("splash.privacy", {
68489         updateMessage,
68490         privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
68491       }));
68492       uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
68493       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
68494       let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
68495         context.container().call(uiIntro(context));
68496         modalSelection.close();
68497       });
68498       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
68499       walkthrough.append("div").call(_t.append("splash.walkthrough"));
68500       let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
68501       startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
68502       startEditing.append("div").call(_t.append("splash.start"));
68503       modalSelection.select("button.close").attr("class", "hide");
68504     };
68505   }
68506
68507   // modules/ui/status.js
68508   function uiStatus(context) {
68509     var osm = context.connection();
68510     return function(selection2) {
68511       if (!osm) return;
68512       function update(err, apiStatus) {
68513         selection2.html("");
68514         if (err) {
68515           if (apiStatus === "connectionSwitched") {
68516             return;
68517           } else if (apiStatus === "rateLimited") {
68518             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) {
68519               d3_event.preventDefault();
68520               osm.authenticate();
68521             });
68522           } else {
68523             var throttledRetry = throttle_default(function() {
68524               context.loadTiles(context.projection);
68525               osm.reloadApiStatus();
68526             }, 2e3);
68527             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) {
68528               d3_event.preventDefault();
68529               throttledRetry();
68530             });
68531           }
68532         } else if (apiStatus === "readonly") {
68533           selection2.call(_t.append("osm_api_status.message.readonly"));
68534         } else if (apiStatus === "offline") {
68535           selection2.call(_t.append("osm_api_status.message.offline"));
68536         }
68537         selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
68538       }
68539       osm.on("apiStatusChange.uiStatus", update);
68540       context.history().on("storage_error", () => {
68541         selection2.selectAll("span.local-storage-full").remove();
68542         selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
68543         selection2.classed("error", true);
68544       });
68545       window.setInterval(function() {
68546         osm.reloadApiStatus();
68547       }, 9e4);
68548       osm.reloadApiStatus();
68549     };
68550   }
68551
68552   // modules/ui/tools/modes.js
68553   function uiToolDrawModes(context) {
68554     var tool = {
68555       id: "old_modes",
68556       label: _t.append("toolbar.add_feature")
68557     };
68558     var modes = [
68559       modeAddPoint(context, {
68560         title: _t.append("modes.add_point.title"),
68561         button: "point",
68562         description: _t.append("modes.add_point.description"),
68563         preset: _mainPresetIndex.item("point"),
68564         key: "1"
68565       }),
68566       modeAddLine(context, {
68567         title: _t.append("modes.add_line.title"),
68568         button: "line",
68569         description: _t.append("modes.add_line.description"),
68570         preset: _mainPresetIndex.item("line"),
68571         key: "2"
68572       }),
68573       modeAddArea(context, {
68574         title: _t.append("modes.add_area.title"),
68575         button: "area",
68576         description: _t.append("modes.add_area.description"),
68577         preset: _mainPresetIndex.item("area"),
68578         key: "3"
68579       })
68580     ];
68581     function enabled(_mode) {
68582       return osmEditable();
68583     }
68584     function osmEditable() {
68585       return context.editable();
68586     }
68587     modes.forEach(function(mode) {
68588       context.keybinding().on(mode.key, function() {
68589         if (!enabled(mode)) return;
68590         if (mode.id === context.mode().id) {
68591           context.enter(modeBrowse(context));
68592         } else {
68593           context.enter(mode);
68594         }
68595       });
68596     });
68597     tool.render = function(selection2) {
68598       var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
68599       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68600       context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
68601       context.on("enter.modes", update);
68602       update();
68603       function update() {
68604         var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
68605           return d2.id;
68606         });
68607         buttons.exit().remove();
68608         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
68609           return d2.id + " add-button bar-button";
68610         }).on("click.mode-buttons", function(d3_event, d2) {
68611           if (!enabled(d2)) return;
68612           var currMode = context.mode().id;
68613           if (/^draw/.test(currMode)) return;
68614           if (d2.id === currMode) {
68615             context.enter(modeBrowse(context));
68616           } else {
68617             context.enter(d2);
68618           }
68619         }).call(
68620           uiTooltip().placement("bottom").title(function(d2) {
68621             return d2.description;
68622           }).keys(function(d2) {
68623             return [d2.key];
68624           }).scrollContainer(context.container().select(".top-toolbar"))
68625         );
68626         buttonsEnter.each(function(d2) {
68627           select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
68628         });
68629         buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
68630           mode.title(select_default2(this));
68631         });
68632         if (buttons.enter().size() || buttons.exit().size()) {
68633           context.ui().checkOverflow(".top-toolbar", true);
68634         }
68635         buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
68636           return !enabled(d2);
68637         }).classed("disabled", function(d2) {
68638           return !enabled(d2);
68639         }).attr("aria-pressed", function(d2) {
68640           return context.mode() && context.mode().button === d2.button;
68641         }).classed("active", function(d2) {
68642           return context.mode() && context.mode().button === d2.button;
68643         });
68644       }
68645     };
68646     return tool;
68647   }
68648
68649   // modules/ui/tools/notes.js
68650   function uiToolNotes(context) {
68651     var tool = {
68652       id: "notes",
68653       label: _t.append("modes.add_note.label")
68654     };
68655     var mode = modeAddNote(context);
68656     function enabled() {
68657       return notesEnabled() && notesEditable();
68658     }
68659     function notesEnabled() {
68660       var noteLayer = context.layers().layer("notes");
68661       return noteLayer && noteLayer.enabled();
68662     }
68663     function notesEditable() {
68664       var mode2 = context.mode();
68665       return context.map().notesEditable() && mode2 && mode2.id !== "save";
68666     }
68667     context.keybinding().on(mode.key, function() {
68668       if (!enabled()) return;
68669       if (mode.id === context.mode().id) {
68670         context.enter(modeBrowse(context));
68671       } else {
68672         context.enter(mode);
68673       }
68674     });
68675     tool.render = function(selection2) {
68676       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68677       context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
68678       context.on("enter.notes", update);
68679       update();
68680       function update() {
68681         var showNotes = notesEnabled();
68682         var data = showNotes ? [mode] : [];
68683         var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
68684           return d2.id;
68685         });
68686         buttons.exit().remove();
68687         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
68688           return d2.id + " add-button bar-button";
68689         }).on("click.notes", function(d3_event, d2) {
68690           if (!enabled()) return;
68691           var currMode = context.mode().id;
68692           if (/^draw/.test(currMode)) return;
68693           if (d2.id === currMode) {
68694             context.enter(modeBrowse(context));
68695           } else {
68696             context.enter(d2);
68697           }
68698         }).call(
68699           uiTooltip().placement("bottom").title(function(d2) {
68700             return d2.description;
68701           }).keys(function(d2) {
68702             return [d2.key];
68703           }).scrollContainer(context.container().select(".top-toolbar"))
68704         );
68705         buttonsEnter.each(function(d2) {
68706           select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
68707         });
68708         if (buttons.enter().size() || buttons.exit().size()) {
68709           context.ui().checkOverflow(".top-toolbar", true);
68710         }
68711         buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
68712           return !enabled();
68713         }).attr("aria-disabled", function() {
68714           return !enabled();
68715         }).classed("active", function(d2) {
68716           return context.mode() && context.mode().button === d2.button;
68717         }).attr("aria-pressed", function(d2) {
68718           return context.mode() && context.mode().button === d2.button;
68719         });
68720       }
68721     };
68722     tool.uninstall = function() {
68723       context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
68724       context.map().on("move.notes", null).on("drawn.notes", null);
68725     };
68726     return tool;
68727   }
68728
68729   // modules/ui/tools/save.js
68730   function uiToolSave(context) {
68731     var tool = {
68732       id: "save",
68733       label: _t.append("save.title")
68734     };
68735     var button = null;
68736     var tooltipBehavior = null;
68737     var history = context.history();
68738     var key = uiCmd("\u2318S");
68739     var _numChanges = 0;
68740     function isSaving() {
68741       var mode = context.mode();
68742       return mode && mode.id === "save";
68743     }
68744     function isDisabled() {
68745       return _numChanges === 0 || isSaving();
68746     }
68747     function save(d3_event) {
68748       d3_event.preventDefault();
68749       if (!context.inIntro() && !isSaving() && history.hasChanges()) {
68750         context.enter(modeSave(context));
68751       }
68752     }
68753     function bgColor(numChanges) {
68754       var step;
68755       if (numChanges === 0) {
68756         return null;
68757       } else if (numChanges <= 50) {
68758         step = numChanges / 50;
68759         return rgb_default("#fff", "#ff8")(step);
68760       } else {
68761         step = Math.min((numChanges - 50) / 50, 1);
68762         return rgb_default("#ff8", "#f88")(step);
68763       }
68764     }
68765     function updateCount() {
68766       var val = history.difference().summary().length;
68767       if (val === _numChanges) return;
68768       _numChanges = val;
68769       if (tooltipBehavior) {
68770         tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
68771       }
68772       if (button) {
68773         button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
68774         button.select("span.count").text(_numChanges);
68775       }
68776     }
68777     tool.render = function(selection2) {
68778       tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
68779       var lastPointerUpType;
68780       button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
68781         lastPointerUpType = d3_event.pointerType;
68782       }).on("click", function(d3_event) {
68783         save(d3_event);
68784         if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
68785           context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
68786         }
68787         lastPointerUpType = null;
68788       }).call(tooltipBehavior);
68789       button.call(svgIcon("#iD-icon-save"));
68790       button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
68791       updateCount();
68792       context.keybinding().on(key, save, true);
68793       context.history().on("change.save", updateCount);
68794       context.on("enter.save", function() {
68795         if (button) {
68796           button.classed("disabled", isDisabled());
68797           if (isSaving()) {
68798             button.call(tooltipBehavior.hide);
68799           }
68800         }
68801       });
68802     };
68803     tool.uninstall = function() {
68804       context.keybinding().off(key, true);
68805       context.history().on("change.save", null);
68806       context.on("enter.save", null);
68807       button = null;
68808       tooltipBehavior = null;
68809     };
68810     return tool;
68811   }
68812
68813   // modules/ui/tools/sidebar_toggle.js
68814   function uiToolSidebarToggle(context) {
68815     var tool = {
68816       id: "sidebar_toggle",
68817       label: _t.append("toolbar.inspect")
68818     };
68819     tool.render = function(selection2) {
68820       selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
68821         context.ui().sidebar.toggle();
68822       }).call(
68823         uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
68824       ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
68825     };
68826     return tool;
68827   }
68828
68829   // modules/ui/tools/undo_redo.js
68830   function uiToolUndoRedo(context) {
68831     var tool = {
68832       id: "undo_redo",
68833       label: _t.append("toolbar.undo_redo")
68834     };
68835     var commands = [{
68836       id: "undo",
68837       cmd: uiCmd("\u2318Z"),
68838       action: function() {
68839         context.undo();
68840       },
68841       annotation: function() {
68842         return context.history().undoAnnotation();
68843       },
68844       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
68845     }, {
68846       id: "redo",
68847       cmd: uiCmd("\u2318\u21E7Z"),
68848       action: function() {
68849         context.redo();
68850       },
68851       annotation: function() {
68852         return context.history().redoAnnotation();
68853       },
68854       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
68855     }];
68856     function editable() {
68857       return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
68858         true
68859         /* ignore min zoom */
68860       );
68861     }
68862     tool.render = function(selection2) {
68863       var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
68864         return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
68865       }).keys(function(d2) {
68866         return [d2.cmd];
68867       }).scrollContainer(context.container().select(".top-toolbar"));
68868       var lastPointerUpType;
68869       var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
68870         return "disabled " + d2.id + "-button bar-button";
68871       }).on("pointerup", function(d3_event) {
68872         lastPointerUpType = d3_event.pointerType;
68873       }).on("click", function(d3_event, d2) {
68874         d3_event.preventDefault();
68875         var annotation = d2.annotation();
68876         if (editable() && annotation) {
68877           d2.action();
68878         }
68879         if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
68880           var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
68881           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
68882         }
68883         lastPointerUpType = null;
68884       }).call(tooltipBehavior);
68885       buttons.each(function(d2) {
68886         select_default2(this).call(svgIcon("#" + d2.icon));
68887       });
68888       context.keybinding().on(commands[0].cmd, function(d3_event) {
68889         d3_event.preventDefault();
68890         if (editable()) commands[0].action();
68891       }).on(commands[1].cmd, function(d3_event) {
68892         d3_event.preventDefault();
68893         if (editable()) commands[1].action();
68894       });
68895       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68896       context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
68897       context.history().on("change.undo_redo", function(difference2) {
68898         if (difference2) update();
68899       });
68900       context.on("enter.undo_redo", update);
68901       function update() {
68902         buttons.classed("disabled", function(d2) {
68903           return !editable() || !d2.annotation();
68904         }).each(function() {
68905           var selection3 = select_default2(this);
68906           if (!selection3.select(".tooltip.in").empty()) {
68907             selection3.call(tooltipBehavior.updateContent);
68908           }
68909         });
68910       }
68911     };
68912     tool.uninstall = function() {
68913       context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
68914       context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
68915       context.history().on("change.undo_redo", null);
68916       context.on("enter.undo_redo", null);
68917     };
68918     return tool;
68919   }
68920
68921   // modules/ui/top_toolbar.js
68922   function uiTopToolbar(context) {
68923     var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
68924     function notesEnabled() {
68925       var noteLayer = context.layers().layer("notes");
68926       return noteLayer && noteLayer.enabled();
68927     }
68928     function topToolbar(bar) {
68929       bar.on("wheel.topToolbar", function(d3_event) {
68930         if (!d3_event.deltaX) {
68931           bar.node().scrollLeft += d3_event.deltaY;
68932         }
68933       });
68934       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68935       context.layers().on("change.topToolbar", debouncedUpdate);
68936       update();
68937       function update() {
68938         var tools = [
68939           sidebarToggle,
68940           "spacer",
68941           modes
68942         ];
68943         tools.push("spacer");
68944         if (notesEnabled()) {
68945           tools = tools.concat([notes, "spacer"]);
68946         }
68947         tools = tools.concat([undoRedo, save]);
68948         var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
68949           return d2.id || d2;
68950         });
68951         toolbarItems.exit().each(function(d2) {
68952           if (d2.uninstall) {
68953             d2.uninstall();
68954           }
68955         }).remove();
68956         var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
68957           var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
68958           if (d2.klass) classes += " " + d2.klass;
68959           return classes;
68960         });
68961         var actionableItems = itemsEnter.filter(function(d2) {
68962           return d2 !== "spacer";
68963         });
68964         actionableItems.append("div").attr("class", "item-content").each(function(d2) {
68965           select_default2(this).call(d2.render, bar);
68966         });
68967         actionableItems.append("div").attr("class", "item-label").each(function(d2) {
68968           d2.label(select_default2(this));
68969         });
68970       }
68971     }
68972     return topToolbar;
68973   }
68974
68975   // modules/ui/version.js
68976   var sawVersion = null;
68977   var isNewVersion = false;
68978   var isNewUser = false;
68979   function uiVersion(context) {
68980     var currVersion = context.version;
68981     var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
68982     if (sawVersion === null && matchedVersion !== null) {
68983       if (corePreferences("sawVersion")) {
68984         isNewUser = false;
68985         isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
68986       } else {
68987         isNewUser = true;
68988         isNewVersion = true;
68989       }
68990       corePreferences("sawVersion", currVersion);
68991       sawVersion = currVersion;
68992     }
68993     return function(selection2) {
68994       selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
68995       if (isNewVersion && !isNewUser) {
68996         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(
68997           uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
68998         );
68999       }
69000     };
69001   }
69002
69003   // modules/ui/zoom.js
69004   function uiZoom(context) {
69005     var zooms = [{
69006       id: "zoom-in",
69007       icon: "iD-icon-plus",
69008       title: _t.append("zoom.in"),
69009       action: zoomIn,
69010       disabled: function() {
69011         return !context.map().canZoomIn();
69012       },
69013       disabledTitle: _t.append("zoom.disabled.in"),
69014       key: "+"
69015     }, {
69016       id: "zoom-out",
69017       icon: "iD-icon-minus",
69018       title: _t.append("zoom.out"),
69019       action: zoomOut,
69020       disabled: function() {
69021         return !context.map().canZoomOut();
69022       },
69023       disabledTitle: _t.append("zoom.disabled.out"),
69024       key: "-"
69025     }];
69026     function zoomIn(d3_event) {
69027       if (d3_event.shiftKey) return;
69028       d3_event.preventDefault();
69029       context.map().zoomIn();
69030     }
69031     function zoomOut(d3_event) {
69032       if (d3_event.shiftKey) return;
69033       d3_event.preventDefault();
69034       context.map().zoomOut();
69035     }
69036     function zoomInFurther(d3_event) {
69037       if (d3_event.shiftKey) return;
69038       d3_event.preventDefault();
69039       context.map().zoomInFurther();
69040     }
69041     function zoomOutFurther(d3_event) {
69042       if (d3_event.shiftKey) return;
69043       d3_event.preventDefault();
69044       context.map().zoomOutFurther();
69045     }
69046     return function(selection2) {
69047       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
69048         if (d2.disabled()) {
69049           return d2.disabledTitle;
69050         }
69051         return d2.title;
69052       }).keys(function(d2) {
69053         return [d2.key];
69054       });
69055       var lastPointerUpType;
69056       var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
69057         return d2.id;
69058       }).on("pointerup.editor", function(d3_event) {
69059         lastPointerUpType = d3_event.pointerType;
69060       }).on("click.editor", function(d3_event, d2) {
69061         if (!d2.disabled()) {
69062           d2.action(d3_event);
69063         } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
69064           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
69065         }
69066         lastPointerUpType = null;
69067       }).call(tooltipBehavior);
69068       buttons.each(function(d2) {
69069         select_default2(this).call(svgIcon("#" + d2.icon, "light"));
69070       });
69071       utilKeybinding.plusKeys.forEach(function(key) {
69072         context.keybinding().on([key], zoomIn);
69073         context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
69074       });
69075       utilKeybinding.minusKeys.forEach(function(key) {
69076         context.keybinding().on([key], zoomOut);
69077         context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
69078       });
69079       function updateButtonStates() {
69080         buttons.classed("disabled", function(d2) {
69081           return d2.disabled();
69082         }).each(function() {
69083           var selection3 = select_default2(this);
69084           if (!selection3.select(".tooltip.in").empty()) {
69085             selection3.call(tooltipBehavior.updateContent);
69086           }
69087         });
69088       }
69089       updateButtonStates();
69090       context.map().on("move.uiZoom", updateButtonStates);
69091     };
69092   }
69093
69094   // modules/ui/zoom_to_selection.js
69095   function uiZoomToSelection(context) {
69096     function isDisabled() {
69097       var mode = context.mode();
69098       return !mode || !mode.zoomToSelected;
69099     }
69100     var _lastPointerUpType;
69101     function pointerup(d3_event) {
69102       _lastPointerUpType = d3_event.pointerType;
69103     }
69104     function click(d3_event) {
69105       d3_event.preventDefault();
69106       if (isDisabled()) {
69107         if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
69108           context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
69109         }
69110       } else {
69111         var mode = context.mode();
69112         if (mode && mode.zoomToSelected) {
69113           mode.zoomToSelected();
69114         }
69115       }
69116       _lastPointerUpType = null;
69117     }
69118     return function(selection2) {
69119       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
69120         if (isDisabled()) {
69121           return _t.append("inspector.zoom_to.no_selection");
69122         }
69123         return _t.append("inspector.zoom_to.title");
69124       }).keys([_t("inspector.zoom_to.key")]);
69125       var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
69126       function setEnabledState() {
69127         button.classed("disabled", isDisabled());
69128         if (!button.select(".tooltip.in").empty()) {
69129           button.call(tooltipBehavior.updateContent);
69130         }
69131       }
69132       context.on("enter.uiZoomToSelection", setEnabledState);
69133       setEnabledState();
69134     };
69135   }
69136
69137   // modules/ui/pane.js
69138   function uiPane(id2, context) {
69139     var _key;
69140     var _label = "";
69141     var _description = "";
69142     var _iconName = "";
69143     var _sections;
69144     var _paneSelection = select_default2(null);
69145     var _paneTooltip;
69146     var pane = {
69147       id: id2
69148     };
69149     pane.label = function(val) {
69150       if (!arguments.length) return _label;
69151       _label = val;
69152       return pane;
69153     };
69154     pane.key = function(val) {
69155       if (!arguments.length) return _key;
69156       _key = val;
69157       return pane;
69158     };
69159     pane.description = function(val) {
69160       if (!arguments.length) return _description;
69161       _description = val;
69162       return pane;
69163     };
69164     pane.iconName = function(val) {
69165       if (!arguments.length) return _iconName;
69166       _iconName = val;
69167       return pane;
69168     };
69169     pane.sections = function(val) {
69170       if (!arguments.length) return _sections;
69171       _sections = val;
69172       return pane;
69173     };
69174     pane.selection = function() {
69175       return _paneSelection;
69176     };
69177     function hidePane() {
69178       context.ui().togglePanes();
69179     }
69180     pane.togglePane = function(d3_event) {
69181       if (d3_event) d3_event.preventDefault();
69182       _paneTooltip.hide();
69183       context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
69184     };
69185     pane.renderToggleButton = function(selection2) {
69186       if (!_paneTooltip) {
69187         _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
69188       }
69189       selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
69190     };
69191     pane.renderContent = function(selection2) {
69192       if (_sections) {
69193         _sections.forEach(function(section) {
69194           selection2.call(section.render);
69195         });
69196       }
69197     };
69198     pane.renderPane = function(selection2) {
69199       _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
69200       var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
69201       heading2.append("h2").text("").call(_label);
69202       heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
69203       _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
69204       if (_key) {
69205         context.keybinding().on(_key, pane.togglePane);
69206       }
69207     };
69208     return pane;
69209   }
69210
69211   // modules/ui/sections/background_display_options.js
69212   function uiSectionBackgroundDisplayOptions(context) {
69213     var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
69214     var _storedOpacity = corePreferences("background-opacity");
69215     var _minVal = 0;
69216     var _maxVal = 3;
69217     var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
69218     var _options = {
69219       brightness: _storedOpacity !== null ? +_storedOpacity : 1,
69220       contrast: 1,
69221       saturation: 1,
69222       sharpness: 1
69223     };
69224     function clamp3(x2, min3, max3) {
69225       return Math.max(min3, Math.min(x2, max3));
69226     }
69227     function updateValue(d2, val) {
69228       val = clamp3(val, _minVal, _maxVal);
69229       _options[d2] = val;
69230       context.background()[d2](val);
69231       if (d2 === "brightness") {
69232         corePreferences("background-opacity", val);
69233       }
69234       section.reRender();
69235     }
69236     function renderDisclosureContent(selection2) {
69237       var container = selection2.selectAll(".display-options-container").data([0]);
69238       var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
69239       var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
69240         return "display-control display-control-" + d2;
69241       });
69242       slidersEnter.html(function(d2) {
69243         return _t.html("background." + d2);
69244       }).append("span").attr("class", function(d2) {
69245         return "display-option-value display-option-value-" + d2;
69246       });
69247       var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
69248       sildersControlEnter.append("input").attr("class", function(d2) {
69249         return "display-option-input display-option-input-" + d2;
69250       }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
69251         var val = select_default2(this).property("value");
69252         if (!val && d3_event && d3_event.target) {
69253           val = d3_event.target.value;
69254         }
69255         updateValue(d2, val);
69256       });
69257       sildersControlEnter.append("button").attr("title", function(d2) {
69258         return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
69259       }).attr("class", function(d2) {
69260         return "display-option-reset display-option-reset-" + d2;
69261       }).on("click", function(d3_event, d2) {
69262         if (d3_event.button !== 0) return;
69263         updateValue(d2, 1);
69264       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
69265       containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
69266         d3_event.preventDefault();
69267         for (var i3 = 0; i3 < _sliders.length; i3++) {
69268           updateValue(_sliders[i3], 1);
69269         }
69270       });
69271       container = containerEnter.merge(container);
69272       container.selectAll(".display-option-input").property("value", function(d2) {
69273         return _options[d2];
69274       });
69275       container.selectAll(".display-option-value").text(function(d2) {
69276         return Math.floor(_options[d2] * 100) + "%";
69277       });
69278       container.selectAll(".display-option-reset").classed("disabled", function(d2) {
69279         return _options[d2] === 1;
69280       });
69281       if (containerEnter.size() && _options.brightness !== 1) {
69282         context.background().brightness(_options.brightness);
69283       }
69284     }
69285     return section;
69286   }
69287
69288   // modules/ui/settings/custom_background.js
69289   function uiSettingsCustomBackground() {
69290     var dispatch14 = dispatch_default("change");
69291     function render(selection2) {
69292       var _origSettings = {
69293         template: corePreferences("background-custom-template")
69294       };
69295       var _currSettings = {
69296         template: corePreferences("background-custom-template")
69297       };
69298       var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
69299       var modal = uiConfirm(selection2).okButton();
69300       modal.classed("settings-modal settings-custom-background", true);
69301       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
69302       var textSection = modal.select(".modal-section.message-text");
69303       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, "`");
69304       textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
69305       textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
69306       var buttonSection = modal.select(".modal-section.buttons");
69307       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
69308       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
69309       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
69310       function isSaveDisabled() {
69311         return null;
69312       }
69313       function clickCancel() {
69314         textSection.select(".field-template").property("value", _origSettings.template);
69315         corePreferences("background-custom-template", _origSettings.template);
69316         this.blur();
69317         modal.close();
69318       }
69319       function clickSave() {
69320         _currSettings.template = textSection.select(".field-template").property("value");
69321         corePreferences("background-custom-template", _currSettings.template);
69322         this.blur();
69323         modal.close();
69324         dispatch14.call("change", this, _currSettings);
69325       }
69326     }
69327     return utilRebind(render, dispatch14, "on");
69328   }
69329
69330   // modules/ui/sections/background_list.js
69331   function uiSectionBackgroundList(context) {
69332     var _backgroundList = select_default2(null);
69333     var _customSource = context.background().findSource("custom");
69334     var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
69335     var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
69336     function previousBackgroundID() {
69337       return corePreferences("background-last-used-toggle");
69338     }
69339     function renderDisclosureContent(selection2) {
69340       var container = selection2.selectAll(".layer-background-list").data([0]);
69341       _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
69342       var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
69343       var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
69344         uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
69345       );
69346       minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
69347         d3_event.preventDefault();
69348         uiMapInMap.toggle();
69349       });
69350       minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
69351       var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
69352         uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
69353       );
69354       panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
69355         d3_event.preventDefault();
69356         context.ui().info.toggle("background");
69357       });
69358       panelLabelEnter.append("span").call(_t.append("background.panel.description"));
69359       var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
69360         uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
69361       );
69362       locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
69363         d3_event.preventDefault();
69364         context.ui().info.toggle("location");
69365       });
69366       locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
69367       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"));
69368       _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
69369         chooseBackground(d2);
69370       }, function(d2) {
69371         return !d2.isHidden() && !d2.overlay;
69372       });
69373     }
69374     function setTooltips(selection2) {
69375       selection2.each(function(d2, i3, nodes) {
69376         var item = select_default2(this).select("label");
69377         var span = item.select("span");
69378         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
69379         var hasDescription = d2.hasDescription();
69380         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
69381         item.call(uiTooltip().destroyAny);
69382         if (d2.id === previousBackgroundID()) {
69383           item.call(
69384             uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
69385           );
69386         } else if (hasDescription || isOverflowing) {
69387           item.call(
69388             uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
69389           );
69390         }
69391       });
69392     }
69393     function drawListItems(layerList, type2, change, filter2) {
69394       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
69395         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
69396       });
69397       var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
69398         return d2.id + "---" + i3;
69399       });
69400       layerLinks.exit().remove();
69401       var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
69402         return d2.id === "custom";
69403       }).classed("best", function(d2) {
69404         return d2.best();
69405       });
69406       var label = enter.append("label");
69407       label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
69408         return d2.id;
69409       }).on("change", change);
69410       label.append("span").each(function(d2) {
69411         d2.label()(select_default2(this));
69412       });
69413       enter.filter(function(d2) {
69414         return d2.id === "custom";
69415       }).append("button").attr("class", "layer-browse").call(
69416         uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
69417       ).on("click", function(d3_event) {
69418         d3_event.preventDefault();
69419         editCustom();
69420       }).call(svgIcon("#iD-icon-more"));
69421       enter.filter(function(d2) {
69422         return d2.best();
69423       }).append("div").attr("class", "best").call(
69424         uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
69425       ).append("span").text("\u2605");
69426       layerList.call(updateLayerSelections);
69427     }
69428     function updateLayerSelections(selection2) {
69429       function active(d2) {
69430         return context.background().showsLayer(d2);
69431       }
69432       selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
69433         return d2.id === previousBackgroundID();
69434       }).call(setTooltips).selectAll("input").property("checked", active);
69435     }
69436     function chooseBackground(d2) {
69437       if (d2.id === "custom" && !d2.template()) {
69438         return editCustom();
69439       }
69440       var previousBackground = context.background().baseLayerSource();
69441       corePreferences("background-last-used-toggle", previousBackground.id);
69442       corePreferences("background-last-used", d2.id);
69443       context.background().baseLayerSource(d2);
69444     }
69445     function customChanged(d2) {
69446       if (d2 && d2.template) {
69447         _customSource.template(d2.template);
69448         chooseBackground(_customSource);
69449       } else {
69450         _customSource.template("");
69451         chooseBackground(context.background().findSource("none"));
69452       }
69453     }
69454     function editCustom() {
69455       context.container().call(_settingsCustomBackground);
69456     }
69457     context.background().on("change.background_list", function() {
69458       _backgroundList.call(updateLayerSelections);
69459     });
69460     context.map().on(
69461       "move.background_list",
69462       debounce_default(function() {
69463         window.requestIdleCallback(section.reRender);
69464       }, 1e3)
69465     );
69466     return section;
69467   }
69468
69469   // modules/ui/sections/background_offset.js
69470   function uiSectionBackgroundOffset(context) {
69471     var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
69472     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
69473     var _directions = [
69474       ["top", [0, -0.5]],
69475       ["left", [-0.5, 0]],
69476       ["right", [0.5, 0]],
69477       ["bottom", [0, 0.5]]
69478     ];
69479     function updateValue() {
69480       var meters = geoOffsetToMeters(context.background().offset());
69481       var x2 = +meters[0].toFixed(2);
69482       var y2 = +meters[1].toFixed(2);
69483       context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
69484       context.container().selectAll(".nudge-reset").classed("disabled", function() {
69485         return x2 === 0 && y2 === 0;
69486       });
69487     }
69488     function resetOffset() {
69489       context.background().offset([0, 0]);
69490       updateValue();
69491     }
69492     function nudge(d2) {
69493       context.background().nudge(d2, context.map().zoom());
69494       updateValue();
69495     }
69496     function inputOffset() {
69497       var input = select_default2(this);
69498       var d2 = input.node().value;
69499       if (d2 === "") return resetOffset();
69500       d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
69501         return !isNaN(n3) && n3;
69502       });
69503       if (d2.length !== 2 || !d2[0] || !d2[1]) {
69504         input.classed("error", true);
69505         return;
69506       }
69507       context.background().offset(geoMetersToOffset(d2));
69508       updateValue();
69509     }
69510     function dragOffset(d3_event) {
69511       if (d3_event.button !== 0) return;
69512       var origin = [d3_event.clientX, d3_event.clientY];
69513       var pointerId = d3_event.pointerId || "mouse";
69514       context.container().append("div").attr("class", "nudge-surface");
69515       select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
69516       if (_pointerPrefix === "pointer") {
69517         select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
69518       }
69519       function pointermove(d3_event2) {
69520         if (pointerId !== (d3_event2.pointerId || "mouse")) return;
69521         var latest = [d3_event2.clientX, d3_event2.clientY];
69522         var d2 = [
69523           -(origin[0] - latest[0]) / 4,
69524           -(origin[1] - latest[1]) / 4
69525         ];
69526         origin = latest;
69527         nudge(d2);
69528       }
69529       function pointerup(d3_event2) {
69530         if (pointerId !== (d3_event2.pointerId || "mouse")) return;
69531         if (d3_event2.button !== 0) return;
69532         context.container().selectAll(".nudge-surface").remove();
69533         select_default2(window).on(".drag-bg-offset", null);
69534       }
69535     }
69536     function renderDisclosureContent(selection2) {
69537       var container = selection2.selectAll(".nudge-container").data([0]);
69538       var containerEnter = container.enter().append("div").attr("class", "nudge-container");
69539       containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
69540       var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
69541       var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
69542       nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
69543       nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
69544         return _t("background.nudge.".concat(d2[0]));
69545       }).attr("class", function(d2) {
69546         return d2[0] + " nudge";
69547       }).on("click", function(d3_event, d2) {
69548         nudge(d2[1]);
69549       });
69550       nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
69551         d3_event.preventDefault();
69552         resetOffset();
69553       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
69554       updateValue();
69555     }
69556     context.background().on("change.backgroundOffset-update", updateValue);
69557     return section;
69558   }
69559
69560   // modules/ui/sections/overlay_list.js
69561   function uiSectionOverlayList(context) {
69562     var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
69563     var _overlayList = select_default2(null);
69564     function setTooltips(selection2) {
69565       selection2.each(function(d2, i3, nodes) {
69566         var item = select_default2(this).select("label");
69567         var span = item.select("span");
69568         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
69569         var description = d2.description();
69570         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
69571         item.call(uiTooltip().destroyAny);
69572         if (description || isOverflowing) {
69573           item.call(
69574             uiTooltip().placement(placement).title(() => description || d2.name())
69575           );
69576         }
69577       });
69578     }
69579     function updateLayerSelections(selection2) {
69580       function active(d2) {
69581         return context.background().showsLayer(d2);
69582       }
69583       selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
69584     }
69585     function chooseOverlay(d3_event, d2) {
69586       d3_event.preventDefault();
69587       context.background().toggleOverlayLayer(d2);
69588       _overlayList.call(updateLayerSelections);
69589       document.activeElement.blur();
69590     }
69591     function drawListItems(layerList, type2, change, filter2) {
69592       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
69593       var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
69594         return d2.name();
69595       });
69596       layerLinks.exit().remove();
69597       var enter = layerLinks.enter().append("li");
69598       var label = enter.append("label");
69599       label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
69600       label.append("span").each(function(d2) {
69601         d2.label()(select_default2(this));
69602       });
69603       layerList.selectAll("li").sort(sortSources);
69604       layerList.call(updateLayerSelections);
69605       function sortSources(a2, b2) {
69606         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
69607       }
69608     }
69609     function renderDisclosureContent(selection2) {
69610       var container = selection2.selectAll(".layer-overlay-list").data([0]);
69611       _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
69612       _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
69613         return !d2.isHidden() && d2.overlay;
69614       });
69615     }
69616     context.map().on(
69617       "move.overlay_list",
69618       debounce_default(function() {
69619         window.requestIdleCallback(section.reRender);
69620       }, 1e3)
69621     );
69622     return section;
69623   }
69624
69625   // modules/ui/panes/background.js
69626   function uiPaneBackground(context) {
69627     var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([
69628       uiSectionBackgroundList(context),
69629       uiSectionOverlayList(context),
69630       uiSectionBackgroundDisplayOptions(context),
69631       uiSectionBackgroundOffset(context)
69632     ]);
69633     return backgroundPane;
69634   }
69635
69636   // modules/ui/panes/help.js
69637   function uiPaneHelp(context) {
69638     var docKeys = [
69639       ["help", [
69640         "welcome",
69641         "open_data_h",
69642         "open_data",
69643         "before_start_h",
69644         "before_start",
69645         "open_source_h",
69646         "open_source",
69647         "open_source_attribution",
69648         "open_source_help"
69649       ]],
69650       ["overview", [
69651         "navigation_h",
69652         "navigation_drag",
69653         "navigation_zoom",
69654         "features_h",
69655         "features",
69656         "nodes_ways"
69657       ]],
69658       ["editing", [
69659         "select_h",
69660         "select_left_click",
69661         "select_right_click",
69662         "select_space",
69663         "multiselect_h",
69664         "multiselect",
69665         "multiselect_shift_click",
69666         "multiselect_lasso",
69667         "undo_redo_h",
69668         "undo_redo",
69669         "save_h",
69670         "save",
69671         "save_validation",
69672         "upload_h",
69673         "upload",
69674         "backups_h",
69675         "backups",
69676         "keyboard_h",
69677         "keyboard"
69678       ]],
69679       ["feature_editor", [
69680         "intro",
69681         "definitions",
69682         "type_h",
69683         "type",
69684         "type_picker",
69685         "fields_h",
69686         "fields_all_fields",
69687         "fields_example",
69688         "fields_add_field",
69689         "tags_h",
69690         "tags_all_tags",
69691         "tags_resources"
69692       ]],
69693       ["points", [
69694         "intro",
69695         "add_point_h",
69696         "add_point",
69697         "add_point_finish",
69698         "move_point_h",
69699         "move_point",
69700         "delete_point_h",
69701         "delete_point",
69702         "delete_point_command"
69703       ]],
69704       ["lines", [
69705         "intro",
69706         "add_line_h",
69707         "add_line",
69708         "add_line_draw",
69709         "add_line_continue",
69710         "add_line_finish",
69711         "modify_line_h",
69712         "modify_line_dragnode",
69713         "modify_line_addnode",
69714         "connect_line_h",
69715         "connect_line",
69716         "connect_line_display",
69717         "connect_line_drag",
69718         "connect_line_tag",
69719         "disconnect_line_h",
69720         "disconnect_line_command",
69721         "move_line_h",
69722         "move_line_command",
69723         "move_line_connected",
69724         "delete_line_h",
69725         "delete_line",
69726         "delete_line_command"
69727       ]],
69728       ["areas", [
69729         "intro",
69730         "point_or_area_h",
69731         "point_or_area",
69732         "add_area_h",
69733         "add_area_command",
69734         "add_area_draw",
69735         "add_area_continue",
69736         "add_area_finish",
69737         "square_area_h",
69738         "square_area_command",
69739         "modify_area_h",
69740         "modify_area_dragnode",
69741         "modify_area_addnode",
69742         "delete_area_h",
69743         "delete_area",
69744         "delete_area_command"
69745       ]],
69746       ["relations", [
69747         "intro",
69748         "edit_relation_h",
69749         "edit_relation",
69750         "edit_relation_add",
69751         "edit_relation_delete",
69752         "maintain_relation_h",
69753         "maintain_relation",
69754         "relation_types_h",
69755         "multipolygon_h",
69756         "multipolygon",
69757         "multipolygon_create",
69758         "multipolygon_merge",
69759         "turn_restriction_h",
69760         "turn_restriction",
69761         "turn_restriction_field",
69762         "turn_restriction_editing",
69763         "route_h",
69764         "route",
69765         "route_add",
69766         "boundary_h",
69767         "boundary",
69768         "boundary_add"
69769       ]],
69770       ["operations", [
69771         "intro",
69772         "intro_2",
69773         "straighten",
69774         "orthogonalize",
69775         "circularize",
69776         "move",
69777         "rotate",
69778         "reflect",
69779         "continue",
69780         "reverse",
69781         "disconnect",
69782         "split",
69783         "extract",
69784         "merge",
69785         "delete",
69786         "downgrade",
69787         "copy_paste"
69788       ]],
69789       ["notes", [
69790         "intro",
69791         "add_note_h",
69792         "add_note",
69793         "place_note",
69794         "move_note",
69795         "update_note_h",
69796         "update_note",
69797         "save_note_h",
69798         "save_note"
69799       ]],
69800       ["imagery", [
69801         "intro",
69802         "sources_h",
69803         "choosing",
69804         "sources",
69805         "offsets_h",
69806         "offset",
69807         "offset_change"
69808       ]],
69809       ["streetlevel", [
69810         "intro",
69811         "using_h",
69812         "using",
69813         "photos",
69814         "viewer"
69815       ]],
69816       ["gps", [
69817         "intro",
69818         "survey",
69819         "using_h",
69820         "using",
69821         "tracing",
69822         "upload"
69823       ]],
69824       ["qa", [
69825         "intro",
69826         "tools_h",
69827         "tools",
69828         "issues_h",
69829         "issues"
69830       ]]
69831     ];
69832     var headings = {
69833       "help.help.open_data_h": 3,
69834       "help.help.before_start_h": 3,
69835       "help.help.open_source_h": 3,
69836       "help.overview.navigation_h": 3,
69837       "help.overview.features_h": 3,
69838       "help.editing.select_h": 3,
69839       "help.editing.multiselect_h": 3,
69840       "help.editing.undo_redo_h": 3,
69841       "help.editing.save_h": 3,
69842       "help.editing.upload_h": 3,
69843       "help.editing.backups_h": 3,
69844       "help.editing.keyboard_h": 3,
69845       "help.feature_editor.type_h": 3,
69846       "help.feature_editor.fields_h": 3,
69847       "help.feature_editor.tags_h": 3,
69848       "help.points.add_point_h": 3,
69849       "help.points.move_point_h": 3,
69850       "help.points.delete_point_h": 3,
69851       "help.lines.add_line_h": 3,
69852       "help.lines.modify_line_h": 3,
69853       "help.lines.connect_line_h": 3,
69854       "help.lines.disconnect_line_h": 3,
69855       "help.lines.move_line_h": 3,
69856       "help.lines.delete_line_h": 3,
69857       "help.areas.point_or_area_h": 3,
69858       "help.areas.add_area_h": 3,
69859       "help.areas.square_area_h": 3,
69860       "help.areas.modify_area_h": 3,
69861       "help.areas.delete_area_h": 3,
69862       "help.relations.edit_relation_h": 3,
69863       "help.relations.maintain_relation_h": 3,
69864       "help.relations.relation_types_h": 2,
69865       "help.relations.multipolygon_h": 3,
69866       "help.relations.turn_restriction_h": 3,
69867       "help.relations.route_h": 3,
69868       "help.relations.boundary_h": 3,
69869       "help.notes.add_note_h": 3,
69870       "help.notes.update_note_h": 3,
69871       "help.notes.save_note_h": 3,
69872       "help.imagery.sources_h": 3,
69873       "help.imagery.offsets_h": 3,
69874       "help.streetlevel.using_h": 3,
69875       "help.gps.using_h": 3,
69876       "help.qa.tools_h": 3,
69877       "help.qa.issues_h": 3
69878     };
69879     var docs = docKeys.map(function(key) {
69880       var helpkey = "help." + key[0];
69881       var helpPaneReplacements = { version: context.version };
69882       var text = key[1].reduce(function(all, part) {
69883         var subkey = helpkey + "." + part;
69884         var depth = headings[subkey];
69885         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
69886         return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n";
69887       }, "");
69888       return {
69889         title: _t.html(helpkey + ".title"),
69890         content: marked(text.trim()).replace(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
69891       };
69892     });
69893     var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help");
69894     helpPane.renderContent = function(content) {
69895       function clickHelp(d2, i3) {
69896         var rtl = _mainLocalizer.textDirection() === "rtl";
69897         content.property("scrollTop", 0);
69898         helpPane.selection().select(".pane-heading h2").html(d2.title);
69899         body.html(d2.content);
69900         body.selectAll("a").attr("target", "_blank");
69901         menuItems.classed("selected", function(m2) {
69902           return m2.title === d2.title;
69903         });
69904         nav.html("");
69905         if (rtl) {
69906           nav.call(drawNext).call(drawPrevious);
69907         } else {
69908           nav.call(drawPrevious).call(drawNext);
69909         }
69910         function drawNext(selection2) {
69911           if (i3 < docs.length - 1) {
69912             var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) {
69913               d3_event.preventDefault();
69914               clickHelp(docs[i3 + 1], i3 + 1);
69915             });
69916             nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
69917           }
69918         }
69919         function drawPrevious(selection2) {
69920           if (i3 > 0) {
69921             var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) {
69922               d3_event.preventDefault();
69923               clickHelp(docs[i3 - 1], i3 - 1);
69924             });
69925             prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title);
69926           }
69927         }
69928       }
69929       function clickWalkthrough(d3_event) {
69930         d3_event.preventDefault();
69931         if (context.inIntro()) return;
69932         context.container().call(uiIntro(context));
69933         context.ui().togglePanes();
69934       }
69935       function clickShortcuts(d3_event) {
69936         d3_event.preventDefault();
69937         context.container().call(context.ui().shortcuts, true);
69938       }
69939       var toc = content.append("ul").attr("class", "toc");
69940       var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) {
69941         return d2.title;
69942       }).on("click", function(d3_event, d2) {
69943         d3_event.preventDefault();
69944         clickHelp(d2, docs.indexOf(d2));
69945       });
69946       var shortcuts = toc.append("li").attr("class", "shortcuts").call(
69947         uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top")
69948       ).append("a").attr("href", "#").on("click", clickShortcuts);
69949       shortcuts.append("div").call(_t.append("shortcuts.title"));
69950       var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough);
69951       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
69952       walkthrough.append("div").call(_t.append("splash.walkthrough"));
69953       var helpContent = content.append("div").attr("class", "left-content");
69954       var body = helpContent.append("div").attr("class", "body");
69955       var nav = helpContent.append("div").attr("class", "nav");
69956       clickHelp(docs[0], 0);
69957     };
69958     return helpPane;
69959   }
69960
69961   // modules/ui/sections/validation_issues.js
69962   function uiSectionValidationIssues(id2, severity, context) {
69963     var _issues = [];
69964     var section = uiSection(id2, context).label(function() {
69965       if (!_issues) return "";
69966       var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length);
69967       return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText });
69968     }).disclosureContent(renderDisclosureContent).shouldDisplay(function() {
69969       return _issues && _issues.length;
69970     });
69971     function getOptions() {
69972       return {
69973         what: corePreferences("validate-what") || "edited",
69974         where: corePreferences("validate-where") || "all"
69975       };
69976     }
69977     function reloadIssues() {
69978       _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
69979     }
69980     function renderDisclosureContent(selection2) {
69981       var center = context.map().center();
69982       var graph = context.graph();
69983       var issues = _issues.map(function withDistance(issue) {
69984         var extent = issue.extent(graph);
69985         var dist = extent ? geoSphericalDistance(center, extent.center()) : 0;
69986         return Object.assign(issue, { dist });
69987       }).sort(function byDistance(a2, b2) {
69988         return a2.dist - b2.dist;
69989       });
69990       issues = issues.slice(0, 1e3);
69991       selection2.call(drawIssuesList, issues);
69992     }
69993     function drawIssuesList(selection2, issues) {
69994       var list2 = selection2.selectAll(".issues-list").data([0]);
69995       list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2);
69996       var items = list2.selectAll("li").data(issues, function(d2) {
69997         return d2.key;
69998       });
69999       items.exit().remove();
70000       var itemsEnter = items.enter().append("li").attr("class", function(d2) {
70001         return "issue severity-" + d2.severity;
70002       });
70003       var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) {
70004         context.validator().focusIssue(d2);
70005       }).on("mouseover", function(d3_event, d2) {
70006         utilHighlightEntities(d2.entityIds, true, context);
70007       }).on("mouseout", function(d3_event, d2) {
70008         utilHighlightEntities(d2.entityIds, false, context);
70009       });
70010       var textEnter = labelsEnter.append("span").attr("class", "issue-text");
70011       textEnter.append("span").attr("class", "issue-icon").each(function(d2) {
70012         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
70013         select_default2(this).call(svgIcon(iconName));
70014       });
70015       textEnter.append("span").attr("class", "issue-message");
70016       items = items.merge(itemsEnter).order();
70017       items.selectAll(".issue-message").text("").each(function(d2) {
70018         return d2.message(context)(select_default2(this));
70019       });
70020     }
70021     context.validator().on("validated.uiSectionValidationIssues" + id2, function() {
70022       window.requestIdleCallback(function() {
70023         reloadIssues();
70024         section.reRender();
70025       });
70026     });
70027     context.map().on(
70028       "move.uiSectionValidationIssues" + id2,
70029       debounce_default(function() {
70030         window.requestIdleCallback(function() {
70031           if (getOptions().where === "visible") {
70032             reloadIssues();
70033           }
70034           section.reRender();
70035         });
70036       }, 1e3)
70037     );
70038     return section;
70039   }
70040
70041   // modules/ui/sections/validation_options.js
70042   function uiSectionValidationOptions(context) {
70043     var section = uiSection("issues-options", context).content(renderContent);
70044     function renderContent(selection2) {
70045       var container = selection2.selectAll(".issues-options-container").data([0]);
70046       container = container.enter().append("div").attr("class", "issues-options-container").merge(container);
70047       var data = [
70048         { key: "what", values: ["edited", "all"] },
70049         { key: "where", values: ["visible", "all"] }
70050       ];
70051       var options2 = container.selectAll(".issues-option").data(data, function(d2) {
70052         return d2.key;
70053       });
70054       var optionsEnter = options2.enter().append("div").attr("class", function(d2) {
70055         return "issues-option issues-option-" + d2.key;
70056       });
70057       optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) {
70058         return _t.html("issues.options." + d2.key + ".title");
70059       });
70060       var valuesEnter = optionsEnter.selectAll("label").data(function(d2) {
70061         return d2.values.map(function(val) {
70062           return { value: val, key: d2.key };
70063         });
70064       }).enter().append("label");
70065       valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) {
70066         return "issues-option-" + d2.key;
70067       }).attr("value", function(d2) {
70068         return d2.value;
70069       }).property("checked", function(d2) {
70070         return getOptions()[d2.key] === d2.value;
70071       }).on("change", function(d3_event, d2) {
70072         updateOptionValue(d3_event, d2.key, d2.value);
70073       });
70074       valuesEnter.append("span").html(function(d2) {
70075         return _t.html("issues.options." + d2.key + "." + d2.value);
70076       });
70077     }
70078     function getOptions() {
70079       return {
70080         what: corePreferences("validate-what") || "edited",
70081         // 'all', 'edited'
70082         where: corePreferences("validate-where") || "all"
70083         // 'all', 'visible'
70084       };
70085     }
70086     function updateOptionValue(d3_event, d2, val) {
70087       if (!val && d3_event && d3_event.target) {
70088         val = d3_event.target.value;
70089       }
70090       corePreferences("validate-" + d2, val);
70091       context.validator().validate();
70092     }
70093     return section;
70094   }
70095
70096   // modules/ui/sections/validation_rules.js
70097   function uiSectionValidationRules(context) {
70098     var MINSQUARE = 0;
70099     var MAXSQUARE = 20;
70100     var DEFAULTSQUARE = 5;
70101     var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title"));
70102     var _ruleKeys = context.validator().getRuleKeys().filter(function(key) {
70103       return key !== "maprules";
70104     }).sort(function(key1, key2) {
70105       return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1;
70106     });
70107     function renderDisclosureContent(selection2) {
70108       var container = selection2.selectAll(".issues-rulelist-container").data([0]);
70109       var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container");
70110       containerEnter.append("ul").attr("class", "layer-list issue-rules-list");
70111       var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer");
70112       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
70113         d3_event.preventDefault();
70114         context.validator().disableRules(_ruleKeys);
70115       });
70116       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
70117         d3_event.preventDefault();
70118         context.validator().disableRules([]);
70119       });
70120       container = container.merge(containerEnter);
70121       container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled);
70122     }
70123     function drawListItems(selection2, data, type2, name, change, active) {
70124       var items = selection2.selectAll("li").data(data);
70125       items.exit().remove();
70126       var enter = items.enter().append("li");
70127       if (name === "rule") {
70128         enter.call(
70129           uiTooltip().title(function(d2) {
70130             return _t.append("issues." + d2 + ".tip");
70131           }).placement("top")
70132         );
70133       }
70134       var label = enter.append("label");
70135       label.append("input").attr("type", type2).attr("name", name).on("change", change);
70136       label.append("span").html(function(d2) {
70137         var params = {};
70138         if (d2 === "unsquare_way") {
70139           params.val = { html: '<span class="square-degrees"></span>' };
70140         }
70141         return _t.html("issues." + d2 + ".title", params);
70142       });
70143       items = items.merge(enter);
70144       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
70145       var degStr = corePreferences("validate-square-degrees");
70146       if (degStr === null) {
70147         degStr = DEFAULTSQUARE.toString();
70148       }
70149       var span = items.selectAll(".square-degrees");
70150       var input = span.selectAll(".square-degrees-input").data([0]);
70151       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) {
70152         d3_event.preventDefault();
70153         d3_event.stopPropagation();
70154         this.select();
70155       }).on("keyup", function(d3_event) {
70156         if (d3_event.keyCode === 13) {
70157           this.blur();
70158           this.select();
70159         }
70160       }).on("blur", changeSquare).merge(input).property("value", degStr);
70161     }
70162     function changeSquare() {
70163       var input = select_default2(this);
70164       var degStr = utilGetSetValue(input).trim();
70165       var degNum = Number(degStr);
70166       if (!isFinite(degNum)) {
70167         degNum = DEFAULTSQUARE;
70168       } else if (degNum > MAXSQUARE) {
70169         degNum = MAXSQUARE;
70170       } else if (degNum < MINSQUARE) {
70171         degNum = MINSQUARE;
70172       }
70173       degNum = Math.round(degNum * 10) / 10;
70174       degStr = degNum.toString();
70175       input.property("value", degStr);
70176       corePreferences("validate-square-degrees", degStr);
70177       context.validator().revalidateUnsquare();
70178     }
70179     function isRuleEnabled(d2) {
70180       return context.validator().isRuleEnabled(d2);
70181     }
70182     function toggleRule(d3_event, d2) {
70183       context.validator().toggleRule(d2);
70184     }
70185     context.validator().on("validated.uiSectionValidationRules", function() {
70186       window.requestIdleCallback(section.reRender);
70187     });
70188     return section;
70189   }
70190
70191   // modules/ui/sections/validation_status.js
70192   function uiSectionValidationStatus(context) {
70193     var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() {
70194       var issues = context.validator().getIssues(getOptions());
70195       return issues.length === 0;
70196     });
70197     function getOptions() {
70198       return {
70199         what: corePreferences("validate-what") || "edited",
70200         where: corePreferences("validate-where") || "all"
70201       };
70202     }
70203     function renderContent(selection2) {
70204       var box = selection2.selectAll(".box").data([0]);
70205       var boxEnter = box.enter().append("div").attr("class", "box");
70206       boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text"));
70207       var noIssuesMessage = boxEnter.append("span");
70208       noIssuesMessage.append("strong").attr("class", "message");
70209       noIssuesMessage.append("br");
70210       noIssuesMessage.append("span").attr("class", "details");
70211       renderIgnoredIssuesReset(selection2);
70212       setNoIssuesText(selection2);
70213     }
70214     function renderIgnoredIssuesReset(selection2) {
70215       var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" });
70216       var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []);
70217       resetIgnored.exit().remove();
70218       var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer");
70219       resetIgnoredEnter.append("a").attr("href", "#");
70220       resetIgnored = resetIgnored.merge(resetIgnoredEnter);
70221       resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length }));
70222       resetIgnored.on("click", function(d3_event) {
70223         d3_event.preventDefault();
70224         context.validator().resetIgnoredIssues();
70225       });
70226     }
70227     function setNoIssuesText(selection2) {
70228       var opts = getOptions();
70229       function checkForHiddenIssues(cases) {
70230         for (var type2 in cases) {
70231           var hiddenOpts = cases[type2];
70232           var hiddenIssues = context.validator().getIssues(hiddenOpts);
70233           if (hiddenIssues.length) {
70234             selection2.select(".box .details").html("").call(_t.append(
70235               "issues.no_issues.hidden_issues." + type2,
70236               { count: hiddenIssues.length.toString() }
70237             ));
70238             return;
70239           }
70240         }
70241         selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none"));
70242       }
70243       var messageType;
70244       if (opts.what === "edited" && opts.where === "visible") {
70245         messageType = "edits_in_view";
70246         checkForHiddenIssues({
70247           elsewhere: { what: "edited", where: "all" },
70248           everything_else: { what: "all", where: "visible" },
70249           disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" },
70250           everything_else_elsewhere: { what: "all", where: "all" },
70251           disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" },
70252           ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" },
70253           ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" }
70254         });
70255       } else if (opts.what === "edited" && opts.where === "all") {
70256         messageType = "edits";
70257         checkForHiddenIssues({
70258           everything_else: { what: "all", where: "all" },
70259           disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" },
70260           ignored_issues: { what: "edited", where: "all", includeIgnored: "only" }
70261         });
70262       } else if (opts.what === "all" && opts.where === "visible") {
70263         messageType = "everything_in_view";
70264         checkForHiddenIssues({
70265           elsewhere: { what: "all", where: "all" },
70266           disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" },
70267           disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" },
70268           ignored_issues: { what: "all", where: "visible", includeIgnored: "only" },
70269           ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" }
70270         });
70271       } else if (opts.what === "all" && opts.where === "all") {
70272         messageType = "everything";
70273         checkForHiddenIssues({
70274           disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" },
70275           ignored_issues: { what: "all", where: "all", includeIgnored: "only" }
70276         });
70277       }
70278       if (opts.what === "edited" && context.history().difference().summary().length === 0) {
70279         messageType = "no_edits";
70280       }
70281       selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType));
70282     }
70283     context.validator().on("validated.uiSectionValidationStatus", function() {
70284       window.requestIdleCallback(section.reRender);
70285     });
70286     context.map().on(
70287       "move.uiSectionValidationStatus",
70288       debounce_default(function() {
70289         window.requestIdleCallback(section.reRender);
70290       }, 1e3)
70291     );
70292     return section;
70293   }
70294
70295   // modules/ui/panes/issues.js
70296   function uiPaneIssues(context) {
70297     var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([
70298       uiSectionValidationOptions(context),
70299       uiSectionValidationStatus(context),
70300       uiSectionValidationIssues("issues-errors", "error", context),
70301       uiSectionValidationIssues("issues-warnings", "warning", context),
70302       uiSectionValidationRules(context)
70303     ]);
70304     return issuesPane;
70305   }
70306
70307   // modules/ui/settings/custom_data.js
70308   function uiSettingsCustomData(context) {
70309     var dispatch14 = dispatch_default("change");
70310     function render(selection2) {
70311       var dataLayer = context.layers().layer("data");
70312       var _origSettings = {
70313         fileList: dataLayer && dataLayer.fileList() || null,
70314         url: corePreferences("settings-custom-data-url")
70315       };
70316       var _currSettings = {
70317         fileList: dataLayer && dataLayer.fileList() || null
70318         // url: prefs('settings-custom-data-url')
70319       };
70320       var modal = uiConfirm(selection2).okButton();
70321       modal.classed("settings-modal settings-custom-data", true);
70322       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header"));
70323       var textSection = modal.select(".modal-section.message-text");
70324       textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions"));
70325       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) {
70326         var files = d3_event.target.files;
70327         if (files && files.length) {
70328           _currSettings.url = "";
70329           textSection.select(".field-url").property("value", "");
70330           _currSettings.fileList = files;
70331         } else {
70332           _currSettings.fileList = null;
70333         }
70334       });
70335       textSection.append("h4").call(_t.append("settings.custom_data.or"));
70336       textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions"));
70337       textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url);
70338       var buttonSection = modal.select(".modal-section.buttons");
70339       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
70340       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
70341       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
70342       function isSaveDisabled() {
70343         return null;
70344       }
70345       function clickCancel() {
70346         textSection.select(".field-url").property("value", _origSettings.url);
70347         corePreferences("settings-custom-data-url", _origSettings.url);
70348         this.blur();
70349         modal.close();
70350       }
70351       function clickSave() {
70352         _currSettings.url = textSection.select(".field-url").property("value").trim();
70353         if (_currSettings.url) {
70354           _currSettings.fileList = null;
70355         }
70356         if (_currSettings.fileList) {
70357           _currSettings.url = "";
70358         }
70359         corePreferences("settings-custom-data-url", _currSettings.url);
70360         this.blur();
70361         modal.close();
70362         dispatch14.call("change", this, _currSettings);
70363       }
70364     }
70365     return utilRebind(render, dispatch14, "on");
70366   }
70367
70368   // modules/ui/sections/data_layers.js
70369   function uiSectionDataLayers(context) {
70370     var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged);
70371     var layers = context.layers();
70372     var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent);
70373     function renderDisclosureContent(selection2) {
70374       var container = selection2.selectAll(".data-layer-container").data([0]);
70375       container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems);
70376     }
70377     function showsLayer(which) {
70378       var layer = layers.layer(which);
70379       if (layer) {
70380         return layer.enabled();
70381       }
70382       return false;
70383     }
70384     function setLayer(which, enabled) {
70385       var mode = context.mode();
70386       if (mode && /^draw/.test(mode.id)) return;
70387       var layer = layers.layer(which);
70388       if (layer) {
70389         layer.enabled(enabled);
70390         if (!enabled && (which === "osm" || which === "notes")) {
70391           context.enter(modeBrowse(context));
70392         }
70393       }
70394     }
70395     function toggleLayer(which) {
70396       setLayer(which, !showsLayer(which));
70397     }
70398     function drawOsmItems(selection2) {
70399       var osmKeys = ["osm", "notes"];
70400       var osmLayers = layers.all().filter(function(obj) {
70401         return osmKeys.indexOf(obj.id) !== -1;
70402       });
70403       var ul = selection2.selectAll(".layer-list-osm").data([0]);
70404       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul);
70405       var li = ul.selectAll(".list-item").data(osmLayers);
70406       li.exit().remove();
70407       var liEnter = li.enter().append("li").attr("class", function(d2) {
70408         return "list-item list-item-" + d2.id;
70409       });
70410       var labelEnter = liEnter.append("label").each(function(d2) {
70411         if (d2.id === "osm") {
70412           select_default2(this).call(
70413             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom")
70414           );
70415         } else {
70416           select_default2(this).call(
70417             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
70418           );
70419         }
70420       });
70421       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70422         toggleLayer(d2.id);
70423       });
70424       labelEnter.append("span").html(function(d2) {
70425         return _t.html("map_data.layers." + d2.id + ".title");
70426       });
70427       li.merge(liEnter).classed("active", function(d2) {
70428         return d2.layer.enabled();
70429       }).selectAll("input").property("checked", function(d2) {
70430         return d2.layer.enabled();
70431       });
70432     }
70433     function drawQAItems(selection2) {
70434       var qaKeys = ["keepRight", "osmose"];
70435       var qaLayers = layers.all().filter(function(obj) {
70436         return qaKeys.indexOf(obj.id) !== -1;
70437       });
70438       var ul = selection2.selectAll(".layer-list-qa").data([0]);
70439       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul);
70440       var li = ul.selectAll(".list-item").data(qaLayers);
70441       li.exit().remove();
70442       var liEnter = li.enter().append("li").attr("class", function(d2) {
70443         return "list-item list-item-" + d2.id;
70444       });
70445       var labelEnter = liEnter.append("label").each(function(d2) {
70446         select_default2(this).call(
70447           uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
70448         );
70449       });
70450       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70451         toggleLayer(d2.id);
70452       });
70453       labelEnter.append("span").each(function(d2) {
70454         _t.append("map_data.layers." + d2.id + ".title")(select_default2(this));
70455       });
70456       li.merge(liEnter).classed("active", function(d2) {
70457         return d2.layer.enabled();
70458       }).selectAll("input").property("checked", function(d2) {
70459         return d2.layer.enabled();
70460       });
70461     }
70462     function drawVectorItems(selection2) {
70463       var dataLayer = layers.layer("data");
70464       var vtData = [
70465         {
70466           name: "Detroit Neighborhoods/Parks",
70467           src: "neighborhoods-parks",
70468           tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.",
70469           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"
70470         },
70471         {
70472           name: "Detroit Composite POIs",
70473           src: "composite-poi",
70474           tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.",
70475           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"
70476         },
70477         {
70478           name: "Detroit All-The-Places POIs",
70479           src: "alltheplaces-poi",
70480           tooltip: "Public domain business location data created by web scrapers.",
70481           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"
70482         }
70483       ];
70484       var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]);
70485       var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center());
70486       var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []);
70487       container.exit().remove();
70488       var containerEnter = container.enter().append("div").attr("class", "vectortile-container");
70489       containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)");
70490       containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile");
70491       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");
70492       container = container.merge(containerEnter);
70493       var ul = container.selectAll(".layer-list-vectortile");
70494       var li = ul.selectAll(".list-item").data(vtData);
70495       li.exit().remove();
70496       var liEnter = li.enter().append("li").attr("class", function(d2) {
70497         return "list-item list-item-" + d2.src;
70498       });
70499       var labelEnter = liEnter.append("label").each(function(d2) {
70500         select_default2(this).call(
70501           uiTooltip().title(d2.tooltip).placement("top")
70502         );
70503       });
70504       labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer);
70505       labelEnter.append("span").text(function(d2) {
70506         return d2.name;
70507       });
70508       li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected);
70509       function isVTLayerSelected(d2) {
70510         return dataLayer && dataLayer.template() === d2.template;
70511       }
70512       function selectVTLayer(d3_event, d2) {
70513         corePreferences("settings-custom-data-url", d2.template);
70514         if (dataLayer) {
70515           dataLayer.template(d2.template, d2.src);
70516           dataLayer.enabled(true);
70517         }
70518       }
70519     }
70520     function drawCustomDataItems(selection2) {
70521       var dataLayer = layers.layer("data");
70522       var hasData = dataLayer && dataLayer.hasData();
70523       var showsData = hasData && dataLayer.enabled();
70524       var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []);
70525       ul.exit().remove();
70526       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data");
70527       var liEnter = ulEnter.append("li").attr("class", "list-item-data");
70528       var labelEnter = liEnter.append("label").call(
70529         uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top")
70530       );
70531       labelEnter.append("input").attr("type", "checkbox").on("change", function() {
70532         toggleLayer("data");
70533       });
70534       labelEnter.append("span").call(_t.append("map_data.layers.custom.title"));
70535       liEnter.append("button").attr("class", "open-data-options").call(
70536         uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70537       ).on("click", function(d3_event) {
70538         d3_event.preventDefault();
70539         editCustom();
70540       }).call(svgIcon("#iD-icon-more"));
70541       liEnter.append("button").attr("class", "zoom-to-data").call(
70542         uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70543       ).on("click", function(d3_event) {
70544         if (select_default2(this).classed("disabled")) return;
70545         d3_event.preventDefault();
70546         d3_event.stopPropagation();
70547         dataLayer.fitZoom();
70548       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
70549       ul = ul.merge(ulEnter);
70550       ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
70551       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
70552     }
70553     function editCustom() {
70554       context.container().call(settingsCustomData);
70555     }
70556     function customChanged(d2) {
70557       var dataLayer = layers.layer("data");
70558       if (d2 && d2.url) {
70559         dataLayer.url(d2.url);
70560       } else if (d2 && d2.fileList) {
70561         dataLayer.fileList(d2.fileList);
70562       }
70563     }
70564     function drawPanelItems(selection2) {
70565       var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list");
70566       var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call(
70567         uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top")
70568       );
70569       historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
70570         d3_event.preventDefault();
70571         context.ui().info.toggle("history");
70572       });
70573       historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title"));
70574       var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call(
70575         uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top")
70576       );
70577       measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
70578         d3_event.preventDefault();
70579         context.ui().info.toggle("measurement");
70580       });
70581       measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title"));
70582     }
70583     context.layers().on("change.uiSectionDataLayers", section.reRender);
70584     context.map().on(
70585       "move.uiSectionDataLayers",
70586       debounce_default(function() {
70587         window.requestIdleCallback(section.reRender);
70588       }, 1e3)
70589     );
70590     return section;
70591   }
70592
70593   // modules/ui/sections/map_features.js
70594   function uiSectionMapFeatures(context) {
70595     var _features = context.features().keys();
70596     var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
70597     function renderDisclosureContent(selection2) {
70598       var container = selection2.selectAll(".layer-feature-list-container").data([0]);
70599       var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container");
70600       containerEnter.append("ul").attr("class", "layer-list layer-feature-list");
70601       var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer");
70602       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
70603         d3_event.preventDefault();
70604         context.features().disableAll();
70605       });
70606       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
70607         d3_event.preventDefault();
70608         context.features().enableAll();
70609       });
70610       container = container.merge(containerEnter);
70611       container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature);
70612     }
70613     function drawListItems(selection2, data, type2, name, change, active) {
70614       var items = selection2.selectAll("li").data(data);
70615       items.exit().remove();
70616       var enter = items.enter().append("li").call(
70617         uiTooltip().title(function(d2) {
70618           var tip = _t.append(name + "." + d2 + ".tooltip");
70619           if (autoHiddenFeature(d2)) {
70620             var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden");
70621             return (selection3) => {
70622               selection3.call(tip);
70623               selection3.append("div").call(msg);
70624             };
70625           }
70626           return tip;
70627         }).placement("top")
70628       );
70629       var label = enter.append("label");
70630       label.append("input").attr("type", type2).attr("name", name).on("change", change);
70631       label.append("span").html(function(d2) {
70632         return _t.html(name + "." + d2 + ".description");
70633       });
70634       items = items.merge(enter);
70635       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature);
70636     }
70637     function autoHiddenFeature(d2) {
70638       return context.features().autoHidden(d2);
70639     }
70640     function showsFeature(d2) {
70641       return context.features().enabled(d2);
70642     }
70643     function clickFeature(d3_event, d2) {
70644       context.features().toggle(d2);
70645     }
70646     function showsLayer(id2) {
70647       var layer = context.layers().layer(id2);
70648       return layer && layer.enabled();
70649     }
70650     context.features().on("change.map_features", section.reRender);
70651     return section;
70652   }
70653
70654   // modules/ui/sections/map_style_options.js
70655   function uiSectionMapStyleOptions(context) {
70656     var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
70657     function renderDisclosureContent(selection2) {
70658       var container = selection2.selectAll(".layer-fill-list").data([0]);
70659       container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill);
70660       var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]);
70661       container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() {
70662         return context.surface().classed("highlight-edited");
70663       });
70664     }
70665     function drawListItems(selection2, data, type2, name, change, active) {
70666       var items = selection2.selectAll("li").data(data);
70667       items.exit().remove();
70668       var enter = items.enter().append("li").call(
70669         uiTooltip().title(function(d2) {
70670           return _t.append(name + "." + d2 + ".tooltip");
70671         }).keys(function(d2) {
70672           var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null;
70673           if (d2 === "highlight_edits") key = _t("map_data.highlight_edits.key");
70674           return key ? [key] : null;
70675         }).placement("top")
70676       );
70677       var label = enter.append("label");
70678       label.append("input").attr("type", type2).attr("name", name).on("change", change);
70679       label.append("span").html(function(d2) {
70680         return _t.html(name + "." + d2 + ".description");
70681       });
70682       items = items.merge(enter);
70683       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
70684     }
70685     function isActiveFill(d2) {
70686       return context.map().activeAreaFill() === d2;
70687     }
70688     function toggleHighlightEdited(d3_event) {
70689       d3_event.preventDefault();
70690       context.map().toggleHighlightEdited();
70691     }
70692     function setFill(d3_event, d2) {
70693       context.map().activeAreaFill(d2);
70694     }
70695     context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender);
70696     return section;
70697   }
70698
70699   // modules/ui/settings/local_photos.js
70700   function uiSettingsLocalPhotos(context) {
70701     var dispatch14 = dispatch_default("change");
70702     var photoLayer = context.layers().layer("local-photos");
70703     var modal;
70704     function render(selection2) {
70705       modal = uiConfirm(selection2).okButton();
70706       modal.classed("settings-modal settings-local-photos", true);
70707       modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header"));
70708       modal.select(".modal-section.message-text").append("div").classed("local-photos", true);
70709       var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true);
70710       instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions"));
70711       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) {
70712         var files = d3_event.target.files;
70713         if (files && files.length) {
70714           photoList.select("ul").append("li").classed("placeholder", true).append("div");
70715           dispatch14.call("change", this, files);
70716         }
70717         d3_event.target.value = null;
70718       });
70719       instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label"));
70720       const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true);
70721       photoList.append("ul");
70722       updatePhotoList(photoList.select("ul"));
70723       context.layers().on("change", () => updatePhotoList(photoList.select("ul")));
70724     }
70725     function updatePhotoList(container) {
70726       var _a4;
70727       function locationUnavailable(d2) {
70728         return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
70729       }
70730       container.selectAll("li.placeholder").remove();
70731       let selection2 = container.selectAll("li").data((_a4 = photoLayer.getPhotos()) != null ? _a4 : [], (d2) => d2.id);
70732       selection2.exit().remove();
70733       const selectionEnter = selection2.enter().append("li");
70734       selectionEnter.append("span").classed("filename", true);
70735       selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot"));
70736       selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call(
70737         uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left")
70738       );
70739       selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
70740       selection2 = selection2.merge(selectionEnter);
70741       selection2.classed("invalid", locationUnavailable);
70742       selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name);
70743       selection2.select("span.filename").on("click", (d3_event, d2) => {
70744         photoLayer.openPhoto(d3_event, d2, false);
70745       });
70746       selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => {
70747         photoLayer.openPhoto(d3_event, d2, true);
70748       });
70749       selection2.select("button.remove").on("click", (d3_event, d2) => {
70750         photoLayer.removePhoto(d2.id);
70751         updatePhotoList(container);
70752       });
70753     }
70754     return utilRebind(render, dispatch14, "on");
70755   }
70756
70757   // modules/ui/sections/photo_overlays.js
70758   function uiSectionPhotoOverlays(context) {
70759     var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged);
70760     var layers = context.layers();
70761     var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
70762     function renderDisclosureContent(selection2) {
70763       var container = selection2.selectAll(".photo-overlay-container").data([0]);
70764       container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
70765     }
70766     function drawPhotoItems(selection2) {
70767       var photoKeys = context.photos().overlayLayerIDs();
70768       var photoLayers = layers.all().filter(function(obj) {
70769         return photoKeys.indexOf(obj.id) !== -1;
70770       });
70771       var data = photoLayers.filter(function(obj) {
70772         if (!obj.layer.supported()) return false;
70773         if (layerEnabled(obj)) return true;
70774         if (typeof obj.layer.validHere === "function") {
70775           return obj.layer.validHere(context.map().extent(), context.map().zoom());
70776         }
70777         return true;
70778       });
70779       function layerSupported(d2) {
70780         return d2.layer && d2.layer.supported();
70781       }
70782       function layerEnabled(d2) {
70783         return layerSupported(d2) && d2.layer.enabled();
70784       }
70785       function layerRendered(d2) {
70786         var _a4, _b3, _c2;
70787         return (_c2 = (_b3 = (_a4 = d2.layer).rendered) == null ? void 0 : _b3.call(_a4, context.map().zoom())) != null ? _c2 : true;
70788       }
70789       var ul = selection2.selectAll(".layer-list-photos").data([0]);
70790       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
70791       var li = ul.selectAll(".list-item-photos").data(data, (d2) => d2.id);
70792       li.exit().remove();
70793       var liEnter = li.enter().append("li").attr("class", function(d2) {
70794         var classes = "list-item-photos list-item-" + d2.id;
70795         if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") {
70796           classes += " indented";
70797         }
70798         return classes;
70799       });
70800       var labelEnter = liEnter.append("label").each(function(d2) {
70801         var titleID;
70802         if (d2.id === "mapillary-signs") titleID = "mapillary.signs.tooltip";
70803         else if (d2.id === "mapillary") titleID = "mapillary_images.tooltip";
70804         else if (d2.id === "kartaview") titleID = "kartaview_images.tooltip";
70805         else titleID = d2.id.replace(/-/g, "_") + ".tooltip";
70806         select_default2(this).call(
70807           uiTooltip().title(() => {
70808             if (!layerRendered(d2)) {
70809               return _t.append("street_side.minzoom_tooltip");
70810             } else {
70811               return _t.append(titleID);
70812             }
70813           }).placement("top")
70814         );
70815       });
70816       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70817         toggleLayer(d2.id);
70818       });
70819       labelEnter.append("span").html(function(d2) {
70820         var id2 = d2.id;
70821         if (id2 === "mapillary-signs") id2 = "photo_overlays.traffic_signs";
70822         return _t.html(id2.replace(/-/g, "_") + ".title");
70823       });
70824       li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled);
70825     }
70826     function drawPhotoTypeItems(selection2) {
70827       var data = context.photos().allPhotoTypes();
70828       function typeEnabled(d2) {
70829         return context.photos().showsPhotoType(d2);
70830       }
70831       var ul = selection2.selectAll(".layer-list-photo-types").data([0]);
70832       ul.exit().remove();
70833       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul);
70834       var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []);
70835       li.exit().remove();
70836       var liEnter = li.enter().append("li").attr("class", function(d2) {
70837         return "list-item-photo-types list-item-" + d2;
70838       });
70839       var labelEnter = liEnter.append("label").each(function(d2) {
70840         select_default2(this).call(
70841           uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top")
70842         );
70843       });
70844       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70845         context.photos().togglePhotoType(d2);
70846       });
70847       labelEnter.append("span").html(function(d2) {
70848         return _t.html("photo_overlays.photo_type." + d2 + ".title");
70849       });
70850       li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled);
70851     }
70852     function drawDateFilter(selection2) {
70853       var data = context.photos().dateFilters();
70854       function filterEnabled(d2) {
70855         return context.photos().dateFilterValue(d2);
70856       }
70857       var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
70858       ul.exit().remove();
70859       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
70860       var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
70861       li.exit().remove();
70862       var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
70863       var labelEnter = liEnter.append("label").each(function(d2) {
70864         select_default2(this).call(
70865           uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
70866         );
70867       });
70868       labelEnter.append("span").each(function(d2) {
70869         _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
70870       });
70871       labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
70872         utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
70873       }).on("change", function(d3_event, d2) {
70874         var value = utilGetSetValue(select_default2(this)).trim();
70875         context.photos().setDateFilter(d2, value, true);
70876         li.selectAll("input").each(function(d4) {
70877           utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
70878         });
70879       });
70880       li = li.merge(liEnter).classed("active", filterEnabled);
70881     }
70882     function drawUsernameFilter(selection2) {
70883       function filterEnabled() {
70884         return context.photos().usernames();
70885       }
70886       var ul = selection2.selectAll(".layer-list-username-filter").data([0]);
70887       ul.exit().remove();
70888       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul);
70889       var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []);
70890       li.exit().remove();
70891       var liEnter = li.enter().append("li").attr("class", "list-item-username-filter");
70892       var labelEnter = liEnter.append("label").each(function() {
70893         select_default2(this).call(
70894           uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top")
70895         );
70896       });
70897       labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title"));
70898       labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() {
70899         var value = select_default2(this).property("value");
70900         context.photos().setUsernameFilter(value, true);
70901         select_default2(this).property("value", usernameValue);
70902       });
70903       li.merge(liEnter).classed("active", filterEnabled);
70904       function usernameValue() {
70905         var usernames = context.photos().usernames();
70906         if (usernames) return usernames.join("; ");
70907         return usernames;
70908       }
70909     }
70910     function toggleLayer(which) {
70911       setLayer(which, !showsLayer(which));
70912     }
70913     function showsLayer(which) {
70914       var layer = layers.layer(which);
70915       if (layer) {
70916         return layer.enabled();
70917       }
70918       return false;
70919     }
70920     function setLayer(which, enabled) {
70921       var layer = layers.layer(which);
70922       if (layer) {
70923         layer.enabled(enabled);
70924       }
70925     }
70926     function drawLocalPhotos(selection2) {
70927       var photoLayer = layers.layer("local-photos");
70928       var hasData = photoLayer && photoLayer.hasData();
70929       var showsData = hasData && photoLayer.enabled();
70930       var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []);
70931       ul.exit().remove();
70932       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos");
70933       var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos");
70934       var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip")));
70935       localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() {
70936         toggleLayer("local-photos");
70937       });
70938       localPhotosLabelEnter.call(_t.append("local_photos.header"));
70939       localPhotosEnter.append("button").attr("class", "open-data-options").call(
70940         uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70941       ).on("click", function(d3_event) {
70942         d3_event.preventDefault();
70943         editLocalPhotos();
70944       }).call(svgIcon("#iD-icon-more"));
70945       localPhotosEnter.append("button").attr("class", "zoom-to-data").call(
70946         uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70947       ).on("click", function(d3_event) {
70948         if (select_default2(this).classed("disabled")) return;
70949         d3_event.preventDefault();
70950         d3_event.stopPropagation();
70951         photoLayer.fitZoom();
70952       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
70953       ul = ul.merge(ulEnter);
70954       ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
70955       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
70956     }
70957     function editLocalPhotos() {
70958       context.container().call(settingsLocalPhotos);
70959     }
70960     function localPhotosChanged(d2) {
70961       var localPhotosLayer = layers.layer("local-photos");
70962       localPhotosLayer.fileList(d2);
70963     }
70964     context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
70965     context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
70966     context.map().on(
70967       "move.photo_overlays",
70968       debounce_default(function() {
70969         window.requestIdleCallback(section.reRender);
70970       }, 1e3)
70971     );
70972     return section;
70973   }
70974
70975   // modules/ui/panes/map_data.js
70976   function uiPaneMapData(context) {
70977     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([
70978       uiSectionDataLayers(context),
70979       uiSectionPhotoOverlays(context),
70980       uiSectionMapStyleOptions(context),
70981       uiSectionMapFeatures(context)
70982     ]);
70983     return mapDataPane;
70984   }
70985
70986   // modules/ui/panes/preferences.js
70987   function uiPanePreferences(context) {
70988     let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([
70989       uiSectionPrivacy(context)
70990     ]);
70991     return preferencesPane;
70992   }
70993
70994   // modules/ui/init.js
70995   function uiInit(context) {
70996     var _initCounter = 0;
70997     var _needWidth = {};
70998     var _lastPointerType;
70999     var overMap;
71000     function render(container) {
71001       container.on("click.ui", function(d3_event) {
71002         if (d3_event.button !== 0) return;
71003         if (!d3_event.composedPath) return;
71004         var isOkayTarget = d3_event.composedPath().some(function(node) {
71005           return node.nodeType === 1 && // clicking <input> focuses it and/or changes a value
71006           (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
71007           node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
71008           node.nodeName === "A");
71009         });
71010         if (isOkayTarget) return;
71011         d3_event.preventDefault();
71012       });
71013       var detected = utilDetect();
71014       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
71015       // but we only need to do this on desktop Safari anyway. – #7694
71016       !detected.isMobileWebKit) {
71017         container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
71018           d3_event.preventDefault();
71019         });
71020       }
71021       if ("PointerEvent" in window) {
71022         select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
71023           var pointerType = d3_event.pointerType || "mouse";
71024           if (_lastPointerType !== pointerType) {
71025             _lastPointerType = pointerType;
71026             container.attr("pointer", pointerType);
71027           }
71028         }, true);
71029       } else {
71030         _lastPointerType = "mouse";
71031         container.attr("pointer", "mouse");
71032       }
71033       container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
71034       container.call(uiFullScreen(context));
71035       var map2 = context.map();
71036       map2.redrawEnable(false);
71037       map2.on("hitMinZoom.ui", function() {
71038         ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
71039       });
71040       container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
71041       container.append("div").attr("class", "sidebar").call(ui.sidebar);
71042       var content = container.append("div").attr("class", "main-content active");
71043       content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
71044       content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
71045       overMap = content.append("div").attr("class", "over-map");
71046       overMap.append("div").attr("class", "select-trap").text("t");
71047       overMap.call(uiMapInMap(context)).call(uiNotice(context));
71048       overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
71049       var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
71050       var controls = controlsWrap.append("div").attr("class", "map-controls");
71051       controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
71052       controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
71053       controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
71054       controlsWrap.on("wheel.mapControls", function(d3_event) {
71055         if (!d3_event.deltaX) {
71056           controlsWrap.node().scrollTop += d3_event.deltaY;
71057         }
71058       });
71059       var panes = overMap.append("div").attr("class", "map-panes");
71060       var uiPanes = [
71061         uiPaneBackground(context),
71062         uiPaneMapData(context),
71063         uiPaneIssues(context),
71064         uiPanePreferences(context),
71065         uiPaneHelp(context)
71066       ];
71067       uiPanes.forEach(function(pane) {
71068         controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
71069         panes.call(pane.renderPane);
71070       });
71071       ui.info = uiInfo(context);
71072       overMap.call(ui.info);
71073       overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
71074       overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
71075       var about = content.append("div").attr("class", "map-footer");
71076       about.append("div").attr("class", "api-status").call(uiStatus(context));
71077       var footer = about.append("div").attr("class", "map-footer-bar fillD");
71078       footer.append("div").attr("class", "flash-wrap footer-hide");
71079       var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
71080       footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
71081       var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
71082       aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
71083       var apiConnections = context.connection().apiConnections();
71084       if (apiConnections && apiConnections.length > 1) {
71085         aboutList.append("li").attr("class", "source-switch").call(
71086           uiSourceSwitch(context).keys(apiConnections)
71087         );
71088       }
71089       aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
71090       aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
71091       var issueLinks = aboutList.append("li");
71092       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"));
71093       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"));
71094       aboutList.append("li").attr("class", "version").call(uiVersion(context));
71095       if (!context.embed()) {
71096         aboutList.call(uiAccount(context));
71097       }
71098       ui.onResize();
71099       map2.redrawEnable(true);
71100       ui.hash = behaviorHash(context);
71101       ui.hash();
71102       if (!ui.hash.hadLocation) {
71103         map2.centerZoom([0, 0], 2);
71104       }
71105       window.onbeforeunload = function() {
71106         return context.save();
71107       };
71108       window.onunload = function() {
71109         context.history().unlock();
71110       };
71111       select_default2(window).on("resize.editor", function() {
71112         ui.onResize();
71113       });
71114       var panPixels = 80;
71115       context.keybinding().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) {
71116         if (d3_event) {
71117           d3_event.stopImmediatePropagation();
71118           d3_event.preventDefault();
71119         }
71120         var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
71121         if (previousBackground) {
71122           var currentBackground = context.background().baseLayerSource();
71123           corePreferences("background-last-used-toggle", currentBackground.id);
71124           corePreferences("background-last-used", previousBackground.id);
71125           context.background().baseLayerSource(previousBackground);
71126         }
71127       }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
71128         d3_event.preventDefault();
71129         d3_event.stopPropagation();
71130         context.map().toggleWireframe();
71131       }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
71132         d3_event.preventDefault();
71133         d3_event.stopPropagation();
71134         var mode = context.mode();
71135         if (mode && /^draw/.test(mode.id)) return;
71136         var layer = context.layers().layer("osm");
71137         if (layer) {
71138           layer.enabled(!layer.enabled());
71139           if (!layer.enabled()) {
71140             context.enter(modeBrowse(context));
71141           }
71142         }
71143       }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
71144         d3_event.preventDefault();
71145         context.map().toggleHighlightEdited();
71146       });
71147       context.on("enter.editor", function(entered) {
71148         container.classed("mode-" + entered.id, true);
71149       }).on("exit.editor", function(exited) {
71150         container.classed("mode-" + exited.id, false);
71151       });
71152       context.enter(modeBrowse(context));
71153       if (!_initCounter++) {
71154         if (!ui.hash.startWalkthrough) {
71155           context.container().call(uiSplash(context)).call(uiRestore(context));
71156         }
71157         context.container().call(ui.shortcuts);
71158       }
71159       var osm = context.connection();
71160       var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
71161       if (osm && auth) {
71162         osm.on("authLoading.ui", function() {
71163           context.container().call(auth);
71164         }).on("authDone.ui", function() {
71165           auth.close();
71166         });
71167       }
71168       _initCounter++;
71169       if (ui.hash.startWalkthrough) {
71170         ui.hash.startWalkthrough = false;
71171         context.container().call(uiIntro(context));
71172       }
71173       function pan(d2) {
71174         return function(d3_event) {
71175           if (d3_event.shiftKey) return;
71176           if (context.container().select(".combobox").size()) return;
71177           d3_event.preventDefault();
71178           context.map().pan(d2, 100);
71179         };
71180       }
71181     }
71182     let ui = {};
71183     let _loadPromise;
71184     ui.ensureLoaded = () => {
71185       if (_loadPromise) return _loadPromise;
71186       return _loadPromise = Promise.all([
71187         // must have strings and presets before loading the UI
71188         _mainLocalizer.ensureLoaded(),
71189         _mainPresetIndex.ensureLoaded()
71190       ]).then(() => {
71191         if (!context.container().empty()) render(context.container());
71192       }).catch((err) => console.error(err));
71193     };
71194     ui.restart = function() {
71195       context.keybinding().clear();
71196       _loadPromise = null;
71197       context.container().selectAll("*").remove();
71198       ui.ensureLoaded();
71199     };
71200     ui.lastPointerType = function() {
71201       return _lastPointerType;
71202     };
71203     ui.svgDefs = svgDefs(context);
71204     ui.flash = uiFlash(context);
71205     ui.sidebar = uiSidebar(context);
71206     ui.photoviewer = uiPhotoviewer(context);
71207     ui.shortcuts = uiShortcuts(context);
71208     ui.onResize = function(withPan) {
71209       var map2 = context.map();
71210       var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
71211       utilGetDimensions(context.container().select(".sidebar"), true);
71212       if (withPan !== void 0) {
71213         map2.redrawEnable(false);
71214         map2.pan(withPan);
71215         map2.redrawEnable(true);
71216       }
71217       map2.dimensions(mapDimensions);
71218       ui.photoviewer.onMapResize();
71219       ui.checkOverflow(".top-toolbar");
71220       ui.checkOverflow(".map-footer-bar");
71221       var resizeWindowEvent = document.createEvent("Event");
71222       resizeWindowEvent.initEvent("resizeWindow", true, true);
71223       document.dispatchEvent(resizeWindowEvent);
71224     };
71225     ui.checkOverflow = function(selector, reset) {
71226       if (reset) {
71227         delete _needWidth[selector];
71228       }
71229       var selection2 = context.container().select(selector);
71230       if (selection2.empty()) return;
71231       var scrollWidth = selection2.property("scrollWidth");
71232       var clientWidth = selection2.property("clientWidth");
71233       var needed = _needWidth[selector] || scrollWidth;
71234       if (scrollWidth > clientWidth) {
71235         selection2.classed("narrow", true);
71236         if (!_needWidth[selector]) {
71237           _needWidth[selector] = scrollWidth;
71238         }
71239       } else if (scrollWidth >= needed) {
71240         selection2.classed("narrow", false);
71241       }
71242     };
71243     ui.togglePanes = function(showPane) {
71244       var hidePanes = context.container().selectAll(".map-pane.shown");
71245       var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
71246       hidePanes.classed("shown", false).classed("hide", true);
71247       context.container().selectAll(".map-pane-control button").classed("active", false);
71248       if (showPane) {
71249         hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
71250         context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
71251         showPane.classed("shown", true).classed("hide", false);
71252         if (hidePanes.empty()) {
71253           showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
71254         } else {
71255           showPane.style(side, "0px");
71256         }
71257       } else {
71258         hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
71259           select_default2(this).classed("shown", false).classed("hide", true);
71260         });
71261       }
71262     };
71263     var _editMenu = uiEditMenu(context);
71264     ui.editMenu = function() {
71265       return _editMenu;
71266     };
71267     ui.showEditMenu = function(anchorPoint, triggerType, operations) {
71268       ui.closeEditMenu();
71269       if (!operations && context.mode().operations) operations = context.mode().operations();
71270       if (!operations || !operations.length) return;
71271       if (!context.map().editableDataEnabled()) return;
71272       var surfaceNode = context.surface().node();
71273       if (surfaceNode.focus) {
71274         surfaceNode.focus();
71275       }
71276       operations.forEach(function(operation2) {
71277         if (operation2.point) operation2.point(anchorPoint);
71278       });
71279       _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
71280       overMap.call(_editMenu);
71281     };
71282     ui.closeEditMenu = function() {
71283       if (overMap !== void 0) {
71284         overMap.select(".edit-menu").remove();
71285       }
71286     };
71287     var _saveLoading = select_default2(null);
71288     context.uploader().on("saveStarted.ui", function() {
71289       _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
71290       context.container().call(_saveLoading);
71291     }).on("saveEnded.ui", function() {
71292       _saveLoading.close();
71293       _saveLoading = select_default2(null);
71294     });
71295     marked.use({
71296       mangle: false,
71297       headerIds: false
71298     });
71299     return ui;
71300   }
71301
71302   // modules/ui/commit_warnings.js
71303   function uiCommitWarnings(context) {
71304     function commitWarnings(selection2) {
71305       var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
71306       for (var severity in issuesBySeverity) {
71307         var issues = issuesBySeverity[severity];
71308         if (severity !== "error") {
71309           issues = issues.filter(function(issue) {
71310             return issue.type !== "help_request";
71311           });
71312         }
71313         var section = severity + "-section";
71314         var issueItem = severity + "-item";
71315         var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
71316         container.exit().remove();
71317         var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
71318         containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
71319         containerEnter.append("ul").attr("class", "changeset-list");
71320         container = containerEnter.merge(container);
71321         var items = container.select("ul").selectAll("li").data(issues, function(d2) {
71322           return d2.key;
71323         });
71324         items.exit().remove();
71325         var itemsEnter = items.enter().append("li").attr("class", issueItem);
71326         var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
71327           if (d2.entityIds) {
71328             context.surface().selectAll(
71329               utilEntityOrMemberSelector(
71330                 d2.entityIds,
71331                 context.graph()
71332               )
71333             ).classed("hover", true);
71334           }
71335         }).on("mouseout", function() {
71336           context.surface().selectAll(".hover").classed("hover", false);
71337         }).on("click", function(d3_event, d2) {
71338           context.validator().focusIssue(d2);
71339         });
71340         buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
71341         buttons.append("strong").attr("class", "issue-message");
71342         buttons.filter(function(d2) {
71343           return d2.tooltip;
71344         }).call(
71345           uiTooltip().title(function(d2) {
71346             return d2.tooltip;
71347           }).placement("top")
71348         );
71349         items = itemsEnter.merge(items);
71350         items.selectAll(".issue-message").text("").each(function(d2) {
71351           return d2.message(context)(select_default2(this));
71352         });
71353       }
71354     }
71355     return commitWarnings;
71356   }
71357
71358   // modules/ui/lasso.js
71359   function uiLasso(context) {
71360     var group, polygon2;
71361     lasso.coordinates = [];
71362     function lasso(selection2) {
71363       context.container().classed("lasso", true);
71364       group = selection2.append("g").attr("class", "lasso hide");
71365       polygon2 = group.append("path").attr("class", "lasso-path");
71366       group.call(uiToggle(true));
71367     }
71368     function draw() {
71369       if (polygon2) {
71370         polygon2.data([lasso.coordinates]).attr("d", function(d2) {
71371           return "M" + d2.join(" L") + " Z";
71372         });
71373       }
71374     }
71375     lasso.extent = function() {
71376       return lasso.coordinates.reduce(function(extent, point) {
71377         return extent.extend(geoExtent(point));
71378       }, geoExtent());
71379     };
71380     lasso.p = function(_2) {
71381       if (!arguments.length) return lasso;
71382       lasso.coordinates.push(_2);
71383       draw();
71384       return lasso;
71385     };
71386     lasso.close = function() {
71387       if (group) {
71388         group.call(uiToggle(false, function() {
71389           select_default2(this).remove();
71390         }));
71391       }
71392       context.container().classed("lasso", false);
71393     };
71394     return lasso;
71395   }
71396
71397   // node_modules/osm-community-index/lib/simplify.js
71398   var import_diacritics2 = __toESM(require_diacritics(), 1);
71399   function simplify(str) {
71400     if (typeof str !== "string") return "";
71401     return import_diacritics2.default.remove(
71402       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()
71403     );
71404   }
71405
71406   // node_modules/osm-community-index/lib/resolve_strings.js
71407   function resolveStrings(item, defaults, localizerFn) {
71408     let itemStrings = Object.assign({}, item.strings);
71409     let defaultStrings = Object.assign({}, defaults[item.type]);
71410     const anyToken = new RegExp(/(\{\w+\})/, "gi");
71411     if (localizerFn) {
71412       if (itemStrings.community) {
71413         const communityID = simplify(itemStrings.community);
71414         itemStrings.community = localizerFn("_communities.".concat(communityID));
71415       }
71416       ["name", "description", "extendedDescription"].forEach((prop) => {
71417         if (defaultStrings[prop]) defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
71418         if (itemStrings[prop]) itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
71419       });
71420     }
71421     let replacements = {
71422       account: item.account,
71423       community: itemStrings.community,
71424       signupUrl: itemStrings.signupUrl,
71425       url: itemStrings.url
71426     };
71427     if (!replacements.signupUrl) {
71428       replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
71429     }
71430     if (!replacements.url) {
71431       replacements.url = resolve(itemStrings.url || defaultStrings.url);
71432     }
71433     let resolved = {
71434       name: resolve(itemStrings.name || defaultStrings.name),
71435       url: resolve(itemStrings.url || defaultStrings.url),
71436       signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
71437       description: resolve(itemStrings.description || defaultStrings.description),
71438       extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
71439     };
71440     resolved.nameHTML = linkify(resolved.url, resolved.name);
71441     resolved.urlHTML = linkify(resolved.url);
71442     resolved.signupUrlHTML = linkify(resolved.signupUrl);
71443     resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
71444     resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
71445     return resolved;
71446     function resolve(s2, addLinks) {
71447       if (!s2) return void 0;
71448       let result = s2;
71449       for (let key in replacements) {
71450         const token = "{".concat(key, "}");
71451         const regex = new RegExp(token, "g");
71452         if (regex.test(result)) {
71453           let replacement = replacements[key];
71454           if (!replacement) {
71455             throw new Error("Cannot resolve token: ".concat(token));
71456           } else {
71457             if (addLinks && (key === "signupUrl" || key === "url")) {
71458               replacement = linkify(replacement);
71459             }
71460             result = result.replace(regex, replacement);
71461           }
71462         }
71463       }
71464       const leftovers = result.match(anyToken);
71465       if (leftovers) {
71466         throw new Error("Cannot resolve tokens: ".concat(leftovers));
71467       }
71468       if (addLinks && item.type === "reddit") {
71469         result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
71470       }
71471       return result;
71472     }
71473     function linkify(url, text) {
71474       if (!url) return void 0;
71475       text = text || url;
71476       return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
71477     }
71478   }
71479
71480   // modules/ui/success.js
71481   var _oci = null;
71482   function uiSuccess(context) {
71483     const MAXEVENTS = 2;
71484     const dispatch14 = dispatch_default("cancel");
71485     let _changeset2;
71486     let _location;
71487     ensureOSMCommunityIndex();
71488     function ensureOSMCommunityIndex() {
71489       const data = _mainFileFetcher;
71490       return Promise.all([
71491         data.get("oci_features"),
71492         data.get("oci_resources"),
71493         data.get("oci_defaults")
71494       ]).then((vals) => {
71495         if (_oci) return _oci;
71496         if (vals[0] && Array.isArray(vals[0].features)) {
71497           _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
71498         }
71499         let ociResources = Object.values(vals[1].resources);
71500         if (ociResources.length) {
71501           return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
71502             _oci = {
71503               resources: ociResources,
71504               defaults: vals[2].defaults
71505             };
71506             return _oci;
71507           });
71508         } else {
71509           _oci = {
71510             resources: [],
71511             // no resources?
71512             defaults: vals[2].defaults
71513           };
71514           return _oci;
71515         }
71516       });
71517     }
71518     function parseEventDate(when) {
71519       if (!when) return;
71520       let raw = when.trim();
71521       if (!raw) return;
71522       if (!/Z$/.test(raw)) {
71523         raw += "Z";
71524       }
71525       const parsed = new Date(raw);
71526       return new Date(parsed.toUTCString().slice(0, 25));
71527     }
71528     function success(selection2) {
71529       let header = selection2.append("div").attr("class", "header fillL");
71530       header.append("h2").call(_t.append("success.just_edited"));
71531       header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
71532       let body = selection2.append("div").attr("class", "body save-success fillL");
71533       let summary = body.append("div").attr("class", "save-summary");
71534       summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
71535       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"));
71536       let osm = context.connection();
71537       if (!osm) return;
71538       let changesetURL = osm.changesetURL(_changeset2.id);
71539       let table = summary.append("table").attr("class", "summary-table");
71540       let row = table.append("tr").attr("class", "summary-row");
71541       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");
71542       let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
71543       summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
71544       summaryDetail.append("div").html(_t.html("success.changeset_id", {
71545         changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
71546       }));
71547       if (showDonationMessage !== false) {
71548         const donationUrl = "https://supporting.openstreetmap.org/";
71549         let supporting = body.append("div").attr("class", "save-supporting");
71550         supporting.append("h3").call(_t.append("success.supporting.title"));
71551         supporting.append("p").call(_t.append("success.supporting.details"));
71552         table = supporting.append("table").attr("class", "supporting-table");
71553         row = table.append("tr").attr("class", "supporting-row");
71554         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");
71555         let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
71556         supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
71557         supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
71558       }
71559       ensureOSMCommunityIndex().then((oci) => {
71560         const loc = context.map().center();
71561         const validHere = _sharedLocationManager.locationSetsAt(loc);
71562         let communities = [];
71563         oci.resources.forEach((resource) => {
71564           let area = validHere[resource.locationSetID];
71565           if (!area) return;
71566           const localizer = (stringID) => _t.html("community.".concat(stringID));
71567           resource.resolved = resolveStrings(resource, oci.defaults, localizer);
71568           communities.push({
71569             area,
71570             order: resource.order || 0,
71571             resource
71572           });
71573         });
71574         communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
71575         body.call(showCommunityLinks, communities.map((c2) => c2.resource));
71576       });
71577     }
71578     function showCommunityLinks(selection2, resources) {
71579       let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
71580       communityLinks.append("h3").call(_t.append("success.like_osm"));
71581       let table = communityLinks.append("table").attr("class", "community-table");
71582       let row = table.selectAll(".community-row").data(resources);
71583       let rowEnter = row.enter().append("tr").attr("class", "community-row");
71584       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));
71585       let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
71586       communityDetail.each(showCommunityDetails);
71587       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"));
71588     }
71589     function showCommunityDetails(d2) {
71590       let selection2 = select_default2(this);
71591       let communityID = d2.id;
71592       selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
71593       selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
71594       if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
71595         selection2.append("div").call(
71596           uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
71597         );
71598       }
71599       let nextEvents = (d2.events || []).map((event) => {
71600         event.date = parseEventDate(event.when);
71601         return event;
71602       }).filter((event) => {
71603         const t2 = event.date.getTime();
71604         const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
71605         return !isNaN(t2) && t2 >= now3;
71606       }).sort((a2, b2) => {
71607         return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
71608       }).slice(0, MAXEVENTS);
71609       if (nextEvents.length) {
71610         selection2.append("div").call(
71611           uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
71612         ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
71613       }
71614       function showMore(selection3) {
71615         let more = selection3.selectAll(".community-more").data([0]);
71616         let moreEnter = more.enter().append("div").attr("class", "community-more");
71617         if (d2.resolved.extendedDescriptionHTML) {
71618           moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
71619         }
71620         if (d2.languageCodes && d2.languageCodes.length) {
71621           const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
71622           moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
71623         }
71624       }
71625       function showNextEvents(selection3) {
71626         let events = selection3.append("div").attr("class", "community-events");
71627         let item = events.selectAll(".community-event").data(nextEvents);
71628         let itemEnter = item.enter().append("div").attr("class", "community-event");
71629         itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
71630           let name = d4.name;
71631           if (d4.i18n && d4.id) {
71632             name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
71633           }
71634           return name;
71635         });
71636         itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
71637           let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
71638           if (d4.date.getHours() || d4.date.getMinutes()) {
71639             options2.hour = "numeric";
71640             options2.minute = "numeric";
71641           }
71642           return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
71643         });
71644         itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
71645           let where = d4.where;
71646           if (d4.i18n && d4.id) {
71647             where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
71648           }
71649           return where;
71650         });
71651         itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
71652           let description = d4.description;
71653           if (d4.i18n && d4.id) {
71654             description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
71655           }
71656           return description;
71657         });
71658       }
71659     }
71660     success.changeset = function(val) {
71661       if (!arguments.length) return _changeset2;
71662       _changeset2 = val;
71663       return success;
71664     };
71665     success.location = function(val) {
71666       if (!arguments.length) return _location;
71667       _location = val;
71668       return success;
71669     };
71670     return utilRebind(success, dispatch14, "on");
71671   }
71672
71673   // modules/ui/fields/input.js
71674   var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
71675   function uiFieldText(field, context) {
71676     var dispatch14 = dispatch_default("change");
71677     var input = select_default2(null);
71678     var outlinkButton = select_default2(null);
71679     var wrap2 = select_default2(null);
71680     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
71681     var _entityIDs = [];
71682     var _tags;
71683     var _phoneFormats = {};
71684     const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
71685     const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
71686     const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
71687     const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
71688     if (field.type === "tel") {
71689       _mainFileFetcher.get("phone_formats").then(function(d2) {
71690         _phoneFormats = d2;
71691         updatePhonePlaceholder();
71692       }).catch(function() {
71693       });
71694     }
71695     function calcLocked() {
71696       var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
71697         var entity = context.graph().hasEntity(entityID);
71698         if (!entity) return false;
71699         if (entity.tags.wikidata) return true;
71700         var preset = _mainPresetIndex.match(entity, context.graph());
71701         var isSuggestion = preset && preset.suggestion;
71702         var which = field.id;
71703         return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
71704       });
71705       field.locked(isLocked);
71706     }
71707     function i3(selection2) {
71708       calcLocked();
71709       var isLocked = field.locked();
71710       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
71711       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
71712       input = wrap2.selectAll("input").data([0]);
71713       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);
71714       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
71715       wrap2.call(_lengthIndicator);
71716       if (field.type === "tel") {
71717         updatePhonePlaceholder();
71718       } else if (field.type === "number") {
71719         var rtl = _mainLocalizer.textDirection() === "rtl";
71720         input.attr("type", "text");
71721         var inc = field.increment;
71722         var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
71723         buttons.enter().append("button").attr("class", function(d2) {
71724           var which = d2 > 0 ? "increment" : "decrement";
71725           return "form-field-button " + which;
71726         }).attr("title", function(d2) {
71727           var which = d2 > 0 ? "increment" : "decrement";
71728           return _t("inspector.".concat(which));
71729         }).merge(buttons).on("click", function(d3_event, d2) {
71730           d3_event.preventDefault();
71731           var isMixed = Array.isArray(_tags[field.key]);
71732           if (isMixed) return;
71733           var raw_vals = input.node().value || "0";
71734           var vals = raw_vals.split(";");
71735           vals = vals.map(function(v2) {
71736             v2 = v2.trim();
71737             const isRawNumber = likelyRawNumberFormat.test(v2);
71738             var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
71739             if (isDirectionField) {
71740               const compassDir = cardinal[v2.toLowerCase()];
71741               if (compassDir !== void 0) {
71742                 num = compassDir;
71743               }
71744             }
71745             if (!isFinite(num)) return v2;
71746             num = parseFloat(num);
71747             if (!isFinite(num)) return v2;
71748             num += d2;
71749             if (isDirectionField) {
71750               num = (num % 360 + 360) % 360;
71751             }
71752             return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
71753           });
71754           input.node().value = vals.join(";");
71755           change()();
71756         });
71757       } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
71758         input.attr("type", "text");
71759         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
71760         outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
71761           var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
71762           if (domainResults.length >= 2 && domainResults[1]) {
71763             var domain = domainResults[1];
71764             return _t("icons.view_on", { domain });
71765           }
71766           return "";
71767         }).merge(outlinkButton);
71768         outlinkButton.on("click", function(d3_event) {
71769           d3_event.preventDefault();
71770           var value = validIdentifierValueForLink();
71771           if (value) {
71772             var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
71773             window.open(url, "_blank");
71774           }
71775         }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
71776       } else if (field.type === "url") {
71777         input.attr("type", "text");
71778         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
71779         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) {
71780           d3_event.preventDefault();
71781           const value = validIdentifierValueForLink();
71782           if (value) window.open(value, "_blank");
71783         }).merge(outlinkButton);
71784       } else if (field.type === "colour") {
71785         input.attr("type", "text");
71786         updateColourPreview();
71787       } else if (field.type === "date") {
71788         input.attr("type", "text");
71789         updateDateField();
71790       }
71791     }
71792     function updateColourPreview() {
71793       wrap2.selectAll(".colour-preview").remove();
71794       const colour = utilGetSetValue(input);
71795       if (!isColourValid(colour) && colour !== "") {
71796         wrap2.selectAll("input.colour-selector").remove();
71797         wrap2.selectAll(".form-field-button").remove();
71798         return;
71799       }
71800       var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
71801       colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
71802         d3_event.preventDefault();
71803         var colour2 = this.value;
71804         if (!isColourValid(colour2)) return;
71805         utilGetSetValue(input, this.value);
71806         change()();
71807         updateColourPreview();
71808       }, 100));
71809       wrap2.selectAll("input.colour-selector").attr("value", colour);
71810       var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
71811       chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
71812       if (colour === "") {
71813         chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
71814       }
71815       chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
71816     }
71817     function updateDateField() {
71818       function isDateValid(date2) {
71819         return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
71820       }
71821       const date = utilGetSetValue(input);
71822       const now3 = /* @__PURE__ */ new Date();
71823       const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
71824       if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
71825         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", () => {
71826           utilGetSetValue(input, today);
71827           change()();
71828           updateDateField();
71829         });
71830       } else {
71831         wrap2.selectAll(".date-set-today").remove();
71832       }
71833       if (!isDateValid(date) && date !== "") {
71834         wrap2.selectAll("input.date-selector").remove();
71835         wrap2.selectAll(".date-calendar").remove();
71836         return;
71837       }
71838       if (utilDetect().browser !== "Safari") {
71839         var dateSelector = wrap2.selectAll(".date-selector").data([0]);
71840         dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
71841           d3_event.preventDefault();
71842           var date2 = this.value;
71843           if (!isDateValid(date2)) return;
71844           utilGetSetValue(input, this.value);
71845           change()();
71846           updateDateField();
71847         }, 100));
71848         wrap2.selectAll("input.date-selector").attr("value", date);
71849         var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
71850         calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
71851         calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
71852       }
71853     }
71854     function updatePhonePlaceholder() {
71855       if (input.empty() || !Object.keys(_phoneFormats).length) return;
71856       var extent = combinedEntityExtent();
71857       var countryCode = extent && iso1A2Code(extent.center());
71858       var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
71859       if (format2) input.attr("placeholder", format2);
71860     }
71861     function validIdentifierValueForLink() {
71862       var _a4;
71863       const value = utilGetSetValue(input).trim();
71864       if (field.type === "url" && value) {
71865         try {
71866           return new URL(value).href;
71867         } catch (e3) {
71868           return null;
71869         }
71870       }
71871       if (field.type === "identifier" && field.pattern) {
71872         return value && ((_a4 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a4[0]);
71873       }
71874       return null;
71875     }
71876     function clamped(num) {
71877       if (field.minValue !== void 0) {
71878         num = Math.max(num, field.minValue);
71879       }
71880       if (field.maxValue !== void 0) {
71881         num = Math.min(num, field.maxValue);
71882       }
71883       return num;
71884     }
71885     function getVals(tags) {
71886       if (field.keys) {
71887         const multiSelection = context.selectedIDs();
71888         tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
71889         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]));
71890       } else {
71891         return new Set([].concat(tags[field.key]));
71892       }
71893     }
71894     function change(onInput) {
71895       return function() {
71896         var t2 = {};
71897         var val = utilGetSetValue(input);
71898         if (!onInput) val = context.cleanTagValue(val);
71899         if (!val && getVals(_tags).size > 1) return;
71900         var displayVal = val;
71901         if (field.type === "number" && val) {
71902           var numbers2 = val.split(";");
71903           numbers2 = numbers2.map(function(v2) {
71904             if (likelyRawNumberFormat.test(v2)) {
71905               return v2;
71906             }
71907             var num = parseLocaleFloat(v2);
71908             const fractionDigits = countDecimalPlaces(v2);
71909             return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
71910           });
71911           val = numbers2.join(";");
71912         }
71913         if (!onInput) utilGetSetValue(input, displayVal);
71914         t2[field.key] = val || void 0;
71915         if (field.keys) {
71916           dispatch14.call("change", this, (tags) => {
71917             if (field.keys.some((key) => tags[key])) {
71918               field.keys.filter((key) => tags[key]).forEach((key) => {
71919                 tags[key] = val || void 0;
71920               });
71921             } else {
71922               tags[field.key] = val || void 0;
71923             }
71924             return tags;
71925           }, onInput);
71926         } else {
71927           dispatch14.call("change", this, t2, onInput);
71928         }
71929       };
71930     }
71931     i3.entityIDs = function(val) {
71932       if (!arguments.length) return _entityIDs;
71933       _entityIDs = val;
71934       return i3;
71935     };
71936     i3.tags = function(tags) {
71937       var _a4;
71938       _tags = tags;
71939       const vals = getVals(tags);
71940       const isMixed = vals.size > 1;
71941       var val = vals.size === 1 ? (_a4 = [...vals][0]) != null ? _a4 : "" : "";
71942       var shouldUpdate;
71943       if (field.type === "number" && val) {
71944         var numbers2 = val.split(";");
71945         var oriNumbers = utilGetSetValue(input).split(";");
71946         if (numbers2.length !== oriNumbers.length) shouldUpdate = true;
71947         numbers2 = numbers2.map(function(v2) {
71948           v2 = v2.trim();
71949           var num = Number(v2);
71950           if (!isFinite(num) || v2 === "") return v2;
71951           const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
71952           return formatFloat(num, fractionDigits);
71953         });
71954         val = numbers2.join(";");
71955         shouldUpdate = (inputValue, setValue) => {
71956           const inputNums = inputValue.split(";").map(
71957             (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
71958           );
71959           const setNums = setValue.split(";").map(parseLocaleFloat);
71960           return !isEqual_default(inputNums, setNums);
71961         };
71962       }
71963       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);
71964       if (field.type === "number") {
71965         const buttons = wrap2.selectAll(".increment, .decrement");
71966         if (isMixed) {
71967           buttons.attr("disabled", "disabled").classed("disabled", true);
71968         } else {
71969           var raw_vals = tags[field.key] || "0";
71970           const canIncDec = raw_vals.split(";").some(
71971             (val2) => isFinite(Number(val2)) || isDirectionField && val2.trim().toLowerCase() in cardinal
71972           );
71973           buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
71974         }
71975       }
71976       if (field.type === "tel") updatePhonePlaceholder();
71977       if (field.type === "colour") updateColourPreview();
71978       if (field.type === "date") updateDateField();
71979       if (outlinkButton && !outlinkButton.empty()) {
71980         var disabled = !validIdentifierValueForLink();
71981         outlinkButton.classed("disabled", disabled);
71982       }
71983       if (!isMixed) {
71984         _lengthIndicator.update(tags[field.key]);
71985       }
71986     };
71987     i3.focus = function() {
71988       var node = input.node();
71989       if (node) node.focus();
71990     };
71991     function combinedEntityExtent() {
71992       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
71993     }
71994     return utilRebind(i3, dispatch14, "on");
71995   }
71996
71997   // modules/ui/fields/access.js
71998   function uiFieldAccess(field, context) {
71999     var dispatch14 = dispatch_default("change");
72000     var items = select_default2(null);
72001     var _tags;
72002     function access(selection2) {
72003       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72004       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72005       var list2 = wrap2.selectAll("ul").data([0]);
72006       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
72007       items = list2.selectAll("li").data(field.keys);
72008       var enter = items.enter().append("li").attr("class", function(d2) {
72009         return "labeled-input preset-access-" + d2;
72010       });
72011       enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
72012         return "preset-input-access-" + d2;
72013       }).html(function(d2) {
72014         return field.t.html("types." + d2);
72015       });
72016       enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
72017         return "preset-input-access preset-input-access-" + d2;
72018       }).call(utilNoAuto).each(function(d2) {
72019         select_default2(this).call(
72020           uiCombobox(context, "access-" + d2).data(access.options(d2))
72021         );
72022       });
72023       items = items.merge(enter);
72024       wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
72025     }
72026     function change(d3_event, d2) {
72027       var tag2 = {};
72028       var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
72029       if (!value && typeof _tags[d2] !== "string") return;
72030       tag2[d2] = value || void 0;
72031       dispatch14.call("change", this, tag2);
72032     }
72033     access.options = function(type2) {
72034       var options2 = [
72035         "yes",
72036         "no",
72037         "designated",
72038         "permissive",
72039         "destination",
72040         "customers",
72041         "private",
72042         "permit",
72043         "unknown"
72044       ];
72045       if (type2 === "access") {
72046         options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
72047       }
72048       if (type2 === "bicycle") {
72049         options2.splice(options2.length - 4, 0, "dismount");
72050       }
72051       var stringsField = field.resolveReference("stringsCrossReference");
72052       return options2.map(function(option) {
72053         return {
72054           title: stringsField.t("options." + option + ".description"),
72055           value: option
72056         };
72057       });
72058     };
72059     const placeholdersByTag = {
72060       highway: {
72061         footway: {
72062           foot: "designated",
72063           motor_vehicle: "no"
72064         },
72065         steps: {
72066           foot: "yes",
72067           motor_vehicle: "no",
72068           bicycle: "no",
72069           horse: "no"
72070         },
72071         ladder: {
72072           foot: "yes",
72073           motor_vehicle: "no",
72074           bicycle: "no",
72075           horse: "no"
72076         },
72077         pedestrian: {
72078           foot: "yes",
72079           motor_vehicle: "no"
72080         },
72081         cycleway: {
72082           motor_vehicle: "no",
72083           bicycle: "designated"
72084         },
72085         bridleway: {
72086           motor_vehicle: "no",
72087           horse: "designated"
72088         },
72089         path: {
72090           foot: "yes",
72091           motor_vehicle: "no",
72092           bicycle: "yes",
72093           horse: "yes"
72094         },
72095         motorway: {
72096           foot: "no",
72097           motor_vehicle: "yes",
72098           bicycle: "no",
72099           horse: "no"
72100         },
72101         trunk: {
72102           motor_vehicle: "yes"
72103         },
72104         primary: {
72105           foot: "yes",
72106           motor_vehicle: "yes",
72107           bicycle: "yes",
72108           horse: "yes"
72109         },
72110         secondary: {
72111           foot: "yes",
72112           motor_vehicle: "yes",
72113           bicycle: "yes",
72114           horse: "yes"
72115         },
72116         tertiary: {
72117           foot: "yes",
72118           motor_vehicle: "yes",
72119           bicycle: "yes",
72120           horse: "yes"
72121         },
72122         residential: {
72123           foot: "yes",
72124           motor_vehicle: "yes",
72125           bicycle: "yes",
72126           horse: "yes"
72127         },
72128         unclassified: {
72129           foot: "yes",
72130           motor_vehicle: "yes",
72131           bicycle: "yes",
72132           horse: "yes"
72133         },
72134         service: {
72135           foot: "yes",
72136           motor_vehicle: "yes",
72137           bicycle: "yes",
72138           horse: "yes"
72139         },
72140         motorway_link: {
72141           foot: "no",
72142           motor_vehicle: "yes",
72143           bicycle: "no",
72144           horse: "no"
72145         },
72146         trunk_link: {
72147           motor_vehicle: "yes"
72148         },
72149         primary_link: {
72150           foot: "yes",
72151           motor_vehicle: "yes",
72152           bicycle: "yes",
72153           horse: "yes"
72154         },
72155         secondary_link: {
72156           foot: "yes",
72157           motor_vehicle: "yes",
72158           bicycle: "yes",
72159           horse: "yes"
72160         },
72161         tertiary_link: {
72162           foot: "yes",
72163           motor_vehicle: "yes",
72164           bicycle: "yes",
72165           horse: "yes"
72166         },
72167         construction: {
72168           access: "no"
72169         },
72170         busway: {
72171           access: "no",
72172           bus: "designated",
72173           emergency: "yes"
72174         }
72175       },
72176       barrier: {
72177         bollard: {
72178           access: "no",
72179           bicycle: "yes",
72180           foot: "yes"
72181         },
72182         bus_trap: {
72183           motor_vehicle: "no",
72184           psv: "yes",
72185           foot: "yes",
72186           bicycle: "yes"
72187         },
72188         city_wall: {
72189           access: "no"
72190         },
72191         coupure: {
72192           access: "yes"
72193         },
72194         cycle_barrier: {
72195           motor_vehicle: "no"
72196         },
72197         ditch: {
72198           access: "no"
72199         },
72200         entrance: {
72201           access: "yes"
72202         },
72203         fence: {
72204           access: "no"
72205         },
72206         hedge: {
72207           access: "no"
72208         },
72209         jersey_barrier: {
72210           access: "no"
72211         },
72212         motorcycle_barrier: {
72213           motor_vehicle: "no"
72214         },
72215         rail_guard: {
72216           access: "no"
72217         }
72218       }
72219     };
72220     access.tags = function(tags) {
72221       _tags = tags;
72222       utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
72223         return typeof tags[d2] === "string" ? tags[d2] : "";
72224       }).classed("mixed", function(d2) {
72225         return tags[d2] && Array.isArray(tags[d2]);
72226       }).attr("title", function(d2) {
72227         return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
72228       }).attr("placeholder", function(d2) {
72229         if (tags[d2] && Array.isArray(tags[d2])) {
72230           return _t("inspector.multiple_values");
72231         }
72232         if (d2 === "bicycle" || d2 === "motor_vehicle") {
72233           if (tags.vehicle && typeof tags.vehicle === "string") {
72234             return tags.vehicle;
72235           }
72236         }
72237         if (tags.access && typeof tags.access === "string") {
72238           return tags.access;
72239         }
72240         function getPlaceholdersByTag(key, placeholdersByKey) {
72241           if (typeof tags[key] === "string") {
72242             if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
72243               return placeholdersByKey[tags[key]][d2];
72244             }
72245           } else {
72246             var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
72247               return placeholdersByKey[val] && placeholdersByKey[val][d2];
72248             }).filter(Boolean);
72249             if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
72250               return impliedAccesses[0];
72251             }
72252           }
72253         }
72254         for (const key in placeholdersByTag) {
72255           if (tags[key]) {
72256             const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
72257             if (impliedAccess) {
72258               return impliedAccess;
72259             }
72260           }
72261         }
72262         if (d2 === "access" && !tags.barrier) {
72263           return "yes";
72264         }
72265         return field.placeholder();
72266       });
72267     };
72268     access.focus = function() {
72269       items.selectAll(".preset-input-access").node().focus();
72270     };
72271     return utilRebind(access, dispatch14, "on");
72272   }
72273
72274   // modules/ui/fields/address.js
72275   function uiFieldAddress(field, context) {
72276     var dispatch14 = dispatch_default("change");
72277     var _selection = select_default2(null);
72278     var _wrap = select_default2(null);
72279     var addrField = _mainPresetIndex.field("address");
72280     var _entityIDs = [];
72281     var _tags;
72282     var _countryCode;
72283     var _addressFormats = [{
72284       format: [
72285         ["housenumber", "street"],
72286         ["city", "postcode"]
72287       ]
72288     }];
72289     _mainFileFetcher.get("address_formats").then(function(d2) {
72290       _addressFormats = d2;
72291       if (!_selection.empty()) {
72292         _selection.call(address);
72293       }
72294     }).catch(function() {
72295     });
72296     function getNear(isAddressable, type2, searchRadius, resultProp) {
72297       var extent = combinedEntityExtent();
72298       var l2 = extent.center();
72299       var box = geoExtent(l2).padByMeters(searchRadius);
72300       var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
72301         let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
72302         if (d2.geometry(context.graph()) === "line") {
72303           var loc = context.projection([
72304             (extent[0][0] + extent[1][0]) / 2,
72305             (extent[0][1] + extent[1][1]) / 2
72306           ]);
72307           var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
72308           dist = geoSphericalDistance(choice.loc, l2);
72309         }
72310         const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
72311         let title = value;
72312         if (type2 === "street") {
72313           title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
72314         } else if (type2 === "place") {
72315           title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
72316         }
72317         return {
72318           title,
72319           value,
72320           dist,
72321           type: type2,
72322           klass: "address-".concat(type2)
72323         };
72324       }).sort(function(a2, b2) {
72325         return a2.dist - b2.dist;
72326       });
72327       return utilArrayUniqBy(features, "value");
72328     }
72329     function getNearStreets() {
72330       function isAddressable(d2) {
72331         return d2.tags.highway && d2.tags.name && d2.type === "way";
72332       }
72333       return getNear(isAddressable, "street", 200);
72334     }
72335     function getNearPlaces() {
72336       function isAddressable(d2) {
72337         if (d2.tags.name) {
72338           if (d2.tags.place) return true;
72339           if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8) return true;
72340         }
72341         return false;
72342       }
72343       return getNear(isAddressable, "place", 200);
72344     }
72345     function getNearCities() {
72346       function isAddressable(d2) {
72347         if (d2.tags.name) {
72348           if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8") return true;
72349           if (d2.tags.border_type === "city") return true;
72350           if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village") return true;
72351         }
72352         if (d2.tags["".concat(field.key, ":city")]) return true;
72353         return false;
72354       }
72355       return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
72356     }
72357     function getNearPostcodes() {
72358       return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
72359     }
72360     function getNearValues(key) {
72361       const tagKey = "".concat(field.key, ":").concat(key);
72362       function hasTag(d2) {
72363         return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
72364       }
72365       return getNear(hasTag, key, 200, tagKey);
72366     }
72367     function updateForCountryCode() {
72368       if (!_countryCode) return;
72369       var addressFormat;
72370       for (var i3 = 0; i3 < _addressFormats.length; i3++) {
72371         var format2 = _addressFormats[i3];
72372         if (!format2.countryCodes) {
72373           addressFormat = format2;
72374         } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
72375           addressFormat = format2;
72376           break;
72377         }
72378       }
72379       var dropdowns = addressFormat.dropdowns || [
72380         "city",
72381         "county",
72382         "country",
72383         "district",
72384         "hamlet",
72385         "neighbourhood",
72386         "place",
72387         "postcode",
72388         "province",
72389         "quarter",
72390         "state",
72391         "street",
72392         "street+place",
72393         "subdistrict",
72394         "suburb"
72395       ];
72396       var widths = addressFormat.widths || {
72397         housenumber: 1 / 5,
72398         unit: 1 / 5,
72399         street: 1 / 2,
72400         place: 1 / 2,
72401         city: 2 / 3,
72402         state: 1 / 4,
72403         postcode: 1 / 3
72404       };
72405       function row(r2) {
72406         var total = r2.reduce(function(sum, key) {
72407           return sum + (widths[key] || 0.5);
72408         }, 0);
72409         return r2.map(function(key) {
72410           return {
72411             id: key,
72412             width: (widths[key] || 0.5) / total
72413           };
72414         });
72415       }
72416       var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
72417         return d2.toString();
72418       });
72419       rows.exit().remove();
72420       rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").attr("class", function(d2) {
72421         return "addr-" + d2.id;
72422       }).call(utilNoAuto).each(addDropdown).call(updatePlaceholder).style("width", function(d2) {
72423         return d2.width * 100 + "%";
72424       });
72425       function addDropdown(d2) {
72426         if (dropdowns.indexOf(d2.id) === -1) return;
72427         var nearValues;
72428         switch (d2.id) {
72429           case "street":
72430             nearValues = getNearStreets;
72431             break;
72432           case "place":
72433             nearValues = getNearPlaces;
72434             break;
72435           case "street+place":
72436             nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
72437             d2.isAutoStreetPlace = true;
72438             d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
72439             break;
72440           case "city":
72441             nearValues = getNearCities;
72442             break;
72443           case "postcode":
72444             nearValues = getNearPostcodes;
72445             break;
72446           default:
72447             nearValues = getNearValues;
72448         }
72449         select_default2(this).call(
72450           uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
72451             typedValue = typedValue.toLowerCase();
72452             callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
72453           }).on("accept", function(selected) {
72454             if (d2.isAutoStreetPlace) {
72455               d2.id = selected ? selected.type : "street";
72456               utilTriggerEvent(select_default2(this), "change");
72457             }
72458           })
72459         );
72460       }
72461       _wrap.selectAll("input").on("blur", change()).on("change", change());
72462       _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
72463       if (_tags) updateTags(_tags);
72464     }
72465     function address(selection2) {
72466       _selection = selection2;
72467       _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
72468       _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
72469       var extent = combinedEntityExtent();
72470       if (extent) {
72471         var countryCode;
72472         if (context.inIntro()) {
72473           countryCode = _t("intro.graph.countrycode");
72474         } else {
72475           var center = extent.center();
72476           countryCode = iso1A2Code(center);
72477         }
72478         if (countryCode) {
72479           _countryCode = countryCode.toLowerCase();
72480           updateForCountryCode();
72481         }
72482       }
72483     }
72484     function change(onInput) {
72485       return function() {
72486         var tags = {};
72487         _wrap.selectAll("input").each(function(subfield) {
72488           var key = field.key + ":" + subfield.id;
72489           var value = this.value;
72490           if (!onInput) value = context.cleanTagValue(value);
72491           if (Array.isArray(_tags[key]) && !value) return;
72492           if (subfield.isAutoStreetPlace) {
72493             if (subfield.id === "street") {
72494               tags["".concat(field.key, ":place")] = void 0;
72495             } else if (subfield.id === "place") {
72496               tags["".concat(field.key, ":street")] = void 0;
72497             }
72498           }
72499           tags[key] = value || void 0;
72500         });
72501         Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
72502         dispatch14.call("change", this, tags, onInput);
72503       };
72504     }
72505     function updatePlaceholder(inputSelection) {
72506       return inputSelection.attr("placeholder", function(subfield) {
72507         if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
72508           return _t("inspector.multiple_values");
72509         }
72510         if (subfield.isAutoStreetPlace) {
72511           return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
72512         }
72513         return getLocalPlaceholder(subfield.id);
72514       });
72515     }
72516     function getLocalPlaceholder(key) {
72517       if (_countryCode) {
72518         var localkey = key + "!" + _countryCode;
72519         var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
72520         return addrField.t("placeholders." + tkey);
72521       }
72522     }
72523     function updateTags(tags) {
72524       utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
72525         var val;
72526         if (subfield.isAutoStreetPlace) {
72527           const streetKey = "".concat(field.key, ":street");
72528           const placeKey = "".concat(field.key, ":place");
72529           if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
72530             val = tags[streetKey];
72531             subfield.id = "street";
72532           } else {
72533             val = tags[placeKey];
72534             subfield.id = "place";
72535           }
72536         } else {
72537           val = tags["".concat(field.key, ":").concat(subfield.id)];
72538         }
72539         return typeof val === "string" ? val : "";
72540       }).attr("title", function(subfield) {
72541         var val = tags[field.key + ":" + subfield.id];
72542         return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
72543       }).classed("mixed", function(subfield) {
72544         return Array.isArray(tags[field.key + ":" + subfield.id]);
72545       }).call(updatePlaceholder);
72546     }
72547     function combinedEntityExtent() {
72548       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
72549     }
72550     address.entityIDs = function(val) {
72551       if (!arguments.length) return _entityIDs;
72552       _entityIDs = val;
72553       return address;
72554     };
72555     address.tags = function(tags) {
72556       _tags = tags;
72557       updateTags(tags);
72558     };
72559     address.focus = function() {
72560       var node = _wrap.selectAll("input").node();
72561       if (node) node.focus();
72562     };
72563     return utilRebind(address, dispatch14, "on");
72564   }
72565
72566   // modules/ui/fields/directional_combo.js
72567   function uiFieldDirectionalCombo(field, context) {
72568     var dispatch14 = dispatch_default("change");
72569     var items = select_default2(null);
72570     var wrap2 = select_default2(null);
72571     var _tags;
72572     var _combos = {};
72573     if (field.type === "cycleway") {
72574       field = __spreadProps(__spreadValues({}, field), {
72575         key: field.keys[0],
72576         keys: field.keys.slice(1)
72577       });
72578     }
72579     function directionalCombo(selection2) {
72580       function stripcolon(s2) {
72581         return s2.replace(":", "");
72582       }
72583       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72584       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72585       var div = wrap2.selectAll("ul").data([0]);
72586       div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
72587       items = div.selectAll("li").data(field.keys);
72588       var enter = items.enter().append("li").attr("class", function(d2) {
72589         return "labeled-input preset-directionalcombo-" + stripcolon(d2);
72590       });
72591       enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
72592         return "preset-input-directionalcombo-" + stripcolon(d2);
72593       }).html(function(d2) {
72594         return field.t.html("types." + d2);
72595       });
72596       enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
72597         const subField = __spreadProps(__spreadValues({}, field), {
72598           type: "combo",
72599           key
72600         });
72601         const combo = uiFieldCombo(subField, context);
72602         combo.on("change", (t2) => change(key, t2[key]));
72603         _combos[key] = combo;
72604         select_default2(this).call(combo);
72605       });
72606       items = items.merge(enter);
72607       wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
72608     }
72609     function change(key, newValue) {
72610       const commonKey = field.key;
72611       const otherCommonKey = field.key.endsWith(":both") ? field.key.replace(/:both$/, "") : "".concat(field.key, ":both");
72612       const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
72613       dispatch14.call("change", this, (tags) => {
72614         const otherValue = tags[otherKey] || tags[commonKey] || tags[otherCommonKey];
72615         if (newValue === otherValue) {
72616           tags[commonKey] = newValue;
72617           delete tags[key];
72618           delete tags[otherKey];
72619           delete tags[otherCommonKey];
72620         } else {
72621           tags[key] = newValue;
72622           delete tags[commonKey];
72623           delete tags[otherCommonKey];
72624           tags[otherKey] = otherValue;
72625         }
72626         return tags;
72627       });
72628     }
72629     directionalCombo.tags = function(tags) {
72630       _tags = tags;
72631       const commonKey = field.key.replace(/:both$/, "");
72632       for (let key in _combos) {
72633         const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags["".concat(commonKey, ":both")]).concat(_tags[key]).filter(Boolean))];
72634         _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
72635       }
72636     };
72637     directionalCombo.focus = function() {
72638       var node = wrap2.selectAll("input").node();
72639       if (node) node.focus();
72640     };
72641     return utilRebind(directionalCombo, dispatch14, "on");
72642   }
72643
72644   // modules/ui/fields/lanes.js
72645   function uiFieldLanes(field, context) {
72646     var dispatch14 = dispatch_default("change");
72647     var LANE_WIDTH = 40;
72648     var LANE_HEIGHT = 200;
72649     var _entityIDs = [];
72650     function lanes(selection2) {
72651       var lanesData = context.entity(_entityIDs[0]).lanes();
72652       if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
72653         selection2.call(lanes.off);
72654         return;
72655       }
72656       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72657       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72658       var surface = wrap2.selectAll(".surface").data([0]);
72659       var d2 = utilGetDimensions(wrap2);
72660       var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
72661       surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
72662       var lanesSelection = surface.selectAll(".lanes").data([0]);
72663       lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
72664       lanesSelection.attr("transform", function() {
72665         return "translate(" + freeSpace / 2 + ", 0)";
72666       });
72667       var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
72668       lane.exit().remove();
72669       var enter = lane.enter().append("g").attr("class", "lane");
72670       enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
72671       enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
72672       enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
72673       enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
72674       lane = lane.merge(enter);
72675       lane.attr("transform", function(d4) {
72676         return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
72677       });
72678       lane.select(".forward").style("visibility", function(d4) {
72679         return d4.direction === "forward" ? "visible" : "hidden";
72680       });
72681       lane.select(".bothways").style("visibility", function(d4) {
72682         return d4.direction === "bothways" ? "visible" : "hidden";
72683       });
72684       lane.select(".backward").style("visibility", function(d4) {
72685         return d4.direction === "backward" ? "visible" : "hidden";
72686       });
72687     }
72688     lanes.entityIDs = function(val) {
72689       _entityIDs = val;
72690     };
72691     lanes.tags = function() {
72692     };
72693     lanes.focus = function() {
72694     };
72695     lanes.off = function() {
72696     };
72697     return utilRebind(lanes, dispatch14, "on");
72698   }
72699   uiFieldLanes.supportsMultiselection = false;
72700
72701   // modules/ui/fields/localized.js
72702   var _languagesArray = [];
72703   var LANGUAGE_SUFFIX_REGEX = /^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/;
72704   function uiFieldLocalized(field, context) {
72705     var dispatch14 = dispatch_default("change", "input");
72706     var wikipedia = services.wikipedia;
72707     var input = select_default2(null);
72708     var localizedInputs = select_default2(null);
72709     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
72710     var _countryCode;
72711     var _tags;
72712     _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
72713     });
72714     var _territoryLanguages = {};
72715     _mainFileFetcher.get("territory_languages").then(function(d2) {
72716       _territoryLanguages = d2;
72717     }).catch(function() {
72718     });
72719     var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
72720     var _selection = select_default2(null);
72721     var _multilingual = [];
72722     var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
72723     var _wikiTitles;
72724     var _entityIDs = [];
72725     function loadLanguagesArray(dataLanguages) {
72726       if (_languagesArray.length !== 0) return;
72727       var replacements = {
72728         sr: "sr-Cyrl",
72729         // in OSM, `sr` implies Cyrillic
72730         "sr-Cyrl": false
72731         // `sr-Cyrl` isn't used in OSM
72732       };
72733       for (var code in dataLanguages) {
72734         if (replacements[code] === false) continue;
72735         var metaCode = code;
72736         if (replacements[code]) metaCode = replacements[code];
72737         _languagesArray.push({
72738           localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
72739           nativeName: dataLanguages[metaCode].nativeName,
72740           code,
72741           label: _mainLocalizer.languageName(metaCode)
72742         });
72743       }
72744     }
72745     function calcLocked() {
72746       var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
72747         var entity = context.graph().hasEntity(entityID);
72748         if (!entity) return false;
72749         if (entity.tags.wikidata) return true;
72750         if (entity.tags["name:etymology:wikidata"]) return true;
72751         var preset = _mainPresetIndex.match(entity, context.graph());
72752         if (preset) {
72753           var isSuggestion = preset.suggestion;
72754           var fields = preset.fields(entity.extent(context.graph()).center());
72755           var showsBrandField = fields.some(function(d2) {
72756             return d2.id === "brand";
72757           });
72758           var showsOperatorField = fields.some(function(d2) {
72759             return d2.id === "operator";
72760           });
72761           var setsName = preset.addTags.name;
72762           var setsBrandWikidata = preset.addTags["brand:wikidata"];
72763           var setsOperatorWikidata = preset.addTags["operator:wikidata"];
72764           return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
72765         }
72766         return false;
72767       });
72768       field.locked(isLocked);
72769     }
72770     function calcMultilingual(tags) {
72771       var existingLangsOrdered = _multilingual.map(function(item2) {
72772         return item2.lang;
72773       });
72774       var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
72775       for (var k2 in tags) {
72776         var m2 = k2.match(LANGUAGE_SUFFIX_REGEX);
72777         if (m2 && m2[1] === field.key && m2[2]) {
72778           var item = { lang: m2[2], value: tags[k2] };
72779           if (existingLangs.has(item.lang)) {
72780             _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
72781             existingLangs.delete(item.lang);
72782           } else {
72783             _multilingual.push(item);
72784           }
72785         }
72786       }
72787       _multilingual.forEach(function(item2) {
72788         if (item2.lang && existingLangs.has(item2.lang)) {
72789           item2.value = "";
72790         }
72791       });
72792     }
72793     function localized(selection2) {
72794       _selection = selection2;
72795       calcLocked();
72796       var isLocked = field.locked();
72797       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72798       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72799       input = wrap2.selectAll(".localized-main").data([0]);
72800       input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
72801       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
72802       wrap2.call(_lengthIndicator);
72803       var translateButton = wrap2.selectAll(".localized-add").data([0]);
72804       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);
72805       translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
72806       if (_tags && !_multilingual.length) {
72807         calcMultilingual(_tags);
72808       }
72809       localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
72810       localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
72811       localizedInputs.call(renderMultilingual);
72812       localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
72813       selection2.selectAll(".combobox-caret").classed("nope", true);
72814       function addNew(d3_event) {
72815         d3_event.preventDefault();
72816         if (field.locked()) return;
72817         var defaultLang = _mainLocalizer.languageCode().toLowerCase();
72818         var langExists = _multilingual.find(function(datum2) {
72819           return datum2.lang === defaultLang;
72820         });
72821         var isLangEn = defaultLang.indexOf("en") > -1;
72822         if (isLangEn || langExists) {
72823           defaultLang = "";
72824           langExists = _multilingual.find(function(datum2) {
72825             return datum2.lang === defaultLang;
72826           });
72827         }
72828         if (!langExists) {
72829           _multilingual.unshift({ lang: defaultLang, value: "" });
72830           localizedInputs.call(renderMultilingual);
72831         }
72832       }
72833       function change(onInput) {
72834         return function(d3_event) {
72835           if (field.locked()) {
72836             d3_event.preventDefault();
72837             return;
72838           }
72839           var val = utilGetSetValue(select_default2(this));
72840           if (!onInput) val = context.cleanTagValue(val);
72841           if (!val && Array.isArray(_tags[field.key])) return;
72842           var t2 = {};
72843           t2[field.key] = val || void 0;
72844           dispatch14.call("change", this, t2, onInput);
72845         };
72846       }
72847     }
72848     function key(lang) {
72849       return field.key + ":" + lang;
72850     }
72851     function changeLang(d3_event, d2) {
72852       var tags = {};
72853       var lang = utilGetSetValue(select_default2(this)).toLowerCase();
72854       var language = _languagesArray.find(function(d4) {
72855         return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
72856       });
72857       if (language) lang = language.code;
72858       if (d2.lang && d2.lang !== lang) {
72859         tags[key(d2.lang)] = void 0;
72860       }
72861       var newKey = lang && context.cleanTagKey(key(lang));
72862       var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
72863       if (newKey && value) {
72864         tags[newKey] = value;
72865       } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
72866         tags[newKey] = _wikiTitles[d2.lang];
72867       }
72868       d2.lang = lang;
72869       dispatch14.call("change", this, tags);
72870     }
72871     function changeValue(d3_event, d2) {
72872       if (!d2.lang) return;
72873       var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
72874       if (!value && Array.isArray(d2.value)) return;
72875       var t2 = {};
72876       t2[key(d2.lang)] = value;
72877       d2.value = value;
72878       dispatch14.call("change", this, t2);
72879     }
72880     function fetchLanguages(value, cb) {
72881       var v2 = value.toLowerCase();
72882       var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
72883       if (_countryCode && _territoryLanguages[_countryCode]) {
72884         langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
72885       }
72886       var langItems = [];
72887       langCodes.forEach(function(code) {
72888         var langItem = _languagesArray.find(function(item) {
72889           return item.code === code;
72890         });
72891         if (langItem) langItems.push(langItem);
72892       });
72893       langItems = utilArrayUniq(langItems.concat(_languagesArray));
72894       cb(langItems.filter(function(d2) {
72895         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;
72896       }).map(function(d2) {
72897         return { value: d2.label };
72898       }));
72899     }
72900     function renderMultilingual(selection2) {
72901       var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
72902         return d2.lang;
72903       });
72904       entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
72905       var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
72906         var wrap2 = select_default2(this);
72907         var domId = utilUniqueDomId(index);
72908         var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
72909         var text = label.append("span").attr("class", "label-text");
72910         text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
72911         text.append("span").attr("class", "label-textannotation");
72912         label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
72913           if (field.locked()) return;
72914           d3_event.preventDefault();
72915           _multilingual.splice(_multilingual.indexOf(d2), 1);
72916           var langKey = d2.lang && key(d2.lang);
72917           if (langKey && langKey in _tags) {
72918             delete _tags[langKey];
72919             var t2 = {};
72920             t2[langKey] = void 0;
72921             dispatch14.call("change", this, t2);
72922             return;
72923           }
72924           renderMultilingual(selection2);
72925         }).call(svgIcon("#iD-operation-delete"));
72926         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);
72927         wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
72928       });
72929       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() {
72930         select_default2(this).style("max-height", "").style("overflow", "visible");
72931       });
72932       entries = entries.merge(entriesEnter);
72933       entries.order();
72934       entries.classed("present", true);
72935       utilGetSetValue(entries.select(".localized-lang"), function(d2) {
72936         var langItem = _languagesArray.find(function(item) {
72937           return item.code === d2.lang;
72938         });
72939         if (langItem) return langItem.label;
72940         return d2.lang;
72941       });
72942       utilGetSetValue(entries.select(".localized-value"), function(d2) {
72943         return typeof d2.value === "string" ? d2.value : "";
72944       }).attr("title", function(d2) {
72945         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
72946       }).attr("placeholder", function(d2) {
72947         return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
72948       }).attr("lang", function(d2) {
72949         return d2.lang;
72950       }).classed("mixed", function(d2) {
72951         return Array.isArray(d2.value);
72952       });
72953     }
72954     localized.tags = function(tags) {
72955       _tags = tags;
72956       if (typeof tags.wikipedia === "string" && !_wikiTitles) {
72957         _wikiTitles = {};
72958         var wm = tags.wikipedia.match(/([^:]+):(.+)/);
72959         if (wm && wm[0] && wm[1]) {
72960           wikipedia.translations(wm[1], wm[2], function(err, d2) {
72961             if (err || !d2) return;
72962             _wikiTitles = d2;
72963           });
72964         }
72965       }
72966       var isMixed = Array.isArray(tags[field.key]);
72967       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);
72968       calcMultilingual(tags);
72969       _selection.call(localized);
72970       if (!isMixed) {
72971         _lengthIndicator.update(tags[field.key]);
72972       }
72973     };
72974     localized.focus = function() {
72975       input.node().focus();
72976     };
72977     localized.entityIDs = function(val) {
72978       if (!arguments.length) return _entityIDs;
72979       _entityIDs = val;
72980       _multilingual = [];
72981       loadCountryCode();
72982       return localized;
72983     };
72984     function loadCountryCode() {
72985       var extent = combinedEntityExtent();
72986       var countryCode = extent && iso1A2Code(extent.center());
72987       _countryCode = countryCode && countryCode.toLowerCase();
72988     }
72989     function combinedEntityExtent() {
72990       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
72991     }
72992     return utilRebind(localized, dispatch14, "on");
72993   }
72994
72995   // modules/ui/fields/roadheight.js
72996   function uiFieldRoadheight(field, context) {
72997     var dispatch14 = dispatch_default("change");
72998     var primaryUnitInput = select_default2(null);
72999     var primaryInput = select_default2(null);
73000     var secondaryInput = select_default2(null);
73001     var secondaryUnitInput = select_default2(null);
73002     var _entityIDs = [];
73003     var _tags;
73004     var _isImperial;
73005     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
73006     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
73007     var primaryUnits = [
73008       {
73009         value: "m",
73010         title: _t("inspector.roadheight.meter")
73011       },
73012       {
73013         value: "ft",
73014         title: _t("inspector.roadheight.foot")
73015       }
73016     ];
73017     var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
73018     function roadheight(selection2) {
73019       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73020       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
73021       primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
73022       primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
73023       primaryInput.on("change", change).on("blur", change);
73024       var loc = combinedEntityExtent().center();
73025       _isImperial = roadHeightUnit(loc) === "ft";
73026       primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
73027       primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
73028       primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
73029       secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
73030       secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
73031       secondaryInput.on("change", change).on("blur", change);
73032       secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
73033       secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
73034       function changeUnits() {
73035         var primaryUnit = utilGetSetValue(primaryUnitInput);
73036         if (primaryUnit === "m") {
73037           _isImperial = false;
73038         } else if (primaryUnit === "ft") {
73039           _isImperial = true;
73040         }
73041         utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
73042         setUnitSuggestions();
73043         change();
73044       }
73045     }
73046     function setUnitSuggestions() {
73047       utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
73048     }
73049     function change() {
73050       var tag2 = {};
73051       var primaryValue = utilGetSetValue(primaryInput).trim();
73052       var secondaryValue = utilGetSetValue(secondaryInput).trim();
73053       if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key])) return;
73054       if (!primaryValue && !secondaryValue) {
73055         tag2[field.key] = void 0;
73056       } else {
73057         var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
73058         if (isNaN(rawPrimaryValue)) rawPrimaryValue = primaryValue;
73059         var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
73060         if (isNaN(rawSecondaryValue)) rawSecondaryValue = secondaryValue;
73061         if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
73062           tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
73063         } else {
73064           if (rawPrimaryValue !== "") {
73065             rawPrimaryValue = rawPrimaryValue + "'";
73066           }
73067           if (rawSecondaryValue !== "") {
73068             rawSecondaryValue = rawSecondaryValue + '"';
73069           }
73070           tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
73071         }
73072       }
73073       dispatch14.call("change", this, tag2);
73074     }
73075     roadheight.tags = function(tags) {
73076       _tags = tags;
73077       var primaryValue = tags[field.key];
73078       var secondaryValue;
73079       var isMixed = Array.isArray(primaryValue);
73080       if (!isMixed) {
73081         if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
73082           secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
73083           if (secondaryValue !== null) {
73084             secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
73085           }
73086           primaryValue = primaryValue.match(/(-?[\d.]+)'/);
73087           if (primaryValue !== null) {
73088             primaryValue = formatFloat(parseFloat(primaryValue[1]));
73089           }
73090           _isImperial = true;
73091         } else if (primaryValue) {
73092           var rawValue = primaryValue;
73093           primaryValue = parseFloat(rawValue);
73094           if (isNaN(primaryValue)) {
73095             primaryValue = rawValue;
73096           } else {
73097             primaryValue = formatFloat(primaryValue);
73098           }
73099           _isImperial = false;
73100         }
73101       }
73102       setUnitSuggestions();
73103       var inchesPlaceholder = formatFloat(0);
73104       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);
73105       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");
73106       secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
73107     };
73108     roadheight.focus = function() {
73109       primaryInput.node().focus();
73110     };
73111     roadheight.entityIDs = function(val) {
73112       _entityIDs = val;
73113     };
73114     function combinedEntityExtent() {
73115       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
73116     }
73117     return utilRebind(roadheight, dispatch14, "on");
73118   }
73119
73120   // modules/ui/fields/roadspeed.js
73121   function uiFieldRoadspeed(field, context) {
73122     var dispatch14 = dispatch_default("change");
73123     var unitInput = select_default2(null);
73124     var input = select_default2(null);
73125     var _entityIDs = [];
73126     var _tags;
73127     var _isImperial;
73128     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
73129     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
73130     var speedCombo = uiCombobox(context, "roadspeed");
73131     var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
73132     var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
73133     var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
73134     function roadspeed(selection2) {
73135       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73136       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
73137       input = wrap2.selectAll("input.roadspeed-number").data([0]);
73138       input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
73139       input.on("change", change).on("blur", change);
73140       var loc = combinedEntityExtent().center();
73141       _isImperial = roadSpeedUnit(loc) === "mph";
73142       unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
73143       unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
73144       unitInput.on("blur", changeUnits).on("change", changeUnits);
73145       function changeUnits() {
73146         var unit2 = utilGetSetValue(unitInput);
73147         if (unit2 === "km/h") {
73148           _isImperial = false;
73149         } else if (unit2 === "mph") {
73150           _isImperial = true;
73151         }
73152         utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
73153         setUnitSuggestions();
73154         change();
73155       }
73156     }
73157     function setUnitSuggestions() {
73158       speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
73159       utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
73160     }
73161     function comboValues(d2) {
73162       return {
73163         value: formatFloat(d2),
73164         title: formatFloat(d2)
73165       };
73166     }
73167     function change() {
73168       var tag2 = {};
73169       var value = utilGetSetValue(input).trim();
73170       if (!value && Array.isArray(_tags[field.key])) return;
73171       if (!value) {
73172         tag2[field.key] = void 0;
73173       } else {
73174         var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
73175         if (isNaN(rawValue)) rawValue = value;
73176         if (isNaN(rawValue) || !_isImperial) {
73177           tag2[field.key] = context.cleanTagValue(rawValue);
73178         } else {
73179           tag2[field.key] = context.cleanTagValue(rawValue + " mph");
73180         }
73181       }
73182       dispatch14.call("change", this, tag2);
73183     }
73184     roadspeed.tags = function(tags) {
73185       _tags = tags;
73186       var rawValue = tags[field.key];
73187       var value = rawValue;
73188       var isMixed = Array.isArray(value);
73189       if (!isMixed) {
73190         if (rawValue && rawValue.indexOf("mph") >= 0) {
73191           _isImperial = true;
73192         } else if (rawValue) {
73193           _isImperial = false;
73194         }
73195         value = parseInt(value, 10);
73196         if (isNaN(value)) {
73197           value = rawValue;
73198         } else {
73199           value = formatFloat(value);
73200         }
73201       }
73202       setUnitSuggestions();
73203       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);
73204     };
73205     roadspeed.focus = function() {
73206       input.node().focus();
73207     };
73208     roadspeed.entityIDs = function(val) {
73209       _entityIDs = val;
73210     };
73211     function combinedEntityExtent() {
73212       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
73213     }
73214     return utilRebind(roadspeed, dispatch14, "on");
73215   }
73216
73217   // modules/ui/fields/radio.js
73218   function uiFieldRadio(field, context) {
73219     var dispatch14 = dispatch_default("change");
73220     var placeholder = select_default2(null);
73221     var wrap2 = select_default2(null);
73222     var labels = select_default2(null);
73223     var radios = select_default2(null);
73224     var radioData = (field.options || field.keys).slice();
73225     var typeField;
73226     var layerField;
73227     var _oldType = {};
73228     var _entityIDs = [];
73229     function selectedKey() {
73230       var node = wrap2.selectAll(".form-field-input-radio label.active input");
73231       return !node.empty() && node.datum();
73232     }
73233     function radio(selection2) {
73234       selection2.classed("preset-radio", true);
73235       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73236       var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
73237       enter.append("span").attr("class", "placeholder");
73238       wrap2 = wrap2.merge(enter);
73239       placeholder = wrap2.selectAll(".placeholder");
73240       labels = wrap2.selectAll("label").data(radioData);
73241       enter = labels.enter().append("label");
73242       var stringsField = field.resolveReference("stringsCrossReference");
73243       enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
73244         return stringsField.t("options." + d2, { "default": d2 });
73245       }).attr("checked", false);
73246       enter.append("span").each(function(d2) {
73247         stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
73248       });
73249       labels = labels.merge(enter);
73250       radios = labels.selectAll("input").on("change", changeRadio);
73251     }
73252     function structureExtras(selection2, tags) {
73253       var selected = selectedKey() || tags.layer !== void 0;
73254       var type2 = _mainPresetIndex.field(selected);
73255       var layer = _mainPresetIndex.field("layer");
73256       var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
73257       var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
73258       extrasWrap.exit().remove();
73259       extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
73260       var list2 = extrasWrap.selectAll("ul").data([0]);
73261       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
73262       if (type2) {
73263         if (!typeField || typeField.id !== selected) {
73264           typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
73265         }
73266         typeField.tags(tags);
73267       } else {
73268         typeField = null;
73269       }
73270       var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
73271         return d2.id;
73272       });
73273       typeItem.exit().remove();
73274       var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
73275       typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
73276       typeEnter.append("div").attr("class", "structure-input-type-wrap");
73277       typeItem = typeItem.merge(typeEnter);
73278       if (typeField) {
73279         typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
73280       }
73281       if (layer && showLayer) {
73282         if (!layerField) {
73283           layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
73284         }
73285         layerField.tags(tags);
73286         field.keys = utilArrayUnion(field.keys, ["layer"]);
73287       } else {
73288         layerField = null;
73289         field.keys = field.keys.filter(function(k2) {
73290           return k2 !== "layer";
73291         });
73292       }
73293       var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
73294       layerItem.exit().remove();
73295       var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
73296       layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
73297       layerEnter.append("div").attr("class", "structure-input-layer-wrap");
73298       layerItem = layerItem.merge(layerEnter);
73299       if (layerField) {
73300         layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
73301       }
73302     }
73303     function changeType(t2, onInput) {
73304       var key = selectedKey();
73305       if (!key) return;
73306       var val = t2[key];
73307       if (val !== "no") {
73308         _oldType[key] = val;
73309       }
73310       if (field.type === "structureRadio") {
73311         if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
73312           t2.layer = void 0;
73313         }
73314         if (t2.layer === void 0) {
73315           if (key === "bridge" && val !== "no") {
73316             t2.layer = "1";
73317           }
73318           if (key === "tunnel" && val !== "no" && val !== "building_passage") {
73319             t2.layer = "-1";
73320           }
73321         }
73322       }
73323       dispatch14.call("change", this, t2, onInput);
73324     }
73325     function changeLayer(t2, onInput) {
73326       if (t2.layer === "0") {
73327         t2.layer = void 0;
73328       }
73329       dispatch14.call("change", this, t2, onInput);
73330     }
73331     function changeRadio() {
73332       var t2 = {};
73333       var activeKey;
73334       if (field.key) {
73335         t2[field.key] = void 0;
73336       }
73337       radios.each(function(d2) {
73338         var active = select_default2(this).property("checked");
73339         if (active) activeKey = d2;
73340         if (field.key) {
73341           if (active) t2[field.key] = d2;
73342         } else {
73343           var val = _oldType[activeKey] || "yes";
73344           t2[d2] = active ? val : void 0;
73345         }
73346       });
73347       if (field.type === "structureRadio") {
73348         if (activeKey === "bridge") {
73349           t2.layer = "1";
73350         } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
73351           t2.layer = "-1";
73352         } else {
73353           t2.layer = void 0;
73354         }
73355       }
73356       dispatch14.call("change", this, t2);
73357     }
73358     radio.tags = function(tags) {
73359       function isOptionChecked(d2) {
73360         if (field.key) {
73361           return tags[field.key] === d2;
73362         }
73363         return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
73364       }
73365       function isMixed(d2) {
73366         if (field.key) {
73367           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
73368         }
73369         return Array.isArray(tags[d2]);
73370       }
73371       radios.property("checked", function(d2) {
73372         return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
73373       });
73374       labels.classed("active", function(d2) {
73375         if (field.key) {
73376           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
73377         }
73378         return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
73379       }).classed("mixed", isMixed).attr("title", function(d2) {
73380         return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
73381       });
73382       var selection2 = radios.filter(function() {
73383         return this.checked;
73384       });
73385       if (selection2.empty()) {
73386         placeholder.text("");
73387         placeholder.call(_t.append("inspector.none"));
73388       } else {
73389         placeholder.text(selection2.attr("value"));
73390         _oldType[selection2.datum()] = tags[selection2.datum()];
73391       }
73392       if (field.type === "structureRadio") {
73393         if (!!tags.waterway && !_oldType.tunnel) {
73394           _oldType.tunnel = "culvert";
73395         }
73396         if (!!tags.waterway && !_oldType.bridge) {
73397           _oldType.bridge = "aqueduct";
73398         }
73399         wrap2.call(structureExtras, tags);
73400       }
73401     };
73402     radio.focus = function() {
73403       radios.node().focus();
73404     };
73405     radio.entityIDs = function(val) {
73406       if (!arguments.length) return _entityIDs;
73407       _entityIDs = val;
73408       _oldType = {};
73409       return radio;
73410     };
73411     radio.isAllowed = function() {
73412       return _entityIDs.length === 1;
73413     };
73414     return utilRebind(radio, dispatch14, "on");
73415   }
73416
73417   // modules/ui/fields/restrictions.js
73418   function uiFieldRestrictions(field, context) {
73419     var dispatch14 = dispatch_default("change");
73420     var breathe = behaviorBreathe(context);
73421     corePreferences("turn-restriction-via-way", null);
73422     var storedViaWay = corePreferences("turn-restriction-via-way0");
73423     var storedDistance = corePreferences("turn-restriction-distance");
73424     var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
73425     var _maxDistance = storedDistance ? +storedDistance : 30;
73426     var _initialized3 = false;
73427     var _parent = select_default2(null);
73428     var _container = select_default2(null);
73429     var _oldTurns;
73430     var _graph;
73431     var _vertexID;
73432     var _intersection;
73433     var _fromWayID;
73434     var _lastXPos;
73435     function restrictions(selection2) {
73436       _parent = selection2;
73437       if (_vertexID && (context.graph() !== _graph || !_intersection)) {
73438         _graph = context.graph();
73439         _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
73440       }
73441       var isOK = _intersection && _intersection.vertices.length && // has vertices
73442       _intersection.vertices.filter(function(vertex) {
73443         return vertex.id === _vertexID;
73444       }).length && _intersection.ways.length > 2;
73445       select_default2(selection2.node().parentNode).classed("hide", !isOK);
73446       if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
73447         selection2.call(restrictions.off);
73448         return;
73449       }
73450       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73451       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
73452       var container = wrap2.selectAll(".restriction-container").data([0]);
73453       var containerEnter = container.enter().append("div").attr("class", "restriction-container");
73454       containerEnter.append("div").attr("class", "restriction-help");
73455       _container = containerEnter.merge(container).call(renderViewer);
73456       var controls = wrap2.selectAll(".restriction-controls").data([0]);
73457       controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
73458     }
73459     function renderControls(selection2) {
73460       var distControl = selection2.selectAll(".restriction-distance").data([0]);
73461       distControl.exit().remove();
73462       var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
73463       distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
73464       distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
73465       distControlEnter.append("span").attr("class", "restriction-distance-text");
73466       selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
73467         var val = select_default2(this).property("value");
73468         _maxDistance = +val;
73469         _intersection = null;
73470         _container.selectAll(".layer-osm .layer-turns *").remove();
73471         corePreferences("turn-restriction-distance", _maxDistance);
73472         _parent.call(restrictions);
73473       });
73474       selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
73475       var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
73476       viaControl.exit().remove();
73477       var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
73478       viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
73479       viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
73480       viaControlEnter.append("span").attr("class", "restriction-via-way-text");
73481       selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
73482         var val = select_default2(this).property("value");
73483         _maxViaWay = +val;
73484         _container.selectAll(".layer-osm .layer-turns *").remove();
73485         corePreferences("turn-restriction-via-way0", _maxViaWay);
73486         _parent.call(restrictions);
73487       });
73488       selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
73489     }
73490     function renderViewer(selection2) {
73491       if (!_intersection) return;
73492       var vgraph = _intersection.graph;
73493       var filter2 = utilFunctor(true);
73494       var projection2 = geoRawMercator();
73495       var sdims = utilGetDimensions(context.container().select(".sidebar"));
73496       var d2 = [sdims[0] - 50, 370];
73497       var c2 = geoVecScale(d2, 0.5);
73498       var z2 = 22;
73499       projection2.scale(geoZoomToScale(z2));
73500       var extent = geoExtent();
73501       for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
73502         extent._extend(_intersection.vertices[i3].extent());
73503       }
73504       var padTop = 35;
73505       if (_intersection.vertices.length > 1) {
73506         var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
73507         var vPadding = 160;
73508         var tl = projection2([extent[0][0], extent[1][1]]);
73509         var br2 = projection2([extent[1][0], extent[0][1]]);
73510         var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
73511         var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
73512         var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
73513         var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
73514         z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
73515         projection2.scale(geoZoomToScale(z2));
73516       }
73517       var extentCenter = projection2(extent.center());
73518       extentCenter[1] = extentCenter[1] - padTop / 2;
73519       projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
73520       var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
73521       var drawVertices = svgVertices(projection2, context);
73522       var drawLines = svgLines(projection2, context);
73523       var drawTurns = svgTurns(projection2, context);
73524       var firstTime = selection2.selectAll(".surface").empty();
73525       selection2.call(drawLayers);
73526       var surface = selection2.selectAll(".surface").classed("tr", true);
73527       if (firstTime) {
73528         _initialized3 = true;
73529         surface.call(breathe);
73530       }
73531       if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
73532         _fromWayID = null;
73533         _oldTurns = null;
73534       }
73535       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));
73536       surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
73537       surface.selectAll(".selected").classed("selected", false);
73538       surface.selectAll(".related").classed("related", false);
73539       var way;
73540       if (_fromWayID) {
73541         way = vgraph.entity(_fromWayID);
73542         surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
73543       }
73544       document.addEventListener("resizeWindow", function() {
73545         utilSetDimensions(_container, null);
73546         redraw(1);
73547       }, false);
73548       updateHints(null);
73549       function click(d3_event) {
73550         surface.call(breathe.off).call(breathe);
73551         var datum2 = d3_event.target.__data__;
73552         var entity = datum2 && datum2.properties && datum2.properties.entity;
73553         if (entity) {
73554           datum2 = entity;
73555         }
73556         if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
73557           _fromWayID = datum2.id;
73558           _oldTurns = null;
73559           redraw();
73560         } else if (datum2 instanceof osmTurn) {
73561           var actions, extraActions, turns, i4;
73562           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
73563           if (datum2.restrictionID && !datum2.direct) {
73564             return;
73565           } else if (datum2.restrictionID && !datum2.only) {
73566             var seen = {};
73567             var datumOnly = JSON.parse(JSON.stringify(datum2));
73568             datumOnly.only = true;
73569             restrictionType = restrictionType.replace(/^no/, "only");
73570             turns = _intersection.turns(_fromWayID, 2);
73571             extraActions = [];
73572             _oldTurns = [];
73573             for (i4 = 0; i4 < turns.length; i4++) {
73574               var turn = turns[i4];
73575               if (seen[turn.restrictionID]) continue;
73576               if (turn.direct && turn.path[1] === datum2.path[1]) {
73577                 seen[turns[i4].restrictionID] = true;
73578                 turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
73579                 _oldTurns.push(turn);
73580                 extraActions.push(actionUnrestrictTurn(turn));
73581               }
73582             }
73583             actions = _intersection.actions.concat(extraActions, [
73584               actionRestrictTurn(datumOnly, restrictionType),
73585               _t("operations.restriction.annotation.create")
73586             ]);
73587           } else if (datum2.restrictionID) {
73588             turns = _oldTurns || [];
73589             extraActions = [];
73590             for (i4 = 0; i4 < turns.length; i4++) {
73591               if (turns[i4].key !== datum2.key) {
73592                 extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
73593               }
73594             }
73595             _oldTurns = null;
73596             actions = _intersection.actions.concat(extraActions, [
73597               actionUnrestrictTurn(datum2),
73598               _t("operations.restriction.annotation.delete")
73599             ]);
73600           } else {
73601             actions = _intersection.actions.concat([
73602               actionRestrictTurn(datum2, restrictionType),
73603               _t("operations.restriction.annotation.create")
73604             ]);
73605           }
73606           context.perform.apply(context, actions);
73607           var s2 = surface.selectAll("." + datum2.key);
73608           datum2 = s2.empty() ? null : s2.datum();
73609           updateHints(datum2);
73610         } else {
73611           _fromWayID = null;
73612           _oldTurns = null;
73613           redraw();
73614         }
73615       }
73616       function mouseover(d3_event) {
73617         var datum2 = d3_event.target.__data__;
73618         updateHints(datum2);
73619       }
73620       _lastXPos = _lastXPos || sdims[0];
73621       function redraw(minChange) {
73622         var xPos = -1;
73623         if (minChange) {
73624           xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
73625         }
73626         if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
73627           if (context.hasEntity(_vertexID)) {
73628             _lastXPos = xPos;
73629             _container.call(renderViewer);
73630           }
73631         }
73632       }
73633       function highlightPathsFrom(wayID) {
73634         surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
73635         surface.selectAll("." + wayID).classed("related", true);
73636         if (wayID) {
73637           var turns = _intersection.turns(wayID, _maxViaWay);
73638           for (var i4 = 0; i4 < turns.length; i4++) {
73639             var turn = turns[i4];
73640             var ids = [turn.to.way];
73641             var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
73642             if (turn.only || turns.length === 1) {
73643               if (turn.via.ways) {
73644                 ids = ids.concat(turn.via.ways);
73645               }
73646             } else if (turn.to.way === wayID) {
73647               continue;
73648             }
73649             surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
73650           }
73651         }
73652       }
73653       function updateHints(datum2) {
73654         var help = _container.selectAll(".restriction-help").html("");
73655         var placeholders = {};
73656         ["from", "via", "to"].forEach(function(k2) {
73657           placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
73658         });
73659         var entity = datum2 && datum2.properties && datum2.properties.entity;
73660         if (entity) {
73661           datum2 = entity;
73662         }
73663         if (_fromWayID) {
73664           way = vgraph.entity(_fromWayID);
73665           surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
73666         }
73667         if (datum2 instanceof osmWay && datum2.__from) {
73668           way = datum2;
73669           highlightPathsFrom(_fromWayID ? null : way.id);
73670           surface.selectAll("." + way.id).classed("related", true);
73671           var clickSelect = !_fromWayID || _fromWayID !== way.id;
73672           help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
73673             from: placeholders.from,
73674             fromName: displayName(way.id, vgraph)
73675           }));
73676         } else if (datum2 instanceof osmTurn) {
73677           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
73678           var turnType = restrictionType.replace(/^(only|no)\_/, "");
73679           var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
73680           var klass, turnText, nextText;
73681           if (datum2.no) {
73682             klass = "restrict";
73683             turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
73684             nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
73685           } else if (datum2.only) {
73686             klass = "only";
73687             turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
73688             nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
73689           } else {
73690             klass = "allow";
73691             turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
73692             nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
73693           }
73694           help.append("div").attr("class", "qualifier " + klass).html(turnText);
73695           help.append("div").html(_t.html("restriction.help.from_name_to_name", {
73696             from: placeholders.from,
73697             fromName: displayName(datum2.from.way, vgraph),
73698             to: placeholders.to,
73699             toName: displayName(datum2.to.way, vgraph)
73700           }));
73701           if (datum2.via.ways && datum2.via.ways.length) {
73702             var names = [];
73703             for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
73704               var prev = names[names.length - 1];
73705               var curr = displayName(datum2.via.ways[i4], vgraph);
73706               if (!prev || curr !== prev) {
73707                 names.push(curr);
73708               }
73709             }
73710             help.append("div").html(_t.html("restriction.help.via_names", {
73711               via: placeholders.via,
73712               viaNames: names.join(", ")
73713             }));
73714           }
73715           if (!indirect) {
73716             help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
73717           }
73718           highlightPathsFrom(null);
73719           var alongIDs = datum2.path.slice();
73720           surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
73721         } else {
73722           highlightPathsFrom(null);
73723           if (_fromWayID) {
73724             help.append("div").html(_t.html("restriction.help.from_name", {
73725               from: placeholders.from,
73726               fromName: displayName(_fromWayID, vgraph)
73727             }));
73728           } else {
73729             help.append("div").html(_t.html("restriction.help.select_from", {
73730               from: placeholders.from
73731             }));
73732           }
73733         }
73734       }
73735     }
73736     function displayMaxDistance(maxDist) {
73737       return (selection2) => {
73738         var isImperial = !_mainLocalizer.usesMetric();
73739         var opts;
73740         if (isImperial) {
73741           var distToFeet = {
73742             // imprecise conversion for prettier display
73743             20: 70,
73744             25: 85,
73745             30: 100,
73746             35: 115,
73747             40: 130,
73748             45: 145,
73749             50: 160
73750           }[maxDist];
73751           opts = { distance: _t("units.feet", { quantity: distToFeet }) };
73752         } else {
73753           opts = { distance: _t("units.meters", { quantity: maxDist }) };
73754         }
73755         return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
73756       };
73757     }
73758     function displayMaxVia(maxVia) {
73759       return (selection2) => {
73760         selection2 = selection2.html("");
73761         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"));
73762       };
73763     }
73764     function displayName(entityID, graph) {
73765       var entity = graph.entity(entityID);
73766       var name = utilDisplayName(entity) || "";
73767       var matched = _mainPresetIndex.match(entity, graph);
73768       var type2 = matched && matched.name() || utilDisplayType(entity.id);
73769       return name || type2;
73770     }
73771     restrictions.entityIDs = function(val) {
73772       _intersection = null;
73773       _fromWayID = null;
73774       _oldTurns = null;
73775       _vertexID = val[0];
73776     };
73777     restrictions.tags = function() {
73778     };
73779     restrictions.focus = function() {
73780     };
73781     restrictions.off = function(selection2) {
73782       if (!_initialized3) return;
73783       selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
73784       select_default2(window).on("resize.restrictions", null);
73785     };
73786     return utilRebind(restrictions, dispatch14, "on");
73787   }
73788   uiFieldRestrictions.supportsMultiselection = false;
73789
73790   // modules/ui/fields/textarea.js
73791   function uiFieldTextarea(field, context) {
73792     var dispatch14 = dispatch_default("change");
73793     var input = select_default2(null);
73794     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
73795     var _tags;
73796     function textarea(selection2) {
73797       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73798       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
73799       input = wrap2.selectAll("textarea").data([0]);
73800       input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
73801       wrap2.call(_lengthIndicator);
73802       function change(onInput) {
73803         return function() {
73804           var val = utilGetSetValue(input);
73805           if (!onInput) val = context.cleanTagValue(val);
73806           if (!val && Array.isArray(_tags[field.key])) return;
73807           var t2 = {};
73808           t2[field.key] = val || void 0;
73809           dispatch14.call("change", this, t2, onInput);
73810         };
73811       }
73812     }
73813     textarea.tags = function(tags) {
73814       _tags = tags;
73815       var isMixed = Array.isArray(tags[field.key]);
73816       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);
73817       if (!isMixed) {
73818         _lengthIndicator.update(tags[field.key]);
73819       }
73820     };
73821     textarea.focus = function() {
73822       input.node().focus();
73823     };
73824     return utilRebind(textarea, dispatch14, "on");
73825   }
73826
73827   // modules/ui/fields/wikidata.js
73828   function uiFieldWikidata(field, context) {
73829     var wikidata = services.wikidata;
73830     var dispatch14 = dispatch_default("change");
73831     var _selection = select_default2(null);
73832     var _searchInput = select_default2(null);
73833     var _qid = null;
73834     var _wikidataEntity = null;
73835     var _wikiURL = "";
73836     var _entityIDs = [];
73837     var _wikipediaKey = field.keys && field.keys.find(function(key) {
73838       return key.includes("wikipedia");
73839     });
73840     var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
73841     var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
73842     function wiki(selection2) {
73843       _selection = selection2;
73844       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73845       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
73846       var list2 = wrap2.selectAll("ul").data([0]);
73847       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
73848       var searchRow = list2.selectAll("li.wikidata-search").data([0]);
73849       var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
73850       searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
73851         var node = select_default2(this).node();
73852         node.setSelectionRange(0, node.value.length);
73853       }).on("blur", function() {
73854         setLabelForEntity();
73855       }).call(combobox.fetcher(fetchWikidataItems));
73856       combobox.on("accept", function(d2) {
73857         if (d2) {
73858           _qid = d2.id;
73859           change();
73860         }
73861       }).on("cancel", function() {
73862         setLabelForEntity();
73863       });
73864       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) {
73865         d3_event.preventDefault();
73866         if (_wikiURL) window.open(_wikiURL, "_blank");
73867       });
73868       searchRow = searchRow.merge(searchRowEnter);
73869       _searchInput = searchRow.select("input");
73870       var wikidataProperties = ["description", "identifier"];
73871       var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
73872       var enter = items.enter().append("li").attr("class", function(d2) {
73873         return "labeled-input preset-wikidata-" + d2;
73874       });
73875       enter.append("div").attr("class", "label").html(function(d2) {
73876         return _t.html("wikidata." + d2);
73877       });
73878       enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
73879       enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
73880         d3_event.preventDefault();
73881         select_default2(this.parentNode).select("input").node().select();
73882         document.execCommand("copy");
73883       });
73884     }
73885     function fetchWikidataItems(q2, callback) {
73886       if (!q2 && _hintKey) {
73887         for (var i3 in _entityIDs) {
73888           var entity = context.hasEntity(_entityIDs[i3]);
73889           if (entity.tags[_hintKey]) {
73890             q2 = entity.tags[_hintKey];
73891             break;
73892           }
73893         }
73894       }
73895       wikidata.itemsForSearchQuery(q2, function(err, data) {
73896         if (err) {
73897           if (err !== "No query") console.error(err);
73898           return;
73899         }
73900         var result = data.map(function(item) {
73901           return {
73902             id: item.id,
73903             value: item.display.label.value + " (" + item.id + ")",
73904             display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
73905             title: item.display.description && item.display.description.value,
73906             terms: item.aliases
73907           };
73908         });
73909         if (callback) callback(result);
73910       });
73911     }
73912     function change() {
73913       var syncTags = {};
73914       syncTags[field.key] = _qid;
73915       dispatch14.call("change", this, syncTags);
73916       var initGraph = context.graph();
73917       var initEntityIDs = _entityIDs;
73918       wikidata.entityByQID(_qid, function(err, entity) {
73919         if (err) return;
73920         if (context.graph() !== initGraph) return;
73921         if (!entity.sitelinks) return;
73922         var langs = wikidata.languagesToQuery();
73923         ["labels", "descriptions"].forEach(function(key) {
73924           if (!entity[key]) return;
73925           var valueLangs = Object.keys(entity[key]);
73926           if (valueLangs.length === 0) return;
73927           var valueLang = valueLangs[0];
73928           if (langs.indexOf(valueLang) === -1) {
73929             langs.push(valueLang);
73930           }
73931         });
73932         var newWikipediaValue;
73933         if (_wikipediaKey) {
73934           var foundPreferred;
73935           for (var i3 in langs) {
73936             var lang = langs[i3];
73937             var siteID = lang.replace("-", "_") + "wiki";
73938             if (entity.sitelinks[siteID]) {
73939               foundPreferred = true;
73940               newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
73941               break;
73942             }
73943           }
73944           if (!foundPreferred) {
73945             var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
73946               return site.endsWith("wiki");
73947             });
73948             if (wikiSiteKeys.length === 0) {
73949               newWikipediaValue = null;
73950             } else {
73951               var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
73952               var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
73953               newWikipediaValue = wikiLang + ":" + wikiTitle;
73954             }
73955           }
73956         }
73957         if (newWikipediaValue) {
73958           newWikipediaValue = context.cleanTagValue(newWikipediaValue);
73959         }
73960         if (typeof newWikipediaValue === "undefined") return;
73961         var actions = initEntityIDs.map(function(entityID) {
73962           var entity2 = context.hasEntity(entityID);
73963           if (!entity2) return null;
73964           var currTags = Object.assign({}, entity2.tags);
73965           if (newWikipediaValue === null) {
73966             if (!currTags[_wikipediaKey]) return null;
73967             delete currTags[_wikipediaKey];
73968           } else {
73969             currTags[_wikipediaKey] = newWikipediaValue;
73970           }
73971           return actionChangeTags(entityID, currTags);
73972         }).filter(Boolean);
73973         if (!actions.length) return;
73974         context.overwrite(
73975           function actionUpdateWikipediaTags(graph) {
73976             actions.forEach(function(action) {
73977               graph = action(graph);
73978             });
73979             return graph;
73980           },
73981           context.history().undoAnnotation()
73982         );
73983       });
73984     }
73985     function setLabelForEntity() {
73986       var label = {
73987         value: ""
73988       };
73989       if (_wikidataEntity) {
73990         label = entityPropertyForDisplay(_wikidataEntity, "labels");
73991         if (label.value.length === 0) {
73992           label.value = _wikidataEntity.id.toString();
73993         }
73994       }
73995       utilGetSetValue(_searchInput, label.value).attr("lang", label.language);
73996     }
73997     wiki.tags = function(tags) {
73998       var isMixed = Array.isArray(tags[field.key]);
73999       _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
74000       _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
74001       if (!/^Q[0-9]*$/.test(_qid)) {
74002         unrecognized();
74003         return;
74004       }
74005       _wikiURL = "https://wikidata.org/wiki/" + _qid;
74006       wikidata.entityByQID(_qid, function(err, entity) {
74007         if (err) {
74008           unrecognized();
74009           return;
74010         }
74011         _wikidataEntity = entity;
74012         setLabelForEntity();
74013         var description = entityPropertyForDisplay(entity, "descriptions");
74014         _selection.select("button.wiki-link").classed("disabled", false);
74015         _selection.select(".preset-wikidata-description").style("display", function() {
74016           return description.value.length > 0 ? "flex" : "none";
74017         }).select("input").attr("value", description.value).attr("lang", description.language);
74018         _selection.select(".preset-wikidata-identifier").style("display", function() {
74019           return entity.id ? "flex" : "none";
74020         }).select("input").attr("value", entity.id);
74021       });
74022       function unrecognized() {
74023         _wikidataEntity = null;
74024         setLabelForEntity();
74025         _selection.select(".preset-wikidata-description").style("display", "none");
74026         _selection.select(".preset-wikidata-identifier").style("display", "none");
74027         _selection.select("button.wiki-link").classed("disabled", true);
74028         if (_qid && _qid !== "") {
74029           _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
74030         } else {
74031           _wikiURL = "";
74032         }
74033       }
74034     };
74035     function entityPropertyForDisplay(wikidataEntity, propKey) {
74036       var blankResponse = { value: "" };
74037       if (!wikidataEntity[propKey]) return blankResponse;
74038       var propObj = wikidataEntity[propKey];
74039       var langKeys = Object.keys(propObj);
74040       if (langKeys.length === 0) return blankResponse;
74041       var langs = wikidata.languagesToQuery();
74042       for (var i3 in langs) {
74043         var lang = langs[i3];
74044         var valueObj = propObj[lang];
74045         if (valueObj && valueObj.value && valueObj.value.length > 0) return valueObj;
74046       }
74047       return propObj[langKeys[0]];
74048     }
74049     wiki.entityIDs = function(val) {
74050       if (!arguments.length) return _entityIDs;
74051       _entityIDs = val;
74052       return wiki;
74053     };
74054     wiki.focus = function() {
74055       _searchInput.node().focus();
74056     };
74057     return utilRebind(wiki, dispatch14, "on");
74058   }
74059
74060   // modules/ui/fields/wikipedia.js
74061   function uiFieldWikipedia(field, context) {
74062     const scheme = "https://";
74063     const domain = "wikipedia.org";
74064     const dispatch14 = dispatch_default("change");
74065     const wikipedia = services.wikipedia;
74066     const wikidata = services.wikidata;
74067     let _langInput = select_default2(null);
74068     let _titleInput = select_default2(null);
74069     let _wikiURL = "";
74070     let _entityIDs;
74071     let _tags;
74072     let _dataWikipedia = [];
74073     _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
74074       _dataWikipedia = d2;
74075       if (_tags) updateForTags(_tags);
74076     }).catch(() => {
74077     });
74078     const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
74079       const v2 = value.toLowerCase();
74080       callback(
74081         _dataWikipedia.filter((d2) => {
74082           return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
74083         }).map((d2) => ({ value: d2[1] }))
74084       );
74085     });
74086     const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
74087       if (!value) {
74088         value = "";
74089         for (let i3 in _entityIDs) {
74090           let entity = context.hasEntity(_entityIDs[i3]);
74091           if (entity.tags.name) {
74092             value = entity.tags.name;
74093             break;
74094           }
74095         }
74096       }
74097       const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
74098       searchfn(language()[2], value, (query, data) => {
74099         callback(data.map((d2) => ({ value: d2 })));
74100       });
74101     });
74102     function wiki(selection2) {
74103       let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
74104       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
74105       let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
74106       langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
74107       _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
74108       _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);
74109       _langInput.on("blur", changeLang).on("change", changeLang);
74110       let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
74111       titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
74112       _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
74113       _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
74114       _titleInput.on("blur", function() {
74115         change(true);
74116       }).on("change", function() {
74117         change(false);
74118       });
74119       let link3 = titleContainer.selectAll(".wiki-link").data([0]);
74120       link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain })).call(svgIcon("#iD-icon-out-link")).merge(link3);
74121       link3.on("click", (d3_event) => {
74122         d3_event.preventDefault();
74123         if (_wikiURL) window.open(_wikiURL, "_blank");
74124       });
74125     }
74126     function defaultLanguageInfo(skipEnglishFallback) {
74127       const langCode = _mainLocalizer.languageCode().toLowerCase();
74128       for (let i3 in _dataWikipedia) {
74129         let d2 = _dataWikipedia[i3];
74130         if (d2[2] === langCode) return d2;
74131       }
74132       return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
74133     }
74134     function language(skipEnglishFallback) {
74135       const value = utilGetSetValue(_langInput).toLowerCase();
74136       for (let i3 in _dataWikipedia) {
74137         let d2 = _dataWikipedia[i3];
74138         if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value) return d2;
74139       }
74140       return defaultLanguageInfo(skipEnglishFallback);
74141     }
74142     function changeLang() {
74143       utilGetSetValue(_langInput, language()[1]);
74144       change(true);
74145     }
74146     function change(skipWikidata) {
74147       let value = utilGetSetValue(_titleInput);
74148       const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
74149       const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
74150       let syncTags = {};
74151       if (langInfo) {
74152         const nativeLangName = langInfo[1];
74153         value = decodeURIComponent(m2[2]).replace(/_/g, " ");
74154         if (m2[3]) {
74155           let anchor;
74156           anchor = decodeURIComponent(m2[3]);
74157           value += "#" + anchor.replace(/_/g, " ");
74158         }
74159         value = value.slice(0, 1).toUpperCase() + value.slice(1);
74160         utilGetSetValue(_langInput, nativeLangName).attr("lang", langInfo[2]);
74161         utilGetSetValue(_titleInput, value);
74162       }
74163       if (value) {
74164         syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
74165       } else {
74166         syncTags.wikipedia = void 0;
74167       }
74168       dispatch14.call("change", this, syncTags);
74169       if (skipWikidata || !value || !language()[2]) return;
74170       const initGraph = context.graph();
74171       const initEntityIDs = _entityIDs;
74172       wikidata.itemsByTitle(language()[2], value, (err, data) => {
74173         if (err || !data || !Object.keys(data).length) return;
74174         if (context.graph() !== initGraph) return;
74175         const qids = Object.keys(data);
74176         const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
74177         let actions = initEntityIDs.map((entityID) => {
74178           let entity = context.entity(entityID).tags;
74179           let currTags = Object.assign({}, entity);
74180           if (currTags.wikidata !== value2) {
74181             currTags.wikidata = value2;
74182             return actionChangeTags(entityID, currTags);
74183           }
74184           return null;
74185         }).filter(Boolean);
74186         if (!actions.length) return;
74187         context.overwrite(
74188           function actionUpdateWikidataTags(graph) {
74189             actions.forEach(function(action) {
74190               graph = action(graph);
74191             });
74192             return graph;
74193           },
74194           context.history().undoAnnotation()
74195         );
74196       });
74197     }
74198     wiki.tags = (tags) => {
74199       _tags = tags;
74200       updateForTags(tags);
74201     };
74202     function updateForTags(tags) {
74203       const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
74204       const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
74205       const tagLang = m2 && m2[1];
74206       const tagArticleTitle = m2 && m2[2];
74207       let anchor = m2 && m2[3];
74208       const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
74209       if (tagLangInfo) {
74210         const nativeLangName = tagLangInfo[1];
74211         utilGetSetValue(_langInput, nativeLangName);
74212         _titleInput.attr("lang", tagLangInfo[2]);
74213         utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
74214         _wikiURL = "".concat(scheme).concat(tagLang, ".").concat(domain, "/wiki/").concat(wiki.encodePath(tagArticleTitle, anchor));
74215       } else {
74216         utilGetSetValue(_titleInput, value);
74217         if (value && value !== "") {
74218           utilGetSetValue(_langInput, "");
74219           const defaultLangInfo = defaultLanguageInfo();
74220           _wikiURL = "".concat(scheme).concat(defaultLangInfo[2], ".").concat(domain, "/w/index.php?fulltext=1&search=").concat(value);
74221         } else {
74222           const shownOrDefaultLangInfo = language(
74223             true
74224             /* skipEnglishFallback */
74225           );
74226           utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
74227           _wikiURL = "";
74228         }
74229       }
74230     }
74231     wiki.encodePath = (tagArticleTitle, anchor) => {
74232       const underscoredTitle = tagArticleTitle.replace(/ /g, "_");
74233       const uriEncodedUnderscoredTitle = encodeURIComponent(underscoredTitle);
74234       const uriEncodedAnchorFragment = wiki.encodeURIAnchorFragment(anchor);
74235       return "".concat(uriEncodedUnderscoredTitle).concat(uriEncodedAnchorFragment);
74236     };
74237     wiki.encodeURIAnchorFragment = (anchor) => {
74238       if (!anchor) return "";
74239       const underscoredAnchor = anchor.replace(/ /g, "_");
74240       return "#" + encodeURIComponent(underscoredAnchor);
74241     };
74242     wiki.entityIDs = (val) => {
74243       if (!arguments.length) return _entityIDs;
74244       _entityIDs = val;
74245       return wiki;
74246     };
74247     wiki.focus = () => {
74248       _titleInput.node().focus();
74249     };
74250     return utilRebind(wiki, dispatch14, "on");
74251   }
74252   uiFieldWikipedia.supportsMultiselection = false;
74253
74254   // modules/ui/fields/index.js
74255   var uiFields = {
74256     access: uiFieldAccess,
74257     address: uiFieldAddress,
74258     check: uiFieldCheck,
74259     colour: uiFieldText,
74260     combo: uiFieldCombo,
74261     cycleway: uiFieldDirectionalCombo,
74262     date: uiFieldText,
74263     defaultCheck: uiFieldCheck,
74264     directionalCombo: uiFieldDirectionalCombo,
74265     email: uiFieldText,
74266     identifier: uiFieldText,
74267     lanes: uiFieldLanes,
74268     localized: uiFieldLocalized,
74269     roadheight: uiFieldRoadheight,
74270     roadspeed: uiFieldRoadspeed,
74271     manyCombo: uiFieldCombo,
74272     multiCombo: uiFieldCombo,
74273     networkCombo: uiFieldCombo,
74274     number: uiFieldText,
74275     onewayCheck: uiFieldCheck,
74276     radio: uiFieldRadio,
74277     restrictions: uiFieldRestrictions,
74278     semiCombo: uiFieldCombo,
74279     structureRadio: uiFieldRadio,
74280     tel: uiFieldText,
74281     text: uiFieldText,
74282     textarea: uiFieldTextarea,
74283     typeCombo: uiFieldCombo,
74284     url: uiFieldText,
74285     wikidata: uiFieldWikidata,
74286     wikipedia: uiFieldWikipedia
74287   };
74288
74289   // modules/ui/field.js
74290   function uiField(context, presetField2, entityIDs, options2) {
74291     options2 = Object.assign({
74292       show: true,
74293       wrap: true,
74294       remove: true,
74295       revert: true,
74296       info: true
74297     }, options2);
74298     var dispatch14 = dispatch_default("change", "revert");
74299     var field = Object.assign({}, presetField2);
74300     field.domId = utilUniqueDomId("form-field-" + field.safeid);
74301     var _show = options2.show;
74302     var _state = "";
74303     var _tags = {};
74304     var _entityExtent;
74305     if (entityIDs && entityIDs.length) {
74306       _entityExtent = entityIDs.reduce(function(extent, entityID) {
74307         var entity = context.graph().entity(entityID);
74308         return extent.extend(entity.extent(context.graph()));
74309       }, geoExtent());
74310     }
74311     var _locked = false;
74312     var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
74313     if (_show && !field.impl) {
74314       createField();
74315     }
74316     function createField() {
74317       field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
74318         dispatch14.call("change", field, t2, onInput);
74319       });
74320       if (entityIDs) {
74321         field.entityIDs = entityIDs;
74322         if (field.impl.entityIDs) {
74323           field.impl.entityIDs(entityIDs);
74324         }
74325       }
74326     }
74327     function allKeys() {
74328       let keys2 = field.keys || [field.key];
74329       if (field.type === "directionalCombo" && field.key) {
74330         const baseKey = field.key.replace(/:both$/, "");
74331         keys2 = keys2.concat(baseKey, "".concat(baseKey, ":both"));
74332       }
74333       return keys2;
74334     }
74335     function isModified() {
74336       if (!entityIDs || !entityIDs.length) return false;
74337       return entityIDs.some(function(entityID) {
74338         var original = context.graph().base().entities[entityID];
74339         var latest = context.graph().entity(entityID);
74340         return allKeys().some(function(key) {
74341           return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
74342         });
74343       });
74344     }
74345     function tagsContainFieldKey() {
74346       return allKeys().some(function(key) {
74347         if (field.type === "multiCombo") {
74348           for (var tagKey in _tags) {
74349             if (tagKey.indexOf(key) === 0) {
74350               return true;
74351             }
74352           }
74353           return false;
74354         }
74355         if (field.type === "localized") {
74356           for (let tagKey2 in _tags) {
74357             let match = tagKey2.match(LANGUAGE_SUFFIX_REGEX);
74358             if (match && match[1] === field.key && match[2]) {
74359               return true;
74360             }
74361           }
74362         }
74363         return _tags[key] !== void 0;
74364       });
74365     }
74366     function revert(d3_event, d2) {
74367       d3_event.stopPropagation();
74368       d3_event.preventDefault();
74369       if (!entityIDs || _locked) return;
74370       dispatch14.call("revert", d2, allKeys());
74371     }
74372     function remove2(d3_event, d2) {
74373       d3_event.stopPropagation();
74374       d3_event.preventDefault();
74375       if (_locked) return;
74376       var t2 = {};
74377       allKeys().forEach(function(key) {
74378         t2[key] = void 0;
74379       });
74380       dispatch14.call("change", d2, t2);
74381     }
74382     field.render = function(selection2) {
74383       var container = selection2.selectAll(".form-field").data([field]);
74384       var enter = container.enter().append("div").attr("class", function(d2) {
74385         return "form-field form-field-" + d2.safeid;
74386       }).classed("nowrap", !options2.wrap);
74387       if (options2.wrap) {
74388         var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
74389           return d2.domId;
74390         });
74391         var textEnter = labelEnter.append("span").attr("class", "label-text");
74392         textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
74393           d2.label()(select_default2(this));
74394         });
74395         textEnter.append("span").attr("class", "label-textannotation");
74396         if (options2.remove) {
74397           labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
74398         }
74399         if (options2.revert) {
74400           labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
74401         }
74402       }
74403       container = container.merge(enter);
74404       container.select(".field-label > .remove-icon").on("click", remove2);
74405       container.select(".field-label > .modified-icon").on("click", revert);
74406       container.each(function(d2) {
74407         var selection3 = select_default2(this);
74408         if (!d2.impl) {
74409           createField();
74410         }
74411         var reference, help;
74412         if (options2.wrap && field.type === "restrictions") {
74413           help = uiFieldHelp(context, "restrictions");
74414         }
74415         if (options2.wrap && options2.info) {
74416           var referenceKey = d2.key || "";
74417           if (d2.type === "multiCombo") {
74418             referenceKey = referenceKey.replace(/:$/, "");
74419           }
74420           var referenceOptions = d2.reference || {
74421             key: referenceKey,
74422             value: _tags[referenceKey]
74423           };
74424           reference = uiTagReference(referenceOptions, context);
74425           if (_state === "hover") {
74426             reference.showing(false);
74427           }
74428         }
74429         selection3.call(d2.impl);
74430         if (help) {
74431           selection3.call(help.body).select(".field-label").call(help.button);
74432         }
74433         if (reference) {
74434           selection3.call(reference.body).select(".field-label").call(reference.button);
74435         }
74436         d2.impl.tags(_tags);
74437       });
74438       container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
74439       var annotation = container.selectAll(".field-label .label-textannotation");
74440       var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
74441       icon2.exit().remove();
74442       icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
74443       container.call(_locked ? _lockedTip : _lockedTip.destroy);
74444     };
74445     field.state = function(val) {
74446       if (!arguments.length) return _state;
74447       _state = val;
74448       return field;
74449     };
74450     field.tags = function(val) {
74451       if (!arguments.length) return _tags;
74452       _tags = val;
74453       if (tagsContainFieldKey() && !_show) {
74454         _show = true;
74455         if (!field.impl) {
74456           createField();
74457         }
74458       }
74459       return field;
74460     };
74461     field.locked = function(val) {
74462       if (!arguments.length) return _locked;
74463       _locked = val;
74464       return field;
74465     };
74466     field.show = function() {
74467       _show = true;
74468       if (!field.impl) {
74469         createField();
74470       }
74471       if (field.default && field.key && _tags[field.key] !== field.default) {
74472         var t2 = {};
74473         t2[field.key] = field.default;
74474         dispatch14.call("change", this, t2);
74475       }
74476     };
74477     field.isShown = function() {
74478       return _show;
74479     };
74480     field.isAllowed = function() {
74481       if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false) return false;
74482       if (field.geometry && !entityIDs.every(function(entityID) {
74483         return field.matchGeometry(context.graph().geometry(entityID));
74484       })) return false;
74485       if (entityIDs && _entityExtent && field.locationSetID) {
74486         var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
74487         if (!validHere[field.locationSetID]) return false;
74488       }
74489       var prerequisiteTag = field.prerequisiteTag;
74490       if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
74491       prerequisiteTag) {
74492         if (!entityIDs.every(function(entityID) {
74493           var entity = context.graph().entity(entityID);
74494           if (prerequisiteTag.key) {
74495             var value = entity.tags[prerequisiteTag.key];
74496             if (!value) return false;
74497             if (prerequisiteTag.valueNot) {
74498               return prerequisiteTag.valueNot !== value;
74499             }
74500             if (prerequisiteTag.value) {
74501               return prerequisiteTag.value === value;
74502             }
74503           } else if (prerequisiteTag.keyNot) {
74504             if (entity.tags[prerequisiteTag.keyNot]) return false;
74505           }
74506           return true;
74507         })) return false;
74508       }
74509       return true;
74510     };
74511     field.focus = function() {
74512       if (field.impl) {
74513         field.impl.focus();
74514       }
74515     };
74516     return utilRebind(field, dispatch14, "on");
74517   }
74518
74519   // modules/ui/changeset_editor.js
74520   function uiChangesetEditor(context) {
74521     var dispatch14 = dispatch_default("change");
74522     var formFields = uiFormFields(context);
74523     var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
74524     var _fieldsArr;
74525     var _tags;
74526     var _changesetID;
74527     function changesetEditor(selection2) {
74528       render(selection2);
74529     }
74530     function render(selection2) {
74531       var _a4;
74532       var initial = false;
74533       if (!_fieldsArr) {
74534         initial = true;
74535         var presets = _mainPresetIndex;
74536         _fieldsArr = [
74537           uiField(context, presets.field("comment"), null, { show: true, revert: false }),
74538           uiField(context, presets.field("source"), null, { show: true, revert: false }),
74539           uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
74540         ];
74541         _fieldsArr.forEach(function(field) {
74542           field.on("change", function(t2, onInput) {
74543             dispatch14.call("change", field, void 0, t2, onInput);
74544           });
74545         });
74546       }
74547       _fieldsArr.forEach(function(field) {
74548         field.tags(_tags);
74549       });
74550       selection2.call(formFields.fieldsArr(_fieldsArr));
74551       if (initial) {
74552         var commentField = selection2.select(".form-field-comment textarea");
74553         const sourceField = _fieldsArr.find((field) => field.id === "source");
74554         var commentNode = commentField.node();
74555         if (commentNode) {
74556           commentNode.focus();
74557           commentNode.select();
74558         }
74559         utilTriggerEvent(commentField, "blur");
74560         var osm = context.connection();
74561         if (osm) {
74562           osm.userChangesets(function(err, changesets) {
74563             if (err) return;
74564             var comments = changesets.map(function(changeset) {
74565               var comment = changeset.tags.comment;
74566               return comment ? { title: comment, value: comment } : null;
74567             }).filter(Boolean);
74568             commentField.call(
74569               commentCombo.data(utilArrayUniqBy(comments, "title"))
74570             );
74571             const recentSources = changesets.flatMap((changeset) => {
74572               var _a5;
74573               return (_a5 = changeset.tags.source) == null ? void 0 : _a5.split(";");
74574             }).filter((value) => !sourceField.options.includes(value)).filter(Boolean).map((title) => ({ title, value: title, klass: "raw-option" }));
74575             sourceField.impl.setCustomOptions(utilArrayUniqBy(recentSources, "title"));
74576           });
74577         }
74578       }
74579       const warnings = [];
74580       if ((_a4 = _tags.comment) == null ? void 0 : _a4.match(/google/i)) {
74581         warnings.push({
74582           id: 'contains "google"',
74583           msg: _t.append("commit.google_warning"),
74584           link: _t("commit.google_warning_link")
74585         });
74586       }
74587       const maxChars = context.maxCharsForTagValue();
74588       const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
74589       if (strLen > maxChars || false) {
74590         warnings.push({
74591           id: "message too long",
74592           msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
74593         });
74594       }
74595       var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
74596       commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
74597       var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
74598       commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
74599       commentEnter.transition().duration(200).style("opacity", 1);
74600       commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
74601         let selection3 = select_default2(this);
74602         if (d2.link) {
74603           selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
74604         }
74605         selection3.call(d2.msg);
74606       });
74607     }
74608     changesetEditor.tags = function(_2) {
74609       if (!arguments.length) return _tags;
74610       _tags = _2;
74611       return changesetEditor;
74612     };
74613     changesetEditor.changesetID = function(_2) {
74614       if (!arguments.length) return _changesetID;
74615       if (_changesetID === _2) return changesetEditor;
74616       _changesetID = _2;
74617       _fieldsArr = null;
74618       return changesetEditor;
74619     };
74620     return utilRebind(changesetEditor, dispatch14, "on");
74621   }
74622
74623   // modules/ui/sections/changes.js
74624   function uiSectionChanges(context) {
74625     var _discardTags = {};
74626     _mainFileFetcher.get("discarded").then(function(d2) {
74627       _discardTags = d2;
74628     }).catch(function() {
74629     });
74630     var section = uiSection("changes-list", context).label(function() {
74631       var history = context.history();
74632       var summary = history.difference().summary();
74633       return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
74634     }).disclosureContent(renderDisclosureContent);
74635     function renderDisclosureContent(selection2) {
74636       var history = context.history();
74637       var summary = history.difference().summary();
74638       var container = selection2.selectAll(".commit-section").data([0]);
74639       var containerEnter = container.enter().append("div").attr("class", "commit-section");
74640       containerEnter.append("ul").attr("class", "changeset-list");
74641       container = containerEnter.merge(container);
74642       var items = container.select("ul").selectAll("li").data(summary);
74643       var itemsEnter = items.enter().append("li").attr("class", "change-item");
74644       var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
74645       buttons.each(function(d2) {
74646         select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
74647       });
74648       buttons.append("span").attr("class", "change-type").html(function(d2) {
74649         return _t.html("commit." + d2.changeType) + " ";
74650       });
74651       buttons.append("strong").attr("class", "entity-type").text(function(d2) {
74652         var matched = _mainPresetIndex.match(d2.entity, d2.graph);
74653         return matched && matched.name() || utilDisplayType(d2.entity.id);
74654       });
74655       buttons.append("span").attr("class", "entity-name").text(function(d2) {
74656         var name = utilDisplayName(d2.entity) || "", string = "";
74657         if (name !== "") {
74658           string += ":";
74659         }
74660         return string += " " + name;
74661       });
74662       items = itemsEnter.merge(items);
74663       var changeset = new osmChangeset().update({ id: void 0 });
74664       var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
74665       delete changeset.id;
74666       var data = JXON.stringify(changeset.osmChangeJXON(changes));
74667       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
74668       var fileName = "changes.osc";
74669       var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
74670       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
74671       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
74672       function mouseover(d2) {
74673         if (d2.entity) {
74674           context.surface().selectAll(
74675             utilEntityOrMemberSelector([d2.entity.id], context.graph())
74676           ).classed("hover", true);
74677         }
74678       }
74679       function mouseout() {
74680         context.surface().selectAll(".hover").classed("hover", false);
74681       }
74682       function click(d3_event, change) {
74683         if (change.changeType !== "deleted") {
74684           var entity = change.entity;
74685           context.map().zoomToEase(entity);
74686           context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
74687         }
74688       }
74689     }
74690     return section;
74691   }
74692
74693   // modules/ui/commit.js
74694   var readOnlyTags = [
74695     /^changesets_count$/,
74696     /^created_by$/,
74697     /^ideditor:/,
74698     /^imagery_used$/,
74699     /^host$/,
74700     /^locale$/,
74701     /^warnings:/,
74702     /^resolved:/,
74703     /^closed:note$/,
74704     /^closed:keepright$/,
74705     /^closed:osmose:/
74706   ];
74707   var hashtagRegex = /([##][^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
74708   function uiCommit(context) {
74709     var dispatch14 = dispatch_default("cancel");
74710     var _userDetails2;
74711     var _selection;
74712     var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
74713     var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
74714     var commitChanges = uiSectionChanges(context);
74715     var commitWarnings = uiCommitWarnings(context);
74716     function commit(selection2) {
74717       _selection = selection2;
74718       if (!context.changeset) initChangeset();
74719       loadDerivedChangesetTags();
74720       selection2.call(render);
74721     }
74722     function initChangeset() {
74723       var commentDate = +corePreferences("commentDate") || 0;
74724       var currDate = Date.now();
74725       var cutoff = 2 * 86400 * 1e3;
74726       if (commentDate > currDate || currDate - commentDate > cutoff) {
74727         corePreferences("comment", null);
74728         corePreferences("hashtags", null);
74729         corePreferences("source", null);
74730       }
74731       if (context.defaultChangesetComment()) {
74732         corePreferences("comment", context.defaultChangesetComment());
74733         corePreferences("commentDate", Date.now());
74734       }
74735       if (context.defaultChangesetSource()) {
74736         corePreferences("source", context.defaultChangesetSource());
74737         corePreferences("commentDate", Date.now());
74738       }
74739       if (context.defaultChangesetHashtags()) {
74740         corePreferences("hashtags", context.defaultChangesetHashtags());
74741         corePreferences("commentDate", Date.now());
74742       }
74743       var detected = utilDetect();
74744       var tags = {
74745         comment: corePreferences("comment") || "",
74746         created_by: context.cleanTagValue("iD " + context.version),
74747         host: context.cleanTagValue(detected.host),
74748         locale: context.cleanTagValue(_mainLocalizer.localeCode())
74749       };
74750       findHashtags(tags, true);
74751       var hashtags = corePreferences("hashtags");
74752       if (hashtags) {
74753         tags.hashtags = hashtags;
74754       }
74755       var source = corePreferences("source");
74756       if (source) {
74757         tags.source = source;
74758       }
74759       var photoOverlaysUsed = context.history().photoOverlaysUsed();
74760       if (photoOverlaysUsed.length) {
74761         var sources = (tags.source || "").split(";");
74762         if (sources.indexOf("streetlevel imagery") === -1) {
74763           sources.push("streetlevel imagery");
74764         }
74765         photoOverlaysUsed.forEach(function(photoOverlay) {
74766           if (sources.indexOf(photoOverlay) === -1) {
74767             sources.push(photoOverlay);
74768           }
74769         });
74770         tags.source = context.cleanTagValue(sources.filter(Boolean).join(";"));
74771       }
74772       context.changeset = new osmChangeset({ tags });
74773     }
74774     function loadDerivedChangesetTags() {
74775       var osm = context.connection();
74776       if (!osm) return;
74777       var tags = Object.assign({}, context.changeset.tags);
74778       var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
74779       tags.imagery_used = imageryUsed || "None";
74780       var osmClosed = osm.getClosedIDs();
74781       var itemType;
74782       if (osmClosed.length) {
74783         tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
74784       }
74785       if (services.keepRight) {
74786         var krClosed = services.keepRight.getClosedIDs();
74787         if (krClosed.length) {
74788           tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
74789         }
74790       }
74791       if (services.osmose) {
74792         var osmoseClosed = services.osmose.getClosedCounts();
74793         for (itemType in osmoseClosed) {
74794           tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
74795         }
74796       }
74797       for (var key in tags) {
74798         if (key.match(/(^warnings:)|(^resolved:)/)) {
74799           delete tags[key];
74800         }
74801       }
74802       function addIssueCounts(issues, prefix) {
74803         var issuesByType = utilArrayGroupBy(issues, "type");
74804         for (var issueType in issuesByType) {
74805           var issuesOfType = issuesByType[issueType];
74806           if (issuesOfType[0].subtype) {
74807             var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
74808             for (var issueSubtype in issuesBySubtype) {
74809               var issuesOfSubtype = issuesBySubtype[issueSubtype];
74810               tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
74811             }
74812           } else {
74813             tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
74814           }
74815         }
74816       }
74817       var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
74818         return issue.type !== "help_request";
74819       });
74820       addIssueCounts(warnings, "warnings");
74821       var resolvedIssues = context.validator().getResolvedIssues();
74822       addIssueCounts(resolvedIssues, "resolved");
74823       context.changeset = context.changeset.update({ tags });
74824     }
74825     function render(selection2) {
74826       var osm = context.connection();
74827       if (!osm) return;
74828       var header = selection2.selectAll(".header").data([0]);
74829       var headerTitle = header.enter().append("div").attr("class", "header fillL");
74830       headerTitle.append("div").append("h2").call(_t.append("commit.title"));
74831       headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
74832         dispatch14.call("cancel", this);
74833       }).call(svgIcon("#iD-icon-close"));
74834       var body = selection2.selectAll(".body").data([0]);
74835       body = body.enter().append("div").attr("class", "body").merge(body);
74836       var changesetSection = body.selectAll(".changeset-editor").data([0]);
74837       changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
74838       changesetSection.call(
74839         changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
74840       );
74841       body.call(commitWarnings);
74842       var saveSection = body.selectAll(".save-section").data([0]);
74843       saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
74844       var prose = saveSection.selectAll(".commit-info").data([0]);
74845       if (prose.enter().size()) {
74846         _userDetails2 = null;
74847       }
74848       prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
74849       osm.userDetails(function(err, user) {
74850         if (err) return;
74851         if (_userDetails2 === user) return;
74852         _userDetails2 = user;
74853         var userLink = select_default2(document.createElement("div"));
74854         if (user.image_url) {
74855           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
74856         }
74857         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
74858         prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
74859       });
74860       var requestReview = saveSection.selectAll(".request-review").data([0]);
74861       var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
74862       var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
74863       var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
74864       if (!labelEnter.empty()) {
74865         labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
74866       }
74867       labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
74868       labelEnter.append("span").call(_t.append("commit.request_review"));
74869       requestReview = requestReview.merge(requestReviewEnter);
74870       var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
74871       var buttonSection = saveSection.selectAll(".buttons").data([0]);
74872       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
74873       buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
74874       var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
74875       uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
74876       var uploadBlockerTooltipText = getUploadBlockerMessage();
74877       buttonSection = buttonSection.merge(buttonEnter);
74878       buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
74879         dispatch14.call("cancel", this);
74880       });
74881       buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
74882         if (!select_default2(this).classed("disabled")) {
74883           this.blur();
74884           for (var key in context.changeset.tags) {
74885             if (!key) delete context.changeset.tags[key];
74886           }
74887           context.uploader().save(context.changeset);
74888         }
74889       });
74890       uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
74891       if (uploadBlockerTooltipText) {
74892         buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
74893       }
74894       var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
74895       tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
74896       tagSection.call(
74897         rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
74898       );
74899       var changesSection = body.selectAll(".commit-changes-section").data([0]);
74900       changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
74901       changesSection.call(commitChanges.render);
74902       function toggleRequestReview() {
74903         var rr = requestReviewInput.property("checked");
74904         updateChangeset({ review_requested: rr ? "yes" : void 0 });
74905         tagSection.call(
74906           rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
74907         );
74908       }
74909     }
74910     function getUploadBlockerMessage() {
74911       var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
74912       if (errors.length) {
74913         return _t.append("commit.outstanding_errors_message", { count: errors.length });
74914       } else {
74915         var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
74916         if (!hasChangesetComment) {
74917           return _t.append("commit.comment_needed_message");
74918         }
74919       }
74920       return null;
74921     }
74922     function changeTags(_2, changed, onInput) {
74923       if (changed.hasOwnProperty("comment")) {
74924         if (!onInput) {
74925           corePreferences("comment", changed.comment);
74926           corePreferences("commentDate", Date.now());
74927         }
74928       }
74929       if (changed.hasOwnProperty("source")) {
74930         if (changed.source === void 0) {
74931           corePreferences("source", null);
74932         } else if (!onInput) {
74933           corePreferences("source", changed.source);
74934           corePreferences("commentDate", Date.now());
74935         }
74936       }
74937       updateChangeset(changed, onInput);
74938       if (_selection) {
74939         _selection.call(render);
74940       }
74941     }
74942     function findHashtags(tags, commentOnly) {
74943       var detectedHashtags = commentHashtags();
74944       if (detectedHashtags.length) {
74945         corePreferences("hashtags", null);
74946       }
74947       if (!detectedHashtags.length || !commentOnly) {
74948         detectedHashtags = detectedHashtags.concat(hashtagHashtags());
74949       }
74950       var allLowerCase = /* @__PURE__ */ new Set();
74951       return detectedHashtags.filter(function(hashtag) {
74952         var lowerCase = hashtag.toLowerCase();
74953         if (!allLowerCase.has(lowerCase)) {
74954           allLowerCase.add(lowerCase);
74955           return true;
74956         }
74957         return false;
74958       });
74959       function commentHashtags() {
74960         var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
74961         return matches || [];
74962       }
74963       function hashtagHashtags() {
74964         var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
74965           if (s2[0] !== "#") {
74966             s2 = "#" + s2;
74967           }
74968           var matched = s2.match(hashtagRegex);
74969           return matched && matched[0];
74970         }).filter(Boolean);
74971         return matches || [];
74972       }
74973     }
74974     function isReviewRequested(tags) {
74975       var rr = tags.review_requested;
74976       if (rr === void 0) return false;
74977       rr = rr.trim().toLowerCase();
74978       return !(rr === "" || rr === "no");
74979     }
74980     function updateChangeset(changed, onInput) {
74981       var tags = Object.assign({}, context.changeset.tags);
74982       Object.keys(changed).forEach(function(k2) {
74983         var v2 = changed[k2];
74984         k2 = context.cleanTagKey(k2);
74985         if (readOnlyTags.indexOf(k2) !== -1) return;
74986         if (v2 === void 0) {
74987           delete tags[k2];
74988         } else if (onInput) {
74989           tags[k2] = v2;
74990         } else {
74991           tags[k2] = context.cleanTagValue(v2);
74992         }
74993       });
74994       if (!onInput) {
74995         var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
74996         var arr = findHashtags(tags, commentOnly);
74997         if (arr.length) {
74998           tags.hashtags = context.cleanTagValue(arr.join(";"));
74999           corePreferences("hashtags", tags.hashtags);
75000         } else {
75001           delete tags.hashtags;
75002           corePreferences("hashtags", null);
75003         }
75004       }
75005       if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
75006         var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
75007         tags.changesets_count = String(changesetsCount);
75008         if (changesetsCount <= 100) {
75009           var s2;
75010           s2 = corePreferences("walkthrough_completed");
75011           if (s2) {
75012             tags["ideditor:walkthrough_completed"] = s2;
75013           }
75014           s2 = corePreferences("walkthrough_progress");
75015           if (s2) {
75016             tags["ideditor:walkthrough_progress"] = s2;
75017           }
75018           s2 = corePreferences("walkthrough_started");
75019           if (s2) {
75020             tags["ideditor:walkthrough_started"] = s2;
75021           }
75022         }
75023       } else {
75024         delete tags.changesets_count;
75025       }
75026       if (!(0, import_fast_deep_equal10.default)(context.changeset.tags, tags)) {
75027         context.changeset = context.changeset.update({ tags });
75028       }
75029     }
75030     commit.reset = function() {
75031       context.changeset = null;
75032     };
75033     return utilRebind(commit, dispatch14, "on");
75034   }
75035
75036   // modules/modes/save.js
75037   function modeSave(context) {
75038     var mode = { id: "save" };
75039     var keybinding = utilKeybinding("modeSave");
75040     var commit = uiCommit(context).on("cancel", cancel);
75041     var _conflictsUi;
75042     var _location;
75043     var _success;
75044     var uploader = context.uploader().on("saveStarted.modeSave", function() {
75045       keybindingOff();
75046     }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
75047       cancel();
75048     }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
75049     function cancel() {
75050       context.enter(modeBrowse(context));
75051     }
75052     function showProgress(num, total) {
75053       var modal = context.container().select(".loading-modal .modal-section");
75054       var progress = modal.selectAll(".progress").data([0]);
75055       progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
75056     }
75057     function showConflicts(changeset, conflicts, origChanges) {
75058       var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
75059       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
75060       _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
75061         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
75062         selection2.remove();
75063         keybindingOn();
75064         uploader.cancelConflictResolution();
75065       }).on("save", function() {
75066         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
75067         selection2.remove();
75068         uploader.processResolvedConflicts(changeset);
75069       });
75070       selection2.call(_conflictsUi);
75071     }
75072     function showErrors(errors) {
75073       keybindingOn();
75074       var selection2 = uiConfirm(context.container());
75075       selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
75076       addErrors(selection2, errors);
75077       selection2.okButton();
75078     }
75079     function addErrors(selection2, data) {
75080       var message = selection2.select(".modal-section.message-text");
75081       var items = message.selectAll(".error-container").data(data);
75082       var enter = items.enter().append("div").attr("class", "error-container");
75083       enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
75084         return d2.msg || _t("save.unknown_error_details");
75085       }).on("click", function(d3_event) {
75086         d3_event.preventDefault();
75087         var error = select_default2(this);
75088         var detail = select_default2(this.nextElementSibling);
75089         var exp2 = error.classed("expanded");
75090         detail.style("display", exp2 ? "none" : "block");
75091         error.classed("expanded", !exp2);
75092       });
75093       var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
75094       details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
75095         return d2.details || [];
75096       }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
75097         return d2;
75098       });
75099       items.exit().remove();
75100     }
75101     function showSuccess(changeset) {
75102       commit.reset();
75103       var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
75104         context.ui().sidebar.hide();
75105       });
75106       context.enter(modeBrowse(context).sidebar(ui));
75107     }
75108     function keybindingOn() {
75109       select_default2(document).call(keybinding.on("\u238B", cancel, true));
75110     }
75111     function keybindingOff() {
75112       select_default2(document).call(keybinding.unbind);
75113     }
75114     function prepareForSuccess() {
75115       _success = uiSuccess(context);
75116       _location = null;
75117       if (!services.geocoder) return;
75118       services.geocoder.reverse(context.map().center(), function(err, result) {
75119         if (err || !result || !result.address) return;
75120         var addr = result.address;
75121         var place = addr && (addr.town || addr.city || addr.county) || "";
75122         var region = addr && (addr.state || addr.country) || "";
75123         var separator = place && region ? _t("success.thank_you_where.separator") : "";
75124         _location = _t(
75125           "success.thank_you_where.format",
75126           { place, separator, region }
75127         );
75128       });
75129     }
75130     mode.selectedIDs = function() {
75131       return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
75132     };
75133     mode.enter = function() {
75134       context.ui().sidebar.expand();
75135       function done() {
75136         context.ui().sidebar.show(commit);
75137       }
75138       keybindingOn();
75139       context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
75140       var osm = context.connection();
75141       if (!osm) {
75142         cancel();
75143         return;
75144       }
75145       if (osm.authenticated()) {
75146         done();
75147       } else {
75148         osm.authenticate(function(err) {
75149           if (err) {
75150             cancel();
75151           } else {
75152             done();
75153           }
75154         });
75155       }
75156     };
75157     mode.exit = function() {
75158       keybindingOff();
75159       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
75160       context.ui().sidebar.hide();
75161     };
75162     return mode;
75163   }
75164
75165   // modules/modes/select_error.js
75166   function modeSelectError(context, selectedErrorID, selectedErrorService) {
75167     var mode = {
75168       id: "select-error",
75169       button: "browse"
75170     };
75171     var keybinding = utilKeybinding("select-error");
75172     var errorService = services[selectedErrorService];
75173     var errorEditor;
75174     switch (selectedErrorService) {
75175       case "keepRight":
75176         errorEditor = uiKeepRightEditor(context).on("change", function() {
75177           context.map().pan([0, 0]);
75178           var error = checkSelectedID();
75179           if (!error) return;
75180           context.ui().sidebar.show(errorEditor.error(error));
75181         });
75182         break;
75183       case "osmose":
75184         errorEditor = uiOsmoseEditor(context).on("change", function() {
75185           context.map().pan([0, 0]);
75186           var error = checkSelectedID();
75187           if (!error) return;
75188           context.ui().sidebar.show(errorEditor.error(error));
75189         });
75190         break;
75191     }
75192     var behaviors = [
75193       behaviorBreathe(context),
75194       behaviorHover(context),
75195       behaviorSelect(context),
75196       behaviorLasso(context),
75197       modeDragNode(context).behavior,
75198       modeDragNote(context).behavior
75199     ];
75200     function checkSelectedID() {
75201       if (!errorService) return;
75202       var error = errorService.getError(selectedErrorID);
75203       if (!error) {
75204         context.enter(modeBrowse(context));
75205       }
75206       return error;
75207     }
75208     mode.zoomToSelected = function() {
75209       if (!errorService) return;
75210       var error = errorService.getError(selectedErrorID);
75211       if (error) {
75212         context.map().centerZoomEase(error.loc, 20);
75213       }
75214     };
75215     mode.enter = function() {
75216       var error = checkSelectedID();
75217       if (!error) return;
75218       behaviors.forEach(context.install);
75219       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
75220       select_default2(document).call(keybinding);
75221       selectError();
75222       var sidebar = context.ui().sidebar;
75223       sidebar.show(errorEditor.error(error));
75224       context.map().on("drawn.select-error", selectError);
75225       function selectError(d3_event, drawn) {
75226         if (!checkSelectedID()) return;
75227         var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
75228         if (selection2.empty()) {
75229           var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
75230           if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
75231             context.enter(modeBrowse(context));
75232           }
75233         } else {
75234           selection2.classed("selected", true);
75235           context.selectedErrorID(selectedErrorID);
75236         }
75237       }
75238       function esc() {
75239         if (context.container().select(".combobox").size()) return;
75240         context.enter(modeBrowse(context));
75241       }
75242     };
75243     mode.exit = function() {
75244       behaviors.forEach(context.uninstall);
75245       select_default2(document).call(keybinding.unbind);
75246       context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
75247       context.map().on("drawn.select-error", null);
75248       context.ui().sidebar.hide();
75249       context.selectedErrorID(null);
75250       context.features().forceVisible([]);
75251     };
75252     return mode;
75253   }
75254
75255   // modules/core/context.js
75256   function coreContext() {
75257     const dispatch14 = dispatch_default("enter", "exit", "change");
75258     const context = {};
75259     let _deferred2 = /* @__PURE__ */ new Set();
75260     context.version = package_default.version;
75261     context.privacyVersion = "20201202";
75262     context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
75263     context.changeset = null;
75264     let _defaultChangesetComment = context.initialHashParams.comment;
75265     let _defaultChangesetSource = context.initialHashParams.source;
75266     let _defaultChangesetHashtags = context.initialHashParams.hashtags;
75267     context.defaultChangesetComment = function(val) {
75268       if (!arguments.length) return _defaultChangesetComment;
75269       _defaultChangesetComment = val;
75270       return context;
75271     };
75272     context.defaultChangesetSource = function(val) {
75273       if (!arguments.length) return _defaultChangesetSource;
75274       _defaultChangesetSource = val;
75275       return context;
75276     };
75277     context.defaultChangesetHashtags = function(val) {
75278       if (!arguments.length) return _defaultChangesetHashtags;
75279       _defaultChangesetHashtags = val;
75280       return context;
75281     };
75282     let _setsDocumentTitle = true;
75283     context.setsDocumentTitle = function(val) {
75284       if (!arguments.length) return _setsDocumentTitle;
75285       _setsDocumentTitle = val;
75286       return context;
75287     };
75288     let _documentTitleBase = document.title;
75289     context.documentTitleBase = function(val) {
75290       if (!arguments.length) return _documentTitleBase;
75291       _documentTitleBase = val;
75292       return context;
75293     };
75294     let _ui;
75295     context.ui = () => _ui;
75296     context.lastPointerType = () => _ui.lastPointerType();
75297     let _keybinding = utilKeybinding("context");
75298     context.keybinding = () => _keybinding;
75299     select_default2(document).call(_keybinding);
75300     let _connection = services.osm;
75301     let _history;
75302     let _validator;
75303     let _uploader;
75304     context.connection = () => _connection;
75305     context.history = () => _history;
75306     context.validator = () => _validator;
75307     context.uploader = () => _uploader;
75308     context.preauth = (options2) => {
75309       if (_connection) {
75310         _connection.switch(options2);
75311       }
75312       return context;
75313     };
75314     context.locale = function(locale2) {
75315       if (!arguments.length) return _mainLocalizer.localeCode();
75316       _mainLocalizer.preferredLocaleCodes(locale2);
75317       return context;
75318     };
75319     function afterLoad(cid, callback) {
75320       return (err, result) => {
75321         if (err) {
75322           if (err.status === 400 || err.status === 401 || err.status === 403) {
75323             if (_connection) {
75324               _connection.logout();
75325             }
75326           }
75327           if (typeof callback === "function") {
75328             callback(err);
75329           }
75330           return;
75331         } else if (_connection && _connection.getConnectionId() !== cid) {
75332           if (typeof callback === "function") {
75333             callback({ message: "Connection Switched", status: -1 });
75334           }
75335           return;
75336         } else {
75337           _history.merge(result.data, result.extent);
75338           if (typeof callback === "function") {
75339             callback(err, result);
75340           }
75341           return;
75342         }
75343       };
75344     }
75345     context.loadTiles = (projection2, callback) => {
75346       const handle = window.requestIdleCallback(() => {
75347         _deferred2.delete(handle);
75348         if (_connection && context.editableDataEnabled()) {
75349           const cid = _connection.getConnectionId();
75350           _connection.loadTiles(projection2, afterLoad(cid, callback));
75351         }
75352       });
75353       _deferred2.add(handle);
75354     };
75355     context.loadTileAtLoc = (loc, callback) => {
75356       const handle = window.requestIdleCallback(() => {
75357         _deferred2.delete(handle);
75358         if (_connection && context.editableDataEnabled()) {
75359           const cid = _connection.getConnectionId();
75360           _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
75361         }
75362       });
75363       _deferred2.add(handle);
75364     };
75365     context.loadEntity = (entityID, callback) => {
75366       if (_connection) {
75367         const cid = _connection.getConnectionId();
75368         _connection.loadEntity(entityID, afterLoad(cid, callback));
75369         _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
75370       }
75371     };
75372     context.loadNote = (entityID, callback) => {
75373       if (_connection) {
75374         const cid = _connection.getConnectionId();
75375         _connection.loadEntityNote(entityID, afterLoad(cid, callback));
75376       }
75377     };
75378     context.zoomToEntity = (entityID, zoomTo) => {
75379       context.zoomToEntities([entityID], zoomTo);
75380     };
75381     context.zoomToEntities = (entityIDs, zoomTo) => {
75382       let loadedEntities = [];
75383       const throttledZoomTo = throttle_default(() => _map.zoomTo(loadedEntities), 500);
75384       entityIDs.forEach((entityID) => context.loadEntity(entityID, (err, result) => {
75385         if (err) return;
75386         const entity = result.data.find((e3) => e3.id === entityID);
75387         if (!entity) return;
75388         loadedEntities.push(entity);
75389         if (zoomTo !== false) {
75390           throttledZoomTo();
75391         }
75392       }));
75393       _map.on("drawn.zoomToEntity", () => {
75394         if (!entityIDs.every((entityID) => context.hasEntity(entityID))) return;
75395         _map.on("drawn.zoomToEntity", null);
75396         context.on("enter.zoomToEntity", null);
75397         context.enter(modeSelect(context, entityIDs));
75398       });
75399       context.on("enter.zoomToEntity", () => {
75400         if (_mode.id !== "browse") {
75401           _map.on("drawn.zoomToEntity", null);
75402           context.on("enter.zoomToEntity", null);
75403         }
75404       });
75405     };
75406     context.moveToNote = (noteId, moveTo) => {
75407       context.loadNote(noteId, (err, result) => {
75408         if (err) return;
75409         const entity = result.data.find((e3) => e3.id === noteId);
75410         if (!entity) return;
75411         const note = services.osm.getNote(noteId);
75412         if (moveTo !== false) {
75413           context.map().center(note.loc);
75414         }
75415         const noteLayer = context.layers().layer("notes");
75416         noteLayer.enabled(true);
75417         context.enter(modeSelectNote(context, noteId));
75418       });
75419     };
75420     let _minEditableZoom = 16;
75421     context.minEditableZoom = function(val) {
75422       if (!arguments.length) return _minEditableZoom;
75423       _minEditableZoom = val;
75424       if (_connection) {
75425         _connection.tileZoom(val);
75426       }
75427       return context;
75428     };
75429     context.maxCharsForTagKey = () => 255;
75430     context.maxCharsForTagValue = () => 255;
75431     context.maxCharsForRelationRole = () => 255;
75432     context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
75433     context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
75434     context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
75435     let _inIntro = false;
75436     context.inIntro = function(val) {
75437       if (!arguments.length) return _inIntro;
75438       _inIntro = val;
75439       return context;
75440     };
75441     context.save = () => {
75442       if (_inIntro || context.container().select(".modal").size()) return;
75443       let canSave;
75444       if (_mode && _mode.id === "save") {
75445         canSave = false;
75446         if (services.osm && services.osm.isChangesetInflight()) {
75447           _history.clearSaved();
75448           return;
75449         }
75450       } else {
75451         canSave = context.selectedIDs().every((id2) => {
75452           const entity = context.hasEntity(id2);
75453           return entity && !entity.isDegenerate();
75454         });
75455       }
75456       if (canSave) {
75457         _history.save();
75458       }
75459       if (_history.hasChanges()) {
75460         return _t("save.unsaved_changes");
75461       }
75462     };
75463     context.debouncedSave = debounce_default(context.save, 350);
75464     function withDebouncedSave(fn) {
75465       return function() {
75466         const result = fn.apply(_history, arguments);
75467         context.debouncedSave();
75468         return result;
75469       };
75470     }
75471     context.hasEntity = (id2) => _history.graph().hasEntity(id2);
75472     context.entity = (id2) => _history.graph().entity(id2);
75473     let _mode;
75474     context.mode = () => _mode;
75475     context.enter = (newMode) => {
75476       if (_mode) {
75477         _mode.exit();
75478         dispatch14.call("exit", this, _mode);
75479       }
75480       _mode = newMode;
75481       _mode.enter();
75482       dispatch14.call("enter", this, _mode);
75483     };
75484     context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
75485     context.activeID = () => _mode && _mode.activeID && _mode.activeID();
75486     let _selectedNoteID;
75487     context.selectedNoteID = function(noteID) {
75488       if (!arguments.length) return _selectedNoteID;
75489       _selectedNoteID = noteID;
75490       return context;
75491     };
75492     let _selectedErrorID;
75493     context.selectedErrorID = function(errorID) {
75494       if (!arguments.length) return _selectedErrorID;
75495       _selectedErrorID = errorID;
75496       return context;
75497     };
75498     context.install = (behavior) => context.surface().call(behavior);
75499     context.uninstall = (behavior) => context.surface().call(behavior.off);
75500     let _copyGraph;
75501     context.copyGraph = () => _copyGraph;
75502     let _copyIDs = [];
75503     context.copyIDs = function(val) {
75504       if (!arguments.length) return _copyIDs;
75505       _copyIDs = val;
75506       _copyGraph = _history.graph();
75507       return context;
75508     };
75509     let _copyLonLat;
75510     context.copyLonLat = function(val) {
75511       if (!arguments.length) return _copyLonLat;
75512       _copyLonLat = val;
75513       return context;
75514     };
75515     let _background;
75516     context.background = () => _background;
75517     let _features;
75518     context.features = () => _features;
75519     context.hasHiddenConnections = (id2) => {
75520       const graph = _history.graph();
75521       const entity = graph.entity(id2);
75522       return _features.hasHiddenConnections(entity, graph);
75523     };
75524     let _photos;
75525     context.photos = () => _photos;
75526     let _map;
75527     context.map = () => _map;
75528     context.layers = () => _map.layers();
75529     context.surface = () => _map.surface;
75530     context.editableDataEnabled = () => _map.editableDataEnabled();
75531     context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
75532     context.editable = () => {
75533       const mode = context.mode();
75534       if (!mode || mode.id === "save") return false;
75535       return _map.editableDataEnabled();
75536     };
75537     let _debugFlags = {
75538       tile: false,
75539       // tile boundaries
75540       collision: false,
75541       // label collision bounding boxes
75542       imagery: false,
75543       // imagery bounding polygons
75544       target: false,
75545       // touch targets
75546       downloaded: false
75547       // downloaded data from osm
75548     };
75549     context.debugFlags = () => _debugFlags;
75550     context.getDebug = (flag) => flag && _debugFlags[flag];
75551     context.setDebug = function(flag, val) {
75552       if (arguments.length === 1) val = true;
75553       _debugFlags[flag] = val;
75554       dispatch14.call("change");
75555       return context;
75556     };
75557     let _container = select_default2(null);
75558     context.container = function(val) {
75559       if (!arguments.length) return _container;
75560       _container = val;
75561       _container.classed("ideditor", true);
75562       return context;
75563     };
75564     context.containerNode = function(val) {
75565       if (!arguments.length) return context.container().node();
75566       context.container(select_default2(val));
75567       return context;
75568     };
75569     let _embed;
75570     context.embed = function(val) {
75571       if (!arguments.length) return _embed;
75572       _embed = val;
75573       return context;
75574     };
75575     let _assetPath = "";
75576     context.assetPath = function(val) {
75577       if (!arguments.length) return _assetPath;
75578       _assetPath = val;
75579       _mainFileFetcher.assetPath(val);
75580       return context;
75581     };
75582     let _assetMap = {};
75583     context.assetMap = function(val) {
75584       if (!arguments.length) return _assetMap;
75585       _assetMap = val;
75586       _mainFileFetcher.assetMap(val);
75587       return context;
75588     };
75589     context.asset = (val) => {
75590       if (/^http(s)?:\/\//i.test(val)) return val;
75591       const filename = _assetPath + val;
75592       return _assetMap[filename] || filename;
75593     };
75594     context.imagePath = (val) => context.asset("img/".concat(val));
75595     context.reset = context.flush = () => {
75596       context.debouncedSave.cancel();
75597       Array.from(_deferred2).forEach((handle) => {
75598         window.cancelIdleCallback(handle);
75599         _deferred2.delete(handle);
75600       });
75601       Object.values(services).forEach((service) => {
75602         if (service && typeof service.reset === "function") {
75603           service.reset(context);
75604         }
75605       });
75606       context.changeset = null;
75607       _validator.reset();
75608       _features.reset();
75609       _history.reset();
75610       _uploader.reset();
75611       context.container().select(".inspector-wrap *").remove();
75612       return context;
75613     };
75614     context.projection = geoRawMercator();
75615     context.curtainProjection = geoRawMercator();
75616     context.init = () => {
75617       instantiateInternal();
75618       initializeDependents();
75619       return context;
75620       function instantiateInternal() {
75621         _history = coreHistory(context);
75622         context.graph = _history.graph;
75623         context.pauseChangeDispatch = _history.pauseChangeDispatch;
75624         context.resumeChangeDispatch = _history.resumeChangeDispatch;
75625         context.perform = withDebouncedSave(_history.perform);
75626         context.replace = withDebouncedSave(_history.replace);
75627         context.pop = withDebouncedSave(_history.pop);
75628         context.overwrite = withDebouncedSave(_history.overwrite);
75629         context.undo = withDebouncedSave(_history.undo);
75630         context.redo = withDebouncedSave(_history.redo);
75631         _validator = coreValidator(context);
75632         _uploader = coreUploader(context);
75633         _background = rendererBackground(context);
75634         _features = rendererFeatures(context);
75635         _map = rendererMap(context);
75636         _photos = rendererPhotos(context);
75637         _ui = uiInit(context);
75638       }
75639       function initializeDependents() {
75640         if (context.initialHashParams.presets) {
75641           _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
75642         }
75643         if (context.initialHashParams.locale) {
75644           _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
75645         }
75646         _mainLocalizer.ensureLoaded();
75647         _mainPresetIndex.ensureLoaded();
75648         _background.ensureLoaded();
75649         Object.values(services).forEach((service) => {
75650           if (service && typeof service.init === "function") {
75651             service.init();
75652           }
75653         });
75654         _map.init();
75655         _validator.init();
75656         _features.init();
75657         if (services.maprules && context.initialHashParams.maprules) {
75658           json_default(context.initialHashParams.maprules).then((mapcss) => {
75659             services.maprules.init();
75660             mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
75661           }).catch(() => {
75662           });
75663         }
75664         if (!context.container().empty()) {
75665           _ui.ensureLoaded().then(() => {
75666             _background.init();
75667             _photos.init();
75668           });
75669         }
75670       }
75671     };
75672     return utilRebind(context, dispatch14, "on");
75673   }
75674
75675   // modules/services/nominatim.js
75676   var apibase = nominatimApiUrl;
75677   var _inflight = {};
75678   var _nominatimCache;
75679   var nominatim_default = {
75680     init: function() {
75681       _inflight = {};
75682       _nominatimCache = new RBush();
75683     },
75684     reset: function() {
75685       Object.values(_inflight).forEach(function(controller) {
75686         controller.abort();
75687       });
75688       _inflight = {};
75689       _nominatimCache = new RBush();
75690     },
75691     countryCode: function(location, callback) {
75692       this.reverse(location, function(err, result) {
75693         if (err) {
75694           return callback(err);
75695         } else if (result.address) {
75696           return callback(null, result.address.country_code);
75697         } else {
75698           return callback("Unable to geocode", null);
75699         }
75700       });
75701     },
75702     reverse: function(loc, callback) {
75703       var cached = _nominatimCache.search(
75704         { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
75705       );
75706       if (cached.length > 0) {
75707         if (callback) callback(null, cached[0].data);
75708         return;
75709       }
75710       var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
75711       var url = apibase + "reverse?" + utilQsString(params);
75712       if (_inflight[url]) return;
75713       var controller = new AbortController();
75714       _inflight[url] = controller;
75715       json_default(url, {
75716         signal: controller.signal,
75717         headers: {
75718           "Accept-Language": _mainLocalizer.localeCodes().join(",")
75719         }
75720       }).then(function(result) {
75721         delete _inflight[url];
75722         if (result && result.error) {
75723           throw new Error(result.error);
75724         }
75725         var extent = geoExtent(loc).padByMeters(200);
75726         _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
75727         if (callback) callback(null, result);
75728       }).catch(function(err) {
75729         delete _inflight[url];
75730         if (err.name === "AbortError") return;
75731         if (callback) callback(err.message);
75732       });
75733     },
75734     search: function(val, callback) {
75735       const params = {
75736         q: val,
75737         limit: 10,
75738         format: "json"
75739       };
75740       var url = apibase + "search?" + utilQsString(params);
75741       if (_inflight[url]) return;
75742       var controller = new AbortController();
75743       _inflight[url] = controller;
75744       json_default(url, {
75745         signal: controller.signal,
75746         headers: {
75747           "Accept-Language": _mainLocalizer.localeCodes().join(",")
75748         }
75749       }).then(function(result) {
75750         delete _inflight[url];
75751         if (result && result.error) {
75752           throw new Error(result.error);
75753         }
75754         if (callback) callback(null, result);
75755       }).catch(function(err) {
75756         delete _inflight[url];
75757         if (err.name === "AbortError") return;
75758         if (callback) callback(err.message);
75759       });
75760     }
75761   };
75762
75763   // node_modules/name-suggestion-index/lib/matcher.js
75764   var import_which_polygon4 = __toESM(require_which_polygon(), 1);
75765
75766   // node_modules/name-suggestion-index/lib/simplify.js
75767   var import_diacritics3 = __toESM(require_diacritics(), 1);
75768   function simplify2(str) {
75769     if (typeof str !== "string") return "";
75770     return import_diacritics3.default.remove(
75771       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()
75772     );
75773   }
75774
75775   // node_modules/name-suggestion-index/config/matchGroups.json
75776   var matchGroups_default = {
75777     matchGroups: {
75778       adult_gaming_centre: [
75779         "amenity/casino",
75780         "amenity/gambling",
75781         "leisure/adult_gaming_centre"
75782       ],
75783       bar: [
75784         "amenity/bar",
75785         "amenity/pub",
75786         "amenity/restaurant"
75787       ],
75788       beauty: [
75789         "shop/beauty",
75790         "shop/hairdresser_supply"
75791       ],
75792       bed: [
75793         "shop/bed",
75794         "shop/furniture"
75795       ],
75796       beverages: [
75797         "shop/alcohol",
75798         "shop/beer",
75799         "shop/beverages",
75800         "shop/kiosk",
75801         "shop/wine"
75802       ],
75803       camping: [
75804         "tourism/camp_site",
75805         "tourism/caravan_site"
75806       ],
75807       car_parts: [
75808         "shop/car_parts",
75809         "shop/car_repair",
75810         "shop/tires",
75811         "shop/tyres"
75812       ],
75813       clinic: [
75814         "amenity/clinic",
75815         "amenity/doctors",
75816         "healthcare/clinic",
75817         "healthcare/laboratory",
75818         "healthcare/physiotherapist",
75819         "healthcare/sample_collection",
75820         "healthcare/dialysis"
75821       ],
75822       convenience: [
75823         "shop/beauty",
75824         "shop/chemist",
75825         "shop/convenience",
75826         "shop/cosmetics",
75827         "shop/grocery",
75828         "shop/kiosk",
75829         "shop/newsagent",
75830         "shop/perfumery"
75831       ],
75832       coworking: [
75833         "amenity/coworking_space",
75834         "office/coworking",
75835         "office/coworking_space"
75836       ],
75837       dentist: [
75838         "amenity/dentist",
75839         "amenity/doctors",
75840         "healthcare/dentist"
75841       ],
75842       electronics: [
75843         "office/telecommunication",
75844         "shop/appliance",
75845         "shop/computer",
75846         "shop/electronics",
75847         "shop/hifi",
75848         "shop/kiosk",
75849         "shop/mobile",
75850         "shop/mobile_phone",
75851         "shop/telecommunication",
75852         "shop/video_games"
75853       ],
75854       estate_agents: [
75855         "office/estate_agent",
75856         "shop/estate_agent",
75857         "office/mortgage",
75858         "office/financial"
75859       ],
75860       fabric: [
75861         "shop/fabric",
75862         "shop/haberdashery",
75863         "shop/sewing"
75864       ],
75865       fashion: [
75866         "shop/accessories",
75867         "shop/bag",
75868         "shop/boutique",
75869         "shop/clothes",
75870         "shop/department_store",
75871         "shop/fashion",
75872         "shop/fashion_accessories",
75873         "shop/sports",
75874         "shop/shoes"
75875       ],
75876       financial: [
75877         "amenity/bank",
75878         "office/accountant",
75879         "office/financial",
75880         "office/financial_advisor",
75881         "office/tax_advisor",
75882         "shop/tax"
75883       ],
75884       fitness: [
75885         "leisure/fitness_centre",
75886         "leisure/fitness_center",
75887         "leisure/sports_centre",
75888         "leisure/sports_center"
75889       ],
75890       food: [
75891         "amenity/cafe",
75892         "amenity/fast_food",
75893         "amenity/ice_cream",
75894         "amenity/restaurant",
75895         "shop/bakery",
75896         "shop/candy",
75897         "shop/chocolate",
75898         "shop/coffee",
75899         "shop/confectionary",
75900         "shop/confectionery",
75901         "shop/deli",
75902         "shop/food",
75903         "shop/kiosk",
75904         "shop/ice_cream",
75905         "shop/pastry",
75906         "shop/tea"
75907       ],
75908       fuel: [
75909         "amenity/fuel",
75910         "shop/gas",
75911         "shop/convenience;gas",
75912         "shop/gas;convenience"
75913       ],
75914       gift: [
75915         "shop/gift",
75916         "shop/card",
75917         "shop/cards",
75918         "shop/kiosk",
75919         "shop/stationery"
75920       ],
75921       glass: [
75922         "craft/window_construction",
75923         "craft/glaziery",
75924         "shop/car_repair"
75925       ],
75926       hardware: [
75927         "shop/bathroom_furnishing",
75928         "shop/carpet",
75929         "shop/diy",
75930         "shop/doityourself",
75931         "shop/doors",
75932         "shop/electrical",
75933         "shop/flooring",
75934         "shop/hardware",
75935         "shop/hardware_store",
75936         "shop/power_tools",
75937         "shop/tool_hire",
75938         "shop/tools",
75939         "shop/trade"
75940       ],
75941       health_food: [
75942         "shop/health",
75943         "shop/health_food",
75944         "shop/herbalist",
75945         "shop/nutrition_supplements"
75946       ],
75947       hobby: [
75948         "shop/electronics",
75949         "shop/hobby",
75950         "shop/books",
75951         "shop/games",
75952         "shop/collector",
75953         "shop/toys",
75954         "shop/model",
75955         "shop/video_games",
75956         "shop/anime"
75957       ],
75958       hospital: [
75959         "amenity/doctors",
75960         "amenity/hospital",
75961         "healthcare/hospital"
75962       ],
75963       houseware: [
75964         "shop/houseware",
75965         "shop/interior_decoration"
75966       ],
75967       water_rescue: [
75968         "amenity/lifeboat_station",
75969         "emergency/lifeboat_station",
75970         "emergency/marine_rescue",
75971         "emergency/water_rescue"
75972       ],
75973       locksmith: [
75974         "craft/key_cutter",
75975         "craft/locksmith",
75976         "shop/locksmith"
75977       ],
75978       lodging: [
75979         "tourism/guest_house",
75980         "tourism/hotel",
75981         "tourism/motel"
75982       ],
75983       money_transfer: [
75984         "amenity/money_transfer",
75985         "shop/money_transfer"
75986       ],
75987       music: ["shop/music", "shop/musical_instrument"],
75988       office_supplies: [
75989         "shop/office_supplies",
75990         "shop/stationary",
75991         "shop/stationery"
75992       ],
75993       outdoor: [
75994         "shop/clothes",
75995         "shop/outdoor",
75996         "shop/sports"
75997       ],
75998       parcel_locker: [
75999         "amenity/parcel_locker",
76000         "amenity/vending_machine"
76001       ],
76002       pharmacy: [
76003         "amenity/doctors",
76004         "amenity/pharmacy",
76005         "healthcare/pharmacy",
76006         "shop/chemist"
76007       ],
76008       playground: [
76009         "amenity/theme_park",
76010         "leisure/amusement_arcade",
76011         "leisure/playground"
76012       ],
76013       rental: [
76014         "amenity/bicycle_rental",
76015         "amenity/boat_rental",
76016         "amenity/car_rental",
76017         "amenity/truck_rental",
76018         "amenity/vehicle_rental",
76019         "shop/kiosk",
76020         "shop/plant_hire",
76021         "shop/rental",
76022         "shop/tool_hire"
76023       ],
76024       school: [
76025         "amenity/childcare",
76026         "amenity/college",
76027         "amenity/kindergarten",
76028         "amenity/language_school",
76029         "amenity/prep_school",
76030         "amenity/school",
76031         "amenity/university"
76032       ],
76033       storage: [
76034         "shop/storage_units",
76035         "shop/storage_rental"
76036       ],
76037       substation: [
76038         "power/station",
76039         "power/substation",
76040         "power/sub_station"
76041       ],
76042       supermarket: [
76043         "shop/food",
76044         "shop/frozen_food",
76045         "shop/greengrocer",
76046         "shop/grocery",
76047         "shop/supermarket",
76048         "shop/wholesale"
76049       ],
76050       thrift: [
76051         "shop/charity",
76052         "shop/clothes",
76053         "shop/second_hand"
76054       ],
76055       tobacco: [
76056         "shop/e-cigarette",
76057         "shop/tobacco"
76058       ],
76059       variety_store: [
76060         "shop/variety_store",
76061         "shop/discount",
76062         "shop/convenience"
76063       ],
76064       vending: [
76065         "amenity/vending_machine",
76066         "shop/kiosk",
76067         "shop/vending_machine"
76068       ],
76069       weight_loss: [
76070         "amenity/clinic",
76071         "amenity/doctors",
76072         "amenity/weight_clinic",
76073         "healthcare/counselling",
76074         "leisure/fitness_centre",
76075         "office/therapist",
76076         "shop/beauty",
76077         "shop/diet",
76078         "shop/food",
76079         "shop/health_food",
76080         "shop/herbalist",
76081         "shop/nutrition",
76082         "shop/nutrition_supplements",
76083         "shop/weight_loss"
76084       ],
76085       wholesale: [
76086         "shop/wholesale",
76087         "shop/supermarket",
76088         "shop/department_store"
76089       ]
76090     }
76091   };
76092
76093   // node_modules/name-suggestion-index/config/genericWords.json
76094   var genericWords_default = {
76095     genericWords: [
76096       "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
76097       "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
76098       "^(club|green|out|ware)\\s?house$",
76099       "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
76100       "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
76101       "^(hofladen|librairie|magazine?|maison|toko)$",
76102       "^(mobile home|skate)?\\s?park$",
76103       "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
76104       "^\\?+$",
76105       "^private$",
76106       "^tattoo( studio)?$",
76107       "^windmill$",
76108       "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
76109     ]
76110   };
76111
76112   // node_modules/name-suggestion-index/config/trees.json
76113   var trees_default = {
76114     trees: {
76115       brands: {
76116         emoji: "\u{1F354}",
76117         mainTag: "brand:wikidata",
76118         sourceTags: ["brand", "name"],
76119         nameTags: {
76120           primary: "^(name|name:\\w+)$",
76121           alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
76122         }
76123       },
76124       flags: {
76125         emoji: "\u{1F6A9}",
76126         mainTag: "flag:wikidata",
76127         nameTags: {
76128           primary: "^(flag:name|flag:name:\\w+)$",
76129           alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
76130         }
76131       },
76132       operators: {
76133         emoji: "\u{1F4BC}",
76134         mainTag: "operator:wikidata",
76135         sourceTags: ["operator"],
76136         nameTags: {
76137           primary: "^(name|name:\\w+|operator|operator:\\w+)$",
76138           alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
76139         }
76140       },
76141       transit: {
76142         emoji: "\u{1F687}",
76143         mainTag: "network:wikidata",
76144         sourceTags: ["network"],
76145         nameTags: {
76146           primary: "^network$",
76147           alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
76148         }
76149       }
76150     }
76151   };
76152
76153   // node_modules/name-suggestion-index/lib/matcher.js
76154   var matchGroups = matchGroups_default.matchGroups;
76155   var trees = trees_default.trees;
76156   var Matcher = class {
76157     //
76158     // `constructor`
76159     // initialize the genericWords regexes
76160     constructor() {
76161       this.matchIndex = void 0;
76162       this.genericWords = /* @__PURE__ */ new Map();
76163       (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
76164       this.itemLocation = void 0;
76165       this.locationSets = void 0;
76166       this.locationIndex = void 0;
76167       this.warnings = [];
76168     }
76169     //
76170     // `buildMatchIndex()`
76171     // Call this to prepare the matcher for use
76172     //
76173     // `data` needs to be an Object indexed on a 'tree/key/value' path.
76174     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
76175     // {
76176     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
76177     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
76178     //    …
76179     // }
76180     //
76181     buildMatchIndex(data) {
76182       const that = this;
76183       if (that.matchIndex) return;
76184       that.matchIndex = /* @__PURE__ */ new Map();
76185       const seenTree = /* @__PURE__ */ new Map();
76186       Object.keys(data).forEach((tkv) => {
76187         const category = data[tkv];
76188         const parts = tkv.split("/", 3);
76189         const t2 = parts[0];
76190         const k2 = parts[1];
76191         const v2 = parts[2];
76192         const thiskv = "".concat(k2, "/").concat(v2);
76193         const tree = trees[t2];
76194         let branch = that.matchIndex.get(thiskv);
76195         if (!branch) {
76196           branch = {
76197             primary: /* @__PURE__ */ new Map(),
76198             alternate: /* @__PURE__ */ new Map(),
76199             excludeGeneric: /* @__PURE__ */ new Map(),
76200             excludeNamed: /* @__PURE__ */ new Map()
76201           };
76202           that.matchIndex.set(thiskv, branch);
76203         }
76204         const properties = category.properties || {};
76205         const exclude = properties.exclude || {};
76206         (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
76207         (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
76208         const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
76209         let items = category.items;
76210         if (!Array.isArray(items) || !items.length) return;
76211         const primaryName = new RegExp(tree.nameTags.primary, "i");
76212         const alternateName = new RegExp(tree.nameTags.alternate, "i");
76213         const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
76214         const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
76215         const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
76216         const matchGroupKV = /* @__PURE__ */ new Set();
76217         Object.values(matchGroups).forEach((matchGroup) => {
76218           const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
76219           if (!inGroup) return;
76220           matchGroup.forEach((otherkv) => {
76221             if (otherkv === thiskv) return;
76222             matchGroupKV.add(otherkv);
76223             const otherk = otherkv.split("/", 2)[0];
76224             genericKV.add("".concat(otherk, "/yes"));
76225           });
76226         });
76227         items.forEach((item) => {
76228           if (!item.id) return;
76229           if (Array.isArray(item.matchTags) && item.matchTags.length) {
76230             item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && matchTag !== thiskv && !genericKV.has(matchTag));
76231             if (!item.matchTags.length) delete item.matchTags;
76232           }
76233           let kvTags = ["".concat(thiskv)].concat(item.matchTags || []);
76234           if (!skipGenericKV) {
76235             kvTags = kvTags.concat(Array.from(genericKV));
76236           }
76237           Object.keys(item.tags).forEach((osmkey) => {
76238             if (notName.test(osmkey)) return;
76239             const osmvalue = item.tags[osmkey];
76240             if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue))) return;
76241             if (primaryName.test(osmkey)) {
76242               kvTags.forEach((kv) => insertName("primary", t2, kv, simplify2(osmvalue), item.id));
76243             } else if (alternateName.test(osmkey)) {
76244               kvTags.forEach((kv) => insertName("alternate", t2, kv, simplify2(osmvalue), item.id));
76245             }
76246           });
76247           let keepMatchNames = /* @__PURE__ */ new Set();
76248           (item.matchNames || []).forEach((matchName) => {
76249             const nsimple = simplify2(matchName);
76250             kvTags.forEach((kv) => {
76251               const branch2 = that.matchIndex.get(kv);
76252               const primaryLeaf = branch2 && branch2.primary.get(nsimple);
76253               const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
76254               const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
76255               const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
76256               if (!inPrimary && !inAlternate) {
76257                 insertName("alternate", t2, kv, nsimple, item.id);
76258                 keepMatchNames.add(matchName);
76259               }
76260             });
76261           });
76262           if (keepMatchNames.size) {
76263             item.matchNames = Array.from(keepMatchNames);
76264           } else {
76265             delete item.matchNames;
76266           }
76267         });
76268       });
76269       function insertName(which, t2, kv, nsimple, itemID) {
76270         if (!nsimple) {
76271           that.warnings.push("Warning: skipping empty ".concat(which, " name for item ").concat(t2, "/").concat(kv, ": ").concat(itemID));
76272           return;
76273         }
76274         let branch = that.matchIndex.get(kv);
76275         if (!branch) {
76276           branch = {
76277             primary: /* @__PURE__ */ new Map(),
76278             alternate: /* @__PURE__ */ new Map(),
76279             excludeGeneric: /* @__PURE__ */ new Map(),
76280             excludeNamed: /* @__PURE__ */ new Map()
76281           };
76282           that.matchIndex.set(kv, branch);
76283         }
76284         let leaf = branch[which].get(nsimple);
76285         if (!leaf) {
76286           leaf = /* @__PURE__ */ new Set();
76287           branch[which].set(nsimple, leaf);
76288         }
76289         leaf.add(itemID);
76290         if (!/yes$/.test(kv)) {
76291           const kvnsimple = "".concat(kv, "/").concat(nsimple);
76292           const existing = seenTree.get(kvnsimple);
76293           if (existing && existing !== t2) {
76294             const items = Array.from(leaf);
76295             that.warnings.push('Duplicate cache key "'.concat(kvnsimple, '" in trees "').concat(t2, '" and "').concat(existing, '", check items: ').concat(items));
76296             return;
76297           }
76298           seenTree.set(kvnsimple, t2);
76299         }
76300       }
76301       function skipGenericKVMatches(t2, k2, v2) {
76302         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";
76303       }
76304     }
76305     //
76306     // `buildLocationIndex()`
76307     // Call this to prepare a which-polygon location index.
76308     // This *resolves* all the locationSets into GeoJSON, which takes some time.
76309     // You can skip this step if you don't care about matching within a location.
76310     //
76311     // `data` needs to be an Object indexed on a 'tree/key/value' path.
76312     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
76313     // {
76314     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
76315     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
76316     //    …
76317     // }
76318     //
76319     buildLocationIndex(data, loco) {
76320       const that = this;
76321       if (that.locationIndex) return;
76322       that.itemLocation = /* @__PURE__ */ new Map();
76323       that.locationSets = /* @__PURE__ */ new Map();
76324       Object.keys(data).forEach((tkv) => {
76325         const items = data[tkv].items;
76326         if (!Array.isArray(items) || !items.length) return;
76327         items.forEach((item) => {
76328           if (that.itemLocation.has(item.id)) return;
76329           let resolved;
76330           try {
76331             resolved = loco.resolveLocationSet(item.locationSet);
76332           } catch (err) {
76333             console.warn("buildLocationIndex: ".concat(err.message));
76334           }
76335           if (!resolved || !resolved.id) return;
76336           that.itemLocation.set(item.id, resolved.id);
76337           if (that.locationSets.has(resolved.id)) return;
76338           let feature3 = _cloneDeep2(resolved.feature);
76339           feature3.id = resolved.id;
76340           feature3.properties.id = resolved.id;
76341           if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
76342             console.warn("buildLocationIndex: locationSet ".concat(resolved.id, " for ").concat(item.id, " resolves to an empty feature:"));
76343             console.warn(JSON.stringify(feature3));
76344             return;
76345           }
76346           that.locationSets.set(resolved.id, feature3);
76347         });
76348       });
76349       that.locationIndex = (0, import_which_polygon4.default)({ type: "FeatureCollection", features: [...that.locationSets.values()] });
76350       function _cloneDeep2(obj) {
76351         return JSON.parse(JSON.stringify(obj));
76352       }
76353     }
76354     //
76355     // `match()`
76356     // Pass parts and return an Array of matches.
76357     // `k` - key
76358     // `v` - value
76359     // `n` - namelike
76360     // `loc` - optional - [lon,lat] location to search
76361     //
76362     // 1. If the [k,v,n] tuple matches a canonical item…
76363     // Return an Array of match results.
76364     // Each result will include the area in km² that the item is valid.
76365     //
76366     // Order of results:
76367     // Primary ordering will be on the "match" column:
76368     //   "primary" - where the query matches the `name` tag, followed by
76369     //   "alternate" - where the query matches an alternate name tag (e.g. short_name, brand, operator, etc)
76370     // Secondary ordering will be on the "area" column:
76371     //   "area descending" if no location was provided, (worldwide before local)
76372     //   "area ascending" if location was provided (local before worldwide)
76373     //
76374     // [
76375     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
76376     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
76377     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
76378     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
76379     //   …
76380     // ]
76381     //
76382     // -or-
76383     //
76384     // 2. If the [k,v,n] tuple matches an exclude pattern…
76385     // Return an Array with a single exclude result, either
76386     //
76387     // [ { match: 'excludeGeneric', pattern: String,  kv: String } ]  // "generic" e.g. "Food Court"
76388     //   or
76389     // [ { match: 'excludeNamed', pattern: String,  kv: String } ]    // "named", e.g. "Kebabai"
76390     //
76391     // About results
76392     //   "generic" - a generic word that is probably not really a name.
76393     //     For these, iD should warn the user "Hey don't put 'food court' in the name tag".
76394     //   "named" - a real name like "Kebabai" that is just common, but not a brand.
76395     //     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.
76396     //
76397     // -or-
76398     //
76399     // 3. If the [k,v,n] tuple matches nothing of any kind, return `null`
76400     //
76401     //
76402     match(k2, v2, n3, loc) {
76403       const that = this;
76404       if (!that.matchIndex) {
76405         throw new Error("match:  matchIndex not built.");
76406       }
76407       let matchLocations;
76408       if (Array.isArray(loc) && that.locationIndex) {
76409         matchLocations = that.locationIndex([loc[0], loc[1], loc[0], loc[1]], true);
76410       }
76411       const nsimple = simplify2(n3);
76412       let seen = /* @__PURE__ */ new Set();
76413       let results = [];
76414       gatherResults("primary");
76415       gatherResults("alternate");
76416       if (results.length) return results;
76417       gatherResults("exclude");
76418       return results.length ? results : null;
76419       function gatherResults(which) {
76420         const kv = "".concat(k2, "/").concat(v2);
76421         let didMatch = tryMatch(which, kv);
76422         if (didMatch) return;
76423         for (let mg in matchGroups) {
76424           const matchGroup = matchGroups[mg];
76425           const inGroup = matchGroup.some((otherkv) => otherkv === kv);
76426           if (!inGroup) continue;
76427           for (let i3 = 0; i3 < matchGroup.length; i3++) {
76428             const otherkv = matchGroup[i3];
76429             if (otherkv === kv) continue;
76430             didMatch = tryMatch(which, otherkv);
76431             if (didMatch) return;
76432           }
76433         }
76434         if (which === "exclude") {
76435           const regex = [...that.genericWords.values()].find((regex2) => regex2.test(n3));
76436           if (regex) {
76437             results.push({ match: "excludeGeneric", pattern: String(regex) });
76438             return;
76439           }
76440         }
76441       }
76442       function tryMatch(which, kv) {
76443         const branch = that.matchIndex.get(kv);
76444         if (!branch) return;
76445         if (which === "exclude") {
76446           let regex = [...branch.excludeNamed.values()].find((regex2) => regex2.test(n3));
76447           if (regex) {
76448             results.push({ match: "excludeNamed", pattern: String(regex), kv });
76449             return;
76450           }
76451           regex = [...branch.excludeGeneric.values()].find((regex2) => regex2.test(n3));
76452           if (regex) {
76453             results.push({ match: "excludeGeneric", pattern: String(regex), kv });
76454             return;
76455           }
76456           return;
76457         }
76458         const leaf = branch[which].get(nsimple);
76459         if (!leaf || !leaf.size) return;
76460         let hits = Array.from(leaf).map((itemID) => {
76461           let area = Infinity;
76462           if (that.itemLocation && that.locationSets) {
76463             const location = that.locationSets.get(that.itemLocation.get(itemID));
76464             area = location && location.properties.area || Infinity;
76465           }
76466           return { match: which, itemID, area, kv, nsimple };
76467         });
76468         let sortFn = byAreaDescending;
76469         if (matchLocations) {
76470           hits = hits.filter(isValidLocation);
76471           sortFn = byAreaAscending;
76472         }
76473         if (!hits.length) return;
76474         hits.sort(sortFn).forEach((hit) => {
76475           if (seen.has(hit.itemID)) return;
76476           seen.add(hit.itemID);
76477           results.push(hit);
76478         });
76479         return true;
76480         function isValidLocation(hit) {
76481           if (!that.itemLocation) return true;
76482           return matchLocations.find((props) => props.id === that.itemLocation.get(hit.itemID));
76483         }
76484         function byAreaAscending(hitA, hitB) {
76485           return hitA.area - hitB.area;
76486         }
76487         function byAreaDescending(hitA, hitB) {
76488           return hitB.area - hitA.area;
76489         }
76490       }
76491     }
76492     //
76493     // `getWarnings()`
76494     // Return any warnings discovered when buiding the index.
76495     // (currently this does nothing)
76496     //
76497     getWarnings() {
76498       return this.warnings;
76499     }
76500   };
76501
76502   // modules/services/nsi.js
76503   var import_vparse2 = __toESM(require_vparse());
76504   var _nsiStatus = "loading";
76505   var _nsi = {};
76506   var buildingPreset = {
76507     "building/commercial": true,
76508     "building/government": true,
76509     "building/hotel": true,
76510     "building/retail": true,
76511     "building/office": true,
76512     "building/supermarket": true,
76513     "building/yes": true
76514   };
76515   var notNames = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
76516   var notBranches = /(coop|express|wireless|factory|outlet)/i;
76517   function setNsiSources() {
76518     const nsiVersion = package_default.dependencies["name-suggestion-index"] || package_default.devDependencies["name-suggestion-index"];
76519     const v2 = (0, import_vparse2.default)(nsiVersion);
76520     const vMinor = "".concat(v2.major, ".").concat(v2.minor);
76521     const cdn = nsiCdnUrl.replace("{version}", vMinor);
76522     const sources = {
76523       "nsi_data": cdn + "dist/nsi.min.json",
76524       "nsi_dissolved": cdn + "dist/dissolved.min.json",
76525       "nsi_features": cdn + "dist/featureCollection.min.json",
76526       "nsi_generics": cdn + "dist/genericWords.min.json",
76527       "nsi_presets": cdn + "dist/presets/nsi-id-presets.min.json",
76528       "nsi_replacements": cdn + "dist/replacements.min.json",
76529       "nsi_trees": cdn + "dist/trees.min.json"
76530     };
76531     let fileMap = _mainFileFetcher.fileMap();
76532     for (const k2 in sources) {
76533       if (!fileMap[k2]) fileMap[k2] = sources[k2];
76534     }
76535   }
76536   function loadNsiPresets() {
76537     return Promise.all([
76538       _mainFileFetcher.get("nsi_presets"),
76539       _mainFileFetcher.get("nsi_features")
76540     ]).then((vals) => {
76541       Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true);
76542       Object.values(vals[0].presets).forEach((preset) => {
76543         if (preset.tags["brand:wikidata"]) {
76544           preset.removeTags = __spreadValues({ "brand:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
76545         }
76546         if (preset.tags["operator:wikidata"]) {
76547           preset.removeTags = __spreadValues({ "operator:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
76548         }
76549         if (preset.tags["network:wikidata"]) {
76550           preset.removeTags = __spreadValues({ "network:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
76551         }
76552       });
76553       _mainPresetIndex.merge({
76554         presets: vals[0].presets,
76555         featureCollection: vals[1]
76556       });
76557     });
76558   }
76559   function loadNsiData() {
76560     return Promise.all([
76561       _mainFileFetcher.get("nsi_data"),
76562       _mainFileFetcher.get("nsi_dissolved"),
76563       _mainFileFetcher.get("nsi_replacements"),
76564       _mainFileFetcher.get("nsi_trees")
76565     ]).then((vals) => {
76566       _nsi = {
76567         data: vals[0].nsi,
76568         // the raw name-suggestion-index data
76569         dissolved: vals[1].dissolved,
76570         // list of dissolved items
76571         replacements: vals[2].replacements,
76572         // trivial old->new qid replacements
76573         trees: vals[3].trees,
76574         // metadata about trees, main tags
76575         kvt: /* @__PURE__ */ new Map(),
76576         // Map (k -> Map (v -> t) )
76577         qids: /* @__PURE__ */ new Map(),
76578         // Map (wd/wp tag values -> qids)
76579         ids: /* @__PURE__ */ new Map()
76580         // Map (id -> NSI item)
76581       };
76582       const matcher = _nsi.matcher = new Matcher();
76583       matcher.buildMatchIndex(_nsi.data);
76584       matcher.itemLocation = /* @__PURE__ */ new Map();
76585       matcher.locationSets = /* @__PURE__ */ new Map();
76586       Object.keys(_nsi.data).forEach((tkv) => {
76587         const items = _nsi.data[tkv].items;
76588         if (!Array.isArray(items) || !items.length) return;
76589         items.forEach((item) => {
76590           if (matcher.itemLocation.has(item.id)) return;
76591           const locationSetID = _sharedLocationManager.locationSetID(item.locationSet);
76592           matcher.itemLocation.set(item.id, locationSetID);
76593           if (matcher.locationSets.has(locationSetID)) return;
76594           const fakeFeature = { id: locationSetID, properties: { id: locationSetID, area: 1 } };
76595           matcher.locationSets.set(locationSetID, fakeFeature);
76596         });
76597       });
76598       matcher.locationIndex = (bbox2) => {
76599         const validHere = _sharedLocationManager.locationSetsAt([bbox2[0], bbox2[1]]);
76600         const results = [];
76601         for (const [locationSetID, area] of Object.entries(validHere)) {
76602           const fakeFeature = matcher.locationSets.get(locationSetID);
76603           if (fakeFeature) {
76604             fakeFeature.properties.area = area;
76605             results.push(fakeFeature);
76606           }
76607         }
76608         return results;
76609       };
76610       Object.keys(_nsi.data).forEach((tkv) => {
76611         const category = _nsi.data[tkv];
76612         const parts = tkv.split("/", 3);
76613         const t2 = parts[0];
76614         const k2 = parts[1];
76615         const v2 = parts[2];
76616         let vmap = _nsi.kvt.get(k2);
76617         if (!vmap) {
76618           vmap = /* @__PURE__ */ new Map();
76619           _nsi.kvt.set(k2, vmap);
76620         }
76621         vmap.set(v2, t2);
76622         const tree = _nsi.trees[t2];
76623         const mainTag = tree.mainTag;
76624         const items = category.items || [];
76625         items.forEach((item) => {
76626           item.tkv = tkv;
76627           item.mainTag = mainTag;
76628           _nsi.ids.set(item.id, item);
76629           const wd = item.tags[mainTag];
76630           const wp = item.tags[mainTag.replace("wikidata", "wikipedia")];
76631           if (wd) _nsi.qids.set(wd, wd);
76632           if (wp && wd) _nsi.qids.set(wp, wd);
76633         });
76634       });
76635     });
76636   }
76637   function gatherKVs(tags) {
76638     let primary = /* @__PURE__ */ new Set();
76639     let alternate = /* @__PURE__ */ new Set();
76640     Object.keys(tags).forEach((osmkey) => {
76641       const osmvalue = tags[osmkey];
76642       if (!osmvalue) return;
76643       if (osmkey === "route_master") osmkey = "route";
76644       const vmap = _nsi.kvt.get(osmkey);
76645       if (!vmap) return;
76646       if (vmap.get(osmvalue)) {
76647         primary.add("".concat(osmkey, "/").concat(osmvalue));
76648       } else if (osmvalue === "yes") {
76649         alternate.add("".concat(osmkey, "/").concat(osmvalue));
76650       }
76651     });
76652     const preset = _mainPresetIndex.matchTags(tags, "area");
76653     if (buildingPreset[preset.id]) {
76654       alternate.add("building/yes");
76655     }
76656     return { primary, alternate };
76657   }
76658   function identifyTree(tags) {
76659     let unknown;
76660     let t2;
76661     Object.keys(tags).forEach((osmkey) => {
76662       if (t2) return;
76663       const osmvalue = tags[osmkey];
76664       if (!osmvalue) return;
76665       if (osmkey === "route_master") osmkey = "route";
76666       const vmap = _nsi.kvt.get(osmkey);
76667       if (!vmap) return;
76668       if (osmvalue === "yes") {
76669         unknown = "unknown";
76670       } else {
76671         t2 = vmap.get(osmvalue);
76672       }
76673     });
76674     return t2 || unknown || null;
76675   }
76676   function gatherNames(tags) {
76677     const empty2 = { primary: /* @__PURE__ */ new Set(), alternate: /* @__PURE__ */ new Set() };
76678     let primary = /* @__PURE__ */ new Set();
76679     let alternate = /* @__PURE__ */ new Set();
76680     let foundSemi = false;
76681     let testNameFragments = false;
76682     let patterns2;
76683     let t2 = identifyTree(tags);
76684     if (!t2) return empty2;
76685     if (t2 === "transit") {
76686       patterns2 = {
76687         primary: /^network$/i,
76688         alternate: /^(operator|operator:\w+|network:\w+|\w+_name|\w+_name:\w+)$/i
76689       };
76690     } else if (t2 === "flags") {
76691       patterns2 = {
76692         primary: /^(flag:name|flag:name:\w+)$/i,
76693         alternate: /^(flag|flag:\w+|subject|subject:\w+)$/i
76694         // note: no `country`, we special-case it below
76695       };
76696     } else if (t2 === "brands") {
76697       testNameFragments = true;
76698       patterns2 = {
76699         primary: /^(name|name:\w+)$/i,
76700         alternate: /^(brand|brand:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
76701       };
76702     } else if (t2 === "operators") {
76703       testNameFragments = true;
76704       patterns2 = {
76705         primary: /^(name|name:\w+|operator|operator:\w+)$/i,
76706         alternate: /^(brand|brand:\w+|\w+_name|\w+_name:\w+)/i
76707       };
76708     } else {
76709       testNameFragments = true;
76710       patterns2 = {
76711         primary: /^(name|name:\w+)$/i,
76712         alternate: /^(brand|brand:\w+|network|network:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
76713       };
76714     }
76715     if (tags.name && testNameFragments) {
76716       const nameParts = tags.name.split(/[\s\-\/,.]/);
76717       for (let split = nameParts.length; split > 0; split--) {
76718         const name = nameParts.slice(0, split).join(" ");
76719         primary.add(name);
76720       }
76721     }
76722     Object.keys(tags).forEach((osmkey) => {
76723       const osmvalue = tags[osmkey];
76724       if (!osmvalue) return;
76725       if (isNamelike(osmkey, "primary")) {
76726         if (/;/.test(osmvalue)) {
76727           foundSemi = true;
76728         } else {
76729           primary.add(osmvalue);
76730           alternate.delete(osmvalue);
76731         }
76732       } else if (!primary.has(osmvalue) && isNamelike(osmkey, "alternate")) {
76733         if (/;/.test(osmvalue)) {
76734           foundSemi = true;
76735         } else {
76736           alternate.add(osmvalue);
76737         }
76738       }
76739     });
76740     if (tags.man_made === "flagpole" && !primary.size && !alternate.size && !!tags.country) {
76741       const osmvalue = tags.country;
76742       if (/;/.test(osmvalue)) {
76743         foundSemi = true;
76744       } else {
76745         alternate.add(osmvalue);
76746       }
76747     }
76748     if (foundSemi) {
76749       return empty2;
76750     } else {
76751       return { primary, alternate };
76752     }
76753     function isNamelike(osmkey, which) {
76754       if (osmkey === "old_name") return false;
76755       return patterns2[which].test(osmkey) && !notNames.test(osmkey);
76756     }
76757   }
76758   function gatherTuples(tryKVs, tryNames) {
76759     let tuples = [];
76760     ["primary", "alternate"].forEach((whichName) => {
76761       const arr = Array.from(tryNames[whichName]).sort((a2, b2) => b2.length - a2.length);
76762       arr.forEach((n3) => {
76763         ["primary", "alternate"].forEach((whichKV) => {
76764           tryKVs[whichKV].forEach((kv) => {
76765             const parts = kv.split("/", 2);
76766             const k2 = parts[0];
76767             const v2 = parts[1];
76768             tuples.push({ k: k2, v: v2, n: n3 });
76769           });
76770         });
76771       });
76772     });
76773     return tuples;
76774   }
76775   function _upgradeTags(tags, loc) {
76776     let newTags = Object.assign({}, tags);
76777     let changed = false;
76778     Object.keys(newTags).forEach((osmkey) => {
76779       const matchTag = osmkey.match(/^(\w+:)?wikidata$/);
76780       if (matchTag) {
76781         const prefix = matchTag[1] || "";
76782         const wd = newTags[osmkey];
76783         const replace = _nsi.replacements[wd];
76784         if (replace && replace.wikidata !== void 0) {
76785           changed = true;
76786           if (replace.wikidata) {
76787             newTags[osmkey] = replace.wikidata;
76788           } else {
76789             delete newTags[osmkey];
76790           }
76791         }
76792         if (replace && replace.wikipedia !== void 0) {
76793           changed = true;
76794           const wpkey = "".concat(prefix, "wikipedia");
76795           if (replace.wikipedia) {
76796             newTags[wpkey] = replace.wikipedia;
76797           } else {
76798             delete newTags[wpkey];
76799           }
76800         }
76801       }
76802     });
76803     const isRouteMaster = tags.type === "route_master";
76804     const tryKVs = gatherKVs(tags);
76805     if (!tryKVs.primary.size && !tryKVs.alternate.size) {
76806       return changed ? { newTags, matched: null } : null;
76807     }
76808     const tryNames = gatherNames(tags);
76809     const foundQID = _nsi.qids.get(tags.wikidata) || _nsi.qids.get(tags.wikipedia);
76810     if (foundQID) tryNames.primary.add(foundQID);
76811     if (!tryNames.primary.size && !tryNames.alternate.size) {
76812       return changed ? { newTags, matched: null } : null;
76813     }
76814     const tuples = gatherTuples(tryKVs, tryNames);
76815     for (let i3 = 0; i3 < tuples.length; i3++) {
76816       const tuple = tuples[i3];
76817       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n, loc);
76818       if (!hits || !hits.length) continue;
76819       if (hits[0].match !== "primary" && hits[0].match !== "alternate") break;
76820       let itemID, item;
76821       for (let j2 = 0; j2 < hits.length; j2++) {
76822         const hit = hits[j2];
76823         itemID = hit.itemID;
76824         if (_nsi.dissolved[itemID]) continue;
76825         item = _nsi.ids.get(itemID);
76826         if (!item) continue;
76827         const mainTag = item.mainTag;
76828         const itemQID = item.tags[mainTag];
76829         const notQID = newTags["not:".concat(mainTag)];
76830         if (
76831           // Exceptions, skip this hit
76832           !itemQID || itemQID === notQID || // No `*:wikidata` or matched a `not:*:wikidata`
76833           newTags.office && !item.tags.office
76834         ) {
76835           item = null;
76836           continue;
76837         } else {
76838           break;
76839         }
76840       }
76841       if (!item) continue;
76842       item = JSON.parse(JSON.stringify(item));
76843       const tkv = item.tkv;
76844       const parts = tkv.split("/", 3);
76845       const k2 = parts[1];
76846       const v2 = parts[2];
76847       const category = _nsi.data[tkv];
76848       const properties = category.properties || {};
76849       let preserveTags = item.preserveTags || properties.preserveTags || [];
76850       ["building", "emergency", "internet_access", "opening_hours", "takeaway"].forEach((osmkey) => {
76851         if (k2 !== osmkey) preserveTags.push("^".concat(osmkey, "$"));
76852       });
76853       const regexes = preserveTags.map((s2) => new RegExp(s2, "i"));
76854       let keepTags = {};
76855       Object.keys(newTags).forEach((osmkey) => {
76856         if (regexes.some((regex) => regex.test(osmkey))) {
76857           keepTags[osmkey] = newTags[osmkey];
76858         }
76859       });
76860       _nsi.kvt.forEach((vmap, k3) => {
76861         if (newTags[k3] === "yes") delete newTags[k3];
76862       });
76863       if (foundQID) {
76864         delete newTags.wikipedia;
76865         delete newTags.wikidata;
76866       }
76867       Object.assign(newTags, item.tags, keepTags);
76868       if (isRouteMaster) {
76869         newTags.route_master = newTags.route;
76870         delete newTags.route;
76871       }
76872       const origName = tags.name;
76873       const newName = newTags.name;
76874       if (newName && origName && newName !== origName && !newTags.branch) {
76875         const newNames = gatherNames(newTags);
76876         const newSet = /* @__PURE__ */ new Set([...newNames.primary, ...newNames.alternate]);
76877         const isMoved = newSet.has(origName);
76878         if (!isMoved) {
76879           const nameParts = origName.split(/[\s\-\/,.]/);
76880           for (let split = nameParts.length; split > 0; split--) {
76881             const name = nameParts.slice(0, split).join(" ");
76882             const branch = nameParts.slice(split).join(" ");
76883             const nameHits = _nsi.matcher.match(k2, v2, name, loc);
76884             if (!nameHits || !nameHits.length) continue;
76885             if (nameHits.some((hit) => hit.itemID === itemID)) {
76886               if (branch) {
76887                 if (notBranches.test(branch)) {
76888                   newTags.name = origName;
76889                 } else {
76890                   const branchHits = _nsi.matcher.match(k2, v2, branch, loc);
76891                   if (branchHits && branchHits.length) {
76892                     if (branchHits[0].match === "primary" || branchHits[0].match === "alternate") {
76893                       return null;
76894                     }
76895                   } else {
76896                     newTags.branch = branch;
76897                   }
76898                 }
76899               }
76900               break;
76901             }
76902           }
76903         }
76904       }
76905       return { newTags, matched: item };
76906     }
76907     return changed ? { newTags, matched: null } : null;
76908   }
76909   function _isGenericName(tags) {
76910     const n3 = tags.name;
76911     if (!n3) return false;
76912     const tryNames = { primary: /* @__PURE__ */ new Set([n3]), alternate: /* @__PURE__ */ new Set() };
76913     const tryKVs = gatherKVs(tags);
76914     if (!tryKVs.primary.size && !tryKVs.alternate.size) return false;
76915     const tuples = gatherTuples(tryKVs, tryNames);
76916     for (let i3 = 0; i3 < tuples.length; i3++) {
76917       const tuple = tuples[i3];
76918       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n);
76919       if (hits && hits.length && hits[0].match === "excludeGeneric") return true;
76920     }
76921     return false;
76922   }
76923   var nsi_default = {
76924     // `init()`
76925     // On init, start preparing the name-suggestion-index
76926     //
76927     init: () => {
76928       setNsiSources();
76929       _mainPresetIndex.ensureLoaded().then(() => loadNsiPresets()).then(() => loadNsiData()).then(() => _nsiStatus = "ok").catch(() => _nsiStatus = "failed");
76930     },
76931     // `reset()`
76932     // Reset is called when user saves data to OSM (does nothing here)
76933     //
76934     reset: () => {
76935     },
76936     // `status()`
76937     // To let other code know how it's going...
76938     //
76939     // Returns
76940     //   `String`: 'loading', 'ok', 'failed'
76941     //
76942     status: () => _nsiStatus,
76943     // `isGenericName()`
76944     // Is the `name` tag generic?
76945     //
76946     // Arguments
76947     //   `tags`: `Object` containing the feature's OSM tags
76948     // Returns
76949     //   `true` if it is generic, `false` if not
76950     //
76951     isGenericName: (tags) => _isGenericName(tags),
76952     // `upgradeTags()`
76953     // Suggest tag upgrades.
76954     // This function will not modify the input tags, it makes a copy.
76955     //
76956     // Arguments
76957     //   `tags`: `Object` containing the feature's OSM tags
76958     //   `loc`: Location where this feature exists, as a [lon, lat]
76959     // Returns
76960     //   `Object` containing the result, or `null` if no changes needed:
76961     //   {
76962     //     'newTags': `Object` - The tags the the feature should have
76963     //     'matched': `Object` - The matched item
76964     //   }
76965     //
76966     upgradeTags: (tags, loc) => _upgradeTags(tags, loc),
76967     // `cache()`
76968     // Direct access to the NSI cache, useful for testing or breaking things
76969     //
76970     // Returns
76971     //   `Object`: the internal NSI cache
76972     //
76973     cache: () => _nsi
76974   };
76975
76976   // modules/services/kartaview.js
76977   var apibase2 = "https://kartaview.org";
76978   var maxResults = 1e3;
76979   var tileZoom = 14;
76980   var tiler3 = utilTiler().zoomExtent([tileZoom, tileZoom]).skipNullIsland(true);
76981   var dispatch6 = dispatch_default("loadedImages");
76982   var imgZoom2 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
76983   var _oscCache;
76984   var _oscSelectedImage;
76985   var _loadViewerPromise2;
76986   function abortRequest3(controller) {
76987     controller.abort();
76988   }
76989   function maxPageAtZoom(z2) {
76990     if (z2 < 15) return 2;
76991     if (z2 === 15) return 5;
76992     if (z2 === 16) return 10;
76993     if (z2 === 17) return 20;
76994     if (z2 === 18) return 40;
76995     if (z2 > 18) return 80;
76996   }
76997   function loadTiles2(which, url, projection2) {
76998     var currZoom = Math.floor(geoScaleToZoom(projection2.scale()));
76999     var tiles = tiler3.getTiles(projection2);
77000     var cache = _oscCache[which];
77001     Object.keys(cache.inflight).forEach(function(k2) {
77002       var wanted = tiles.find(function(tile) {
77003         return k2.indexOf(tile.id + ",") === 0;
77004       });
77005       if (!wanted) {
77006         abortRequest3(cache.inflight[k2]);
77007         delete cache.inflight[k2];
77008       }
77009     });
77010     tiles.forEach(function(tile) {
77011       loadNextTilePage(which, currZoom, url, tile);
77012     });
77013   }
77014   function loadNextTilePage(which, currZoom, url, tile) {
77015     var cache = _oscCache[which];
77016     var bbox2 = tile.extent.bbox();
77017     var maxPages = maxPageAtZoom(currZoom);
77018     var nextPage = cache.nextPage[tile.id] || 1;
77019     var params = utilQsString({
77020       ipp: maxResults,
77021       page: nextPage,
77022       // client_id: clientId,
77023       bbTopLeft: [bbox2.maxY, bbox2.minX].join(","),
77024       bbBottomRight: [bbox2.minY, bbox2.maxX].join(",")
77025     }, true);
77026     if (nextPage > maxPages) return;
77027     var id2 = tile.id + "," + String(nextPage);
77028     if (cache.loaded[id2] || cache.inflight[id2]) return;
77029     var controller = new AbortController();
77030     cache.inflight[id2] = controller;
77031     var options2 = {
77032       method: "POST",
77033       signal: controller.signal,
77034       body: params,
77035       headers: { "Content-Type": "application/x-www-form-urlencoded" }
77036     };
77037     json_default(url, options2).then(function(data) {
77038       cache.loaded[id2] = true;
77039       delete cache.inflight[id2];
77040       if (!data || !data.currentPageItems || !data.currentPageItems.length) {
77041         throw new Error("No Data");
77042       }
77043       var features = data.currentPageItems.map(function(item) {
77044         var loc = [+item.lng, +item.lat];
77045         var d2;
77046         if (which === "images") {
77047           d2 = {
77048             loc,
77049             key: item.id,
77050             ca: +item.heading,
77051             captured_at: item.shot_date || item.date_added,
77052             captured_by: item.username,
77053             imagePath: item.lth_name,
77054             sequence_id: item.sequence_id,
77055             sequence_index: +item.sequence_index
77056           };
77057           var seq = _oscCache.sequences[d2.sequence_id];
77058           if (!seq) {
77059             seq = { rotation: 0, images: [] };
77060             _oscCache.sequences[d2.sequence_id] = seq;
77061           }
77062           seq.images[d2.sequence_index] = d2;
77063           _oscCache.images.forImageKey[d2.key] = d2;
77064         }
77065         return {
77066           minX: loc[0],
77067           minY: loc[1],
77068           maxX: loc[0],
77069           maxY: loc[1],
77070           data: d2
77071         };
77072       });
77073       cache.rtree.load(features);
77074       if (data.currentPageItems.length === maxResults) {
77075         cache.nextPage[tile.id] = nextPage + 1;
77076         loadNextTilePage(which, currZoom, url, tile);
77077       } else {
77078         cache.nextPage[tile.id] = Infinity;
77079       }
77080       if (which === "images") {
77081         dispatch6.call("loadedImages");
77082       }
77083     }).catch(function() {
77084       cache.loaded[id2] = true;
77085       delete cache.inflight[id2];
77086     });
77087   }
77088   function partitionViewport2(projection2) {
77089     var z2 = geoScaleToZoom(projection2.scale());
77090     var z22 = Math.ceil(z2 * 2) / 2 + 2.5;
77091     var tiler8 = utilTiler().zoomExtent([z22, z22]);
77092     return tiler8.getTiles(projection2).map(function(tile) {
77093       return tile.extent;
77094     });
77095   }
77096   function searchLimited2(limit, projection2, rtree) {
77097     limit = limit || 5;
77098     return partitionViewport2(projection2).reduce(function(result, extent) {
77099       var found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
77100         return d2.data;
77101       });
77102       return found.length ? result.concat(found) : result;
77103     }, []);
77104   }
77105   var kartaview_default = {
77106     init: function() {
77107       if (!_oscCache) {
77108         this.reset();
77109       }
77110       this.event = utilRebind(this, dispatch6, "on");
77111     },
77112     reset: function() {
77113       if (_oscCache) {
77114         Object.values(_oscCache.images.inflight).forEach(abortRequest3);
77115       }
77116       _oscCache = {
77117         images: { inflight: {}, loaded: {}, nextPage: {}, rtree: new RBush(), forImageKey: {} },
77118         sequences: {}
77119       };
77120       _oscSelectedImage = null;
77121     },
77122     images: function(projection2) {
77123       var limit = 5;
77124       return searchLimited2(limit, projection2, _oscCache.images.rtree);
77125     },
77126     sequences: function(projection2) {
77127       var viewport = projection2.clipExtent();
77128       var min3 = [viewport[0][0], viewport[1][1]];
77129       var max3 = [viewport[1][0], viewport[0][1]];
77130       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
77131       var sequenceKeys = {};
77132       _oscCache.images.rtree.search(bbox2).forEach(function(d2) {
77133         sequenceKeys[d2.data.sequence_id] = true;
77134       });
77135       var lineStrings = [];
77136       Object.keys(sequenceKeys).forEach(function(sequenceKey) {
77137         var seq = _oscCache.sequences[sequenceKey];
77138         var images = seq && seq.images;
77139         if (images) {
77140           lineStrings.push({
77141             type: "LineString",
77142             coordinates: images.map(function(d2) {
77143               return d2.loc;
77144             }).filter(Boolean),
77145             properties: {
77146               captured_at: images[0] ? images[0].captured_at : null,
77147               captured_by: images[0] ? images[0].captured_by : null,
77148               key: sequenceKey
77149             }
77150           });
77151         }
77152       });
77153       return lineStrings;
77154     },
77155     cachedImage: function(imageKey) {
77156       return _oscCache.images.forImageKey[imageKey];
77157     },
77158     loadImages: function(projection2) {
77159       var url = apibase2 + "/1.0/list/nearby-photos/";
77160       loadTiles2("images", url, projection2);
77161     },
77162     ensureViewerLoaded: function(context) {
77163       if (_loadViewerPromise2) return _loadViewerPromise2;
77164       var wrap2 = context.container().select(".photoviewer").selectAll(".kartaview-wrapper").data([0]);
77165       var that = this;
77166       var wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper kartaview-wrapper").classed("hide", true).call(imgZoom2.on("zoom", zoomPan2)).on("dblclick.zoom", null);
77167       wrapEnter.append("div").attr("class", "photo-attribution fillD");
77168       var controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
77169       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
77170       controlsEnter.append("button").on("click.rotate-ccw", rotate(-90)).text("\u293F");
77171       controlsEnter.append("button").on("click.rotate-cw", rotate(90)).text("\u293E");
77172       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
77173       wrapEnter.append("div").attr("class", "kartaview-image-wrap");
77174       context.ui().photoviewer.on("resize.kartaview", function(dimensions) {
77175         imgZoom2.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]);
77176       });
77177       function zoomPan2(d3_event) {
77178         var t2 = d3_event.transform;
77179         context.container().select(".photoviewer .kartaview-image-wrap").call(utilSetTransform, t2.x, t2.y, t2.k);
77180       }
77181       function rotate(deg) {
77182         return function() {
77183           if (!_oscSelectedImage) return;
77184           var sequenceKey = _oscSelectedImage.sequence_id;
77185           var sequence = _oscCache.sequences[sequenceKey];
77186           if (!sequence) return;
77187           var r2 = sequence.rotation || 0;
77188           r2 += deg;
77189           if (r2 > 180) r2 -= 360;
77190           if (r2 < -180) r2 += 360;
77191           sequence.rotation = r2;
77192           var wrap3 = context.container().select(".photoviewer .kartaview-wrapper");
77193           wrap3.transition().duration(100).call(imgZoom2.transform, identity2);
77194           wrap3.selectAll(".kartaview-image").transition().duration(100).style("transform", "rotate(" + r2 + "deg)");
77195         };
77196       }
77197       function step(stepBy) {
77198         return function() {
77199           if (!_oscSelectedImage) return;
77200           var sequenceKey = _oscSelectedImage.sequence_id;
77201           var sequence = _oscCache.sequences[sequenceKey];
77202           if (!sequence) return;
77203           var nextIndex = _oscSelectedImage.sequence_index + stepBy;
77204           var nextImage = sequence.images[nextIndex];
77205           if (!nextImage) return;
77206           context.map().centerEase(nextImage.loc);
77207           that.selectImage(context, nextImage.key);
77208         };
77209       }
77210       _loadViewerPromise2 = Promise.resolve();
77211       return _loadViewerPromise2;
77212     },
77213     showViewer: function(context) {
77214       var viewer = context.container().select(".photoviewer").classed("hide", false);
77215       var isHidden = viewer.selectAll(".photo-wrapper.kartaview-wrapper.hide").size();
77216       if (isHidden) {
77217         viewer.selectAll(".photo-wrapper:not(.kartaview-wrapper)").classed("hide", true);
77218         viewer.selectAll(".photo-wrapper.kartaview-wrapper").classed("hide", false);
77219       }
77220       return this;
77221     },
77222     hideViewer: function(context) {
77223       _oscSelectedImage = null;
77224       this.updateUrlImage(null);
77225       var viewer = context.container().select(".photoviewer");
77226       if (!viewer.empty()) viewer.datum(null);
77227       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
77228       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
77229       return this.setStyles(context, null, true);
77230     },
77231     selectImage: function(context, imageKey) {
77232       var d2 = this.cachedImage(imageKey);
77233       _oscSelectedImage = d2;
77234       this.updateUrlImage(imageKey);
77235       var viewer = context.container().select(".photoviewer");
77236       if (!viewer.empty()) viewer.datum(d2);
77237       this.setStyles(context, null, true);
77238       context.container().selectAll(".icon-sign").classed("currentView", false);
77239       if (!d2) return this;
77240       var wrap2 = context.container().select(".photoviewer .kartaview-wrapper");
77241       var imageWrap = wrap2.selectAll(".kartaview-image-wrap");
77242       var attribution = wrap2.selectAll(".photo-attribution").text("");
77243       wrap2.transition().duration(100).call(imgZoom2.transform, identity2);
77244       imageWrap.selectAll(".kartaview-image").remove();
77245       if (d2) {
77246         var sequence = _oscCache.sequences[d2.sequence_id];
77247         var r2 = sequence && sequence.rotation || 0;
77248         imageWrap.append("img").attr("class", "kartaview-image").attr("src", apibase2 + "/" + d2.imagePath).style("transform", "rotate(" + r2 + "deg)");
77249         if (d2.captured_by) {
77250           attribution.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://kartaview.org/user/" + encodeURIComponent(d2.captured_by)).text("@" + d2.captured_by);
77251           attribution.append("span").text("|");
77252         }
77253         if (d2.captured_at) {
77254           attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.captured_at));
77255           attribution.append("span").text("|");
77256         }
77257         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");
77258       }
77259       return this;
77260       function localeDateString2(s2) {
77261         if (!s2) return null;
77262         var options2 = { day: "numeric", month: "short", year: "numeric" };
77263         var d4 = new Date(s2);
77264         if (isNaN(d4.getTime())) return null;
77265         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
77266       }
77267     },
77268     getSelectedImage: function() {
77269       return _oscSelectedImage;
77270     },
77271     getSequenceKeyForImage: function(d2) {
77272       return d2 && d2.sequence_id;
77273     },
77274     // Updates the currently highlighted sequence and selected bubble.
77275     // Reset is only necessary when interacting with the viewport because
77276     // this implicitly changes the currently selected bubble/sequence
77277     setStyles: function(context, hovered, reset) {
77278       if (reset) {
77279         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
77280         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
77281       }
77282       var hoveredImageId = hovered && hovered.key;
77283       var hoveredSequenceId = this.getSequenceKeyForImage(hovered);
77284       var viewer = context.container().select(".photoviewer");
77285       var selected = viewer.empty() ? void 0 : viewer.datum();
77286       var selectedImageId = selected && selected.key;
77287       var selectedSequenceId = this.getSequenceKeyForImage(selected);
77288       context.container().selectAll(".layer-kartaview .viewfield-group").classed("highlighted", function(d2) {
77289         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
77290       }).classed("hovered", function(d2) {
77291         return d2.key === hoveredImageId;
77292       }).classed("currentView", function(d2) {
77293         return d2.key === selectedImageId;
77294       });
77295       context.container().selectAll(".layer-kartaview .sequence").classed("highlighted", function(d2) {
77296         return d2.properties.key === hoveredSequenceId;
77297       }).classed("currentView", function(d2) {
77298         return d2.properties.key === selectedSequenceId;
77299       });
77300       context.container().selectAll(".layer-kartaview .viewfield-group .viewfield").attr("d", viewfieldPath);
77301       function viewfieldPath() {
77302         var d2 = this.parentNode.__data__;
77303         if (d2.pano && d2.key !== selectedImageId) {
77304           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
77305         } else {
77306           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
77307         }
77308       }
77309       return this;
77310     },
77311     updateUrlImage: function(imageKey) {
77312       if (!window.mocha) {
77313         var hash2 = utilStringQs(window.location.hash);
77314         if (imageKey) {
77315           hash2.photo = "kartaview/" + imageKey;
77316         } else {
77317           delete hash2.photo;
77318         }
77319         window.location.replace("#" + utilQsString(hash2, true));
77320       }
77321     },
77322     cache: function() {
77323       return _oscCache;
77324     }
77325   };
77326
77327   // modules/services/pannellum_photo.js
77328   var pannellumViewerCSS = "pannellum/pannellum.css";
77329   var pannellumViewerJS = "pannellum/pannellum.js";
77330   var dispatch7 = dispatch_default("viewerChanged");
77331   var _currScenes = [];
77332   var _pannellumViewer;
77333   var pannellum_photo_default = {
77334     init: async function(context, selection2) {
77335       selection2.append("div").attr("class", "photo-frame pannellum-frame").attr("id", "ideditor-pannellum-viewer").classed("hide", true).on("keydown", function(e3) {
77336         e3.stopPropagation();
77337       });
77338       if (!window.pannellum) {
77339         await this.loadPannellum(context);
77340       }
77341       const options2 = {
77342         "default": { firstScene: "" },
77343         scenes: {},
77344         minHfov: 20
77345       };
77346       _pannellumViewer = window.pannellum.viewer("ideditor-pannellum-viewer", options2);
77347       _pannellumViewer.on("mousedown", () => {
77348         select_default2(window).on("pointermove.pannellum mousemove.pannellum", () => {
77349           dispatch7.call("viewerChanged");
77350         });
77351       }).on("mouseup", () => {
77352         select_default2(window).on("pointermove.pannellum mousemove.pannellum", null);
77353       }).on("animatefinished", () => {
77354         dispatch7.call("viewerChanged");
77355       });
77356       context.ui().photoviewer.on("resize.pannellum", () => {
77357         _pannellumViewer.resize();
77358       });
77359       this.event = utilRebind(this, dispatch7, "on");
77360       return this;
77361     },
77362     loadPannellum: function(context) {
77363       const head = select_default2("head");
77364       return Promise.all([
77365         new Promise((resolve, reject) => {
77366           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);
77367         }),
77368         new Promise((resolve, reject) => {
77369           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);
77370         })
77371       ]);
77372     },
77373     showPhotoFrame: function(context) {
77374       const isHidden = context.selectAll(".photo-frame.pannellum-frame.hide").size();
77375       if (isHidden) {
77376         context.selectAll(".photo-frame:not(.pannellum-frame)").classed("hide", true);
77377         context.selectAll(".photo-frame.pannellum-frame").classed("hide", false);
77378       }
77379       return this;
77380     },
77381     hidePhotoFrame: function(viewerContext) {
77382       viewerContext.select("photo-frame.pannellum-frame").classed("hide", false);
77383       return this;
77384     },
77385     selectPhoto: function(data, keepOrientation) {
77386       const { key } = data;
77387       if (!(key in _currScenes)) {
77388         let newSceneOptions = {
77389           showFullscreenCtrl: false,
77390           autoLoad: false,
77391           compass: false,
77392           yaw: 0,
77393           type: "equirectangular",
77394           preview: data.preview_path,
77395           panorama: data.image_path,
77396           northOffset: data.ca
77397         };
77398         _currScenes.push(key);
77399         _pannellumViewer.addScene(key, newSceneOptions);
77400       }
77401       let yaw = 0;
77402       let pitch = 0;
77403       if (keepOrientation) {
77404         yaw = this.getYaw();
77405         pitch = _pannellumViewer.getPitch();
77406       }
77407       _pannellumViewer.loadScene(key, pitch, yaw);
77408       dispatch7.call("viewerChanged");
77409       if (_currScenes.length > 3) {
77410         const old_key = _currScenes.shift();
77411         _pannellumViewer.removeScene(old_key);
77412       }
77413       _pannellumViewer.resize();
77414       return this;
77415     },
77416     getYaw: function() {
77417       return _pannellumViewer.getYaw();
77418     }
77419   };
77420
77421   // modules/services/vegbilder.js
77422   var owsEndpoint = "https://www.vegvesen.no/kart/ogc/vegbilder_1_0/ows?";
77423   var tileZoom2 = 14;
77424   var tiler4 = utilTiler().zoomExtent([tileZoom2, tileZoom2]).skipNullIsland(true);
77425   var dispatch8 = dispatch_default("loadedImages", "viewerChanged");
77426   var directionEnum = Object.freeze({
77427     forward: Symbol(0),
77428     backward: Symbol(1)
77429   });
77430   var _planeFrame;
77431   var _pannellumFrame;
77432   var _currentFrame;
77433   var _loadViewerPromise3;
77434   var _vegbilderCache;
77435   async function fetchAvailableLayers() {
77436     var _a4, _b3, _c2;
77437     const params = {
77438       service: "WFS",
77439       request: "GetCapabilities",
77440       version: "2.0.0"
77441     };
77442     const urlForRequest = owsEndpoint + utilQsString(params);
77443     const response = await xml_default(urlForRequest);
77444     const regexMatcher = new RegExp("^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\\d{4})$");
77445     const availableLayers = [];
77446     for (const node of response.querySelectorAll("FeatureType > Name")) {
77447       const match = (_a4 = node.textContent) == null ? void 0 : _a4.match(regexMatcher);
77448       if (match) {
77449         availableLayers.push({
77450           name: match[0],
77451           is_sphere: !!((_b3 = match.groups) == null ? void 0 : _b3.image_type),
77452           year: parseInt((_c2 = match.groups) == null ? void 0 : _c2.year, 10)
77453         });
77454       }
77455     }
77456     return availableLayers;
77457   }
77458   function filterAvailableLayers(photoContex) {
77459     const fromDateString = photoContex.fromDate();
77460     const toDateString = photoContex.toDate();
77461     const fromYear = fromDateString ? new Date(fromDateString).getFullYear() : 2016;
77462     const toYear = toDateString ? new Date(toDateString).getFullYear() : null;
77463     const showsFlat = photoContex.showsFlat();
77464     const showsPano = photoContex.showsPanoramic();
77465     return Array.from(_vegbilderCache.wfslayers.values()).filter(({ layerInfo }) => layerInfo.year >= fromYear && (!toYear || layerInfo.year <= toYear) && (!layerInfo.is_sphere && showsFlat || layerInfo.is_sphere && showsPano));
77466   }
77467   function loadWFSLayers(projection2, margin, wfslayers) {
77468     const tiles = tiler4.margin(margin).getTiles(projection2);
77469     for (const cache of wfslayers) {
77470       loadWFSLayer(projection2, cache, tiles);
77471     }
77472   }
77473   function loadWFSLayer(projection2, cache, tiles) {
77474     for (const [key, controller] of cache.inflight.entries()) {
77475       const wanted = tiles.some((tile) => key === tile.id);
77476       if (!wanted) {
77477         controller.abort();
77478         cache.inflight.delete(key);
77479       }
77480     }
77481     Promise.all(tiles.map(
77482       (tile) => loadTile2(cache, cache.layerInfo.name, tile)
77483     )).then(() => orderSequences(projection2, cache));
77484   }
77485   async function loadTile2(cache, typename, tile) {
77486     const bbox2 = tile.extent.bbox();
77487     const tileid = tile.id;
77488     if (cache.loaded.get(tileid) === true || cache.inflight.has(tileid)) return;
77489     const params = {
77490       service: "WFS",
77491       request: "GetFeature",
77492       version: "2.0.0",
77493       typenames: typename,
77494       bbox: [bbox2.minY, bbox2.minX, bbox2.maxY, bbox2.maxX].join(","),
77495       outputFormat: "json"
77496     };
77497     const controller = new AbortController();
77498     cache.inflight.set(tileid, controller);
77499     const options2 = {
77500       method: "GET",
77501       signal: controller.signal
77502     };
77503     const urlForRequest = owsEndpoint + utilQsString(params);
77504     let featureCollection;
77505     try {
77506       featureCollection = await json_default(urlForRequest, options2);
77507     } catch (e3) {
77508       cache.loaded.set(tileid, false);
77509       return;
77510     } finally {
77511       cache.inflight.delete(tileid);
77512     }
77513     cache.loaded.set(tileid, true);
77514     if (featureCollection.features.length === 0) {
77515       return;
77516     }
77517     const features = featureCollection.features.map((feature3) => {
77518       const loc = feature3.geometry.coordinates;
77519       const key = feature3.id;
77520       const properties = feature3.properties;
77521       const {
77522         RETNING: ca,
77523         TIDSPUNKT: captured_at,
77524         URL: image_path,
77525         URLPREVIEW: preview_path,
77526         BILDETYPE: image_type,
77527         METER: metering,
77528         FELTKODE: lane_code
77529       } = properties;
77530       const lane_number = parseInt(lane_code.match(/^[0-9]+/)[0], 10);
77531       const direction = lane_number % 2 === 0 ? directionEnum.backward : directionEnum.forward;
77532       const data = {
77533         loc,
77534         key,
77535         ca,
77536         image_path,
77537         preview_path,
77538         road_reference: roadReference(properties),
77539         metering,
77540         lane_code,
77541         direction,
77542         captured_at: new Date(captured_at),
77543         is_sphere: image_type === "360"
77544       };
77545       cache.points.set(key, data);
77546       return {
77547         minX: loc[0],
77548         minY: loc[1],
77549         maxX: loc[0],
77550         maxY: loc[1],
77551         data
77552       };
77553     });
77554     _vegbilderCache.rtree.load(features);
77555     dispatch8.call("loadedImages");
77556   }
77557   function orderSequences(projection2, cache) {
77558     const { points } = cache;
77559     const grouped = Array.from(points.values()).reduce((grouped2, image) => {
77560       const key = image.road_reference;
77561       if (grouped2.has(key)) {
77562         grouped2.get(key).push(image);
77563       } else {
77564         grouped2.set(key, [image]);
77565       }
77566       return grouped2;
77567     }, /* @__PURE__ */ new Map());
77568     const imageSequences = Array.from(grouped.values()).reduce((imageSequences2, imageGroup) => {
77569       imageGroup.sort((a2, b2) => {
77570         if (a2.captured_at.valueOf() > b2.captured_at.valueOf()) {
77571           return 1;
77572         } else if (a2.captured_at.valueOf() < b2.captured_at.valueOf()) {
77573           return -1;
77574         } else {
77575           const { direction } = a2;
77576           if (direction === directionEnum.forward) {
77577             return a2.metering - b2.metering;
77578           } else {
77579             return b2.metering - a2.metering;
77580           }
77581         }
77582       });
77583       let imageSequence = [imageGroup[0]];
77584       let angle2 = null;
77585       for (const [lastImage, image] of pairs(imageGroup)) {
77586         if (lastImage.ca === null) {
77587           const b2 = projection2(lastImage.loc);
77588           const a2 = projection2(image.loc);
77589           if (!geoVecEqual(a2, b2)) {
77590             angle2 = geoVecAngle(a2, b2);
77591             angle2 *= 180 / Math.PI;
77592             angle2 -= 90;
77593             angle2 = angle2 >= 0 ? angle2 : angle2 + 360;
77594           }
77595           lastImage.ca = angle2;
77596         }
77597         if (image.direction === lastImage.direction && image.captured_at.valueOf() - lastImage.captured_at.valueOf() <= 2e4) {
77598           imageSequence.push(image);
77599         } else {
77600           imageSequences2.push(imageSequence);
77601           imageSequence = [image];
77602         }
77603       }
77604       imageSequences2.push(imageSequence);
77605       return imageSequences2;
77606     }, []);
77607     cache.sequences = imageSequences.map((images) => {
77608       const sequence = {
77609         images,
77610         key: images[0].key,
77611         geometry: {
77612           type: "LineString",
77613           coordinates: images.map((image) => image.loc)
77614         }
77615       };
77616       for (const image of images) {
77617         _vegbilderCache.image2sequence_map.set(image.key, sequence);
77618       }
77619       return sequence;
77620     });
77621   }
77622   function roadReference(properties) {
77623     const {
77624       FYLKENUMMER: county_number,
77625       VEGKATEGORI: road_class,
77626       VEGSTATUS: road_status,
77627       VEGNUMMER: road_number,
77628       STREKNING: section,
77629       DELSTREKNING: subsection,
77630       HP: parcel,
77631       KRYSSDEL: junction_part,
77632       SIDEANLEGGSDEL: services_part,
77633       ANKERPUNKT: anker_point,
77634       AAR: year
77635     } = properties;
77636     let reference;
77637     if (year >= 2020) {
77638       reference = "".concat(road_class).concat(road_status).concat(road_number, " S").concat(section, "D").concat(subsection);
77639       if (junction_part) {
77640         reference = "".concat(reference, " M").concat(anker_point, " KD").concat(junction_part);
77641       } else if (services_part) {
77642         reference = "".concat(reference, " M").concat(anker_point, " SD").concat(services_part);
77643       }
77644     } else {
77645       reference = "".concat(county_number).concat(road_class).concat(road_status).concat(road_number, " HP").concat(parcel);
77646     }
77647     return reference;
77648   }
77649   function localeTimestamp(date) {
77650     const options2 = {
77651       day: "2-digit",
77652       month: "2-digit",
77653       year: "numeric",
77654       hour: "numeric",
77655       minute: "numeric",
77656       second: "numeric"
77657     };
77658     return date.toLocaleString(_mainLocalizer.localeCode(), options2);
77659   }
77660   function partitionViewport3(projection2) {
77661     const zoom = geoScaleToZoom(projection2.scale());
77662     const roundZoom = Math.ceil(zoom * 2) / 2 + 2.5;
77663     const tiler8 = utilTiler().zoomExtent([roundZoom, roundZoom]);
77664     return tiler8.getTiles(projection2).map((tile) => tile.extent);
77665   }
77666   function searchLimited3(limit, projection2, rtree) {
77667     limit != null ? limit : limit = 5;
77668     return partitionViewport3(projection2).reduce((result, extent) => {
77669       const found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
77670       return result.concat(found);
77671     }, []);
77672   }
77673   var vegbilder_default = {
77674     init: function() {
77675       this.event = utilRebind(this, dispatch8, "on");
77676     },
77677     reset: async function() {
77678       if (_vegbilderCache) {
77679         for (const layer of _vegbilderCache.wfslayers.values()) {
77680           for (const controller of layer.inflight.values()) {
77681             controller.abort();
77682           }
77683         }
77684       }
77685       _vegbilderCache = {
77686         wfslayers: /* @__PURE__ */ new Map(),
77687         rtree: new RBush(),
77688         image2sequence_map: /* @__PURE__ */ new Map()
77689       };
77690       const availableLayers = await fetchAvailableLayers();
77691       const { wfslayers } = _vegbilderCache;
77692       for (const layerInfo of availableLayers) {
77693         const cache = {
77694           layerInfo,
77695           loaded: /* @__PURE__ */ new Map(),
77696           inflight: /* @__PURE__ */ new Map(),
77697           points: /* @__PURE__ */ new Map(),
77698           sequences: []
77699         };
77700         wfslayers.set(layerInfo.name, cache);
77701       }
77702     },
77703     images: function(projection2) {
77704       const limit = 5;
77705       return searchLimited3(limit, projection2, _vegbilderCache.rtree);
77706     },
77707     sequences: function(projection2) {
77708       const viewport = projection2.clipExtent();
77709       const min3 = [viewport[0][0], viewport[1][1]];
77710       const max3 = [viewport[1][0], viewport[0][1]];
77711       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
77712       const seen = /* @__PURE__ */ new Set();
77713       const line_strings = [];
77714       for (const { data } of _vegbilderCache.rtree.search(bbox2)) {
77715         const sequence = _vegbilderCache.image2sequence_map.get(data.key);
77716         if (!sequence) continue;
77717         const { key, geometry, images } = sequence;
77718         if (seen.has(key)) continue;
77719         seen.add(key);
77720         const line = {
77721           type: "LineString",
77722           coordinates: geometry.coordinates,
77723           key,
77724           images
77725         };
77726         line_strings.push(line);
77727       }
77728       return line_strings;
77729     },
77730     cachedImage: function(key) {
77731       for (const { points } of _vegbilderCache.wfslayers.values()) {
77732         if (points.has(key)) return points.get(key);
77733       }
77734     },
77735     getSequenceForImage: function(image) {
77736       return _vegbilderCache == null ? void 0 : _vegbilderCache.image2sequence_map.get(image == null ? void 0 : image.key);
77737     },
77738     loadImages: async function(context, margin) {
77739       if (!_vegbilderCache) {
77740         await this.reset();
77741       }
77742       margin != null ? margin : margin = 1;
77743       const wfslayers = filterAvailableLayers(context.photos());
77744       loadWFSLayers(context.projection, margin, wfslayers);
77745     },
77746     photoFrame: function() {
77747       return _currentFrame;
77748     },
77749     ensureViewerLoaded: function(context) {
77750       if (_loadViewerPromise3) return _loadViewerPromise3;
77751       const step = (stepBy) => () => {
77752         const viewer = context.container().select(".photoviewer");
77753         const selected = viewer.empty() ? void 0 : viewer.datum();
77754         if (!selected) return;
77755         const sequence = this.getSequenceForImage(selected);
77756         const nextIndex = sequence.images.indexOf(selected) + stepBy;
77757         const nextImage = sequence.images[nextIndex];
77758         if (!nextImage) return;
77759         context.map().centerEase(nextImage.loc);
77760         this.selectImage(context, nextImage.key, true);
77761       };
77762       const wrap2 = context.container().select(".photoviewer").selectAll(".vegbilder-wrapper").data([0]);
77763       const wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper vegbilder-wrapper").classed("hide", true);
77764       wrapEnter.append("div").attr("class", "photo-attribution fillD");
77765       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
77766       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
77767       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
77768       _loadViewerPromise3 = Promise.all([
77769         pannellum_photo_default.init(context, wrapEnter),
77770         plane_photo_default.init(context, wrapEnter)
77771       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
77772         _pannellumFrame = pannellumPhotoFrame;
77773         _pannellumFrame.event.on("viewerChanged", () => dispatch8.call("viewerChanged"));
77774         _planeFrame = planePhotoFrame;
77775         _planeFrame.event.on("viewerChanged", () => dispatch8.call("viewerChanged"));
77776       });
77777       return _loadViewerPromise3;
77778     },
77779     selectImage: function(context, key, keepOrientation) {
77780       const d2 = this.cachedImage(key);
77781       this.updateUrlImage(key);
77782       const viewer = context.container().select(".photoviewer");
77783       if (!viewer.empty()) {
77784         viewer.datum(d2);
77785       }
77786       this.setStyles(context, null, true);
77787       if (!d2) return this;
77788       const wrap2 = context.container().select(".photoviewer .vegbilder-wrapper");
77789       const attribution = wrap2.selectAll(".photo-attribution").text("");
77790       if (d2.captured_at) {
77791         attribution.append("span").attr("class", "captured_at").text(localeTimestamp(d2.captured_at));
77792       }
77793       attribution.append("a").attr("target", "_blank").attr("href", "https://vegvesen.no").call(_t.append("vegbilder.publisher"));
77794       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"));
77795       _currentFrame = d2.is_sphere ? _pannellumFrame : _planeFrame;
77796       _currentFrame.selectPhoto(d2, keepOrientation).showPhotoFrame(wrap2);
77797       return this;
77798     },
77799     showViewer: function(context) {
77800       const viewer = context.container().select(".photoviewer").classed("hide", false);
77801       const isHidden = viewer.selectAll(".photo-wrapper.vegbilder-wrapper.hide").size();
77802       if (isHidden) {
77803         viewer.selectAll(".photo-wrapper:not(.vegbilder-wrapper)").classed("hide", true);
77804         viewer.selectAll(".photo-wrapper.vegbilder-wrapper").classed("hide", false);
77805       }
77806       return this;
77807     },
77808     hideViewer: function(context) {
77809       this.updateUrlImage(null);
77810       const viewer = context.container().select(".photoviewer");
77811       if (!viewer.empty()) viewer.datum(null);
77812       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
77813       context.container().selectAll(".viewfield-group, .sequence").classed("currentView", false);
77814       return this.setStyles(context, null, true);
77815     },
77816     // Updates the currently highlighted sequence and selected bubble.
77817     // Reset is only necessary when interacting with the viewport because
77818     // this implicitly changes the currently selected bubble/sequence
77819     setStyles: function(context, hovered, reset) {
77820       var _a4, _b3;
77821       if (reset) {
77822         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
77823         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
77824       }
77825       const hoveredImageKey = hovered == null ? void 0 : hovered.key;
77826       const hoveredSequence = this.getSequenceForImage(hovered);
77827       const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key;
77828       const hoveredImageKeys = (_a4 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a4 : [];
77829       const viewer = context.container().select(".photoviewer");
77830       const selected = viewer.empty() ? void 0 : viewer.datum();
77831       const selectedImageKey = selected == null ? void 0 : selected.key;
77832       const selectedSequence = this.getSequenceForImage(selected);
77833       const selectedSequenceKey = selectedSequence == null ? void 0 : selectedSequence.key;
77834       const selectedImageKeys = (_b3 = selectedSequence == null ? void 0 : selectedSequence.images.map((d2) => d2.key)) != null ? _b3 : [];
77835       const highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
77836       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);
77837       context.container().selectAll(".layer-vegbilder .sequence").classed("highlighted", (d2) => d2.key === hoveredSequenceKey).classed("currentView", (d2) => d2.key === selectedSequenceKey);
77838       context.container().selectAll(".layer-vegbilder .viewfield-group .viewfield").attr("d", viewfieldPath);
77839       function viewfieldPath() {
77840         const d2 = this.parentNode.__data__;
77841         if (d2.is_sphere && d2.key !== selectedImageKey) {
77842           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
77843         } else {
77844           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
77845         }
77846       }
77847       return this;
77848     },
77849     updateUrlImage: function(key) {
77850       if (!window.mocha) {
77851         const hash2 = utilStringQs(window.location.hash);
77852         if (key) {
77853           hash2.photo = "vegbilder/" + key;
77854         } else {
77855           delete hash2.photo;
77856         }
77857         window.location.replace("#" + utilQsString(hash2, true));
77858       }
77859     },
77860     validHere: function(extent) {
77861       const bbox2 = Object.values(extent.bbox());
77862       return iso1A2Codes(bbox2).includes("NO");
77863     },
77864     cache: function() {
77865       return _vegbilderCache;
77866     }
77867   };
77868
77869   // node_modules/osm-auth/src/osm-auth.mjs
77870   function osmAuth(o2) {
77871     var oauth2 = {};
77872     var _store = null;
77873     try {
77874       _store = window.localStorage;
77875     } catch (e3) {
77876       var _mock = /* @__PURE__ */ new Map();
77877       _store = {
77878         isMocked: true,
77879         hasItem: (k2) => _mock.has(k2),
77880         getItem: (k2) => _mock.get(k2),
77881         setItem: (k2, v2) => _mock.set(k2, v2),
77882         removeItem: (k2) => _mock.delete(k2),
77883         clear: () => _mock.clear()
77884       };
77885     }
77886     function token(k2, v2) {
77887       var key = o2.url + k2;
77888       if (arguments.length === 1) {
77889         var val = _store.getItem(key) || "";
77890         return val.replace(/"/g, "");
77891       } else if (arguments.length === 2) {
77892         if (v2) {
77893           return _store.setItem(key, v2);
77894         } else {
77895           return _store.removeItem(key);
77896         }
77897       }
77898     }
77899     oauth2.authenticated = function() {
77900       return !!token("oauth2_access_token");
77901     };
77902     oauth2.logout = function() {
77903       token("oauth2_access_token", "");
77904       token("oauth_token", "");
77905       token("oauth_token_secret", "");
77906       token("oauth_request_token_secret", "");
77907       return oauth2;
77908     };
77909     oauth2.authenticate = function(callback, options2) {
77910       if (oauth2.authenticated()) {
77911         callback(null, oauth2);
77912         return;
77913       }
77914       oauth2.logout();
77915       _preopenPopup(function(error, popup) {
77916         if (error) {
77917           callback(error);
77918         } else {
77919           _generatePkceChallenge(function(pkce) {
77920             _authenticate(pkce, options2, popup, callback);
77921           });
77922         }
77923       });
77924     };
77925     oauth2.authenticateAsync = function(options2) {
77926       if (oauth2.authenticated()) {
77927         return Promise.resolve(oauth2);
77928       }
77929       oauth2.logout();
77930       return new Promise((resolve, reject) => {
77931         var errback = (err, result) => {
77932           if (err) {
77933             reject(err);
77934           } else {
77935             resolve(result);
77936           }
77937         };
77938         _preopenPopup((error, popup) => {
77939           if (error) {
77940             errback(error);
77941           } else {
77942             _generatePkceChallenge((pkce) => _authenticate(pkce, options2, popup, errback));
77943           }
77944         });
77945       });
77946     };
77947     function _preopenPopup(callback) {
77948       if (o2.singlepage) {
77949         callback(null, void 0);
77950         return;
77951       }
77952       var w2 = 550;
77953       var h2 = 610;
77954       var settings = [
77955         ["width", w2],
77956         ["height", h2],
77957         ["left", window.screen.width / 2 - w2 / 2],
77958         ["top", window.screen.height / 2 - h2 / 2]
77959       ].map(function(x2) {
77960         return x2.join("=");
77961       }).join(",");
77962       var popup = window.open("about:blank", "oauth_window", settings);
77963       if (popup) {
77964         callback(null, popup);
77965       } else {
77966         var error = new Error("Popup was blocked");
77967         error.status = "popup-blocked";
77968         callback(error);
77969       }
77970     }
77971     function _authenticate(pkce, options2, popup, callback) {
77972       var state = generateState();
77973       var path = "/oauth2/authorize?" + utilQsString2({
77974         client_id: o2.client_id,
77975         redirect_uri: o2.redirect_uri,
77976         response_type: "code",
77977         scope: o2.scope,
77978         state,
77979         code_challenge: pkce.code_challenge,
77980         code_challenge_method: pkce.code_challenge_method,
77981         locale: o2.locale || ""
77982       });
77983       var url = (options2 == null ? void 0 : options2.switchUser) ? "".concat(o2.url, "/logout?referer=").concat(encodeURIComponent("/login?referer=".concat(encodeURIComponent(path)))) : o2.url + path;
77984       if (o2.singlepage) {
77985         if (_store.isMocked) {
77986           var error = new Error("localStorage unavailable, but required in singlepage mode");
77987           error.status = "pkce-localstorage-unavailable";
77988           callback(error);
77989           return;
77990         }
77991         var params = utilStringQs2(window.location.search.slice(1));
77992         if (params.code) {
77993           oauth2.bootstrapToken(params.code, callback);
77994         } else {
77995           token("oauth2_state", state);
77996           token("oauth2_pkce_code_verifier", pkce.code_verifier);
77997           window.location = url;
77998         }
77999       } else {
78000         var popupClosedWatcher = setInterval(function() {
78001           if (popup.closed) {
78002             var error2 = new Error("Popup was closed prematurely");
78003             error2.status = "popup-closed";
78004             callback(error2);
78005             window.clearInterval(popupClosedWatcher);
78006             delete window.authComplete;
78007           }
78008         }, 1e3);
78009         oauth2.popupWindow = popup;
78010         popup.location = url;
78011       }
78012       window.authComplete = function(url2) {
78013         clearTimeout(popupClosedWatcher);
78014         var params2 = utilStringQs2(url2.split("?")[1]);
78015         if (params2.state !== state) {
78016           var error2 = new Error("Invalid state");
78017           error2.status = "invalid-state";
78018           callback(error2);
78019           return;
78020         }
78021         _getAccessToken(params2.code, pkce.code_verifier, accessTokenDone);
78022         delete window.authComplete;
78023       };
78024       function accessTokenDone(err, xhr) {
78025         o2.done();
78026         if (err) {
78027           callback(err);
78028           return;
78029         }
78030         var access_token = JSON.parse(xhr.response);
78031         token("oauth2_access_token", access_token.access_token);
78032         callback(null, oauth2);
78033       }
78034     }
78035     function _getAccessToken(auth_code, code_verifier, accessTokenDone) {
78036       var url = o2.url + "/oauth2/token?" + utilQsString2({
78037         client_id: o2.client_id,
78038         redirect_uri: o2.redirect_uri,
78039         grant_type: "authorization_code",
78040         code: auth_code,
78041         code_verifier
78042       });
78043       oauth2.rawxhr("POST", url, null, null, null, accessTokenDone);
78044       o2.loading();
78045     }
78046     oauth2.bringPopupWindowToFront = function() {
78047       var broughtPopupToFront = false;
78048       try {
78049         if (oauth2.popupWindow && !oauth2.popupWindow.closed) {
78050           oauth2.popupWindow.focus();
78051           broughtPopupToFront = true;
78052         }
78053       } catch (err) {
78054       }
78055       return broughtPopupToFront;
78056     };
78057     oauth2.bootstrapToken = function(auth_code, callback) {
78058       var state = token("oauth2_state");
78059       token("oauth2_state", "");
78060       var params = utilStringQs2(window.location.search.slice(1));
78061       if (params.state !== state) {
78062         var error = new Error("Invalid state");
78063         error.status = "invalid-state";
78064         callback(error);
78065         return;
78066       }
78067       var code_verifier = token("oauth2_pkce_code_verifier");
78068       token("oauth2_pkce_code_verifier", "");
78069       _getAccessToken(auth_code, code_verifier, accessTokenDone);
78070       function accessTokenDone(err, xhr) {
78071         o2.done();
78072         if (err) {
78073           callback(err);
78074           return;
78075         }
78076         var access_token = JSON.parse(xhr.response);
78077         token("oauth2_access_token", access_token.access_token);
78078         callback(null, oauth2);
78079       }
78080     };
78081     oauth2.fetch = function(resource, options2) {
78082       if (oauth2.authenticated()) {
78083         return _doFetch();
78084       } else {
78085         if (o2.auto) {
78086           return oauth2.authenticateAsync().then(_doFetch);
78087         } else {
78088           return Promise.reject(new Error("not authenticated"));
78089         }
78090       }
78091       function _doFetch() {
78092         options2 = options2 || {};
78093         if (!options2.headers) {
78094           options2.headers = { "Content-Type": "application/x-www-form-urlencoded" };
78095         }
78096         options2.headers.Authorization = "Bearer " + token("oauth2_access_token");
78097         return fetch(resource, options2);
78098       }
78099     };
78100     oauth2.xhr = function(options2, callback) {
78101       if (oauth2.authenticated()) {
78102         return _doXHR();
78103       } else {
78104         if (o2.auto) {
78105           oauth2.authenticate(_doXHR);
78106           return;
78107         } else {
78108           callback("not authenticated", null);
78109           return;
78110         }
78111       }
78112       function _doXHR() {
78113         var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path;
78114         return oauth2.rawxhr(
78115           options2.method,
78116           url,
78117           token("oauth2_access_token"),
78118           options2.content,
78119           options2.headers,
78120           done
78121         );
78122       }
78123       function done(err, xhr) {
78124         if (err) {
78125           callback(err);
78126         } else if (xhr.responseXML) {
78127           callback(err, xhr.responseXML);
78128         } else {
78129           callback(err, xhr.response);
78130         }
78131       }
78132     };
78133     oauth2.rawxhr = function(method, url, access_token, data, headers, callback) {
78134       headers = headers || { "Content-Type": "application/x-www-form-urlencoded" };
78135       if (access_token) {
78136         headers.Authorization = "Bearer " + access_token;
78137       }
78138       var xhr = new XMLHttpRequest();
78139       xhr.onreadystatechange = function() {
78140         if (4 === xhr.readyState && 0 !== xhr.status) {
78141           if (/^20\d$/.test(xhr.status)) {
78142             callback(null, xhr);
78143           } else {
78144             callback(xhr, null);
78145           }
78146         }
78147       };
78148       xhr.onerror = function(e3) {
78149         callback(e3, null);
78150       };
78151       xhr.open(method, url, true);
78152       for (var h2 in headers) xhr.setRequestHeader(h2, headers[h2]);
78153       xhr.send(data);
78154       return xhr;
78155     };
78156     oauth2.preauth = function(val) {
78157       if (val && val.access_token) {
78158         token("oauth2_access_token", val.access_token);
78159       }
78160       return oauth2;
78161     };
78162     oauth2.options = function(val) {
78163       if (!arguments.length) return o2;
78164       o2 = val;
78165       o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org";
78166       o2.url = o2.url || "https://www.openstreetmap.org";
78167       o2.auto = o2.auto || false;
78168       o2.singlepage = o2.singlepage || false;
78169       o2.loading = o2.loading || function() {
78170       };
78171       o2.done = o2.done || function() {
78172       };
78173       return oauth2.preauth(o2);
78174     };
78175     oauth2.options(o2);
78176     return oauth2;
78177   }
78178   function utilQsString2(obj) {
78179     return Object.keys(obj).filter(function(key) {
78180       return obj[key] !== void 0;
78181     }).sort().map(function(key) {
78182       return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
78183     }).join("&");
78184   }
78185   function utilStringQs2(str) {
78186     var i3 = 0;
78187     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#")) i3++;
78188     str = str.slice(i3);
78189     return str.split("&").reduce(function(obj, pair3) {
78190       var parts = pair3.split("=");
78191       if (parts.length === 2) {
78192         obj[parts[0]] = decodeURIComponent(parts[1]);
78193       }
78194       return obj;
78195     }, {});
78196   }
78197   function supportsWebCryptoAPI() {
78198     return window && window.crypto && window.crypto.getRandomValues && window.crypto.subtle && window.crypto.subtle.digest;
78199   }
78200   function _generatePkceChallenge(callback) {
78201     var code_verifier;
78202     if (supportsWebCryptoAPI()) {
78203       var random = window.crypto.getRandomValues(new Uint8Array(32));
78204       code_verifier = base64(random.buffer);
78205       var verifier = Uint8Array.from(Array.from(code_verifier).map(function(char) {
78206         return char.charCodeAt(0);
78207       }));
78208       window.crypto.subtle.digest("SHA-256", verifier).then(function(hash2) {
78209         var code_challenge = base64(hash2);
78210         callback({
78211           code_challenge,
78212           code_verifier,
78213           code_challenge_method: "S256"
78214         });
78215       });
78216     } else {
78217       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
78218       code_verifier = "";
78219       for (var i3 = 0; i3 < 64; i3++) {
78220         code_verifier += chars[Math.floor(Math.random() * chars.length)];
78221       }
78222       callback({
78223         code_verifier,
78224         code_challenge: code_verifier,
78225         code_challenge_method: "plain"
78226       });
78227     }
78228   }
78229   function generateState() {
78230     var state;
78231     if (supportsWebCryptoAPI()) {
78232       var random = window.crypto.getRandomValues(new Uint8Array(32));
78233       state = base64(random.buffer);
78234     } else {
78235       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
78236       state = "";
78237       for (var i3 = 0; i3 < 64; i3++) {
78238         state += chars[Math.floor(Math.random() * chars.length)];
78239       }
78240     }
78241     return state;
78242   }
78243   function base64(buffer) {
78244     return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]/g, "");
78245   }
78246
78247   // modules/services/osm.js
78248   var tiler5 = utilTiler();
78249   var dispatch9 = dispatch_default("apiStatusChange", "authLoading", "authDone", "change", "loading", "loaded", "loadedNotes");
78250   var urlroot = osmApiConnections[0].url;
78251   var apiUrlroot = osmApiConnections[0].apiUrl || urlroot;
78252   var redirectPath = window.location.origin + window.location.pathname;
78253   var oauth = osmAuth({
78254     url: urlroot,
78255     apiUrl: apiUrlroot,
78256     client_id: osmApiConnections[0].client_id,
78257     scope: "read_prefs write_prefs write_api read_gpx write_notes",
78258     redirect_uri: redirectPath + "land.html",
78259     loading: authLoading,
78260     done: authDone
78261   });
78262   var _apiConnections = osmApiConnections;
78263   var _imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
78264   var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
78265   var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
78266   var _userCache = { toLoad: {}, user: {} };
78267   var _cachedApiStatus;
78268   var _changeset = {};
78269   var _deferred = /* @__PURE__ */ new Set();
78270   var _connectionID = 1;
78271   var _tileZoom3 = 16;
78272   var _noteZoom = 12;
78273   var _rateLimitError;
78274   var _userChangesets;
78275   var _userDetails;
78276   var _off;
78277   var _maxWayNodes = 2e3;
78278   function authLoading() {
78279     dispatch9.call("authLoading");
78280   }
78281   function authDone() {
78282     dispatch9.call("authDone");
78283   }
78284   function abortRequest4(controllerOrXHR) {
78285     if (controllerOrXHR) {
78286       controllerOrXHR.abort();
78287     }
78288   }
78289   function hasInflightRequests(cache) {
78290     return Object.keys(cache.inflight).length;
78291   }
78292   function abortUnwantedRequests3(cache, visibleTiles) {
78293     Object.keys(cache.inflight).forEach(function(k2) {
78294       if (cache.toLoad[k2]) return;
78295       if (visibleTiles.find(function(tile) {
78296         return k2 === tile.id;
78297       })) return;
78298       abortRequest4(cache.inflight[k2]);
78299       delete cache.inflight[k2];
78300     });
78301   }
78302   function getLoc(attrs) {
78303     var lon = attrs.lon && attrs.lon.value;
78304     var lat = attrs.lat && attrs.lat.value;
78305     return [Number(lon), Number(lat)];
78306   }
78307   function getNodes(obj) {
78308     var elems = obj.getElementsByTagName("nd");
78309     var nodes = new Array(elems.length);
78310     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
78311       nodes[i3] = "n" + elems[i3].attributes.ref.value;
78312     }
78313     return nodes;
78314   }
78315   function getNodesJSON(obj) {
78316     var elems = obj.nodes;
78317     var nodes = new Array(elems.length);
78318     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
78319       nodes[i3] = "n" + elems[i3];
78320     }
78321     return nodes;
78322   }
78323   function getTags(obj) {
78324     var elems = obj.getElementsByTagName("tag");
78325     var tags = {};
78326     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
78327       var attrs = elems[i3].attributes;
78328       tags[attrs.k.value] = attrs.v.value;
78329     }
78330     return tags;
78331   }
78332   function getMembers(obj) {
78333     var elems = obj.getElementsByTagName("member");
78334     var members = new Array(elems.length);
78335     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
78336       var attrs = elems[i3].attributes;
78337       members[i3] = {
78338         id: attrs.type.value[0] + attrs.ref.value,
78339         type: attrs.type.value,
78340         role: attrs.role.value
78341       };
78342     }
78343     return members;
78344   }
78345   function getMembersJSON(obj) {
78346     var elems = obj.members;
78347     var members = new Array(elems.length);
78348     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
78349       var attrs = elems[i3];
78350       members[i3] = {
78351         id: attrs.type[0] + attrs.ref,
78352         type: attrs.type,
78353         role: attrs.role
78354       };
78355     }
78356     return members;
78357   }
78358   function getVisible(attrs) {
78359     return !attrs.visible || attrs.visible.value !== "false";
78360   }
78361   function parseComments(comments) {
78362     var parsedComments = [];
78363     for (var i3 = 0; i3 < comments.length; i3++) {
78364       var comment = comments[i3];
78365       if (comment.nodeName === "comment") {
78366         var childNodes = comment.childNodes;
78367         var parsedComment = {};
78368         for (var j2 = 0; j2 < childNodes.length; j2++) {
78369           var node = childNodes[j2];
78370           var nodeName = node.nodeName;
78371           if (nodeName === "#text") continue;
78372           parsedComment[nodeName] = node.textContent;
78373           if (nodeName === "uid") {
78374             var uid = node.textContent;
78375             if (uid && !_userCache.user[uid]) {
78376               _userCache.toLoad[uid] = true;
78377             }
78378           }
78379         }
78380         if (parsedComment) {
78381           parsedComments.push(parsedComment);
78382         }
78383       }
78384     }
78385     return parsedComments;
78386   }
78387   function encodeNoteRtree(note) {
78388     return {
78389       minX: note.loc[0],
78390       minY: note.loc[1],
78391       maxX: note.loc[0],
78392       maxY: note.loc[1],
78393       data: note
78394     };
78395   }
78396   var jsonparsers = {
78397     node: function nodeData(obj, uid) {
78398       return new osmNode({
78399         id: uid,
78400         visible: typeof obj.visible === "boolean" ? obj.visible : true,
78401         version: obj.version && obj.version.toString(),
78402         changeset: obj.changeset && obj.changeset.toString(),
78403         timestamp: obj.timestamp,
78404         user: obj.user,
78405         uid: obj.uid && obj.uid.toString(),
78406         loc: [Number(obj.lon), Number(obj.lat)],
78407         tags: obj.tags
78408       });
78409     },
78410     way: function wayData(obj, uid) {
78411       return new osmWay({
78412         id: uid,
78413         visible: typeof obj.visible === "boolean" ? obj.visible : true,
78414         version: obj.version && obj.version.toString(),
78415         changeset: obj.changeset && obj.changeset.toString(),
78416         timestamp: obj.timestamp,
78417         user: obj.user,
78418         uid: obj.uid && obj.uid.toString(),
78419         tags: obj.tags,
78420         nodes: getNodesJSON(obj)
78421       });
78422     },
78423     relation: function relationData(obj, uid) {
78424       return new osmRelation({
78425         id: uid,
78426         visible: typeof obj.visible === "boolean" ? obj.visible : true,
78427         version: obj.version && obj.version.toString(),
78428         changeset: obj.changeset && obj.changeset.toString(),
78429         timestamp: obj.timestamp,
78430         user: obj.user,
78431         uid: obj.uid && obj.uid.toString(),
78432         tags: obj.tags,
78433         members: getMembersJSON(obj)
78434       });
78435     },
78436     user: function parseUser(obj, uid) {
78437       return {
78438         id: uid,
78439         display_name: obj.display_name,
78440         account_created: obj.account_created,
78441         image_url: obj.img && obj.img.href,
78442         changesets_count: obj.changesets && obj.changesets.count && obj.changesets.count.toString() || "0",
78443         active_blocks: obj.blocks && obj.blocks.received && obj.blocks.received.active && obj.blocks.received.active.toString() || "0"
78444       };
78445     }
78446   };
78447   function parseJSON(payload, callback, options2) {
78448     options2 = Object.assign({ skipSeen: true }, options2);
78449     if (!payload) {
78450       return callback({ message: "No JSON", status: -1 });
78451     }
78452     var json = payload;
78453     if (typeof json !== "object") json = JSON.parse(payload);
78454     if (!json.elements) return callback({ message: "No JSON", status: -1 });
78455     var children2 = json.elements;
78456     var handle = window.requestIdleCallback(function() {
78457       _deferred.delete(handle);
78458       var results = [];
78459       var result;
78460       for (var i3 = 0; i3 < children2.length; i3++) {
78461         result = parseChild(children2[i3]);
78462         if (result) results.push(result);
78463       }
78464       callback(null, results);
78465     });
78466     _deferred.add(handle);
78467     function parseChild(child) {
78468       var parser3 = jsonparsers[child.type];
78469       if (!parser3) return null;
78470       var uid;
78471       uid = osmEntity.id.fromOSM(child.type, child.id);
78472       if (options2.skipSeen) {
78473         if (_tileCache.seen[uid]) return null;
78474         _tileCache.seen[uid] = true;
78475       }
78476       return parser3(child, uid);
78477     }
78478   }
78479   function parseUserJSON(payload, callback, options2) {
78480     options2 = Object.assign({ skipSeen: true }, options2);
78481     if (!payload) {
78482       return callback({ message: "No JSON", status: -1 });
78483     }
78484     var json = payload;
78485     if (typeof json !== "object") json = JSON.parse(payload);
78486     if (!json.users && !json.user) return callback({ message: "No JSON", status: -1 });
78487     var objs = json.users || [json];
78488     var handle = window.requestIdleCallback(function() {
78489       _deferred.delete(handle);
78490       var results = [];
78491       var result;
78492       for (var i3 = 0; i3 < objs.length; i3++) {
78493         result = parseObj(objs[i3]);
78494         if (result) results.push(result);
78495       }
78496       callback(null, results);
78497     });
78498     _deferred.add(handle);
78499     function parseObj(obj) {
78500       var uid = obj.user.id && obj.user.id.toString();
78501       if (options2.skipSeen && _userCache.user[uid]) {
78502         delete _userCache.toLoad[uid];
78503         return null;
78504       }
78505       var user = jsonparsers.user(obj.user, uid);
78506       _userCache.user[uid] = user;
78507       delete _userCache.toLoad[uid];
78508       return user;
78509     }
78510   }
78511   var parsers = {
78512     node: function nodeData2(obj, uid) {
78513       var attrs = obj.attributes;
78514       return new osmNode({
78515         id: uid,
78516         visible: getVisible(attrs),
78517         version: attrs.version.value,
78518         changeset: attrs.changeset && attrs.changeset.value,
78519         timestamp: attrs.timestamp && attrs.timestamp.value,
78520         user: attrs.user && attrs.user.value,
78521         uid: attrs.uid && attrs.uid.value,
78522         loc: getLoc(attrs),
78523         tags: getTags(obj)
78524       });
78525     },
78526     way: function wayData2(obj, uid) {
78527       var attrs = obj.attributes;
78528       return new osmWay({
78529         id: uid,
78530         visible: getVisible(attrs),
78531         version: attrs.version.value,
78532         changeset: attrs.changeset && attrs.changeset.value,
78533         timestamp: attrs.timestamp && attrs.timestamp.value,
78534         user: attrs.user && attrs.user.value,
78535         uid: attrs.uid && attrs.uid.value,
78536         tags: getTags(obj),
78537         nodes: getNodes(obj)
78538       });
78539     },
78540     relation: function relationData2(obj, uid) {
78541       var attrs = obj.attributes;
78542       return new osmRelation({
78543         id: uid,
78544         visible: getVisible(attrs),
78545         version: attrs.version.value,
78546         changeset: attrs.changeset && attrs.changeset.value,
78547         timestamp: attrs.timestamp && attrs.timestamp.value,
78548         user: attrs.user && attrs.user.value,
78549         uid: attrs.uid && attrs.uid.value,
78550         tags: getTags(obj),
78551         members: getMembers(obj)
78552       });
78553     },
78554     note: function parseNote(obj, uid) {
78555       var attrs = obj.attributes;
78556       var childNodes = obj.childNodes;
78557       var props = {};
78558       props.id = uid;
78559       props.loc = getLoc(attrs);
78560       if (!_noteCache.note[uid]) {
78561         let coincident = false;
78562         const epsilon3 = 1e-5;
78563         do {
78564           if (coincident) {
78565             props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]);
78566           }
78567           const bbox2 = geoExtent(props.loc).bbox();
78568           coincident = _noteCache.rtree.search(bbox2).length;
78569         } while (coincident);
78570       } else {
78571         props.loc = _noteCache.note[uid].loc;
78572       }
78573       for (var i3 = 0; i3 < childNodes.length; i3++) {
78574         var node = childNodes[i3];
78575         var nodeName = node.nodeName;
78576         if (nodeName === "#text") continue;
78577         if (nodeName === "comments") {
78578           props[nodeName] = parseComments(node.childNodes);
78579         } else {
78580           props[nodeName] = node.textContent;
78581         }
78582       }
78583       var note = new osmNote(props);
78584       var item = encodeNoteRtree(note);
78585       _noteCache.note[note.id] = note;
78586       updateRtree3(item, true);
78587       return note;
78588     },
78589     user: function parseUser2(obj, uid) {
78590       var attrs = obj.attributes;
78591       var user = {
78592         id: uid,
78593         display_name: attrs.display_name && attrs.display_name.value,
78594         account_created: attrs.account_created && attrs.account_created.value,
78595         changesets_count: "0",
78596         active_blocks: "0"
78597       };
78598       var img = obj.getElementsByTagName("img");
78599       if (img && img[0] && img[0].getAttribute("href")) {
78600         user.image_url = img[0].getAttribute("href");
78601       }
78602       var changesets = obj.getElementsByTagName("changesets");
78603       if (changesets && changesets[0] && changesets[0].getAttribute("count")) {
78604         user.changesets_count = changesets[0].getAttribute("count");
78605       }
78606       var blocks = obj.getElementsByTagName("blocks");
78607       if (blocks && blocks[0]) {
78608         var received = blocks[0].getElementsByTagName("received");
78609         if (received && received[0] && received[0].getAttribute("active")) {
78610           user.active_blocks = received[0].getAttribute("active");
78611         }
78612       }
78613       _userCache.user[uid] = user;
78614       delete _userCache.toLoad[uid];
78615       return user;
78616     }
78617   };
78618   function parseXML(xml, callback, options2) {
78619     options2 = Object.assign({ skipSeen: true }, options2);
78620     if (!xml || !xml.childNodes) {
78621       return callback({ message: "No XML", status: -1 });
78622     }
78623     var root3 = xml.childNodes[0];
78624     var children2 = root3.childNodes;
78625     var handle = window.requestIdleCallback(function() {
78626       _deferred.delete(handle);
78627       var results = [];
78628       var result;
78629       for (var i3 = 0; i3 < children2.length; i3++) {
78630         result = parseChild(children2[i3]);
78631         if (result) results.push(result);
78632       }
78633       callback(null, results);
78634     });
78635     _deferred.add(handle);
78636     function parseChild(child) {
78637       var parser3 = parsers[child.nodeName];
78638       if (!parser3) return null;
78639       var uid;
78640       if (child.nodeName === "user") {
78641         uid = child.attributes.id.value;
78642         if (options2.skipSeen && _userCache.user[uid]) {
78643           delete _userCache.toLoad[uid];
78644           return null;
78645         }
78646       } else if (child.nodeName === "note") {
78647         uid = child.getElementsByTagName("id")[0].textContent;
78648       } else {
78649         uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value);
78650         if (options2.skipSeen) {
78651           if (_tileCache.seen[uid]) return null;
78652           _tileCache.seen[uid] = true;
78653         }
78654       }
78655       return parser3(child, uid);
78656     }
78657   }
78658   function updateRtree3(item, replace) {
78659     _noteCache.rtree.remove(item, function isEql(a2, b2) {
78660       return a2.data.id === b2.data.id;
78661     });
78662     if (replace) {
78663       _noteCache.rtree.insert(item);
78664     }
78665   }
78666   function wrapcb(thisArg, callback, cid) {
78667     return function(err, result) {
78668       if (err) {
78669         if (err.status === 401 || err.status === 403) {
78670           thisArg.logout();
78671         }
78672         return callback.call(thisArg, err);
78673       } else if (thisArg.getConnectionId() !== cid) {
78674         return callback.call(thisArg, { message: "Connection Switched", status: -1 });
78675       } else {
78676         return callback.call(thisArg, err, result);
78677       }
78678     };
78679   }
78680   var osm_default = {
78681     init: function() {
78682       utilRebind(this, dispatch9, "on");
78683     },
78684     reset: function() {
78685       Array.from(_deferred).forEach(function(handle) {
78686         window.cancelIdleCallback(handle);
78687         _deferred.delete(handle);
78688       });
78689       _connectionID++;
78690       _userChangesets = void 0;
78691       _userDetails = void 0;
78692       _rateLimitError = void 0;
78693       Object.values(_tileCache.inflight).forEach(abortRequest4);
78694       Object.values(_noteCache.inflight).forEach(abortRequest4);
78695       Object.values(_noteCache.inflightPost).forEach(abortRequest4);
78696       if (_changeset.inflight) abortRequest4(_changeset.inflight);
78697       _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
78698       _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
78699       _userCache = { toLoad: {}, user: {} };
78700       _cachedApiStatus = void 0;
78701       _changeset = {};
78702       return this;
78703     },
78704     getConnectionId: function() {
78705       return _connectionID;
78706     },
78707     getUrlRoot: function() {
78708       return urlroot;
78709     },
78710     getApiUrlRoot: function() {
78711       return apiUrlroot;
78712     },
78713     changesetURL: function(changesetID) {
78714       return urlroot + "/changeset/" + changesetID;
78715     },
78716     changesetsURL: function(center, zoom) {
78717       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
78718       return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
78719     },
78720     entityURL: function(entity) {
78721       return urlroot + "/" + entity.type + "/" + entity.osmId();
78722     },
78723     historyURL: function(entity) {
78724       return urlroot + "/" + entity.type + "/" + entity.osmId() + "/history";
78725     },
78726     userURL: function(username) {
78727       return urlroot + "/user/" + encodeURIComponent(username);
78728     },
78729     noteURL: function(note) {
78730       return urlroot + "/note/" + note.id;
78731     },
78732     noteReportURL: function(note) {
78733       return urlroot + "/reports/new?reportable_type=Note&reportable_id=" + note.id;
78734     },
78735     // Generic method to load data from the OSM API
78736     // Can handle either auth or unauth calls.
78737     loadFromAPI: function(path, callback, options2) {
78738       options2 = Object.assign({ skipSeen: true }, options2);
78739       var that = this;
78740       var cid = _connectionID;
78741       function done(err, payload) {
78742         if (that.getConnectionId() !== cid) {
78743           if (callback) callback({ message: "Connection Switched", status: -1 });
78744           return;
78745         }
78746         var isAuthenticated = that.authenticated();
78747         if (isAuthenticated && err && err.status && (err.status === 401 || err.status === 403)) {
78748           that.logout();
78749           that.loadFromAPI(path, callback, options2);
78750         } else {
78751           if (!isAuthenticated && !_rateLimitError && err && err.status && (err.status === 509 || err.status === 429)) {
78752             _rateLimitError = err;
78753             dispatch9.call("change");
78754             that.reloadApiStatus();
78755           } else if (err && _cachedApiStatus === "online" || !err && _cachedApiStatus !== "online") {
78756             that.reloadApiStatus();
78757           }
78758           if (callback) {
78759             if (err) {
78760               return callback(err);
78761             } else {
78762               if (path.indexOf(".json") !== -1) {
78763                 return parseJSON(payload, callback, options2);
78764               } else {
78765                 return parseXML(payload, callback, options2);
78766               }
78767             }
78768           }
78769         }
78770       }
78771       if (this.authenticated()) {
78772         return oauth.xhr({
78773           method: "GET",
78774           path
78775         }, done);
78776       } else {
78777         var url = apiUrlroot + path;
78778         var controller = new AbortController();
78779         var fn;
78780         if (path.indexOf(".json") !== -1) {
78781           fn = json_default;
78782         } else {
78783           fn = xml_default;
78784         }
78785         fn(url, { signal: controller.signal }).then(function(data) {
78786           done(null, data);
78787         }).catch(function(err) {
78788           if (err.name === "AbortError") return;
78789           var match = err.message.match(/^\d{3}/);
78790           if (match) {
78791             done({ status: +match[0], statusText: err.message });
78792           } else {
78793             done(err.message);
78794           }
78795         });
78796         return controller;
78797       }
78798     },
78799     // Load a single entity by id (ways and relations use the `/full` call to include
78800     // nodes and members). Parent relations are not included, see `loadEntityRelations`.
78801     // GET /api/0.6/node/#id
78802     // GET /api/0.6/[way|relation]/#id/full
78803     loadEntity: function(id2, callback) {
78804       var type2 = osmEntity.id.type(id2);
78805       var osmID = osmEntity.id.toOSM(id2);
78806       var options2 = { skipSeen: false };
78807       this.loadFromAPI(
78808         "/api/0.6/" + type2 + "/" + osmID + (type2 !== "node" ? "/full" : "") + ".json",
78809         function(err, entities) {
78810           if (callback) callback(err, { data: entities });
78811         },
78812         options2
78813       );
78814     },
78815     // Load a single note by id , XML format
78816     // GET /api/0.6/notes/#id
78817     loadEntityNote: function(id2, callback) {
78818       var options2 = { skipSeen: false };
78819       this.loadFromAPI(
78820         "/api/0.6/notes/" + id2,
78821         function(err, entities) {
78822           if (callback) callback(err, { data: entities });
78823         },
78824         options2
78825       );
78826     },
78827     // Load a single entity with a specific version
78828     // GET /api/0.6/[node|way|relation]/#id/#version
78829     loadEntityVersion: function(id2, version, callback) {
78830       var type2 = osmEntity.id.type(id2);
78831       var osmID = osmEntity.id.toOSM(id2);
78832       var options2 = { skipSeen: false };
78833       this.loadFromAPI(
78834         "/api/0.6/" + type2 + "/" + osmID + "/" + version + ".json",
78835         function(err, entities) {
78836           if (callback) callback(err, { data: entities });
78837         },
78838         options2
78839       );
78840     },
78841     // Load the relations of a single entity with the given.
78842     // GET /api/0.6/[node|way|relation]/#id/relations
78843     loadEntityRelations: function(id2, callback) {
78844       var type2 = osmEntity.id.type(id2);
78845       var osmID = osmEntity.id.toOSM(id2);
78846       var options2 = { skipSeen: false };
78847       this.loadFromAPI(
78848         "/api/0.6/" + type2 + "/" + osmID + "/relations.json",
78849         function(err, entities) {
78850           if (callback) callback(err, { data: entities });
78851         },
78852         options2
78853       );
78854     },
78855     // Load multiple entities in chunks
78856     // (note: callback may be called multiple times)
78857     // Unlike `loadEntity`, child nodes and members are not fetched
78858     // GET /api/0.6/[nodes|ways|relations]?#parameters
78859     loadMultiple: function(ids, callback) {
78860       var that = this;
78861       var groups = utilArrayGroupBy(utilArrayUniq(ids), osmEntity.id.type);
78862       Object.keys(groups).forEach(function(k2) {
78863         var type2 = k2 + "s";
78864         var osmIDs = groups[k2].map(function(id2) {
78865           return osmEntity.id.toOSM(id2);
78866         });
78867         var options2 = { skipSeen: false };
78868         utilArrayChunk(osmIDs, 150).forEach(function(arr) {
78869           that.loadFromAPI(
78870             "/api/0.6/" + type2 + ".json?" + type2 + "=" + arr.join(),
78871             function(err, entities) {
78872               if (callback) callback(err, { data: entities });
78873             },
78874             options2
78875           );
78876         });
78877       });
78878     },
78879     // Create, upload, and close a changeset
78880     // PUT /api/0.6/changeset/create
78881     // POST /api/0.6/changeset/#id/upload
78882     // PUT /api/0.6/changeset/#id/close
78883     putChangeset: function(changeset, changes, callback) {
78884       var cid = _connectionID;
78885       if (_changeset.inflight) {
78886         return callback({ message: "Changeset already inflight", status: -2 }, changeset);
78887       } else if (_changeset.open) {
78888         return createdChangeset.call(this, null, _changeset.open);
78889       } else {
78890         var options2 = {
78891           method: "PUT",
78892           path: "/api/0.6/changeset/create",
78893           headers: { "Content-Type": "text/xml" },
78894           content: JXON.stringify(changeset.asJXON())
78895         };
78896         _changeset.inflight = oauth.xhr(
78897           options2,
78898           wrapcb(this, createdChangeset, cid)
78899         );
78900       }
78901       function createdChangeset(err, changesetID) {
78902         _changeset.inflight = null;
78903         if (err) {
78904           return callback(err, changeset);
78905         }
78906         _changeset.open = changesetID;
78907         changeset = changeset.update({ id: changesetID });
78908         var options3 = {
78909           method: "POST",
78910           path: "/api/0.6/changeset/" + changesetID + "/upload",
78911           headers: { "Content-Type": "text/xml" },
78912           content: JXON.stringify(changeset.osmChangeJXON(changes))
78913         };
78914         _changeset.inflight = oauth.xhr(
78915           options3,
78916           wrapcb(this, uploadedChangeset, cid)
78917         );
78918       }
78919       function uploadedChangeset(err) {
78920         _changeset.inflight = null;
78921         if (err) return callback(err, changeset);
78922         window.setTimeout(function() {
78923           callback(null, changeset);
78924         }, 2500);
78925         _changeset.open = null;
78926         if (this.getConnectionId() === cid) {
78927           oauth.xhr({
78928             method: "PUT",
78929             path: "/api/0.6/changeset/" + changeset.id + "/close",
78930             headers: { "Content-Type": "text/xml" }
78931           }, function() {
78932             return true;
78933           });
78934         }
78935       }
78936     },
78937     /** updates the tags on an existing unclosed changeset */
78938     // PUT /api/0.6/changeset/#id
78939     updateChangesetTags: (changeset) => {
78940       return oauth.fetch("".concat(oauth.options().apiUrl, "/api/0.6/changeset/").concat(changeset.id), {
78941         method: "PUT",
78942         headers: { "Content-Type": "text/xml" },
78943         body: JXON.stringify(changeset.asJXON())
78944       });
78945     },
78946     // Load multiple users in chunks
78947     // (note: callback may be called multiple times)
78948     // GET /api/0.6/users?users=#id1,#id2,...,#idn
78949     loadUsers: function(uids, callback) {
78950       var toLoad = [];
78951       var cached = [];
78952       utilArrayUniq(uids).forEach(function(uid) {
78953         if (_userCache.user[uid]) {
78954           delete _userCache.toLoad[uid];
78955           cached.push(_userCache.user[uid]);
78956         } else {
78957           toLoad.push(uid);
78958         }
78959       });
78960       if (cached.length || !this.authenticated()) {
78961         callback(void 0, cached);
78962         if (!this.authenticated()) return;
78963       }
78964       utilArrayChunk(toLoad, 150).forEach((function(arr) {
78965         oauth.xhr({
78966           method: "GET",
78967           path: "/api/0.6/users.json?users=" + arr.join()
78968         }, wrapcb(this, done, _connectionID));
78969       }).bind(this));
78970       function done(err, payload) {
78971         if (err) return callback(err);
78972         var options2 = { skipSeen: true };
78973         return parseUserJSON(payload, function(err2, results) {
78974           if (err2) return callback(err2);
78975           return callback(void 0, results);
78976         }, options2);
78977       }
78978     },
78979     // Load a given user by id
78980     // GET /api/0.6/user/#id
78981     loadUser: function(uid, callback) {
78982       if (_userCache.user[uid] || !this.authenticated()) {
78983         delete _userCache.toLoad[uid];
78984         return callback(void 0, _userCache.user[uid]);
78985       }
78986       oauth.xhr({
78987         method: "GET",
78988         path: "/api/0.6/user/" + uid + ".json"
78989       }, wrapcb(this, done, _connectionID));
78990       function done(err, payload) {
78991         if (err) return callback(err);
78992         var options2 = { skipSeen: true };
78993         return parseUserJSON(payload, function(err2, results) {
78994           if (err2) return callback(err2);
78995           return callback(void 0, results[0]);
78996         }, options2);
78997       }
78998     },
78999     // Load the details of the logged-in user
79000     // GET /api/0.6/user/details
79001     userDetails: function(callback) {
79002       if (_userDetails) {
79003         return callback(void 0, _userDetails);
79004       }
79005       oauth.xhr({
79006         method: "GET",
79007         path: "/api/0.6/user/details.json"
79008       }, wrapcb(this, done, _connectionID));
79009       function done(err, payload) {
79010         if (err) return callback(err);
79011         var options2 = { skipSeen: false };
79012         return parseUserJSON(payload, function(err2, results) {
79013           if (err2) return callback(err2);
79014           _userDetails = results[0];
79015           return callback(void 0, _userDetails);
79016         }, options2);
79017       }
79018     },
79019     // Load previous changesets for the logged in user
79020     // GET /api/0.6/changesets?user=#id
79021     userChangesets: function(callback) {
79022       if (_userChangesets) {
79023         return callback(void 0, _userChangesets);
79024       }
79025       this.userDetails(
79026         wrapcb(this, gotDetails, _connectionID)
79027       );
79028       function gotDetails(err, user) {
79029         if (err) {
79030           return callback(err);
79031         }
79032         oauth.xhr({
79033           method: "GET",
79034           path: "/api/0.6/changesets?user=" + user.id
79035         }, wrapcb(this, done, _connectionID));
79036       }
79037       function done(err, xml) {
79038         if (err) {
79039           return callback(err);
79040         }
79041         _userChangesets = Array.prototype.map.call(
79042           xml.getElementsByTagName("changeset"),
79043           function(changeset) {
79044             return { tags: getTags(changeset) };
79045           }
79046         ).filter(function(changeset) {
79047           var comment = changeset.tags.comment;
79048           return comment && comment !== "";
79049         });
79050         return callback(void 0, _userChangesets);
79051       }
79052     },
79053     // Fetch the status of the OSM API
79054     // GET /api/capabilities
79055     status: function(callback) {
79056       var url = apiUrlroot + "/api/capabilities";
79057       var errback = wrapcb(this, done, _connectionID);
79058       xml_default(url).then(function(data) {
79059         errback(null, data);
79060       }).catch(function(err) {
79061         errback(err.message);
79062       });
79063       function done(err, xml) {
79064         if (err) {
79065           return callback(err, null);
79066         }
79067         var elements = xml.getElementsByTagName("blacklist");
79068         var regexes = [];
79069         for (var i3 = 0; i3 < elements.length; i3++) {
79070           var regexString = elements[i3].getAttribute("regex");
79071           if (regexString) {
79072             try {
79073               var regex = new RegExp(regexString);
79074               regexes.push(regex);
79075             } catch (e3) {
79076             }
79077           }
79078         }
79079         if (regexes.length) {
79080           _imageryBlocklists = regexes;
79081         }
79082         if (_rateLimitError) {
79083           return callback(_rateLimitError, "rateLimited");
79084         } else {
79085           var waynodes = xml.getElementsByTagName("waynodes");
79086           var maxWayNodes = waynodes.length && parseInt(waynodes[0].getAttribute("maximum"), 10);
79087           if (maxWayNodes && isFinite(maxWayNodes)) _maxWayNodes = maxWayNodes;
79088           var apiStatus = xml.getElementsByTagName("status");
79089           var val = apiStatus[0].getAttribute("api");
79090           return callback(void 0, val);
79091         }
79092       }
79093     },
79094     // Calls `status` and dispatches an `apiStatusChange` event if the returned
79095     // status differs from the cached status.
79096     reloadApiStatus: function() {
79097       if (!this.throttledReloadApiStatus) {
79098         var that = this;
79099         this.throttledReloadApiStatus = throttle_default(function() {
79100           that.status(function(err, status) {
79101             if (status !== _cachedApiStatus) {
79102               _cachedApiStatus = status;
79103               dispatch9.call("apiStatusChange", that, err, status);
79104             }
79105           });
79106         }, 500);
79107       }
79108       this.throttledReloadApiStatus();
79109     },
79110     // Returns the maximum number of nodes a single way can have
79111     maxWayNodes: function() {
79112       return _maxWayNodes;
79113     },
79114     // Load data (entities) from the API in tiles
79115     // GET /api/0.6/map?bbox=
79116     loadTiles: function(projection2, callback) {
79117       if (_off) return;
79118       var tiles = tiler5.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
79119       var hadRequests = hasInflightRequests(_tileCache);
79120       abortUnwantedRequests3(_tileCache, tiles);
79121       if (hadRequests && !hasInflightRequests(_tileCache)) {
79122         dispatch9.call("loaded");
79123       }
79124       tiles.forEach(function(tile) {
79125         this.loadTile(tile, callback);
79126       }, this);
79127     },
79128     // Load a single data tile
79129     // GET /api/0.6/map?bbox=
79130     loadTile: function(tile, callback) {
79131       if (_off) return;
79132       if (_tileCache.loaded[tile.id] || _tileCache.inflight[tile.id]) return;
79133       if (!hasInflightRequests(_tileCache)) {
79134         dispatch9.call("loading");
79135       }
79136       var path = "/api/0.6/map.json?bbox=";
79137       var options2 = { skipSeen: true };
79138       _tileCache.inflight[tile.id] = this.loadFromAPI(
79139         path + tile.extent.toParam(),
79140         tileCallback,
79141         options2
79142       );
79143       function tileCallback(err, parsed) {
79144         delete _tileCache.inflight[tile.id];
79145         if (!err) {
79146           delete _tileCache.toLoad[tile.id];
79147           _tileCache.loaded[tile.id] = true;
79148           var bbox2 = tile.extent.bbox();
79149           bbox2.id = tile.id;
79150           _tileCache.rtree.insert(bbox2);
79151         }
79152         if (callback) {
79153           callback(err, Object.assign({ data: parsed }, tile));
79154         }
79155         if (!hasInflightRequests(_tileCache)) {
79156           dispatch9.call("loaded");
79157         }
79158       }
79159     },
79160     isDataLoaded: function(loc) {
79161       var bbox2 = { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] };
79162       return _tileCache.rtree.collides(bbox2);
79163     },
79164     // load the tile that covers the given `loc`
79165     loadTileAtLoc: function(loc, callback) {
79166       if (Object.keys(_tileCache.toLoad).length > 50) return;
79167       var k2 = geoZoomToScale(_tileZoom3 + 1);
79168       var offset = geoRawMercator().scale(k2)(loc);
79169       var projection2 = geoRawMercator().transform({ k: k2, x: -offset[0], y: -offset[1] });
79170       var tiles = tiler5.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
79171       tiles.forEach(function(tile) {
79172         if (_tileCache.toLoad[tile.id] || _tileCache.loaded[tile.id] || _tileCache.inflight[tile.id]) return;
79173         _tileCache.toLoad[tile.id] = true;
79174         this.loadTile(tile, callback);
79175       }, this);
79176     },
79177     // Load notes from the API in tiles
79178     // GET /api/0.6/notes?bbox=
79179     loadNotes: function(projection2, noteOptions) {
79180       noteOptions = Object.assign({ limit: 1e4, closed: 7 }, noteOptions);
79181       if (_off) return;
79182       var that = this;
79183       var path = "/api/0.6/notes?limit=" + noteOptions.limit + "&closed=" + noteOptions.closed + "&bbox=";
79184       var throttleLoadUsers = throttle_default(function() {
79185         var uids = Object.keys(_userCache.toLoad);
79186         if (!uids.length) return;
79187         that.loadUsers(uids, function() {
79188         });
79189       }, 750);
79190       var tiles = tiler5.zoomExtent([_noteZoom, _noteZoom]).getTiles(projection2);
79191       abortUnwantedRequests3(_noteCache, tiles);
79192       tiles.forEach(function(tile) {
79193         if (_noteCache.loaded[tile.id] || _noteCache.inflight[tile.id]) return;
79194         var options2 = { skipSeen: false };
79195         _noteCache.inflight[tile.id] = that.loadFromAPI(
79196           path + tile.extent.toParam(),
79197           function(err) {
79198             delete _noteCache.inflight[tile.id];
79199             if (!err) {
79200               _noteCache.loaded[tile.id] = true;
79201             }
79202             throttleLoadUsers();
79203             dispatch9.call("loadedNotes");
79204           },
79205           options2
79206         );
79207       });
79208     },
79209     // Create a note
79210     // POST /api/0.6/notes?params
79211     postNoteCreate: function(note, callback) {
79212       if (!this.authenticated()) {
79213         return callback({ message: "Not Authenticated", status: -3 }, note);
79214       }
79215       if (_noteCache.inflightPost[note.id]) {
79216         return callback({ message: "Note update already inflight", status: -2 }, note);
79217       }
79218       if (!note.loc[0] || !note.loc[1] || !note.newComment) return;
79219       var comment = note.newComment;
79220       if (note.newCategory && note.newCategory !== "None") {
79221         comment += " #" + note.newCategory;
79222       }
79223       var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment });
79224       _noteCache.inflightPost[note.id] = oauth.xhr({
79225         method: "POST",
79226         path
79227       }, wrapcb(this, done, _connectionID));
79228       function done(err, xml) {
79229         delete _noteCache.inflightPost[note.id];
79230         if (err) {
79231           return callback(err);
79232         }
79233         this.removeNote(note);
79234         var options2 = { skipSeen: false };
79235         return parseXML(xml, function(err2, results) {
79236           if (err2) {
79237             return callback(err2);
79238           } else {
79239             return callback(void 0, results[0]);
79240           }
79241         }, options2);
79242       }
79243     },
79244     // Update a note
79245     // POST /api/0.6/notes/#id/comment?text=comment
79246     // POST /api/0.6/notes/#id/close?text=comment
79247     // POST /api/0.6/notes/#id/reopen?text=comment
79248     postNoteUpdate: function(note, newStatus, callback) {
79249       if (!this.authenticated()) {
79250         return callback({ message: "Not Authenticated", status: -3 }, note);
79251       }
79252       if (_noteCache.inflightPost[note.id]) {
79253         return callback({ message: "Note update already inflight", status: -2 }, note);
79254       }
79255       var action;
79256       if (note.status !== "closed" && newStatus === "closed") {
79257         action = "close";
79258       } else if (note.status !== "open" && newStatus === "open") {
79259         action = "reopen";
79260       } else {
79261         action = "comment";
79262         if (!note.newComment) return;
79263       }
79264       var path = "/api/0.6/notes/" + note.id + "/" + action;
79265       if (note.newComment) {
79266         path += "?" + utilQsString({ text: note.newComment });
79267       }
79268       _noteCache.inflightPost[note.id] = oauth.xhr({
79269         method: "POST",
79270         path
79271       }, wrapcb(this, done, _connectionID));
79272       function done(err, xml) {
79273         delete _noteCache.inflightPost[note.id];
79274         if (err) {
79275           return callback(err);
79276         }
79277         this.removeNote(note);
79278         if (action === "close") {
79279           _noteCache.closed[note.id] = true;
79280         } else if (action === "reopen") {
79281           delete _noteCache.closed[note.id];
79282         }
79283         var options2 = { skipSeen: false };
79284         return parseXML(xml, function(err2, results) {
79285           if (err2) {
79286             return callback(err2);
79287           } else {
79288             return callback(void 0, results[0]);
79289           }
79290         }, options2);
79291       }
79292     },
79293     /* connection options for source switcher (optional) */
79294     apiConnections: function(val) {
79295       if (!arguments.length) return _apiConnections;
79296       _apiConnections = val;
79297       return this;
79298     },
79299     switch: function(newOptions) {
79300       urlroot = newOptions.url;
79301       apiUrlroot = newOptions.apiUrl || urlroot;
79302       if (newOptions.url && !newOptions.apiUrl) {
79303         newOptions = __spreadProps(__spreadValues({}, newOptions), {
79304           apiUrl: newOptions.url
79305         });
79306       }
79307       const oldOptions = utilObjectOmit(oauth.options(), "access_token");
79308       oauth.options(__spreadValues(__spreadValues({}, oldOptions), newOptions));
79309       this.reset();
79310       this.userChangesets(function() {
79311       });
79312       dispatch9.call("change");
79313       return this;
79314     },
79315     toggle: function(val) {
79316       _off = !val;
79317       return this;
79318     },
79319     isChangesetInflight: function() {
79320       return !!_changeset.inflight;
79321     },
79322     // get/set cached data
79323     // This is used to save/restore the state when entering/exiting the walkthrough
79324     // Also used for testing purposes.
79325     caches: function(obj) {
79326       function cloneCache(source) {
79327         var target = {};
79328         Object.keys(source).forEach(function(k2) {
79329           if (k2 === "rtree") {
79330             target.rtree = new RBush().fromJSON(source.rtree.toJSON());
79331           } else if (k2 === "note") {
79332             target.note = {};
79333             Object.keys(source.note).forEach(function(id2) {
79334               target.note[id2] = osmNote(source.note[id2]);
79335             });
79336           } else {
79337             target[k2] = JSON.parse(JSON.stringify(source[k2]));
79338           }
79339         });
79340         return target;
79341       }
79342       if (!arguments.length) {
79343         return {
79344           tile: cloneCache(_tileCache),
79345           note: cloneCache(_noteCache),
79346           user: cloneCache(_userCache)
79347         };
79348       }
79349       if (obj === "get") {
79350         return {
79351           tile: _tileCache,
79352           note: _noteCache,
79353           user: _userCache
79354         };
79355       }
79356       if (obj.tile) {
79357         _tileCache = obj.tile;
79358         _tileCache.inflight = {};
79359       }
79360       if (obj.note) {
79361         _noteCache = obj.note;
79362         _noteCache.inflight = {};
79363         _noteCache.inflightPost = {};
79364       }
79365       if (obj.user) {
79366         _userCache = obj.user;
79367       }
79368       return this;
79369     },
79370     logout: function() {
79371       _userChangesets = void 0;
79372       _userDetails = void 0;
79373       oauth.logout();
79374       dispatch9.call("change");
79375       return this;
79376     },
79377     authenticated: function() {
79378       return oauth.authenticated();
79379     },
79380     /** @param {import('osm-auth').LoginOptions} options */
79381     authenticate: function(callback, options2) {
79382       var that = this;
79383       var cid = _connectionID;
79384       _userChangesets = void 0;
79385       _userDetails = void 0;
79386       function done(err, res) {
79387         if (err) {
79388           if (callback) callback(err);
79389           return;
79390         }
79391         if (that.getConnectionId() !== cid) {
79392           if (callback) callback({ message: "Connection Switched", status: -1 });
79393           return;
79394         }
79395         _rateLimitError = void 0;
79396         dispatch9.call("change");
79397         if (callback) callback(err, res);
79398         that.userChangesets(function() {
79399         });
79400       }
79401       oauth.options(__spreadProps(__spreadValues({}, oauth.options()), {
79402         locale: _mainLocalizer.localeCode()
79403       }));
79404       oauth.authenticate(done, options2);
79405     },
79406     imageryBlocklists: function() {
79407       return _imageryBlocklists;
79408     },
79409     tileZoom: function(val) {
79410       if (!arguments.length) return _tileZoom3;
79411       _tileZoom3 = val;
79412       return this;
79413     },
79414     // get all cached notes covering the viewport
79415     notes: function(projection2) {
79416       var viewport = projection2.clipExtent();
79417       var min3 = [viewport[0][0], viewport[1][1]];
79418       var max3 = [viewport[1][0], viewport[0][1]];
79419       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
79420       return _noteCache.rtree.search(bbox2).map(function(d2) {
79421         return d2.data;
79422       });
79423     },
79424     // get a single note from the cache
79425     getNote: function(id2) {
79426       return _noteCache.note[id2];
79427     },
79428     // remove a single note from the cache
79429     removeNote: function(note) {
79430       if (!(note instanceof osmNote) || !note.id) return;
79431       delete _noteCache.note[note.id];
79432       updateRtree3(encodeNoteRtree(note), false);
79433     },
79434     // replace a single note in the cache
79435     replaceNote: function(note) {
79436       if (!(note instanceof osmNote) || !note.id) return;
79437       _noteCache.note[note.id] = note;
79438       updateRtree3(encodeNoteRtree(note), true);
79439       return note;
79440     },
79441     // Get an array of note IDs closed during this session.
79442     // Used to populate `closed:note` changeset tag
79443     getClosedIDs: function() {
79444       return Object.keys(_noteCache.closed).sort();
79445     }
79446   };
79447
79448   // modules/services/osm_wikibase.js
79449   var apibase3 = "https://wiki.openstreetmap.org/w/api.php";
79450   var _inflight2 = {};
79451   var _wikibaseCache = {};
79452   var _localeIDs = { en: false };
79453   var debouncedRequest = debounce_default(request, 500, { leading: false });
79454   function request(url, callback) {
79455     if (_inflight2[url]) return;
79456     var controller = new AbortController();
79457     _inflight2[url] = controller;
79458     json_default(url, { signal: controller.signal }).then(function(result) {
79459       delete _inflight2[url];
79460       if (callback) callback(null, result);
79461     }).catch(function(err) {
79462       delete _inflight2[url];
79463       if (err.name === "AbortError") return;
79464       if (callback) callback(err.message);
79465     });
79466   }
79467   var osm_wikibase_default = {
79468     init: function() {
79469       _inflight2 = {};
79470       _wikibaseCache = {};
79471       _localeIDs = {};
79472     },
79473     reset: function() {
79474       Object.values(_inflight2).forEach(function(controller) {
79475         controller.abort();
79476       });
79477       _inflight2 = {};
79478     },
79479     /**
79480      * Get the best value for the property, or undefined if not found
79481      * @param entity object from wikibase
79482      * @param property string e.g. 'P4' for image
79483      * @param langCode string e.g. 'fr' for French
79484      */
79485     claimToValue: function(entity, property, langCode) {
79486       if (!entity.claims[property]) return void 0;
79487       var locale2 = _localeIDs[langCode];
79488       var preferredPick, localePick;
79489       entity.claims[property].forEach(function(stmt) {
79490         if (!preferredPick && stmt.rank === "preferred") {
79491           preferredPick = stmt;
79492         }
79493         if (locale2 && stmt.qualifiers && stmt.qualifiers.P26 && stmt.qualifiers.P26[0].datavalue.value.id === locale2) {
79494           localePick = stmt;
79495         }
79496       });
79497       var result = localePick || preferredPick;
79498       if (result) {
79499         var datavalue = result.mainsnak.datavalue;
79500         return datavalue.type === "wikibase-entityid" ? datavalue.value.id : datavalue.value;
79501       } else {
79502         return void 0;
79503       }
79504     },
79505     /**
79506      * Convert monolingual property into a key-value object (language -> value)
79507      * @param entity object from wikibase
79508      * @param property string e.g. 'P31' for monolingual wiki page title
79509      */
79510     monolingualClaimToValueObj: function(entity, property) {
79511       if (!entity || !entity.claims[property]) return void 0;
79512       return entity.claims[property].reduce(function(acc, obj) {
79513         var value = obj.mainsnak.datavalue.value;
79514         acc[value.language] = value.text;
79515         return acc;
79516       }, {});
79517     },
79518     toSitelink: function(key, value) {
79519       var result = value ? "Tag:" + key + "=" + value : "Key:" + key;
79520       return result.replace(/_/g, " ").trim();
79521     },
79522     /**
79523      * Converts text like `tag:...=...` into clickable links
79524      *
79525      * @param {string} unsafeText - unsanitized text
79526      */
79527     linkifyWikiText(unsafeText) {
79528       return (selection2) => {
79529         const segments = unsafeText.split(/(key|tag):([\w-]+)(=([\w-]+))?/g);
79530         for (let i3 = 0; i3 < segments.length; i3 += 5) {
79531           const [plainText, , key, , value] = segments.slice(i3);
79532           if (plainText) {
79533             selection2.append("span").text(plainText);
79534           }
79535           if (key) {
79536             selection2.append("a").attr("href", "https://wiki.openstreetmap.org/wiki/".concat(this.toSitelink(key, value))).attr("target", "_blank").attr("rel", "noreferrer").append("code").text("".concat(key, "=").concat(value || "*"));
79537           }
79538         }
79539       };
79540     },
79541     //
79542     // Pass params object of the form:
79543     // {
79544     //   key: 'string',
79545     //   value: 'string',
79546     //   langCode: 'string'
79547     // }
79548     //
79549     getEntity: function(params, callback) {
79550       var doRequest = params.debounce ? debouncedRequest : request;
79551       var that = this;
79552       var titles = [];
79553       var result = {};
79554       var rtypeSitelink = params.key === "type" && params.value ? ("Relation:" + params.value).replace(/_/g, " ").trim() : false;
79555       var keySitelink = params.key ? this.toSitelink(params.key) : false;
79556       var tagSitelink = params.key && params.value ? this.toSitelink(params.key, params.value) : false;
79557       const localeSitelinks = [];
79558       if (params.langCodes) {
79559         params.langCodes.forEach(function(langCode) {
79560           if (_localeIDs[langCode] === void 0) {
79561             let localeSitelink = ("Locale:" + langCode).replace(/_/g, " ").trim();
79562             titles.push(localeSitelink);
79563             that.addLocale(langCode, false);
79564           }
79565         });
79566       }
79567       if (rtypeSitelink) {
79568         if (_wikibaseCache[rtypeSitelink]) {
79569           result.rtype = _wikibaseCache[rtypeSitelink];
79570         } else {
79571           titles.push(rtypeSitelink);
79572         }
79573       }
79574       if (keySitelink) {
79575         if (_wikibaseCache[keySitelink]) {
79576           result.key = _wikibaseCache[keySitelink];
79577         } else {
79578           titles.push(keySitelink);
79579         }
79580       }
79581       if (tagSitelink) {
79582         if (_wikibaseCache[tagSitelink]) {
79583           result.tag = _wikibaseCache[tagSitelink];
79584         } else {
79585           titles.push(tagSitelink);
79586         }
79587       }
79588       if (!titles.length) {
79589         return callback(null, result);
79590       }
79591       var obj = {
79592         action: "wbgetentities",
79593         sites: "wiki",
79594         titles: titles.join("|"),
79595         languages: params.langCodes.join("|"),
79596         languagefallback: 1,
79597         origin: "*",
79598         format: "json"
79599         // There is an MW Wikibase API bug https://phabricator.wikimedia.org/T212069
79600         // We shouldn't use v1 until it gets fixed, but should switch to it afterwards
79601         // formatversion: 2,
79602       };
79603       var url = apibase3 + "?" + utilQsString(obj);
79604       doRequest(url, function(err, d2) {
79605         if (err) {
79606           callback(err);
79607         } else if (!d2.success || d2.error) {
79608           callback(d2.error.messages.map(function(v2) {
79609             return v2.html["*"];
79610           }).join("<br>"));
79611         } else {
79612           Object.values(d2.entities).forEach(function(res) {
79613             if (res.missing !== "") {
79614               var title = res.sitelinks.wiki.title;
79615               if (title === rtypeSitelink) {
79616                 _wikibaseCache[rtypeSitelink] = res;
79617                 result.rtype = res;
79618               } else if (title === keySitelink) {
79619                 _wikibaseCache[keySitelink] = res;
79620                 result.key = res;
79621               } else if (title === tagSitelink) {
79622                 _wikibaseCache[tagSitelink] = res;
79623                 result.tag = res;
79624               } else if (localeSitelinks.includes(title)) {
79625                 const langCode = title.replace(/ /g, "_").replace(/^Locale:/, "");
79626                 that.addLocale(langCode, res.id);
79627               } else {
79628                 console.log("Unexpected title " + title);
79629               }
79630             }
79631           });
79632           callback(null, result);
79633         }
79634       });
79635     },
79636     //
79637     // Pass params object of the form:
79638     // {
79639     //   key: 'string',     // required
79640     //   value: 'string'    // optional
79641     // }
79642     //
79643     // Get an result object used to display tag documentation
79644     // {
79645     //   title:        'string',
79646     //   description:  'string',
79647     //   editURL:      'string',
79648     //   imageURL:     'string',
79649     //   wiki:         { title: 'string', text: 'string', url: 'string' }
79650     // }
79651     //
79652     getDocs: function(params, callback) {
79653       var that = this;
79654       var langCodes = _mainLocalizer.localeCodes().map(function(code) {
79655         return code.toLowerCase();
79656       });
79657       params.langCodes = langCodes;
79658       this.getEntity(params, function(err, data) {
79659         if (err) {
79660           callback(err);
79661           return;
79662         }
79663         var entity = data.rtype || data.tag || data.key;
79664         if (!entity) {
79665           callback("No entity");
79666           return;
79667         }
79668         var i3;
79669         var description;
79670         for (i3 in langCodes) {
79671           let code2 = langCodes[i3];
79672           if (entity.descriptions[code2] && entity.descriptions[code2].language === code2) {
79673             description = entity.descriptions[code2];
79674             break;
79675           }
79676         }
79677         if (!description && Object.values(entity.descriptions).length) description = Object.values(entity.descriptions)[0];
79678         var result = {
79679           title: entity.title,
79680           description: that.linkifyWikiText((description == null ? void 0 : description.value) || ""),
79681           descriptionLocaleCode: description ? description.language : "",
79682           editURL: "https://wiki.openstreetmap.org/wiki/" + entity.title
79683         };
79684         if (entity.claims) {
79685           var imageroot;
79686           var image = that.claimToValue(entity, "P4", langCodes[0]);
79687           if (image) {
79688             imageroot = "https://commons.wikimedia.org/w/index.php";
79689           } else {
79690             image = that.claimToValue(entity, "P28", langCodes[0]);
79691             if (image) {
79692               imageroot = "https://wiki.openstreetmap.org/w/index.php";
79693             }
79694           }
79695           if (imageroot && image) {
79696             result.imageURL = imageroot + "?" + utilQsString({
79697               title: "Special:Redirect/file/" + image,
79698               width: 400
79699             });
79700           }
79701         }
79702         var rtypeWiki = that.monolingualClaimToValueObj(data.rtype, "P31");
79703         var tagWiki = that.monolingualClaimToValueObj(data.tag, "P31");
79704         var keyWiki = that.monolingualClaimToValueObj(data.key, "P31");
79705         var wikis = [rtypeWiki, tagWiki, keyWiki];
79706         for (i3 in wikis) {
79707           var wiki = wikis[i3];
79708           for (var j2 in langCodes) {
79709             var code = langCodes[j2];
79710             var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference";
79711             var info = getWikiInfo(wiki, code, referenceId);
79712             if (info) {
79713               result.wiki = info;
79714               break;
79715             }
79716           }
79717           if (result.wiki) break;
79718         }
79719         callback(null, result);
79720         function getWikiInfo(wiki2, langCode, tKey) {
79721           if (wiki2 && wiki2[langCode]) {
79722             return {
79723               title: wiki2[langCode],
79724               text: tKey,
79725               url: "https://wiki.openstreetmap.org/wiki/" + wiki2[langCode]
79726             };
79727           }
79728         }
79729       });
79730     },
79731     addLocale: function(langCode, qid) {
79732       _localeIDs[langCode] = qid;
79733     },
79734     apibase: function(val) {
79735       if (!arguments.length) return apibase3;
79736       apibase3 = val;
79737       return this;
79738     }
79739   };
79740
79741   // modules/services/streetside.js
79742   var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}&uriScheme=https";
79743   var maxResults2 = 500;
79744   var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
79745   var pannellumViewerCSS2 = "pannellum/pannellum.css";
79746   var pannellumViewerJS2 = "pannellum/pannellum.js";
79747   var tileZoom3 = 16.5;
79748   var tiler6 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true);
79749   var dispatch10 = dispatch_default("loadedImages", "viewerChanged");
79750   var minHfov = 10;
79751   var maxHfov = 90;
79752   var defaultHfov = 45;
79753   var _hires = false;
79754   var _resolution = 512;
79755   var _currScene = 0;
79756   var _ssCache;
79757   var _pannellumViewer2;
79758   var _sceneOptions = {
79759     showFullscreenCtrl: false,
79760     autoLoad: true,
79761     compass: true,
79762     yaw: 0,
79763     minHfov,
79764     maxHfov,
79765     hfov: defaultHfov,
79766     type: "cubemap",
79767     cubeMap: []
79768   };
79769   var _loadViewerPromise4;
79770   function abortRequest5(i3) {
79771     i3.abort();
79772   }
79773   function localeTimestamp2(s2) {
79774     if (!s2) return null;
79775     const options2 = { day: "numeric", month: "short", year: "numeric" };
79776     const d2 = new Date(s2);
79777     if (isNaN(d2.getTime())) return null;
79778     return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
79779   }
79780   function loadTiles3(which, url, projection2, margin) {
79781     const tiles = tiler6.margin(margin).getTiles(projection2);
79782     const cache = _ssCache[which];
79783     Object.keys(cache.inflight).forEach((k2) => {
79784       const wanted = tiles.find((tile) => k2.indexOf(tile.id + ",") === 0);
79785       if (!wanted) {
79786         abortRequest5(cache.inflight[k2]);
79787         delete cache.inflight[k2];
79788       }
79789     });
79790     tiles.forEach((tile) => loadNextTilePage2(which, url, tile));
79791   }
79792   function loadNextTilePage2(which, url, tile) {
79793     const cache = _ssCache[which];
79794     const nextPage = cache.nextPage[tile.id] || 0;
79795     const id2 = tile.id + "," + String(nextPage);
79796     if (cache.loaded[id2] || cache.inflight[id2]) return;
79797     cache.inflight[id2] = getBubbles(url, tile, (response) => {
79798       cache.loaded[id2] = true;
79799       delete cache.inflight[id2];
79800       if (!response) return;
79801       if (response.resourceSets[0].resources.length === maxResults2) {
79802         const split = tile.extent.split();
79803         loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] });
79804         loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] });
79805         loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] });
79806         loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] });
79807       }
79808       const features = response.resourceSets[0].resources.map((bubble) => {
79809         const bubbleId = bubble.imageUrl;
79810         if (cache.points[bubbleId]) return null;
79811         const loc = [
79812           bubble.lon || bubble.longitude,
79813           bubble.lat || bubble.latitude
79814         ];
79815         const d2 = {
79816           loc,
79817           key: bubbleId,
79818           imageUrl: bubble.imageUrl.replace("{subdomain}", bubble.imageUrlSubdomains[0]),
79819           ca: bubble.he || bubble.heading,
79820           captured_at: bubble.vintageEnd,
79821           captured_by: "microsoft",
79822           pano: true,
79823           sequenceKey: null
79824         };
79825         cache.points[bubbleId] = d2;
79826         return {
79827           minX: loc[0],
79828           minY: loc[1],
79829           maxX: loc[0],
79830           maxY: loc[1],
79831           data: d2
79832         };
79833       }).filter(Boolean);
79834       cache.rtree.load(features);
79835       if (which === "bubbles") {
79836         dispatch10.call("loadedImages");
79837       }
79838     });
79839   }
79840   function getBubbles(url, tile, callback) {
79841     let rect = tile.extent.rectangle();
79842     let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2);
79843     const controller = new AbortController();
79844     fetch(urlForRequest, { signal: controller.signal }).then(function(response) {
79845       if (!response.ok) {
79846         throw new Error(response.status + " " + response.statusText);
79847       }
79848       return response.json();
79849     }).then(function(result) {
79850       if (!result) {
79851         callback(null);
79852       }
79853       return callback(result || []);
79854     }).catch(function(err) {
79855       if (err.name === "AbortError") {
79856       } else {
79857         throw new Error(err);
79858       }
79859     });
79860     return controller;
79861   }
79862   function partitionViewport4(projection2) {
79863     let z2 = geoScaleToZoom(projection2.scale());
79864     let z22 = Math.ceil(z2 * 2) / 2 + 2.5;
79865     let tiler8 = utilTiler().zoomExtent([z22, z22]);
79866     return tiler8.getTiles(projection2).map((tile) => tile.extent);
79867   }
79868   function searchLimited4(limit, projection2, rtree) {
79869     limit = limit || 5;
79870     return partitionViewport4(projection2).reduce((result, extent) => {
79871       let found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
79872       return found.length ? result.concat(found) : result;
79873     }, []);
79874   }
79875   function loadImage2(imgInfo) {
79876     return new Promise((resolve) => {
79877       let img = new Image();
79878       img.onload = () => {
79879         let canvas = document.getElementById("ideditor-canvas" + imgInfo.face);
79880         let ctx = canvas.getContext("2d");
79881         ctx.drawImage(img, imgInfo.x, imgInfo.y);
79882         resolve({ imgInfo, status: "ok" });
79883       };
79884       img.onerror = () => {
79885         resolve({ data: imgInfo, status: "error" });
79886       };
79887       img.setAttribute("crossorigin", "");
79888       img.src = imgInfo.url;
79889     });
79890   }
79891   function loadCanvas(imageGroup) {
79892     return Promise.all(imageGroup.map(loadImage2)).then((data) => {
79893       let canvas = document.getElementById("ideditor-canvas" + data[0].imgInfo.face);
79894       const which = { "01": 0, "02": 1, "03": 2, "10": 3, "11": 4, "12": 5 };
79895       let face = data[0].imgInfo.face;
79896       _sceneOptions.cubeMap[which[face]] = canvas.toDataURL("image/jpeg", 1);
79897       return { status: "loadCanvas for face " + data[0].imgInfo.face + "ok" };
79898     });
79899   }
79900   function loadFaces(faceGroup) {
79901     return Promise.all(faceGroup.map(loadCanvas)).then(() => {
79902       return { status: "loadFaces done" };
79903     });
79904   }
79905   function setupCanvas(selection2, reset) {
79906     if (reset) {
79907       selection2.selectAll("#ideditor-stitcher-canvases").remove();
79908     }
79909     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);
79910   }
79911   function qkToXY(qk) {
79912     let x2 = 0;
79913     let y2 = 0;
79914     let scale = 256;
79915     for (let i3 = qk.length; i3 > 0; i3--) {
79916       const key = qk[i3 - 1];
79917       x2 += +(key === "1" || key === "3") * scale;
79918       y2 += +(key === "2" || key === "3") * scale;
79919       scale *= 2;
79920     }
79921     return [x2, y2];
79922   }
79923   function getQuadKeys() {
79924     let dim = _resolution / 256;
79925     let quadKeys;
79926     if (dim === 16) {
79927       quadKeys = [
79928         "0000",
79929         "0001",
79930         "0010",
79931         "0011",
79932         "0100",
79933         "0101",
79934         "0110",
79935         "0111",
79936         "1000",
79937         "1001",
79938         "1010",
79939         "1011",
79940         "1100",
79941         "1101",
79942         "1110",
79943         "1111",
79944         "0002",
79945         "0003",
79946         "0012",
79947         "0013",
79948         "0102",
79949         "0103",
79950         "0112",
79951         "0113",
79952         "1002",
79953         "1003",
79954         "1012",
79955         "1013",
79956         "1102",
79957         "1103",
79958         "1112",
79959         "1113",
79960         "0020",
79961         "0021",
79962         "0030",
79963         "0031",
79964         "0120",
79965         "0121",
79966         "0130",
79967         "0131",
79968         "1020",
79969         "1021",
79970         "1030",
79971         "1031",
79972         "1120",
79973         "1121",
79974         "1130",
79975         "1131",
79976         "0022",
79977         "0023",
79978         "0032",
79979         "0033",
79980         "0122",
79981         "0123",
79982         "0132",
79983         "0133",
79984         "1022",
79985         "1023",
79986         "1032",
79987         "1033",
79988         "1122",
79989         "1123",
79990         "1132",
79991         "1133",
79992         "0200",
79993         "0201",
79994         "0210",
79995         "0211",
79996         "0300",
79997         "0301",
79998         "0310",
79999         "0311",
80000         "1200",
80001         "1201",
80002         "1210",
80003         "1211",
80004         "1300",
80005         "1301",
80006         "1310",
80007         "1311",
80008         "0202",
80009         "0203",
80010         "0212",
80011         "0213",
80012         "0302",
80013         "0303",
80014         "0312",
80015         "0313",
80016         "1202",
80017         "1203",
80018         "1212",
80019         "1213",
80020         "1302",
80021         "1303",
80022         "1312",
80023         "1313",
80024         "0220",
80025         "0221",
80026         "0230",
80027         "0231",
80028         "0320",
80029         "0321",
80030         "0330",
80031         "0331",
80032         "1220",
80033         "1221",
80034         "1230",
80035         "1231",
80036         "1320",
80037         "1321",
80038         "1330",
80039         "1331",
80040         "0222",
80041         "0223",
80042         "0232",
80043         "0233",
80044         "0322",
80045         "0323",
80046         "0332",
80047         "0333",
80048         "1222",
80049         "1223",
80050         "1232",
80051         "1233",
80052         "1322",
80053         "1323",
80054         "1332",
80055         "1333",
80056         "2000",
80057         "2001",
80058         "2010",
80059         "2011",
80060         "2100",
80061         "2101",
80062         "2110",
80063         "2111",
80064         "3000",
80065         "3001",
80066         "3010",
80067         "3011",
80068         "3100",
80069         "3101",
80070         "3110",
80071         "3111",
80072         "2002",
80073         "2003",
80074         "2012",
80075         "2013",
80076         "2102",
80077         "2103",
80078         "2112",
80079         "2113",
80080         "3002",
80081         "3003",
80082         "3012",
80083         "3013",
80084         "3102",
80085         "3103",
80086         "3112",
80087         "3113",
80088         "2020",
80089         "2021",
80090         "2030",
80091         "2031",
80092         "2120",
80093         "2121",
80094         "2130",
80095         "2131",
80096         "3020",
80097         "3021",
80098         "3030",
80099         "3031",
80100         "3120",
80101         "3121",
80102         "3130",
80103         "3131",
80104         "2022",
80105         "2023",
80106         "2032",
80107         "2033",
80108         "2122",
80109         "2123",
80110         "2132",
80111         "2133",
80112         "3022",
80113         "3023",
80114         "3032",
80115         "3033",
80116         "3122",
80117         "3123",
80118         "3132",
80119         "3133",
80120         "2200",
80121         "2201",
80122         "2210",
80123         "2211",
80124         "2300",
80125         "2301",
80126         "2310",
80127         "2311",
80128         "3200",
80129         "3201",
80130         "3210",
80131         "3211",
80132         "3300",
80133         "3301",
80134         "3310",
80135         "3311",
80136         "2202",
80137         "2203",
80138         "2212",
80139         "2213",
80140         "2302",
80141         "2303",
80142         "2312",
80143         "2313",
80144         "3202",
80145         "3203",
80146         "3212",
80147         "3213",
80148         "3302",
80149         "3303",
80150         "3312",
80151         "3313",
80152         "2220",
80153         "2221",
80154         "2230",
80155         "2231",
80156         "2320",
80157         "2321",
80158         "2330",
80159         "2331",
80160         "3220",
80161         "3221",
80162         "3230",
80163         "3231",
80164         "3320",
80165         "3321",
80166         "3330",
80167         "3331",
80168         "2222",
80169         "2223",
80170         "2232",
80171         "2233",
80172         "2322",
80173         "2323",
80174         "2332",
80175         "2333",
80176         "3222",
80177         "3223",
80178         "3232",
80179         "3233",
80180         "3322",
80181         "3323",
80182         "3332",
80183         "3333"
80184       ];
80185     } else if (dim === 8) {
80186       quadKeys = [
80187         "000",
80188         "001",
80189         "010",
80190         "011",
80191         "100",
80192         "101",
80193         "110",
80194         "111",
80195         "002",
80196         "003",
80197         "012",
80198         "013",
80199         "102",
80200         "103",
80201         "112",
80202         "113",
80203         "020",
80204         "021",
80205         "030",
80206         "031",
80207         "120",
80208         "121",
80209         "130",
80210         "131",
80211         "022",
80212         "023",
80213         "032",
80214         "033",
80215         "122",
80216         "123",
80217         "132",
80218         "133",
80219         "200",
80220         "201",
80221         "210",
80222         "211",
80223         "300",
80224         "301",
80225         "310",
80226         "311",
80227         "202",
80228         "203",
80229         "212",
80230         "213",
80231         "302",
80232         "303",
80233         "312",
80234         "313",
80235         "220",
80236         "221",
80237         "230",
80238         "231",
80239         "320",
80240         "321",
80241         "330",
80242         "331",
80243         "222",
80244         "223",
80245         "232",
80246         "233",
80247         "322",
80248         "323",
80249         "332",
80250         "333"
80251       ];
80252     } else if (dim === 4) {
80253       quadKeys = [
80254         "00",
80255         "01",
80256         "10",
80257         "11",
80258         "02",
80259         "03",
80260         "12",
80261         "13",
80262         "20",
80263         "21",
80264         "30",
80265         "31",
80266         "22",
80267         "23",
80268         "32",
80269         "33"
80270       ];
80271     } else {
80272       quadKeys = [
80273         "0",
80274         "1",
80275         "2",
80276         "3"
80277       ];
80278     }
80279     return quadKeys;
80280   }
80281   var streetside_default = {
80282     /**
80283      * init() initialize streetside.
80284      */
80285     init: function() {
80286       if (!_ssCache) {
80287         this.reset();
80288       }
80289       this.event = utilRebind(this, dispatch10, "on");
80290     },
80291     /**
80292      * reset() reset the cache.
80293      */
80294     reset: function() {
80295       if (_ssCache) {
80296         Object.values(_ssCache.bubbles.inflight).forEach(abortRequest5);
80297       }
80298       _ssCache = {
80299         bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new RBush(), points: {} },
80300         sequences: {}
80301       };
80302     },
80303     /**
80304      * bubbles()
80305      */
80306     bubbles: function(projection2) {
80307       const limit = 5;
80308       return searchLimited4(limit, projection2, _ssCache.bubbles.rtree);
80309     },
80310     cachedImage: function(imageKey) {
80311       return _ssCache.bubbles.points[imageKey];
80312     },
80313     sequences: function(projection2) {
80314       const viewport = projection2.clipExtent();
80315       const min3 = [viewport[0][0], viewport[1][1]];
80316       const max3 = [viewport[1][0], viewport[0][1]];
80317       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
80318       let seen = {};
80319       let results = [];
80320       _ssCache.bubbles.rtree.search(bbox2).forEach((d2) => {
80321         const key = d2.data.sequenceKey;
80322         if (key && !seen[key]) {
80323           seen[key] = true;
80324           results.push(_ssCache.sequences[key].geojson);
80325         }
80326       });
80327       return results;
80328     },
80329     /**
80330      * loadBubbles()
80331      */
80332     loadBubbles: function(projection2, margin) {
80333       if (margin === void 0) margin = 2;
80334       loadTiles3("bubbles", streetsideApi, projection2, margin);
80335     },
80336     viewer: function() {
80337       return _pannellumViewer2;
80338     },
80339     initViewer: function() {
80340       if (!window.pannellum) return;
80341       if (_pannellumViewer2) return;
80342       _currScene += 1;
80343       const sceneID = _currScene.toString();
80344       const options2 = {
80345         "default": { firstScene: sceneID },
80346         scenes: {}
80347       };
80348       options2.scenes[sceneID] = _sceneOptions;
80349       _pannellumViewer2 = window.pannellum.viewer("ideditor-viewer-streetside", options2);
80350     },
80351     ensureViewerLoaded: function(context) {
80352       if (_loadViewerPromise4) return _loadViewerPromise4;
80353       let wrap2 = context.container().select(".photoviewer").selectAll(".ms-wrapper").data([0]);
80354       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper ms-wrapper").classed("hide", true);
80355       let that = this;
80356       let pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
80357       wrapEnter.append("div").attr("id", "ideditor-viewer-streetside").on(pointerPrefix + "down.streetside", () => {
80358         select_default2(window).on(pointerPrefix + "move.streetside", () => {
80359           dispatch10.call("viewerChanged");
80360         }, true);
80361       }).on(pointerPrefix + "up.streetside pointercancel.streetside", () => {
80362         select_default2(window).on(pointerPrefix + "move.streetside", null);
80363         let t2 = timer((elapsed) => {
80364           dispatch10.call("viewerChanged");
80365           if (elapsed > 2e3) {
80366             t2.stop();
80367           }
80368         });
80369       }).append("div").attr("class", "photo-attribution fillD");
80370       let controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
80371       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
80372       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
80373       wrap2 = wrap2.merge(wrapEnter).call(setupCanvas, true);
80374       context.ui().photoviewer.on("resize.streetside", () => {
80375         if (_pannellumViewer2) {
80376           _pannellumViewer2.resize();
80377         }
80378       });
80379       _loadViewerPromise4 = new Promise((resolve, reject) => {
80380         let loadedCount = 0;
80381         function loaded() {
80382           loadedCount += 1;
80383           if (loadedCount === 2) resolve();
80384         }
80385         const head = select_default2("head");
80386         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() {
80387           reject();
80388         });
80389         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() {
80390           reject();
80391         });
80392       }).catch(function() {
80393         _loadViewerPromise4 = null;
80394       });
80395       return _loadViewerPromise4;
80396       function step(stepBy) {
80397         return () => {
80398           let viewer = context.container().select(".photoviewer");
80399           let selected = viewer.empty() ? void 0 : viewer.datum();
80400           if (!selected) return;
80401           let nextID = stepBy === 1 ? selected.ne : selected.pr;
80402           let yaw = _pannellumViewer2.getYaw();
80403           let ca = selected.ca + yaw;
80404           let origin = selected.loc;
80405           const meters = 35;
80406           let p1 = [
80407             origin[0] + geoMetersToLon(meters / 5, origin[1]),
80408             origin[1]
80409           ];
80410           let p2 = [
80411             origin[0] + geoMetersToLon(meters / 2, origin[1]),
80412             origin[1] + geoMetersToLat(meters)
80413           ];
80414           let p3 = [
80415             origin[0] - geoMetersToLon(meters / 2, origin[1]),
80416             origin[1] + geoMetersToLat(meters)
80417           ];
80418           let p4 = [
80419             origin[0] - geoMetersToLon(meters / 5, origin[1]),
80420             origin[1]
80421           ];
80422           let poly = [p1, p2, p3, p4, p1];
80423           let angle2 = (stepBy === 1 ? ca : ca + 180) * (Math.PI / 180);
80424           poly = geoRotate(poly, -angle2, origin);
80425           let extent = poly.reduce((extent2, point) => {
80426             return extent2.extend(geoExtent(point));
80427           }, geoExtent());
80428           let minDist = Infinity;
80429           _ssCache.bubbles.rtree.search(extent.bbox()).forEach((d2) => {
80430             if (d2.data.key === selected.key) return;
80431             if (!geoPointInPolygon(d2.data.loc, poly)) return;
80432             let dist = geoVecLength(d2.data.loc, selected.loc);
80433             let theta = selected.ca - d2.data.ca;
80434             let minTheta = Math.min(Math.abs(theta), 360 - Math.abs(theta));
80435             if (minTheta > 20) {
80436               dist += 5;
80437             }
80438             if (dist < minDist) {
80439               nextID = d2.data.key;
80440               minDist = dist;
80441             }
80442           });
80443           let nextBubble = nextID && that.cachedImage(nextID);
80444           if (!nextBubble) return;
80445           context.map().centerEase(nextBubble.loc);
80446           that.selectImage(context, nextBubble.key).yaw(yaw).showViewer(context);
80447         };
80448       }
80449     },
80450     yaw: function(yaw) {
80451       if (typeof yaw !== "number") return yaw;
80452       _sceneOptions.yaw = yaw;
80453       return this;
80454     },
80455     /**
80456      * showViewer()
80457      */
80458     showViewer: function(context) {
80459       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
80460       let isHidden = wrap2.selectAll(".photo-wrapper.ms-wrapper.hide").size();
80461       if (isHidden) {
80462         wrap2.selectAll(".photo-wrapper:not(.ms-wrapper)").classed("hide", true);
80463         wrap2.selectAll(".photo-wrapper.ms-wrapper").classed("hide", false);
80464       }
80465       return this;
80466     },
80467     /**
80468      * hideViewer()
80469      */
80470     hideViewer: function(context) {
80471       let viewer = context.container().select(".photoviewer");
80472       if (!viewer.empty()) viewer.datum(null);
80473       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
80474       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
80475       this.updateUrlImage(null);
80476       return this.setStyles(context, null, true);
80477     },
80478     /**
80479      * selectImage().
80480      */
80481     selectImage: function(context, key) {
80482       let that = this;
80483       let d2 = this.cachedImage(key);
80484       let viewer = context.container().select(".photoviewer");
80485       if (!viewer.empty()) viewer.datum(d2);
80486       this.setStyles(context, null, true);
80487       let wrap2 = context.container().select(".photoviewer .ms-wrapper");
80488       let attribution = wrap2.selectAll(".photo-attribution").html("");
80489       wrap2.selectAll(".pnlm-load-box").style("display", "block");
80490       if (!d2) return this;
80491       this.updateUrlImage(key);
80492       _sceneOptions.northOffset = d2.ca;
80493       let line1 = attribution.append("div").attr("class", "attribution-row");
80494       const hiresDomId = utilUniqueDomId("streetside-hires");
80495       let label = line1.append("label").attr("for", hiresDomId).attr("class", "streetside-hires");
80496       label.append("input").attr("type", "checkbox").attr("id", hiresDomId).property("checked", _hires).on("click", (d3_event) => {
80497         d3_event.stopPropagation();
80498         _hires = !_hires;
80499         _resolution = _hires ? 1024 : 512;
80500         wrap2.call(setupCanvas, true);
80501         let viewstate = {
80502           yaw: _pannellumViewer2.getYaw(),
80503           pitch: _pannellumViewer2.getPitch(),
80504           hfov: _pannellumViewer2.getHfov()
80505         };
80506         _sceneOptions = Object.assign(_sceneOptions, viewstate);
80507         that.selectImage(context, d2.key).showViewer(context);
80508       });
80509       label.append("span").call(_t.append("streetside.hires"));
80510       let captureInfo = line1.append("div").attr("class", "attribution-capture-info");
80511       if (d2.captured_by) {
80512         const yyyy = (/* @__PURE__ */ new Date()).getFullYear();
80513         captureInfo.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://www.microsoft.com/en-us/maps/streetside").text("\xA9" + yyyy + " Microsoft");
80514         captureInfo.append("span").text("|");
80515       }
80516       if (d2.captured_at) {
80517         captureInfo.append("span").attr("class", "captured_at").text(localeTimestamp2(d2.captured_at));
80518       }
80519       let line2 = attribution.append("div").attr("class", "attribution-row");
80520       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"));
80521       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"));
80522       const faceKeys = ["01", "02", "03", "10", "11", "12"];
80523       let quadKeys = getQuadKeys();
80524       let faces = faceKeys.map((faceKey) => {
80525         return quadKeys.map((quadKey) => {
80526           const xy = qkToXY(quadKey);
80527           return {
80528             face: faceKey,
80529             url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey),
80530             x: xy[0],
80531             y: xy[1]
80532           };
80533         });
80534       });
80535       loadFaces(faces).then(function() {
80536         if (!_pannellumViewer2) {
80537           that.initViewer();
80538         } else {
80539           _currScene += 1;
80540           let sceneID = _currScene.toString();
80541           _pannellumViewer2.addScene(sceneID, _sceneOptions).loadScene(sceneID);
80542           if (_currScene > 2) {
80543             sceneID = (_currScene - 1).toString();
80544             _pannellumViewer2.removeScene(sceneID);
80545           }
80546         }
80547       });
80548       return this;
80549     },
80550     getSequenceKeyForBubble: function(d2) {
80551       return d2 && d2.sequenceKey;
80552     },
80553     // Updates the currently highlighted sequence and selected bubble.
80554     // Reset is only necessary when interacting with the viewport because
80555     // this implicitly changes the currently selected bubble/sequence
80556     setStyles: function(context, hovered, reset) {
80557       if (reset) {
80558         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
80559         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
80560       }
80561       let hoveredBubbleKey = hovered && hovered.key;
80562       let hoveredSequenceKey = this.getSequenceKeyForBubble(hovered);
80563       let hoveredSequence = hoveredSequenceKey && _ssCache.sequences[hoveredSequenceKey];
80564       let hoveredBubbleKeys = hoveredSequence && hoveredSequence.bubbles.map((d2) => d2.key) || [];
80565       let viewer = context.container().select(".photoviewer");
80566       let selected = viewer.empty() ? void 0 : viewer.datum();
80567       let selectedBubbleKey = selected && selected.key;
80568       let selectedSequenceKey = this.getSequenceKeyForBubble(selected);
80569       let selectedSequence = selectedSequenceKey && _ssCache.sequences[selectedSequenceKey];
80570       let selectedBubbleKeys = selectedSequence && selectedSequence.bubbles.map((d2) => d2.key) || [];
80571       let highlightedBubbleKeys = utilArrayUnion(hoveredBubbleKeys, selectedBubbleKeys);
80572       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);
80573       context.container().selectAll(".layer-streetside-images .sequence").classed("highlighted", (d2) => d2.properties.key === hoveredSequenceKey).classed("currentView", (d2) => d2.properties.key === selectedSequenceKey);
80574       context.container().selectAll(".layer-streetside-images .viewfield-group .viewfield").attr("d", viewfieldPath);
80575       function viewfieldPath() {
80576         let d2 = this.parentNode.__data__;
80577         if (d2.pano && d2.key !== selectedBubbleKey) {
80578           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
80579         } else {
80580           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
80581         }
80582       }
80583       return this;
80584     },
80585     updateUrlImage: function(imageKey) {
80586       if (!window.mocha) {
80587         var hash2 = utilStringQs(window.location.hash);
80588         if (imageKey) {
80589           hash2.photo = "streetside/" + imageKey;
80590         } else {
80591           delete hash2.photo;
80592         }
80593         window.location.replace("#" + utilQsString(hash2, true));
80594       }
80595     },
80596     /**
80597      * cache().
80598      */
80599     cache: function() {
80600       return _ssCache;
80601     }
80602   };
80603
80604   // modules/services/taginfo.js
80605   var apibase4 = taginfoApiUrl;
80606   var _inflight3 = {};
80607   var _popularKeys = {};
80608   var _taginfoCache = {};
80609   var tag_sorts = {
80610     point: "count_nodes",
80611     vertex: "count_nodes",
80612     area: "count_ways",
80613     line: "count_ways"
80614   };
80615   var tag_sort_members = {
80616     point: "count_node_members",
80617     vertex: "count_node_members",
80618     area: "count_way_members",
80619     line: "count_way_members",
80620     relation: "count_relation_members"
80621   };
80622   var tag_filters = {
80623     point: "nodes",
80624     vertex: "nodes",
80625     area: "ways",
80626     line: "ways"
80627   };
80628   var tag_members_fractions = {
80629     point: "count_node_members_fraction",
80630     vertex: "count_node_members_fraction",
80631     area: "count_way_members_fraction",
80632     line: "count_way_members_fraction",
80633     relation: "count_relation_members_fraction"
80634   };
80635   function sets(params, n3, o2) {
80636     if (params.geometry && o2[params.geometry]) {
80637       params[n3] = o2[params.geometry];
80638     }
80639     return params;
80640   }
80641   function setFilter(params) {
80642     return sets(params, "filter", tag_filters);
80643   }
80644   function setSort(params) {
80645     return sets(params, "sortname", tag_sorts);
80646   }
80647   function setSortMembers(params) {
80648     return sets(params, "sortname", tag_sort_members);
80649   }
80650   function clean(params) {
80651     return utilObjectOmit(params, ["geometry", "debounce"]);
80652   }
80653   function filterKeys(type2) {
80654     var count_type = type2 ? "count_" + type2 : "count_all";
80655     return function(d2) {
80656       return Number(d2[count_type]) > 2500 || d2.in_wiki;
80657     };
80658   }
80659   function filterMultikeys(prefix) {
80660     return function(d2) {
80661       var re3 = new RegExp("^" + prefix + "(.*)$", "i");
80662       var matches = d2.key.match(re3) || [];
80663       return matches.length === 2 && matches[1].indexOf(":") === -1;
80664     };
80665   }
80666   function filterValues(allowUpperCase) {
80667     return function(d2) {
80668       if (d2.value.match(/[;,]/) !== null) return false;
80669       if (!allowUpperCase && d2.value.match(/[A-Z*]/) !== null) return false;
80670       return d2.count > 100 || d2.in_wiki;
80671     };
80672   }
80673   function filterRoles(geometry) {
80674     return function(d2) {
80675       if (d2.role === "") return false;
80676       if (d2.role.match(/[A-Z*;,]/) !== null) return false;
80677       return Number(d2[tag_members_fractions[geometry]]) > 0;
80678     };
80679   }
80680   function valKey(d2) {
80681     return {
80682       value: d2.key,
80683       title: d2.key
80684     };
80685   }
80686   function valKeyDescription(d2) {
80687     var obj = {
80688       value: d2.value,
80689       title: d2.description || d2.value
80690     };
80691     return obj;
80692   }
80693   function roleKey(d2) {
80694     return {
80695       value: d2.role,
80696       title: d2.role
80697     };
80698   }
80699   function sortKeys(a2, b2) {
80700     return a2.key.indexOf(":") === -1 && b2.key.indexOf(":") !== -1 ? -1 : a2.key.indexOf(":") !== -1 && b2.key.indexOf(":") === -1 ? 1 : 0;
80701   }
80702   var debouncedRequest2 = debounce_default(request2, 300, { leading: false });
80703   function request2(url, params, exactMatch, callback, loaded) {
80704     if (_inflight3[url]) return;
80705     if (checkCache(url, params, exactMatch, callback)) return;
80706     var controller = new AbortController();
80707     _inflight3[url] = controller;
80708     json_default(url, { signal: controller.signal }).then(function(result) {
80709       delete _inflight3[url];
80710       if (loaded) loaded(null, result);
80711     }).catch(function(err) {
80712       delete _inflight3[url];
80713       if (err.name === "AbortError") return;
80714       if (loaded) loaded(err.message);
80715     });
80716   }
80717   function checkCache(url, params, exactMatch, callback) {
80718     var rp = params.rp || 25;
80719     var testQuery = params.query || "";
80720     var testUrl = url;
80721     do {
80722       var hit = _taginfoCache[testUrl];
80723       if (hit && (url === testUrl || hit.length < rp)) {
80724         callback(null, hit);
80725         return true;
80726       }
80727       if (exactMatch || !testQuery.length) return false;
80728       testQuery = testQuery.slice(0, -1);
80729       testUrl = url.replace(/&query=(.*?)&/, "&query=" + testQuery + "&");
80730     } while (testQuery.length >= 0);
80731     return false;
80732   }
80733   var taginfo_default = {
80734     init: function() {
80735       _inflight3 = {};
80736       _taginfoCache = {};
80737       _popularKeys = {
80738         // manually exclude some keys – #5377, #7485
80739         postal_code: true,
80740         full_name: true,
80741         loc_name: true,
80742         reg_name: true,
80743         short_name: true,
80744         sorting_name: true,
80745         artist_name: true,
80746         nat_name: true,
80747         long_name: true,
80748         via: true,
80749         "bridge:name": true
80750       };
80751       var params = {
80752         rp: 100,
80753         sortname: "values_all",
80754         sortorder: "desc",
80755         page: 1,
80756         debounce: false,
80757         lang: _mainLocalizer.languageCode()
80758       };
80759       this.keys(params, function(err, data) {
80760         if (err) return;
80761         data.forEach(function(d2) {
80762           if (d2.value === "opening_hours") return;
80763           _popularKeys[d2.value] = true;
80764         });
80765       });
80766     },
80767     reset: function() {
80768       Object.values(_inflight3).forEach(function(controller) {
80769         controller.abort();
80770       });
80771       _inflight3 = {};
80772     },
80773     keys: function(params, callback) {
80774       var doRequest = params.debounce ? debouncedRequest2 : request2;
80775       params = clean(setSort(params));
80776       params = Object.assign({
80777         rp: 10,
80778         sortname: "count_all",
80779         sortorder: "desc",
80780         page: 1,
80781         lang: _mainLocalizer.languageCode()
80782       }, params);
80783       var url = apibase4 + "keys/all?" + utilQsString(params);
80784       doRequest(url, params, false, callback, function(err, d2) {
80785         if (err) {
80786           callback(err);
80787         } else {
80788           var f2 = filterKeys(params.filter);
80789           var result = d2.data.filter(f2).sort(sortKeys).map(valKey);
80790           _taginfoCache[url] = result;
80791           callback(null, result);
80792         }
80793       });
80794     },
80795     multikeys: function(params, callback) {
80796       var doRequest = params.debounce ? debouncedRequest2 : request2;
80797       params = clean(setSort(params));
80798       params = Object.assign({
80799         rp: 25,
80800         sortname: "count_all",
80801         sortorder: "desc",
80802         page: 1,
80803         lang: _mainLocalizer.languageCode()
80804       }, params);
80805       var prefix = params.query;
80806       var url = apibase4 + "keys/all?" + utilQsString(params);
80807       doRequest(url, params, true, callback, function(err, d2) {
80808         if (err) {
80809           callback(err);
80810         } else {
80811           var f2 = filterMultikeys(prefix);
80812           var result = d2.data.filter(f2).map(valKey);
80813           _taginfoCache[url] = result;
80814           callback(null, result);
80815         }
80816       });
80817     },
80818     values: function(params, callback) {
80819       var key = params.key;
80820       if (key && _popularKeys[key]) {
80821         callback(null, []);
80822         return;
80823       }
80824       var doRequest = params.debounce ? debouncedRequest2 : request2;
80825       params = clean(setSort(setFilter(params)));
80826       params = Object.assign({
80827         rp: 25,
80828         sortname: "count_all",
80829         sortorder: "desc",
80830         page: 1,
80831         lang: _mainLocalizer.languageCode()
80832       }, params);
80833       var url = apibase4 + "key/values?" + utilQsString(params);
80834       doRequest(url, params, false, callback, function(err, d2) {
80835         if (err) {
80836           callback(err);
80837         } else {
80838           var allowUpperCase = allowUpperCaseTagValues.test(params.key);
80839           var f2 = filterValues(allowUpperCase);
80840           var result = d2.data.filter(f2).map(valKeyDescription);
80841           _taginfoCache[url] = result;
80842           callback(null, result);
80843         }
80844       });
80845     },
80846     roles: function(params, callback) {
80847       var doRequest = params.debounce ? debouncedRequest2 : request2;
80848       var geometry = params.geometry;
80849       params = clean(setSortMembers(params));
80850       params = Object.assign({
80851         rp: 25,
80852         sortname: "count_all_members",
80853         sortorder: "desc",
80854         page: 1,
80855         lang: _mainLocalizer.languageCode()
80856       }, params);
80857       var url = apibase4 + "relation/roles?" + utilQsString(params);
80858       doRequest(url, params, true, callback, function(err, d2) {
80859         if (err) {
80860           callback(err);
80861         } else {
80862           var f2 = filterRoles(geometry);
80863           var result = d2.data.filter(f2).map(roleKey);
80864           _taginfoCache[url] = result;
80865           callback(null, result);
80866         }
80867       });
80868     },
80869     docs: function(params, callback) {
80870       var doRequest = params.debounce ? debouncedRequest2 : request2;
80871       params = clean(setSort(params));
80872       var path = "key/wiki_pages?";
80873       if (params.value) {
80874         path = "tag/wiki_pages?";
80875       } else if (params.rtype) {
80876         path = "relation/wiki_pages?";
80877       }
80878       var url = apibase4 + path + utilQsString(params);
80879       doRequest(url, params, true, callback, function(err, d2) {
80880         if (err) {
80881           callback(err);
80882         } else {
80883           _taginfoCache[url] = d2.data;
80884           callback(null, d2.data);
80885         }
80886       });
80887     },
80888     apibase: function(_2) {
80889       if (!arguments.length) return apibase4;
80890       apibase4 = _2;
80891       return this;
80892     }
80893   };
80894
80895   // modules/services/vector_tile.js
80896   var import_fast_deep_equal11 = __toESM(require_fast_deep_equal());
80897   var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify());
80898   var import_polygon_clipping = __toESM(require_polygon_clipping_umd());
80899   var tiler7 = utilTiler().tileSize(512).margin(1);
80900   var dispatch11 = dispatch_default("loadedData");
80901   var _vtCache;
80902   function abortRequest6(controller) {
80903     controller.abort();
80904   }
80905   function vtToGeoJSON(data, tile, mergeCache) {
80906     var vectorTile = new VectorTile(new Pbf(data));
80907     var layers = Object.keys(vectorTile.layers);
80908     if (!Array.isArray(layers)) {
80909       layers = [layers];
80910     }
80911     var features = [];
80912     layers.forEach(function(layerID) {
80913       var layer = vectorTile.layers[layerID];
80914       if (layer) {
80915         for (var i3 = 0; i3 < layer.length; i3++) {
80916           var feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
80917           var geometry = feature3.geometry;
80918           if (geometry.type === "Polygon") {
80919             geometry.type = "MultiPolygon";
80920             geometry.coordinates = [geometry.coordinates];
80921           }
80922           var isClipped = false;
80923           if (geometry.type === "MultiPolygon") {
80924             var featureClip = turf_bbox_clip_default(feature3, tile.extent.rectangle());
80925             if (!(0, import_fast_deep_equal11.default)(feature3.geometry, featureClip.geometry)) {
80926               isClipped = true;
80927             }
80928             if (!feature3.geometry.coordinates.length) continue;
80929             if (!feature3.geometry.coordinates[0].length) continue;
80930           }
80931           var featurehash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3));
80932           var propertyhash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3.properties || {}));
80933           feature3.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, "_");
80934           feature3.__featurehash__ = featurehash;
80935           feature3.__propertyhash__ = propertyhash;
80936           features.push(feature3);
80937           if (isClipped && geometry.type === "MultiPolygon") {
80938             var merged = mergeCache[propertyhash];
80939             if (merged && merged.length) {
80940               var other2 = merged[0];
80941               var coords = import_polygon_clipping.default.union(
80942                 feature3.geometry.coordinates,
80943                 other2.geometry.coordinates
80944               );
80945               if (!coords || !coords.length) {
80946                 continue;
80947               }
80948               merged.push(feature3);
80949               for (var j2 = 0; j2 < merged.length; j2++) {
80950                 merged[j2].geometry.coordinates = coords;
80951                 merged[j2].__featurehash__ = featurehash;
80952               }
80953             } else {
80954               mergeCache[propertyhash] = [feature3];
80955             }
80956           }
80957         }
80958       }
80959     });
80960     return features;
80961   }
80962   function loadTile3(source, tile) {
80963     if (source.loaded[tile.id] || source.inflight[tile.id]) return;
80964     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) {
80965       var subdomains = r2.split(",");
80966       return subdomains[(tile.xyz[0] + tile.xyz[1]) % subdomains.length];
80967     });
80968     var controller = new AbortController();
80969     source.inflight[tile.id] = controller;
80970     fetch(url, { signal: controller.signal }).then(function(response) {
80971       if (!response.ok) {
80972         throw new Error(response.status + " " + response.statusText);
80973       }
80974       source.loaded[tile.id] = [];
80975       delete source.inflight[tile.id];
80976       return response.arrayBuffer();
80977     }).then(function(data) {
80978       if (!data) {
80979         throw new Error("No Data");
80980       }
80981       var z2 = tile.xyz[2];
80982       if (!source.canMerge[z2]) {
80983         source.canMerge[z2] = {};
80984       }
80985       source.loaded[tile.id] = vtToGeoJSON(data, tile, source.canMerge[z2]);
80986       dispatch11.call("loadedData");
80987     }).catch(function() {
80988       source.loaded[tile.id] = [];
80989       delete source.inflight[tile.id];
80990     });
80991   }
80992   var vector_tile_default = {
80993     init: function() {
80994       if (!_vtCache) {
80995         this.reset();
80996       }
80997       this.event = utilRebind(this, dispatch11, "on");
80998     },
80999     reset: function() {
81000       for (var sourceID in _vtCache) {
81001         var source = _vtCache[sourceID];
81002         if (source && source.inflight) {
81003           Object.values(source.inflight).forEach(abortRequest6);
81004         }
81005       }
81006       _vtCache = {};
81007     },
81008     addSource: function(sourceID, template) {
81009       _vtCache[sourceID] = { template, inflight: {}, loaded: {}, canMerge: {} };
81010       return _vtCache[sourceID];
81011     },
81012     data: function(sourceID, projection2) {
81013       var source = _vtCache[sourceID];
81014       if (!source) return [];
81015       var tiles = tiler7.getTiles(projection2);
81016       var seen = {};
81017       var results = [];
81018       for (var i3 = 0; i3 < tiles.length; i3++) {
81019         var features = source.loaded[tiles[i3].id];
81020         if (!features || !features.length) continue;
81021         for (var j2 = 0; j2 < features.length; j2++) {
81022           var feature3 = features[j2];
81023           var hash2 = feature3.__featurehash__;
81024           if (seen[hash2]) continue;
81025           seen[hash2] = true;
81026           results.push(Object.assign({}, feature3));
81027         }
81028       }
81029       return results;
81030     },
81031     loadTiles: function(sourceID, template, projection2) {
81032       var source = _vtCache[sourceID];
81033       if (!source) {
81034         source = this.addSource(sourceID, template);
81035       }
81036       var tiles = tiler7.getTiles(projection2);
81037       Object.keys(source.inflight).forEach(function(k2) {
81038         var wanted = tiles.find(function(tile) {
81039           return k2 === tile.id;
81040         });
81041         if (!wanted) {
81042           abortRequest6(source.inflight[k2]);
81043           delete source.inflight[k2];
81044         }
81045       });
81046       tiles.forEach(function(tile) {
81047         loadTile3(source, tile);
81048       });
81049     },
81050     cache: function() {
81051       return _vtCache;
81052     }
81053   };
81054
81055   // modules/services/wikidata.js
81056   var apibase5 = "https://www.wikidata.org/w/api.php?";
81057   var _wikidataCache = {};
81058   var wikidata_default = {
81059     init: function() {
81060     },
81061     reset: function() {
81062       _wikidataCache = {};
81063     },
81064     // Search for Wikidata items matching the query
81065     itemsForSearchQuery: function(query, callback, language) {
81066       if (!query) {
81067         if (callback) callback("No query", {});
81068         return;
81069       }
81070       var lang = this.languagesToQuery()[0];
81071       var url = apibase5 + utilQsString({
81072         action: "wbsearchentities",
81073         format: "json",
81074         formatversion: 2,
81075         search: query,
81076         type: "item",
81077         // the language to search
81078         language: language || lang,
81079         // the language for the label and description in the result
81080         uselang: lang,
81081         limit: 10,
81082         origin: "*"
81083       });
81084       json_default(url).then((result) => {
81085         if (result && result.error) {
81086           if (result.error.code === "badvalue" && result.error.info.includes(lang) && !language && lang.includes("-")) {
81087             this.itemsForSearchQuery(query, callback, lang.split("-")[0]);
81088             return;
81089           } else {
81090             throw new Error(result.error);
81091           }
81092         }
81093         if (callback) callback(null, result.search || {});
81094       }).catch(function(err) {
81095         if (callback) callback(err.message, {});
81096       });
81097     },
81098     // Given a Wikipedia language and article title,
81099     // return an array of corresponding Wikidata entities.
81100     itemsByTitle: function(lang, title, callback) {
81101       if (!title) {
81102         if (callback) callback("No title", {});
81103         return;
81104       }
81105       lang = lang || "en";
81106       var url = apibase5 + utilQsString({
81107         action: "wbgetentities",
81108         format: "json",
81109         formatversion: 2,
81110         sites: lang.replace(/-/g, "_") + "wiki",
81111         titles: title,
81112         languages: "en",
81113         // shrink response by filtering to one language
81114         origin: "*"
81115       });
81116       json_default(url).then(function(result) {
81117         if (result && result.error) {
81118           throw new Error(result.error);
81119         }
81120         if (callback) callback(null, result.entities || {});
81121       }).catch(function(err) {
81122         if (callback) callback(err.message, {});
81123       });
81124     },
81125     languagesToQuery: function() {
81126       return _mainLocalizer.localeCodes().map(function(code) {
81127         return code.toLowerCase();
81128       }).filter(function(code) {
81129         return code !== "en-us";
81130       });
81131     },
81132     entityByQID: function(qid, callback) {
81133       if (!qid) {
81134         callback("No qid", {});
81135         return;
81136       }
81137       if (_wikidataCache[qid]) {
81138         if (callback) callback(null, _wikidataCache[qid]);
81139         return;
81140       }
81141       var langs = this.languagesToQuery();
81142       var url = apibase5 + utilQsString({
81143         action: "wbgetentities",
81144         format: "json",
81145         formatversion: 2,
81146         ids: qid,
81147         props: "labels|descriptions|claims|sitelinks",
81148         sitefilter: langs.map(function(d2) {
81149           return d2 + "wiki";
81150         }).join("|"),
81151         languages: langs.join("|"),
81152         languagefallback: 1,
81153         origin: "*"
81154       });
81155       json_default(url).then(function(result) {
81156         if (result && result.error) {
81157           throw new Error(result.error);
81158         }
81159         if (callback) callback(null, result.entities[qid] || {});
81160       }).catch(function(err) {
81161         if (callback) callback(err.message, {});
81162       });
81163     },
81164     // Pass `params` object of the form:
81165     // {
81166     //   qid: 'string'      // brand wikidata  (e.g. 'Q37158')
81167     // }
81168     //
81169     // Get an result object used to display tag documentation
81170     // {
81171     //   title:        'string',
81172     //   description:  'string',
81173     //   editURL:      'string',
81174     //   imageURL:     'string',
81175     //   wiki:         { title: 'string', text: 'string', url: 'string' }
81176     // }
81177     //
81178     getDocs: function(params, callback) {
81179       var langs = this.languagesToQuery();
81180       this.entityByQID(params.qid, function(err, entity) {
81181         if (err || !entity) {
81182           callback(err || "No entity");
81183           return;
81184         }
81185         var i3;
81186         var description;
81187         for (i3 in langs) {
81188           let code = langs[i3];
81189           if (entity.descriptions[code] && entity.descriptions[code].language === code) {
81190             description = entity.descriptions[code];
81191             break;
81192           }
81193         }
81194         if (!description && Object.values(entity.descriptions).length) description = Object.values(entity.descriptions)[0];
81195         var result = {
81196           title: entity.id,
81197           description: description ? description.value : "",
81198           descriptionLocaleCode: description ? description.language : "",
81199           editURL: "https://www.wikidata.org/wiki/" + entity.id
81200         };
81201         if (entity.claims) {
81202           var imageroot = "https://commons.wikimedia.org/w/index.php";
81203           var props = ["P154", "P18"];
81204           var prop, image;
81205           for (i3 = 0; i3 < props.length; i3++) {
81206             prop = entity.claims[props[i3]];
81207             if (prop && Object.keys(prop).length > 0) {
81208               image = prop[Object.keys(prop)[0]].mainsnak.datavalue.value;
81209               if (image) {
81210                 result.imageURL = imageroot + "?" + utilQsString({
81211                   title: "Special:Redirect/file/" + image,
81212                   width: 400
81213                 });
81214                 break;
81215               }
81216             }
81217           }
81218         }
81219         if (entity.sitelinks) {
81220           var englishLocale = _mainLocalizer.languageCode().toLowerCase() === "en";
81221           for (i3 = 0; i3 < langs.length; i3++) {
81222             var w2 = langs[i3] + "wiki";
81223             if (entity.sitelinks[w2]) {
81224               var title = entity.sitelinks[w2].title;
81225               var tKey = "inspector.wiki_reference";
81226               if (!englishLocale && langs[i3] === "en") {
81227                 tKey = "inspector.wiki_en_reference";
81228               }
81229               result.wiki = {
81230                 title,
81231                 text: tKey,
81232                 url: "https://" + langs[i3] + ".wikipedia.org/wiki/" + title.replace(/ /g, "_")
81233               };
81234               break;
81235             }
81236           }
81237         }
81238         callback(null, result);
81239       });
81240     }
81241   };
81242
81243   // modules/services/wikipedia.js
81244   var endpoint = "https://en.wikipedia.org/w/api.php?";
81245   var wikipedia_default = {
81246     init: function() {
81247     },
81248     reset: function() {
81249     },
81250     search: function(lang, query, callback) {
81251       if (!query) {
81252         if (callback) callback("No Query", []);
81253         return;
81254       }
81255       lang = lang || "en";
81256       var url = endpoint.replace("en", lang) + utilQsString({
81257         action: "query",
81258         list: "search",
81259         srlimit: "10",
81260         srinfo: "suggestion",
81261         format: "json",
81262         origin: "*",
81263         srsearch: query
81264       });
81265       json_default(url).then(function(result) {
81266         if (result && result.error) {
81267           throw new Error(result.error);
81268         } else if (!result || !result.query || !result.query.search) {
81269           throw new Error("No Results");
81270         }
81271         if (callback) {
81272           var titles = result.query.search.map(function(d2) {
81273             return d2.title;
81274           });
81275           callback(null, titles);
81276         }
81277       }).catch(function(err) {
81278         if (callback) callback(err, []);
81279       });
81280     },
81281     suggestions: function(lang, query, callback) {
81282       if (!query) {
81283         if (callback) callback("", []);
81284         return;
81285       }
81286       lang = lang || "en";
81287       var url = endpoint.replace("en", lang) + utilQsString({
81288         action: "opensearch",
81289         namespace: 0,
81290         suggest: "",
81291         format: "json",
81292         origin: "*",
81293         search: query
81294       });
81295       json_default(url).then(function(result) {
81296         if (result && result.error) {
81297           throw new Error(result.error);
81298         } else if (!result || result.length < 2) {
81299           throw new Error("No Results");
81300         }
81301         if (callback) callback(null, result[1] || []);
81302       }).catch(function(err) {
81303         if (callback) callback(err.message, []);
81304       });
81305     },
81306     translations: function(lang, title, callback) {
81307       if (!title) {
81308         if (callback) callback("No Title");
81309         return;
81310       }
81311       var url = endpoint.replace("en", lang) + utilQsString({
81312         action: "query",
81313         prop: "langlinks",
81314         format: "json",
81315         origin: "*",
81316         lllimit: 500,
81317         titles: title
81318       });
81319       json_default(url).then(function(result) {
81320         if (result && result.error) {
81321           throw new Error(result.error);
81322         } else if (!result || !result.query || !result.query.pages) {
81323           throw new Error("No Results");
81324         }
81325         if (callback) {
81326           var list2 = result.query.pages[Object.keys(result.query.pages)[0]];
81327           var translations = {};
81328           if (list2 && list2.langlinks) {
81329             list2.langlinks.forEach(function(d2) {
81330               translations[d2.lang] = d2["*"];
81331             });
81332           }
81333           callback(null, translations);
81334         }
81335       }).catch(function(err) {
81336         if (callback) callback(err.message);
81337       });
81338     }
81339   };
81340
81341   // modules/services/mapilio.js
81342   var import_lodash5 = __toESM(require_lodash());
81343   var apiUrl2 = "https://end.mapilio.com";
81344   var imageBaseUrl = "https://cdn.mapilio.com/im";
81345   var baseTileUrl2 = "https://geo.mapilio.com/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=mapilio:";
81346   var pointLayer = "map_points";
81347   var lineLayer = "map_roads_line";
81348   var tileStyle = "&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";
81349   var minZoom3 = 14;
81350   var dispatch12 = dispatch_default("loadedImages", "loadedLines");
81351   var imgZoom3 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
81352   var pannellumViewerCSS3 = "pannellum/pannellum.css";
81353   var pannellumViewerJS3 = "pannellum/pannellum.js";
81354   var resolution = 1080;
81355   var _activeImage;
81356   var _cache3;
81357   var _loadViewerPromise5;
81358   var _pannellumViewer3;
81359   var _sceneOptions2 = {
81360     showFullscreenCtrl: false,
81361     autoLoad: true,
81362     yaw: 0,
81363     minHfov: 10,
81364     maxHfov: 90,
81365     hfov: 60
81366   };
81367   var _currScene2 = 0;
81368   function partitionViewport5(projection2) {
81369     const z2 = geoScaleToZoom(projection2.scale());
81370     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81371     const tiler8 = utilTiler().zoomExtent([z22, z22]);
81372     return tiler8.getTiles(projection2).map(function(tile) {
81373       return tile.extent;
81374     });
81375   }
81376   function searchLimited5(limit, projection2, rtree) {
81377     limit = limit || 5;
81378     return partitionViewport5(projection2).reduce(function(result, extent) {
81379       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
81380         return d2.data;
81381       });
81382       return found.length ? result.concat(found) : result;
81383     }, []);
81384   }
81385   function loadTiles4(which, url, maxZoom2, projection2) {
81386     const tiler8 = utilTiler().zoomExtent([minZoom3, maxZoom2]).skipNullIsland(true);
81387     const tiles = tiler8.getTiles(projection2);
81388     tiles.forEach(function(tile) {
81389       loadTile4(which, url, tile);
81390     });
81391   }
81392   function loadTile4(which, url, tile) {
81393     const cache = _cache3.requests;
81394     const tileId = "".concat(tile.id, "-").concat(which);
81395     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
81396     const controller = new AbortController();
81397     cache.inflight[tileId] = controller;
81398     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
81399     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
81400       if (!response.ok) {
81401         throw new Error(response.status + " " + response.statusText);
81402       }
81403       cache.loaded[tileId] = true;
81404       delete cache.inflight[tileId];
81405       return response.arrayBuffer();
81406     }).then(function(data) {
81407       if (data.byteLength === 0) {
81408         throw new Error("No Data");
81409       }
81410       loadTileDataToCache2(data, tile, which);
81411       if (which === "images") {
81412         dispatch12.call("loadedImages");
81413       } else {
81414         dispatch12.call("loadedLines");
81415       }
81416     }).catch(function(e3) {
81417       if (e3.message === "No Data") {
81418         cache.loaded[tileId] = true;
81419       } else {
81420         console.error(e3);
81421       }
81422     });
81423   }
81424   function loadTileDataToCache2(data, tile) {
81425     const vectorTile = new VectorTile(new Pbf(data));
81426     if (vectorTile.layers.hasOwnProperty(pointLayer)) {
81427       const features = [];
81428       const cache = _cache3.images;
81429       const layer = vectorTile.layers[pointLayer];
81430       for (let i3 = 0; i3 < layer.length; i3++) {
81431         const feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81432         const loc = feature3.geometry.coordinates;
81433         let resolutionArr = feature3.properties.resolution.split("x");
81434         let sourceWidth = Math.max(resolutionArr[0], resolutionArr[1]);
81435         let sourceHeight = Math.min(resolutionArr[0], resolutionArr[1]);
81436         let isPano = sourceWidth % sourceHeight === 0;
81437         const d2 = {
81438           loc,
81439           capture_time: feature3.properties.capture_time,
81440           id: feature3.properties.id,
81441           sequence_id: feature3.properties.sequence_uuid,
81442           heading: feature3.properties.heading,
81443           resolution: feature3.properties.resolution,
81444           isPano
81445         };
81446         cache.forImageId[d2.id] = d2;
81447         features.push({
81448           minX: loc[0],
81449           minY: loc[1],
81450           maxX: loc[0],
81451           maxY: loc[1],
81452           data: d2
81453         });
81454       }
81455       if (cache.rtree) {
81456         cache.rtree.load(features);
81457       }
81458     }
81459     if (vectorTile.layers.hasOwnProperty(lineLayer)) {
81460       const cache = _cache3.sequences;
81461       const layer = vectorTile.layers[lineLayer];
81462       for (let i3 = 0; i3 < layer.length; i3++) {
81463         const feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81464         if (cache.lineString[feature3.properties.sequence_uuid]) {
81465           const cacheEntry = cache.lineString[feature3.properties.sequence_uuid];
81466           if (cacheEntry.some((f2) => {
81467             const cachedCoords = f2.geometry.coordinates;
81468             const featureCoords = feature3.geometry.coordinates;
81469             return (0, import_lodash5.isEqual)(cachedCoords, featureCoords);
81470           })) continue;
81471           cacheEntry.push(feature3);
81472         } else {
81473           cache.lineString[feature3.properties.sequence_uuid] = [feature3];
81474         }
81475       }
81476     }
81477   }
81478   function getImageData(imageId, sequenceId) {
81479     return fetch(apiUrl2 + "/api/sequence-detail?sequence_uuid=".concat(sequenceId), { method: "GET" }).then(function(response) {
81480       if (!response.ok) {
81481         throw new Error(response.status + " " + response.statusText);
81482       }
81483       return response.json();
81484     }).then(function(data) {
81485       let index = data.data.findIndex((feature3) => feature3.id === imageId);
81486       const { filename, uploaded_hash } = data.data[index];
81487       _sceneOptions2.panorama = imageBaseUrl + "/" + uploaded_hash + "/" + filename + "/" + resolution;
81488     });
81489   }
81490   var mapilio_default = {
81491     // Initialize Mapilio
81492     init: function() {
81493       if (!_cache3) {
81494         this.reset();
81495       }
81496       this.event = utilRebind(this, dispatch12, "on");
81497     },
81498     // Reset cache and state
81499     reset: function() {
81500       if (_cache3) {
81501         Object.values(_cache3.requests.inflight).forEach(function(request3) {
81502           request3.abort();
81503         });
81504       }
81505       _cache3 = {
81506         images: { rtree: new RBush(), forImageId: {} },
81507         sequences: { rtree: new RBush(), lineString: {} },
81508         requests: { loaded: {}, inflight: {} }
81509       };
81510       _activeImage = null;
81511     },
81512     // Get visible images
81513     images: function(projection2) {
81514       const limit = 5;
81515       return searchLimited5(limit, projection2, _cache3.images.rtree);
81516     },
81517     cachedImage: function(imageKey) {
81518       return _cache3.images.forImageId[imageKey];
81519     },
81520     // Load images in the visible area
81521     loadImages: function(projection2) {
81522       let url = baseTileUrl2 + pointLayer + tileStyle;
81523       loadTiles4("images", url, 14, projection2);
81524     },
81525     // Load line in the visible area
81526     loadLines: function(projection2) {
81527       let url = baseTileUrl2 + lineLayer + tileStyle;
81528       loadTiles4("line", url, 14, projection2);
81529     },
81530     // Get visible sequences
81531     sequences: function(projection2) {
81532       const viewport = projection2.clipExtent();
81533       const min3 = [viewport[0][0], viewport[1][1]];
81534       const max3 = [viewport[1][0], viewport[0][1]];
81535       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81536       const sequenceIds = {};
81537       let lineStrings = [];
81538       _cache3.images.rtree.search(bbox2).forEach(function(d2) {
81539         if (d2.data.sequence_id) {
81540           sequenceIds[d2.data.sequence_id] = true;
81541         }
81542       });
81543       Object.keys(sequenceIds).forEach(function(sequenceId) {
81544         if (_cache3.sequences.lineString[sequenceId]) {
81545           lineStrings = lineStrings.concat(_cache3.sequences.lineString[sequenceId]);
81546         }
81547       });
81548       return lineStrings;
81549     },
81550     // Set the currently visible image
81551     setActiveImage: function(image) {
81552       if (image) {
81553         _activeImage = {
81554           id: image.id,
81555           sequence_id: image.sequence_id
81556         };
81557       } else {
81558         _activeImage = null;
81559       }
81560     },
81561     // Update the currently highlighted sequence and selected bubble.
81562     setStyles: function(context, hovered) {
81563       const hoveredImageId = hovered && hovered.id;
81564       const hoveredSequenceId = hovered && hovered.sequence_id;
81565       const selectedSequenceId = _activeImage && _activeImage.sequence_id;
81566       const selectedImageId = _activeImage && _activeImage.id;
81567       const markers = context.container().selectAll(".layer-mapilio .viewfield-group");
81568       const sequences = context.container().selectAll(".layer-mapilio .sequence");
81569       markers.classed("highlighted", function(d2) {
81570         return d2.id === hoveredImageId;
81571       }).classed("hovered", function(d2) {
81572         return d2.id === hoveredImageId;
81573       }).classed("currentView", function(d2) {
81574         return d2.id === selectedImageId;
81575       });
81576       sequences.classed("highlighted", function(d2) {
81577         return d2.properties.sequence_uuid === hoveredSequenceId;
81578       }).classed("currentView", function(d2) {
81579         return d2.properties.sequence_uuid === selectedSequenceId;
81580       });
81581       return this;
81582     },
81583     updateUrlImage: function(imageKey) {
81584       if (!window.mocha) {
81585         var hash2 = utilStringQs(window.location.hash);
81586         if (imageKey) {
81587           hash2.photo = "mapilio/" + imageKey;
81588         } else {
81589           delete hash2.photo;
81590         }
81591         window.location.replace("#" + utilQsString(hash2, true));
81592       }
81593     },
81594     initViewer: function() {
81595       if (!window.pannellum) return;
81596       if (_pannellumViewer3) return;
81597       _currScene2 += 1;
81598       const sceneID = _currScene2.toString();
81599       const options2 = {
81600         "default": { firstScene: sceneID },
81601         scenes: {}
81602       };
81603       options2.scenes[sceneID] = _sceneOptions2;
81604       _pannellumViewer3 = window.pannellum.viewer("ideditor-viewer-mapilio-pnlm", options2);
81605     },
81606     selectImage: function(context, id2) {
81607       let that = this;
81608       let d2 = this.cachedImage(id2);
81609       this.setActiveImage(d2);
81610       this.updateUrlImage(d2.id);
81611       let viewer = context.container().select(".photoviewer");
81612       if (!viewer.empty()) viewer.datum(d2);
81613       this.setStyles(context, null);
81614       if (!d2) return this;
81615       let wrap2 = context.container().select(".photoviewer .mapilio-wrapper");
81616       let attribution = wrap2.selectAll(".photo-attribution").text("");
81617       if (d2.capture_time) {
81618         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
81619         attribution.append("span").text("|");
81620       }
81621       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");
81622       wrap2.transition().duration(100).call(imgZoom3.transform, identity2);
81623       wrap2.selectAll("img").remove();
81624       wrap2.selectAll("button.back").classed("hide", !_cache3.images.forImageId.hasOwnProperty(+id2 - 1));
81625       wrap2.selectAll("button.forward").classed("hide", !_cache3.images.forImageId.hasOwnProperty(+id2 + 1));
81626       getImageData(d2.id, d2.sequence_id).then(function() {
81627         if (d2.isPano) {
81628           if (!_pannellumViewer3) {
81629             that.initViewer();
81630           } else {
81631             _currScene2 += 1;
81632             let sceneID = _currScene2.toString();
81633             _pannellumViewer3.addScene(sceneID, _sceneOptions2).loadScene(sceneID);
81634             if (_currScene2 > 2) {
81635               sceneID = (_currScene2 - 1).toString();
81636               _pannellumViewer3.removeScene(sceneID);
81637             }
81638           }
81639         } else {
81640           that.initOnlyPhoto(context);
81641         }
81642       });
81643       function localeDateString2(s2) {
81644         if (!s2) return null;
81645         var options2 = { day: "numeric", month: "short", year: "numeric" };
81646         var d4 = new Date(s2);
81647         if (isNaN(d4.getTime())) return null;
81648         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
81649       }
81650       return this;
81651     },
81652     initOnlyPhoto: function(context) {
81653       if (_pannellumViewer3) {
81654         _pannellumViewer3.destroy();
81655         _pannellumViewer3 = null;
81656       }
81657       let wrap2 = context.container().select("#ideditor-viewer-mapilio-simple");
81658       let imgWrap = wrap2.select("img");
81659       if (!imgWrap.empty()) {
81660         imgWrap.attr("src", _sceneOptions2.panorama);
81661       } else {
81662         wrap2.append("img").attr("src", _sceneOptions2.panorama);
81663       }
81664     },
81665     ensureViewerLoaded: function(context) {
81666       let that = this;
81667       let imgWrap = context.container().select("#ideditor-viewer-mapilio-simple > img");
81668       if (!imgWrap.empty()) {
81669         imgWrap.remove();
81670       }
81671       if (_loadViewerPromise5) return _loadViewerPromise5;
81672       let wrap2 = context.container().select(".photoviewer").selectAll(".mapilio-wrapper").data([0]);
81673       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null);
81674       wrapEnter.append("div").attr("class", "photo-attribution fillD");
81675       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio");
81676       controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4");
81677       controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA");
81678       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm");
81679       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple");
81680       context.ui().photoviewer.on("resize.mapilio", () => {
81681         if (_pannellumViewer3) {
81682           _pannellumViewer3.resize();
81683         }
81684       });
81685       _loadViewerPromise5 = new Promise((resolve, reject) => {
81686         let loadedCount = 0;
81687         function loaded() {
81688           loadedCount += 1;
81689           if (loadedCount === 2) resolve();
81690         }
81691         const head = select_default2("head");
81692         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() {
81693           reject();
81694         });
81695         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() {
81696           reject();
81697         });
81698       }).catch(function() {
81699         _loadViewerPromise5 = null;
81700       });
81701       function step(stepBy) {
81702         return function() {
81703           if (!_activeImage) return;
81704           const imageId = _activeImage.id;
81705           const nextIndex = imageId + stepBy;
81706           if (!nextIndex) return;
81707           const nextImage = _cache3.images.forImageId[nextIndex];
81708           context.map().centerEase(nextImage.loc);
81709           that.selectImage(context, nextImage.id);
81710         };
81711       }
81712       function zoomPan2(d3_event) {
81713         var t2 = d3_event.transform;
81714         context.container().select(".photoviewer #ideditor-viewer-mapilio-simple").call(utilSetTransform, t2.x, t2.y, t2.k);
81715       }
81716       return _loadViewerPromise5;
81717     },
81718     showViewer: function(context) {
81719       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
81720       let isHidden = wrap2.selectAll(".photo-wrapper.mapilio-wrapper.hide").size();
81721       if (isHidden) {
81722         wrap2.selectAll(".photo-wrapper:not(.mapilio-wrapper)").classed("hide", true);
81723         wrap2.selectAll(".photo-wrapper.mapilio-wrapper").classed("hide", false);
81724       }
81725       return this;
81726     },
81727     /**
81728      * hideViewer()
81729      */
81730     hideViewer: function(context) {
81731       let viewer = context.container().select(".photoviewer");
81732       if (!viewer.empty()) viewer.datum(null);
81733       this.updateUrlImage(null);
81734       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
81735       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
81736       this.setActiveImage();
81737       return this.setStyles(context, null);
81738     },
81739     // Return the current cache
81740     cache: function() {
81741       return _cache3;
81742     }
81743   };
81744
81745   // modules/services/panoramax.js
81746   var apiUrl3 = "https://api.panoramax.xyz/";
81747   var tileUrl2 = apiUrl3 + "api/map/{z}/{x}/{y}.mvt";
81748   var imageDataUrl = apiUrl3 + "api/collections/{collectionId}/items/{itemId}";
81749   var userIdUrl = apiUrl3 + "api/users/search?q={username}";
81750   var usernameURL = apiUrl3 + "api/users/{userId}";
81751   var viewerUrl = apiUrl3;
81752   var highDefinition = "hd";
81753   var standardDefinition = "sd";
81754   var pictureLayer = "pictures";
81755   var sequenceLayer = "sequences";
81756   var minZoom4 = 10;
81757   var imageMinZoom = 15;
81758   var lineMinZoom = 10;
81759   var dispatch13 = dispatch_default("loadedImages", "loadedLines", "viewerChanged");
81760   var _cache4;
81761   var _loadViewerPromise6;
81762   var _definition = standardDefinition;
81763   var _isHD = false;
81764   var _planeFrame2;
81765   var _pannellumFrame2;
81766   var _currentFrame2;
81767   var _oldestDate;
81768   var _currentScene = {
81769     currentImage: null,
81770     nextImage: null,
81771     prevImage: null
81772   };
81773   var _activeImage2;
81774   function partitionViewport6(projection2) {
81775     const z2 = geoScaleToZoom(projection2.scale());
81776     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81777     const tiler8 = utilTiler().zoomExtent([z22, z22]);
81778     return tiler8.getTiles(projection2).map(function(tile) {
81779       return tile.extent;
81780     });
81781   }
81782   function searchLimited6(limit, projection2, rtree) {
81783     limit = limit || 5;
81784     return partitionViewport6(projection2).reduce(function(result, extent) {
81785       let found = rtree.search(extent.bbox());
81786       const spacing = Math.max(1, Math.floor(found.length / limit));
81787       found = found.filter((d2, idx) => idx % spacing === 0 || d2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)).sort((a2, b2) => {
81788         if (a2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)) return -1;
81789         if (b2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)) return 1;
81790         return 0;
81791       }).slice(0, limit).map((d2) => d2.data);
81792       return found.length ? result.concat(found) : result;
81793     }, []);
81794   }
81795   function loadTiles5(which, url, maxZoom2, projection2, zoom) {
81796     const tiler8 = utilTiler().zoomExtent([minZoom4, maxZoom2]).skipNullIsland(true);
81797     const tiles = tiler8.getTiles(projection2);
81798     tiles.forEach(function(tile) {
81799       loadTile5(which, url, tile, zoom);
81800     });
81801   }
81802   function loadTile5(which, url, tile, zoom) {
81803     const cache = _cache4.requests;
81804     const tileId = "".concat(tile.id, "-").concat(which);
81805     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
81806     const controller = new AbortController();
81807     cache.inflight[tileId] = controller;
81808     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
81809     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
81810       if (!response.ok) {
81811         throw new Error(response.status + " " + response.statusText);
81812       }
81813       cache.loaded[tileId] = true;
81814       delete cache.inflight[tileId];
81815       return response.arrayBuffer();
81816     }).then(function(data) {
81817       if (data.byteLength === 0) {
81818         throw new Error("No Data");
81819       }
81820       loadTileDataToCache3(data, tile, zoom);
81821       if (which === "images") {
81822         dispatch13.call("loadedImages");
81823       } else {
81824         dispatch13.call("loadedLines");
81825       }
81826     }).catch(function(e3) {
81827       if (e3.message === "No Data") {
81828         cache.loaded[tileId] = true;
81829       } else {
81830         console.error(e3);
81831       }
81832     });
81833   }
81834   function loadTileDataToCache3(data, tile, zoom) {
81835     const vectorTile = new VectorTile(new Pbf(data));
81836     let features, cache, layer, i3, feature3, loc, d2;
81837     if (vectorTile.layers.hasOwnProperty(pictureLayer)) {
81838       features = [];
81839       cache = _cache4.images;
81840       layer = vectorTile.layers[pictureLayer];
81841       for (i3 = 0; i3 < layer.length; i3++) {
81842         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81843         loc = feature3.geometry.coordinates;
81844         d2 = {
81845           loc,
81846           capture_time: feature3.properties.ts,
81847           capture_time_parsed: new Date(feature3.properties.ts),
81848           id: feature3.properties.id,
81849           account_id: feature3.properties.account_id,
81850           sequence_id: feature3.properties.sequences.split('"')[1],
81851           heading: parseInt(feature3.properties.heading, 10),
81852           image_path: "",
81853           resolution: feature3.properties.resolution,
81854           isPano: feature3.properties.type === "equirectangular",
81855           model: feature3.properties.model
81856         };
81857         cache.forImageId[d2.id] = d2;
81858         features.push({
81859           minX: loc[0],
81860           minY: loc[1],
81861           maxX: loc[0],
81862           maxY: loc[1],
81863           data: d2
81864         });
81865         if (_oldestDate) {
81866           if (d2.capture_time < _oldestDate) {
81867             _oldestDate = d2.capture_time;
81868           }
81869         } else {
81870           _oldestDate = d2.capture_time;
81871         }
81872       }
81873       if (cache.rtree) {
81874         cache.rtree.load(features);
81875       }
81876     }
81877     if (vectorTile.layers.hasOwnProperty(sequenceLayer)) {
81878       cache = _cache4.sequences;
81879       if (zoom >= lineMinZoom && zoom < imageMinZoom) cache = _cache4.mockSequences;
81880       layer = vectorTile.layers[sequenceLayer];
81881       for (i3 = 0; i3 < layer.length; i3++) {
81882         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81883         if (cache.lineString[feature3.properties.id]) {
81884           cache.lineString[feature3.properties.id].push(feature3);
81885         } else {
81886           cache.lineString[feature3.properties.id] = [feature3];
81887         }
81888         if (_oldestDate) {
81889           if (feature3.properties.date < _oldestDate) {
81890             _oldestDate = feature3.properties.date;
81891           }
81892         } else {
81893           _oldestDate = feature3.properties.date;
81894         }
81895       }
81896     }
81897   }
81898   async function getImageData2(collection_id, image_id) {
81899     const requestUrl = imageDataUrl.replace("{collectionId}", collection_id).replace("{itemId}", image_id);
81900     const response = await fetch(requestUrl, { method: "GET" });
81901     if (!response.ok) {
81902       throw new Error(response.status + " " + response.statusText);
81903     }
81904     const data = await response.json();
81905     return data;
81906   }
81907   async function getUsername(user_id) {
81908     const requestUrl = usernameURL.replace("{userId}", user_id);
81909     const response = await fetch(requestUrl, { method: "GET" });
81910     if (!response.ok) {
81911       throw new Error(response.status + " " + response.statusText);
81912     }
81913     const data = await response.json();
81914     return data.name;
81915   }
81916   var panoramax_default = {
81917     init: function() {
81918       if (!_cache4) {
81919         this.reset();
81920       }
81921       this.event = utilRebind(this, dispatch13, "on");
81922     },
81923     reset: function() {
81924       if (_cache4) {
81925         Object.values(_cache4.requests.inflight).forEach(function(request3) {
81926           request3.abort();
81927         });
81928       }
81929       _cache4 = {
81930         images: { rtree: new RBush(), forImageId: {} },
81931         sequences: { rtree: new RBush(), lineString: {} },
81932         mockSequences: { rtree: new RBush(), lineString: {} },
81933         requests: { loaded: {}, inflight: {} }
81934       };
81935       _currentScene.currentImage = null;
81936       _activeImage2 = null;
81937     },
81938     // Get visible images
81939     images: function(projection2) {
81940       const limit = 5;
81941       return searchLimited6(limit, projection2, _cache4.images.rtree);
81942     },
81943     cachedImage: function(imageKey) {
81944       return _cache4.images.forImageId[imageKey];
81945     },
81946     // Load images in the visible area
81947     loadImages: function(projection2) {
81948       loadTiles5("images", tileUrl2, imageMinZoom, projection2);
81949     },
81950     // Load line in the visible area
81951     loadLines: function(projection2, zoom) {
81952       loadTiles5("line", tileUrl2, lineMinZoom, projection2, zoom);
81953     },
81954     getUserIds: async function(usernames) {
81955       const requestUrls = usernames.map((username) => userIdUrl.replace("{username}", username));
81956       const responses = await Promise.all(requestUrls.map((requestUrl) => fetch(requestUrl, { method: "GET" })));
81957       if (responses.some((response) => !response.ok)) {
81958         const response = responses.find((response2) => !response2.ok);
81959         throw new Error(response.status + " " + response.statusText);
81960       }
81961       const data = await Promise.all(responses.map((response) => response.json()));
81962       return data.flatMap((d2, i3) => d2.features.filter((f2) => f2.name === usernames[i3]).map((f2) => f2.id));
81963     },
81964     getOldestDate: function() {
81965       return _oldestDate;
81966     },
81967     // Get visible sequences
81968     sequences: function(projection2, zoom) {
81969       const viewport = projection2.clipExtent();
81970       const min3 = [viewport[0][0], viewport[1][1]];
81971       const max3 = [viewport[1][0], viewport[0][1]];
81972       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81973       const sequenceIds = {};
81974       let lineStrings = [];
81975       if (zoom >= imageMinZoom) {
81976         _cache4.images.rtree.search(bbox2).forEach(function(d2) {
81977           if (d2.data.sequence_id) {
81978             sequenceIds[d2.data.sequence_id] = true;
81979           }
81980         });
81981         Object.keys(sequenceIds).forEach(function(sequenceId) {
81982           if (_cache4.sequences.lineString[sequenceId]) {
81983             lineStrings = lineStrings.concat(_cache4.sequences.lineString[sequenceId]);
81984           }
81985         });
81986         return lineStrings;
81987       }
81988       if (zoom >= lineMinZoom) {
81989         Object.keys(_cache4.mockSequences.lineString).forEach(function(sequenceId) {
81990           lineStrings = lineStrings.concat(_cache4.mockSequences.lineString[sequenceId]);
81991         });
81992       }
81993       return lineStrings;
81994     },
81995     // Set the currently visible image
81996     setActiveImage: function(image) {
81997       if (image) {
81998         _activeImage2 = {
81999           id: image.id,
82000           sequence_id: image.sequence_id
82001         };
82002       } else {
82003         _activeImage2 = null;
82004       }
82005     },
82006     getActiveImage: function() {
82007       return _activeImage2;
82008     },
82009     // Update the currently highlighted sequence and selected bubble.
82010     setStyles: function(context, hovered) {
82011       const hoveredImageId = hovered && hovered.id;
82012       const hoveredSequenceId = hovered && hovered.sequence_id;
82013       const selectedSequenceId = _activeImage2 && _activeImage2.sequence_id;
82014       const selectedImageId = _activeImage2 && _activeImage2.id;
82015       const markers = context.container().selectAll(".layer-panoramax .viewfield-group");
82016       const sequences = context.container().selectAll(".layer-panoramax .sequence");
82017       markers.classed("highlighted", function(d2) {
82018         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
82019       }).classed("hovered", function(d2) {
82020         return d2.id === hoveredImageId;
82021       }).classed("currentView", function(d2) {
82022         return d2.id === selectedImageId;
82023       });
82024       sequences.classed("highlighted", function(d2) {
82025         return d2.properties.id === hoveredSequenceId;
82026       }).classed("currentView", function(d2) {
82027         return d2.properties.id === selectedSequenceId;
82028       });
82029       context.container().selectAll(".layer-panoramax .viewfield-group .viewfield").attr("d", viewfieldPath);
82030       function viewfieldPath() {
82031         let d2 = this.parentNode.__data__;
82032         if (d2.isPano && d2.id !== selectedImageId) {
82033           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
82034         } else {
82035           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
82036         }
82037       }
82038       return this;
82039     },
82040     updateUrlImage: function(imageKey) {
82041       if (!window.mocha) {
82042         var hash2 = utilStringQs(window.location.hash);
82043         if (imageKey) {
82044           hash2.photo = "panoramax/" + imageKey;
82045         } else {
82046           delete hash2.photo;
82047         }
82048         window.location.replace("#" + utilQsString(hash2, true));
82049       }
82050     },
82051     selectImage: function(context, id2) {
82052       let that = this;
82053       let d2 = that.cachedImage(id2);
82054       that.setActiveImage(d2);
82055       that.updateUrlImage(d2.id);
82056       const viewerLink = "".concat(viewerUrl, "#pic=").concat(d2.id, "&focus=pic");
82057       let viewer = context.container().select(".photoviewer");
82058       if (!viewer.empty()) viewer.datum(d2);
82059       this.setStyles(context, null);
82060       if (!d2) return this;
82061       let wrap2 = context.container().select(".photoviewer .panoramax-wrapper");
82062       let attribution = wrap2.selectAll(".photo-attribution").text("");
82063       let line1 = attribution.append("div").attr("class", "attribution-row");
82064       const hdDomId = utilUniqueDomId("panoramax-hd");
82065       let label = line1.append("label").attr("for", hdDomId).attr("class", "panoramax-hd");
82066       label.append("input").attr("type", "checkbox").attr("id", hdDomId).property("checked", _isHD).on("click", (d3_event) => {
82067         d3_event.stopPropagation();
82068         _isHD = !_isHD;
82069         _definition = _isHD ? highDefinition : standardDefinition;
82070         that.selectImage(context, d2.id).showViewer(context);
82071       });
82072       label.append("span").call(_t.append("panoramax.hd"));
82073       if (d2.capture_time) {
82074         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
82075         attribution.append("span").text("|");
82076       }
82077       attribution.append("a").attr("class", "report-photo").attr("href", "mailto:signalement.ign@panoramax.fr").call(_t.append("panoramax.report"));
82078       attribution.append("span").text("|");
82079       attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", viewerLink).text("panoramax.xyz");
82080       getImageData2(d2.sequence_id, d2.id).then(function(data) {
82081         _currentScene = {
82082           currentImage: null,
82083           nextImage: null,
82084           prevImage: null
82085         };
82086         _currentScene.currentImage = data.assets[_definition];
82087         const nextIndex = data.links.findIndex((x2) => x2.rel === "next");
82088         const prevIndex = data.links.findIndex((x2) => x2.rel === "prev");
82089         if (nextIndex !== -1) {
82090           _currentScene.nextImage = data.links[nextIndex];
82091         }
82092         if (prevIndex !== -1) {
82093           _currentScene.prevImage = data.links[prevIndex];
82094         }
82095         d2.image_path = _currentScene.currentImage.href;
82096         wrap2.selectAll("button.back").classed("hide", _currentScene.prevImage === null);
82097         wrap2.selectAll("button.forward").classed("hide", _currentScene.nextImage === null);
82098         _currentFrame2 = d2.isPano ? _pannellumFrame2 : _planeFrame2;
82099         _currentFrame2.showPhotoFrame(wrap2).selectPhoto(d2, true);
82100       });
82101       function localeDateString2(s2) {
82102         if (!s2) return null;
82103         var options2 = { day: "numeric", month: "short", year: "numeric" };
82104         var d4 = new Date(s2);
82105         if (isNaN(d4.getTime())) return null;
82106         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
82107       }
82108       if (d2.account_id) {
82109         attribution.append("span").text("|");
82110         let line2 = attribution.append("span").attr("class", "attribution-row");
82111         getUsername(d2.account_id).then(function(username) {
82112           line2.append("span").attr("class", "captured_by").text(_t("panoramax.captured_by", { username }));
82113         });
82114       }
82115       return this;
82116     },
82117     photoFrame: function() {
82118       return _currentFrame2;
82119     },
82120     ensureViewerLoaded: function(context) {
82121       let that = this;
82122       let imgWrap = context.container().select("#ideditor-viewer-panoramax-simple > img");
82123       if (!imgWrap.empty()) {
82124         imgWrap.remove();
82125       }
82126       if (_loadViewerPromise6) return _loadViewerPromise6;
82127       let wrap2 = context.container().select(".photoviewer").selectAll(".panoramax-wrapper").data([0]);
82128       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper panoramax-wrapper").classed("hide", true).on("dblclick.zoom", null);
82129       wrapEnter.append("div").attr("class", "photo-attribution fillD");
82130       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-panoramax");
82131       controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4");
82132       controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA");
82133       _loadViewerPromise6 = Promise.all([
82134         pannellum_photo_default.init(context, wrapEnter),
82135         plane_photo_default.init(context, wrapEnter)
82136       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
82137         _pannellumFrame2 = pannellumPhotoFrame;
82138         _pannellumFrame2.event.on("viewerChanged", () => dispatch13.call("viewerChanged"));
82139         _planeFrame2 = planePhotoFrame;
82140         _planeFrame2.event.on("viewerChanged", () => dispatch13.call("viewerChanged"));
82141       });
82142       function step(stepBy) {
82143         return function() {
82144           if (!_currentScene.currentImage) return;
82145           let nextId;
82146           if (stepBy === 1) nextId = _currentScene.nextImage.id;
82147           else nextId = _currentScene.prevImage.id;
82148           if (!nextId) return;
82149           const nextImage = _cache4.images.forImageId[nextId];
82150           if (nextImage) {
82151             context.map().centerEase(nextImage.loc);
82152             that.selectImage(context, nextImage.id);
82153           }
82154         };
82155       }
82156       return _loadViewerPromise6;
82157     },
82158     showViewer: function(context) {
82159       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
82160       let isHidden = wrap2.selectAll(".photo-wrapper.panoramax-wrapper.hide").size();
82161       if (isHidden) {
82162         wrap2.selectAll(".photo-wrapper:not(.panoramax-wrapper)").classed("hide", true);
82163         wrap2.selectAll(".photo-wrapper.panoramax-wrapper").classed("hide", false);
82164       }
82165       return this;
82166     },
82167     hideViewer: function(context) {
82168       let viewer = context.container().select(".photoviewer");
82169       if (!viewer.empty()) viewer.datum(null);
82170       this.updateUrlImage(null);
82171       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
82172       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
82173       this.setActiveImage();
82174       return this.setStyles(context, null);
82175     },
82176     cache: function() {
82177       return _cache4;
82178     }
82179   };
82180
82181   // modules/services/index.js
82182   var services = {
82183     geocoder: nominatim_default,
82184     keepRight: keepRight_default,
82185     osmose: osmose_default,
82186     mapillary: mapillary_default,
82187     nsi: nsi_default,
82188     kartaview: kartaview_default,
82189     vegbilder: vegbilder_default,
82190     osm: osm_default,
82191     osmWikibase: osm_wikibase_default,
82192     maprules: maprules_default,
82193     streetside: streetside_default,
82194     taginfo: taginfo_default,
82195     vectorTile: vector_tile_default,
82196     wikidata: wikidata_default,
82197     wikipedia: wikipedia_default,
82198     mapilio: mapilio_default,
82199     panoramax: panoramax_default
82200   };
82201
82202   // modules/modes/drag_note.js
82203   function modeDragNote(context) {
82204     var mode = {
82205       id: "drag-note",
82206       button: "browse"
82207     };
82208     var edit2 = behaviorEdit(context);
82209     var _nudgeInterval;
82210     var _lastLoc;
82211     var _note;
82212     function startNudge(d3_event, nudge) {
82213       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
82214       _nudgeInterval = window.setInterval(function() {
82215         context.map().pan(nudge);
82216         doMove(d3_event, nudge);
82217       }, 50);
82218     }
82219     function stopNudge() {
82220       if (_nudgeInterval) {
82221         window.clearInterval(_nudgeInterval);
82222         _nudgeInterval = null;
82223       }
82224     }
82225     function origin(note) {
82226       return context.projection(note.loc);
82227     }
82228     function start2(d3_event, note) {
82229       _note = note;
82230       var osm = services.osm;
82231       if (osm) {
82232         _note = osm.getNote(_note.id);
82233       }
82234       context.surface().selectAll(".note-" + _note.id).classed("active", true);
82235       context.perform(actionNoop());
82236       context.enter(mode);
82237       context.selectedNoteID(_note.id);
82238     }
82239     function move(d3_event, entity, point) {
82240       d3_event.stopPropagation();
82241       _lastLoc = context.projection.invert(point);
82242       doMove(d3_event);
82243       var nudge = geoViewportEdge(point, context.map().dimensions());
82244       if (nudge) {
82245         startNudge(d3_event, nudge);
82246       } else {
82247         stopNudge();
82248       }
82249     }
82250     function doMove(d3_event, nudge) {
82251       nudge = nudge || [0, 0];
82252       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
82253       var currMouse = geoVecSubtract(currPoint, nudge);
82254       var loc = context.projection.invert(currMouse);
82255       _note = _note.move(loc);
82256       var osm = services.osm;
82257       if (osm) {
82258         osm.replaceNote(_note);
82259       }
82260       context.replace(actionNoop());
82261     }
82262     function end() {
82263       context.replace(actionNoop());
82264       context.selectedNoteID(_note.id).enter(modeSelectNote(context, _note.id));
82265     }
82266     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);
82267     mode.enter = function() {
82268       context.install(edit2);
82269     };
82270     mode.exit = function() {
82271       context.ui().sidebar.hover.cancel();
82272       context.uninstall(edit2);
82273       context.surface().selectAll(".active").classed("active", false);
82274       stopNudge();
82275     };
82276     mode.behavior = drag;
82277     return mode;
82278   }
82279
82280   // modules/modes/select_data.js
82281   function modeSelectData(context, selectedDatum) {
82282     var mode = {
82283       id: "select-data",
82284       button: "browse"
82285     };
82286     var keybinding = utilKeybinding("select-data");
82287     var dataEditor = uiDataEditor(context);
82288     var behaviors = [
82289       behaviorBreathe(context),
82290       behaviorHover(context),
82291       behaviorSelect(context),
82292       behaviorLasso(context),
82293       modeDragNode(context).behavior,
82294       modeDragNote(context).behavior
82295     ];
82296     function selectData(d3_event, drawn) {
82297       var selection2 = context.surface().selectAll(".layer-mapdata .data" + selectedDatum.__featurehash__);
82298       if (selection2.empty()) {
82299         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
82300         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
82301           context.enter(modeBrowse(context));
82302         }
82303       } else {
82304         selection2.classed("selected", true);
82305       }
82306     }
82307     function esc() {
82308       if (context.container().select(".combobox").size()) return;
82309       context.enter(modeBrowse(context));
82310     }
82311     mode.zoomToSelected = function() {
82312       var extent = geoExtent(bounds_default(selectedDatum));
82313       context.map().centerZoomEase(extent.center(), context.map().trimmedExtentZoom(extent));
82314     };
82315     mode.enter = function() {
82316       behaviors.forEach(context.install);
82317       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
82318       select_default2(document).call(keybinding);
82319       selectData();
82320       var sidebar = context.ui().sidebar;
82321       sidebar.show(dataEditor.datum(selectedDatum));
82322       var extent = geoExtent(bounds_default(selectedDatum));
82323       sidebar.expand(sidebar.intersects(extent));
82324       context.map().on("drawn.select-data", selectData);
82325     };
82326     mode.exit = function() {
82327       behaviors.forEach(context.uninstall);
82328       select_default2(document).call(keybinding.unbind);
82329       context.surface().selectAll(".layer-mapdata .selected").classed("selected hover", false);
82330       context.map().on("drawn.select-data", null);
82331       context.ui().sidebar.hide();
82332     };
82333     return mode;
82334   }
82335
82336   // modules/behavior/select.js
82337   function behaviorSelect(context) {
82338     var _tolerancePx = 4;
82339     var _lastMouseEvent = null;
82340     var _showMenu = false;
82341     var _downPointers = {};
82342     var _longPressTimeout = null;
82343     var _lastInteractionType = null;
82344     var _multiselectionPointerId = null;
82345     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
82346     function keydown(d3_event) {
82347       if (d3_event.keyCode === 32) {
82348         var activeNode = document.activeElement;
82349         if (activeNode && (/* @__PURE__ */ new Set(["INPUT", "TEXTAREA"])).has(activeNode.nodeName)) return;
82350       }
82351       if (d3_event.keyCode === 93 || // context menu key
82352       d3_event.keyCode === 32) {
82353         d3_event.preventDefault();
82354       }
82355       if (d3_event.repeat) return;
82356       cancelLongPress();
82357       if (d3_event.shiftKey) {
82358         context.surface().classed("behavior-multiselect", true);
82359       }
82360       if (d3_event.keyCode === 32) {
82361         if (!_downPointers.spacebar && _lastMouseEvent) {
82362           cancelLongPress();
82363           _longPressTimeout = window.setTimeout(didLongPress, 500, "spacebar", "spacebar");
82364           _downPointers.spacebar = {
82365             firstEvent: _lastMouseEvent,
82366             lastEvent: _lastMouseEvent
82367           };
82368         }
82369       }
82370     }
82371     function keyup(d3_event) {
82372       cancelLongPress();
82373       if (!d3_event.shiftKey) {
82374         context.surface().classed("behavior-multiselect", false);
82375       }
82376       if (d3_event.keyCode === 93) {
82377         d3_event.preventDefault();
82378         _lastInteractionType = "menukey";
82379         contextmenu(d3_event);
82380       } else if (d3_event.keyCode === 32) {
82381         var pointer = _downPointers.spacebar;
82382         if (pointer) {
82383           delete _downPointers.spacebar;
82384           if (pointer.done) return;
82385           d3_event.preventDefault();
82386           _lastInteractionType = "spacebar";
82387           click(pointer.firstEvent, pointer.lastEvent, "spacebar");
82388         }
82389       }
82390     }
82391     function pointerdown(d3_event) {
82392       var id2 = (d3_event.pointerId || "mouse").toString();
82393       cancelLongPress();
82394       if (d3_event.buttons && d3_event.buttons !== 1) return;
82395       context.ui().closeEditMenu();
82396       if (d3_event.pointerType !== "mouse") {
82397         _longPressTimeout = window.setTimeout(didLongPress, 500, id2, "longdown-" + (d3_event.pointerType || "mouse"));
82398       }
82399       _downPointers[id2] = {
82400         firstEvent: d3_event,
82401         lastEvent: d3_event
82402       };
82403     }
82404     function didLongPress(id2, interactionType) {
82405       var pointer = _downPointers[id2];
82406       if (!pointer) return;
82407       for (var i3 in _downPointers) {
82408         _downPointers[i3].done = true;
82409       }
82410       _longPressTimeout = null;
82411       _lastInteractionType = interactionType;
82412       _showMenu = true;
82413       click(pointer.firstEvent, pointer.lastEvent, id2);
82414     }
82415     function pointermove(d3_event) {
82416       var id2 = (d3_event.pointerId || "mouse").toString();
82417       if (_downPointers[id2]) {
82418         _downPointers[id2].lastEvent = d3_event;
82419       }
82420       if (!d3_event.pointerType || d3_event.pointerType === "mouse") {
82421         _lastMouseEvent = d3_event;
82422         if (_downPointers.spacebar) {
82423           _downPointers.spacebar.lastEvent = d3_event;
82424         }
82425       }
82426     }
82427     function pointerup(d3_event) {
82428       var id2 = (d3_event.pointerId || "mouse").toString();
82429       var pointer = _downPointers[id2];
82430       if (!pointer) return;
82431       delete _downPointers[id2];
82432       if (_multiselectionPointerId === id2) {
82433         _multiselectionPointerId = null;
82434       }
82435       if (pointer.done) return;
82436       click(pointer.firstEvent, d3_event, id2);
82437     }
82438     function pointercancel(d3_event) {
82439       var id2 = (d3_event.pointerId || "mouse").toString();
82440       if (!_downPointers[id2]) return;
82441       delete _downPointers[id2];
82442       if (_multiselectionPointerId === id2) {
82443         _multiselectionPointerId = null;
82444       }
82445     }
82446     function contextmenu(d3_event) {
82447       d3_event.preventDefault();
82448       if (!+d3_event.clientX && !+d3_event.clientY) {
82449         if (_lastMouseEvent) {
82450           d3_event = _lastMouseEvent;
82451         } else {
82452           return;
82453         }
82454       } else {
82455         _lastMouseEvent = d3_event;
82456         if (d3_event.pointerType === "touch" || d3_event.pointerType === "pen" || d3_event.mozInputSource && // firefox doesn't give a pointerType on contextmenu events
82457         (d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_TOUCH || d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_PEN)) {
82458           _lastInteractionType = "touch";
82459         } else {
82460           _lastInteractionType = "rightclick";
82461         }
82462       }
82463       _showMenu = true;
82464       click(d3_event, d3_event);
82465     }
82466     function click(firstEvent, lastEvent, pointerId) {
82467       cancelLongPress();
82468       var mapNode = context.container().select(".main-map").node();
82469       var pointGetter = utilFastMouse(mapNode);
82470       var p1 = pointGetter(firstEvent);
82471       var p2 = pointGetter(lastEvent);
82472       var dist = geoVecLength(p1, p2);
82473       if (dist > _tolerancePx || !mapContains(lastEvent)) {
82474         resetProperties();
82475         return;
82476       }
82477       var targetDatum = lastEvent.target.__data__;
82478       var multiselectEntityId;
82479       if (!_multiselectionPointerId) {
82480         var selectPointerInfo = pointerDownOnSelection(pointerId);
82481         if (selectPointerInfo) {
82482           _multiselectionPointerId = selectPointerInfo.pointerId;
82483           multiselectEntityId = !selectPointerInfo.selected && selectPointerInfo.entityId;
82484           _downPointers[selectPointerInfo.pointerId].done = true;
82485         }
82486       }
82487       var isMultiselect = context.mode().id === "select" && // and shift key is down
82488       (lastEvent && lastEvent.shiftKey || // or we're lasso-selecting
82489       context.surface().select(".lasso").node() || // or a pointer is down over a selected feature
82490       _multiselectionPointerId && !multiselectEntityId);
82491       processClick(targetDatum, isMultiselect, p2, multiselectEntityId);
82492       function mapContains(event) {
82493         var rect = mapNode.getBoundingClientRect();
82494         return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
82495       }
82496       function pointerDownOnSelection(skipPointerId) {
82497         var mode = context.mode();
82498         var selectedIDs = mode.id === "select" ? mode.selectedIDs() : [];
82499         for (var pointerId2 in _downPointers) {
82500           if (pointerId2 === "spacebar" || pointerId2 === skipPointerId) continue;
82501           var pointerInfo = _downPointers[pointerId2];
82502           var p12 = pointGetter(pointerInfo.firstEvent);
82503           var p22 = pointGetter(pointerInfo.lastEvent);
82504           if (geoVecLength(p12, p22) > _tolerancePx) continue;
82505           var datum2 = pointerInfo.firstEvent.target.__data__;
82506           var entity = datum2 && datum2.properties && datum2.properties.entity || datum2;
82507           if (context.graph().hasEntity(entity.id)) {
82508             return {
82509               pointerId: pointerId2,
82510               entityId: entity.id,
82511               selected: selectedIDs.indexOf(entity.id) !== -1
82512             };
82513           }
82514         }
82515         return null;
82516       }
82517     }
82518     function processClick(datum2, isMultiselect, point, alsoSelectId) {
82519       var mode = context.mode();
82520       var showMenu = _showMenu;
82521       var interactionType = _lastInteractionType;
82522       var entity = datum2 && datum2.properties && datum2.properties.entity;
82523       if (entity) datum2 = entity;
82524       if (datum2 && datum2.type === "midpoint") {
82525         datum2 = datum2.parents[0];
82526       }
82527       var newMode;
82528       if (datum2 instanceof osmEntity) {
82529         var selectedIDs = context.selectedIDs();
82530         context.selectedNoteID(null);
82531         context.selectedErrorID(null);
82532         if (!isMultiselect) {
82533           if (!showMenu || selectedIDs.length <= 1 || selectedIDs.indexOf(datum2.id) === -1) {
82534             if (alsoSelectId === datum2.id) alsoSelectId = null;
82535             selectedIDs = (alsoSelectId ? [alsoSelectId] : []).concat([datum2.id]);
82536             newMode = mode.id === "select" ? mode.selectedIDs(selectedIDs) : modeSelect(context, selectedIDs).selectBehavior(behavior);
82537             context.enter(newMode);
82538           }
82539         } else {
82540           if (selectedIDs.indexOf(datum2.id) !== -1) {
82541             if (!showMenu) {
82542               selectedIDs = selectedIDs.filter(function(id2) {
82543                 return id2 !== datum2.id;
82544               });
82545               newMode = selectedIDs.length ? mode.selectedIDs(selectedIDs) : modeBrowse(context).selectBehavior(behavior);
82546               context.enter(newMode);
82547             }
82548           } else {
82549             selectedIDs = selectedIDs.concat([datum2.id]);
82550             newMode = mode.selectedIDs(selectedIDs);
82551             context.enter(newMode);
82552           }
82553         }
82554       } else if (datum2 && datum2.__featurehash__ && !isMultiselect) {
82555         context.selectedNoteID(null).enter(modeSelectData(context, datum2));
82556       } else if (datum2 instanceof osmNote && !isMultiselect) {
82557         context.selectedNoteID(datum2.id).enter(modeSelectNote(context, datum2.id));
82558       } else if (datum2 instanceof QAItem && !isMultiselect) {
82559         context.selectedErrorID(datum2.id).enter(modeSelectError(context, datum2.id, datum2.service));
82560       } else {
82561         context.selectedNoteID(null);
82562         context.selectedErrorID(null);
82563         if (!isMultiselect && mode.id !== "browse") {
82564           context.enter(modeBrowse(context));
82565         }
82566       }
82567       context.ui().closeEditMenu();
82568       if (showMenu) context.ui().showEditMenu(point, interactionType);
82569       resetProperties();
82570     }
82571     function cancelLongPress() {
82572       if (_longPressTimeout) window.clearTimeout(_longPressTimeout);
82573       _longPressTimeout = null;
82574     }
82575     function resetProperties() {
82576       cancelLongPress();
82577       _showMenu = false;
82578       _lastInteractionType = null;
82579     }
82580     function behavior(selection2) {
82581       resetProperties();
82582       _lastMouseEvent = context.map().lastPointerEvent();
82583       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) {
82584         var e3 = d3_event;
82585         if (+e3.clientX === 0 && +e3.clientY === 0) {
82586           d3_event.preventDefault();
82587         }
82588       });
82589       selection2.on(_pointerPrefix + "down.select", pointerdown).on("contextmenu.select", contextmenu);
82590     }
82591     behavior.off = function(selection2) {
82592       cancelLongPress();
82593       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);
82594       selection2.on(_pointerPrefix + "down.select", null).on("contextmenu.select", null);
82595       context.surface().classed("behavior-multiselect", false);
82596     };
82597     return behavior;
82598   }
82599
82600   // modules/operations/index.js
82601   var operations_exports = {};
82602   __export(operations_exports, {
82603     operationCircularize: () => operationCircularize,
82604     operationContinue: () => operationContinue,
82605     operationCopy: () => operationCopy,
82606     operationDelete: () => operationDelete,
82607     operationDisconnect: () => operationDisconnect,
82608     operationDowngrade: () => operationDowngrade,
82609     operationExtract: () => operationExtract,
82610     operationMerge: () => operationMerge,
82611     operationMove: () => operationMove,
82612     operationOrthogonalize: () => operationOrthogonalize,
82613     operationPaste: () => operationPaste,
82614     operationReflectLong: () => operationReflectLong,
82615     operationReflectShort: () => operationReflectShort,
82616     operationReverse: () => operationReverse,
82617     operationRotate: () => operationRotate,
82618     operationSplit: () => operationSplit,
82619     operationStraighten: () => operationStraighten
82620   });
82621
82622   // modules/operations/continue.js
82623   function operationContinue(context, selectedIDs) {
82624     var _entities = selectedIDs.map(function(id2) {
82625       return context.graph().entity(id2);
82626     });
82627     var _geometries = Object.assign(
82628       { line: [], vertex: [] },
82629       utilArrayGroupBy(_entities, function(entity) {
82630         return entity.geometry(context.graph());
82631       })
82632     );
82633     var _vertex = _geometries.vertex.length && _geometries.vertex[0];
82634     function candidateWays() {
82635       return _vertex ? context.graph().parentWays(_vertex).filter(function(parent) {
82636         const geom = parent.geometry(context.graph());
82637         return (geom === "line" || geom === "area") && !parent.isClosed() && parent.affix(_vertex.id) && (_geometries.line.length === 0 || _geometries.line[0] === parent);
82638       }) : [];
82639     }
82640     var _candidates = candidateWays();
82641     var operation2 = function() {
82642       var candidate = _candidates[0];
82643       const tagsToRemove = /* @__PURE__ */ new Set();
82644       if (_vertex.tags.fixme === "continue") tagsToRemove.add("fixme");
82645       if (_vertex.tags.noexit === "yes") tagsToRemove.add("noexit");
82646       if (tagsToRemove.size) {
82647         context.perform((graph) => {
82648           const newTags = __spreadValues({}, _vertex.tags);
82649           for (const key of tagsToRemove) {
82650             delete newTags[key];
82651           }
82652           return actionChangeTags(_vertex.id, newTags)(graph);
82653         }, operation2.annotation());
82654       }
82655       context.enter(
82656         modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true)
82657       );
82658     };
82659     operation2.relatedEntityIds = function() {
82660       return _candidates.length ? [_candidates[0].id] : [];
82661     };
82662     operation2.available = function() {
82663       return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph());
82664     };
82665     operation2.disabled = function() {
82666       if (_candidates.length === 0) {
82667         return "not_eligible";
82668       } else if (_candidates.length > 1) {
82669         return "multiple";
82670       }
82671       return false;
82672     };
82673     operation2.tooltip = function() {
82674       var disable = operation2.disabled();
82675       return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description");
82676     };
82677     operation2.annotation = function() {
82678       return _t("operations.continue.annotation.line");
82679     };
82680     operation2.id = "continue";
82681     operation2.keys = [_t("operations.continue.key")];
82682     operation2.title = _t.append("operations.continue.title");
82683     operation2.behavior = behaviorOperation(context).which(operation2);
82684     return operation2;
82685   }
82686
82687   // modules/operations/copy.js
82688   function operationCopy(context, selectedIDs) {
82689     function getFilteredIdsToCopy() {
82690       return selectedIDs.filter(function(selectedID) {
82691         var entity = context.graph().hasEntity(selectedID);
82692         return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex";
82693       });
82694     }
82695     var operation2 = function() {
82696       var graph = context.graph();
82697       var selected = groupEntities(getFilteredIdsToCopy(), graph);
82698       var canCopy = [];
82699       var skip = {};
82700       var entity;
82701       var i3;
82702       for (i3 = 0; i3 < selected.relation.length; i3++) {
82703         entity = selected.relation[i3];
82704         if (!skip[entity.id] && entity.isComplete(graph)) {
82705           canCopy.push(entity.id);
82706           skip = getDescendants(entity.id, graph, skip);
82707         }
82708       }
82709       for (i3 = 0; i3 < selected.way.length; i3++) {
82710         entity = selected.way[i3];
82711         if (!skip[entity.id]) {
82712           canCopy.push(entity.id);
82713           skip = getDescendants(entity.id, graph, skip);
82714         }
82715       }
82716       for (i3 = 0; i3 < selected.node.length; i3++) {
82717         entity = selected.node[i3];
82718         if (!skip[entity.id]) {
82719           canCopy.push(entity.id);
82720         }
82721       }
82722       context.copyIDs(canCopy);
82723       if (_point && (canCopy.length !== 1 || graph.entity(canCopy[0]).type !== "node")) {
82724         context.copyLonLat(context.projection.invert(_point));
82725       } else {
82726         context.copyLonLat(null);
82727       }
82728     };
82729     function groupEntities(ids, graph) {
82730       var entities = ids.map(function(id2) {
82731         return graph.entity(id2);
82732       });
82733       return Object.assign(
82734         { relation: [], way: [], node: [] },
82735         utilArrayGroupBy(entities, "type")
82736       );
82737     }
82738     function getDescendants(id2, graph, descendants) {
82739       var entity = graph.entity(id2);
82740       var children2;
82741       descendants = descendants || {};
82742       if (entity.type === "relation") {
82743         children2 = entity.members.map(function(m2) {
82744           return m2.id;
82745         });
82746       } else if (entity.type === "way") {
82747         children2 = entity.nodes;
82748       } else {
82749         children2 = [];
82750       }
82751       for (var i3 = 0; i3 < children2.length; i3++) {
82752         if (!descendants[children2[i3]]) {
82753           descendants[children2[i3]] = true;
82754           descendants = getDescendants(children2[i3], graph, descendants);
82755         }
82756       }
82757       return descendants;
82758     }
82759     operation2.available = function() {
82760       return getFilteredIdsToCopy().length > 0;
82761     };
82762     operation2.disabled = function() {
82763       var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph());
82764       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
82765         return "too_large";
82766       }
82767       return false;
82768     };
82769     operation2.availableForKeypress = function() {
82770       var selection2 = window.getSelection && window.getSelection();
82771       return !selection2 || !selection2.toString();
82772     };
82773     operation2.tooltip = function() {
82774       var disable = operation2.disabled();
82775       return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length });
82776     };
82777     operation2.annotation = function() {
82778       return _t("operations.copy.annotation", { n: selectedIDs.length });
82779     };
82780     var _point;
82781     operation2.point = function(val) {
82782       _point = val;
82783       return operation2;
82784     };
82785     operation2.id = "copy";
82786     operation2.keys = [uiCmd("\u2318C")];
82787     operation2.title = _t.append("operations.copy.title");
82788     operation2.behavior = behaviorOperation(context).which(operation2);
82789     return operation2;
82790   }
82791
82792   // modules/operations/disconnect.js
82793   function operationDisconnect(context, selectedIDs) {
82794     var _vertexIDs = [];
82795     var _wayIDs = [];
82796     var _otherIDs = [];
82797     var _actions = [];
82798     selectedIDs.forEach(function(id2) {
82799       var entity = context.entity(id2);
82800       if (entity.type === "way") {
82801         _wayIDs.push(id2);
82802       } else if (entity.geometry(context.graph()) === "vertex") {
82803         _vertexIDs.push(id2);
82804       } else {
82805         _otherIDs.push(id2);
82806       }
82807     });
82808     var _coords, _descriptionID = "", _annotationID = "features";
82809     var _disconnectingVertexIds = [];
82810     var _disconnectingWayIds = [];
82811     if (_vertexIDs.length > 0) {
82812       _disconnectingVertexIds = _vertexIDs;
82813       _vertexIDs.forEach(function(vertexID) {
82814         var action = actionDisconnect(vertexID);
82815         if (_wayIDs.length > 0) {
82816           var waysIDsForVertex = _wayIDs.filter(function(wayID) {
82817             var way = context.entity(wayID);
82818             return way.nodes.indexOf(vertexID) !== -1;
82819           });
82820           action.limitWays(waysIDsForVertex);
82821         }
82822         _actions.push(action);
82823         _disconnectingWayIds = _disconnectingWayIds.concat(context.graph().parentWays(context.graph().entity(vertexID)).map((d2) => d2.id));
82824       });
82825       _disconnectingWayIds = utilArrayUniq(_disconnectingWayIds).filter(function(id2) {
82826         return _wayIDs.indexOf(id2) === -1;
82827       });
82828       _descriptionID += _actions.length === 1 ? "single_point." : "multiple_points.";
82829       if (_wayIDs.length === 1) {
82830         _descriptionID += "single_way." + context.graph().geometry(_wayIDs[0]);
82831       } else {
82832         _descriptionID += _wayIDs.length === 0 ? "no_ways" : "multiple_ways";
82833       }
82834     } else if (_wayIDs.length > 0) {
82835       var ways = _wayIDs.map(function(id2) {
82836         return context.entity(id2);
82837       });
82838       var nodes = utilGetAllNodes(_wayIDs, context.graph());
82839       _coords = nodes.map(function(n3) {
82840         return n3.loc;
82841       });
82842       var sharedActions = [];
82843       var sharedNodes = [];
82844       var unsharedActions = [];
82845       var unsharedNodes = [];
82846       nodes.forEach(function(node) {
82847         var action = actionDisconnect(node.id).limitWays(_wayIDs);
82848         if (action.disabled(context.graph()) !== "not_connected") {
82849           var count = 0;
82850           for (var i3 in ways) {
82851             var way = ways[i3];
82852             if (way.nodes.indexOf(node.id) !== -1) {
82853               count += 1;
82854             }
82855             if (count > 1) break;
82856           }
82857           if (count > 1) {
82858             sharedActions.push(action);
82859             sharedNodes.push(node);
82860           } else {
82861             unsharedActions.push(action);
82862             unsharedNodes.push(node);
82863           }
82864         }
82865       });
82866       _descriptionID += "no_points.";
82867       _descriptionID += _wayIDs.length === 1 ? "single_way." : "multiple_ways.";
82868       if (sharedActions.length) {
82869         _actions = sharedActions;
82870         _disconnectingVertexIds = sharedNodes.map((node) => node.id);
82871         _descriptionID += "conjoined";
82872         _annotationID = "from_each_other";
82873       } else {
82874         _actions = unsharedActions;
82875         _disconnectingVertexIds = unsharedNodes.map((node) => node.id);
82876         if (_wayIDs.length === 1) {
82877           _descriptionID += context.graph().geometry(_wayIDs[0]);
82878         } else {
82879           _descriptionID += "separate";
82880         }
82881       }
82882     }
82883     var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph());
82884     var operation2 = function() {
82885       context.perform(function(graph) {
82886         return _actions.reduce(function(graph2, action) {
82887           return action(graph2);
82888         }, graph);
82889       }, operation2.annotation());
82890       context.validator().validate();
82891     };
82892     operation2.relatedEntityIds = function() {
82893       if (_vertexIDs.length) {
82894         return _disconnectingWayIds;
82895       }
82896       return _disconnectingVertexIds;
82897     };
82898     operation2.available = function() {
82899       if (_actions.length === 0) return false;
82900       if (_otherIDs.length !== 0) return false;
82901       if (_vertexIDs.length !== 0 && _wayIDs.length !== 0 && !_wayIDs.every(function(wayID) {
82902         return _vertexIDs.some(function(vertexID) {
82903           var way = context.entity(wayID);
82904           return way.nodes.indexOf(vertexID) !== -1;
82905         });
82906       })) return false;
82907       return true;
82908     };
82909     operation2.disabled = function() {
82910       var reason;
82911       for (var actionIndex in _actions) {
82912         reason = _actions[actionIndex].disabled(context.graph());
82913         if (reason) return reason;
82914       }
82915       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
82916         return "too_large." + ((_vertexIDs.length ? _vertexIDs : _wayIDs).length === 1 ? "single" : "multiple");
82917       } else if (_coords && someMissing()) {
82918         return "not_downloaded";
82919       } else if (selectedIDs.some(context.hasHiddenConnections)) {
82920         return "connected_to_hidden";
82921       }
82922       return false;
82923       function someMissing() {
82924         if (context.inIntro()) return false;
82925         var osm = context.connection();
82926         if (osm) {
82927           var missing = _coords.filter(function(loc) {
82928             return !osm.isDataLoaded(loc);
82929           });
82930           if (missing.length) {
82931             missing.forEach(function(loc) {
82932               context.loadTileAtLoc(loc);
82933             });
82934             return true;
82935           }
82936         }
82937         return false;
82938       }
82939     };
82940     operation2.tooltip = function() {
82941       var disable = operation2.disabled();
82942       return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID);
82943     };
82944     operation2.annotation = function() {
82945       return _t("operations.disconnect.annotation." + _annotationID);
82946     };
82947     operation2.id = "disconnect";
82948     operation2.keys = [_t("operations.disconnect.key")];
82949     operation2.title = _t.append("operations.disconnect.title");
82950     operation2.behavior = behaviorOperation(context).which(operation2);
82951     return operation2;
82952   }
82953
82954   // modules/operations/downgrade.js
82955   function operationDowngrade(context, selectedIDs) {
82956     var _affectedFeatureCount = 0;
82957     var _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
82958     var _multi = _affectedFeatureCount === 1 ? "single" : "multiple";
82959     function downgradeTypeForEntityIDs(entityIds) {
82960       var downgradeType;
82961       _affectedFeatureCount = 0;
82962       for (var i3 in entityIds) {
82963         var entityID = entityIds[i3];
82964         var type2 = downgradeTypeForEntityID(entityID);
82965         if (type2) {
82966           _affectedFeatureCount += 1;
82967           if (downgradeType && type2 !== downgradeType) {
82968             if (downgradeType !== "generic" && type2 !== "generic") {
82969               downgradeType = "building_address";
82970             } else {
82971               downgradeType = "generic";
82972             }
82973           } else {
82974             downgradeType = type2;
82975           }
82976         }
82977       }
82978       return downgradeType;
82979     }
82980     function downgradeTypeForEntityID(entityID) {
82981       var graph = context.graph();
82982       var entity = graph.entity(entityID);
82983       var preset = _mainPresetIndex.match(entity, graph);
82984       if (!preset || preset.isFallback()) return null;
82985       if (entity.type === "node" && preset.id !== "address" && Object.keys(entity.tags).some(function(key) {
82986         return key.match(/^addr:.{1,}/);
82987       })) {
82988         return "address";
82989       }
82990       var geometry = entity.geometry(graph);
82991       if (geometry === "area" && entity.tags.building && !preset.tags.building) {
82992         return "building";
82993       }
82994       if (geometry === "vertex" && Object.keys(entity.tags).length) {
82995         return "generic";
82996       }
82997       return null;
82998     }
82999     var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"];
83000     var addressKeysToKeep = ["source"];
83001     var operation2 = function() {
83002       context.perform(function(graph) {
83003         for (var i3 in selectedIDs) {
83004           var entityID = selectedIDs[i3];
83005           var type2 = downgradeTypeForEntityID(entityID);
83006           if (!type2) continue;
83007           var tags = Object.assign({}, graph.entity(entityID).tags);
83008           for (var key in tags) {
83009             if (type2 === "address" && addressKeysToKeep.indexOf(key) !== -1) continue;
83010             if (type2 === "building") {
83011               if (buildingKeysToKeep.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/)) continue;
83012             }
83013             if (type2 !== "generic") {
83014               if (key.match(/^addr:.{1,}/) || key.match(/^source:.{1,}/)) continue;
83015             }
83016             delete tags[key];
83017           }
83018           graph = actionChangeTags(entityID, tags)(graph);
83019         }
83020         return graph;
83021       }, operation2.annotation());
83022       context.validator().validate();
83023       context.enter(modeSelect(context, selectedIDs));
83024     };
83025     operation2.available = function() {
83026       return _downgradeType;
83027     };
83028     operation2.disabled = function() {
83029       if (selectedIDs.some(hasWikidataTag)) {
83030         return "has_wikidata_tag";
83031       }
83032       return false;
83033       function hasWikidataTag(id2) {
83034         var entity = context.entity(id2);
83035         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
83036       }
83037     };
83038     operation2.tooltip = function() {
83039       var disable = operation2.disabled();
83040       return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType);
83041     };
83042     operation2.annotation = function() {
83043       var suffix;
83044       if (_downgradeType === "building_address") {
83045         suffix = "generic";
83046       } else {
83047         suffix = _downgradeType;
83048       }
83049       return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount });
83050     };
83051     operation2.id = "downgrade";
83052     operation2.keys = [uiCmd("\u232B")];
83053     operation2.title = _t.append("operations.downgrade.title");
83054     operation2.behavior = behaviorOperation(context).which(operation2);
83055     return operation2;
83056   }
83057
83058   // modules/operations/extract.js
83059   function operationExtract(context, selectedIDs) {
83060     var _amount = selectedIDs.length === 1 ? "single" : "multiple";
83061     var _geometries = utilArrayUniq(selectedIDs.map(function(entityID) {
83062       return context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
83063     }).filter(Boolean));
83064     var _geometryID = _geometries.length === 1 ? _geometries[0] : "feature";
83065     var _extent;
83066     var _actions = selectedIDs.map(function(entityID) {
83067       var graph = context.graph();
83068       var entity = graph.hasEntity(entityID);
83069       if (!entity || !entity.hasInterestingTags()) return null;
83070       if (entity.type === "node" && graph.parentWays(entity).length === 0) return null;
83071       if (entity.type !== "node") {
83072         var preset = _mainPresetIndex.match(entity, graph);
83073         if (preset.geometry.indexOf("point") === -1) return null;
83074       }
83075       _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph);
83076       return actionExtract(entityID, context.projection);
83077     }).filter(Boolean);
83078     var operation2 = function(d3_event) {
83079       const shiftKeyPressed = (d3_event == null ? void 0 : d3_event.shiftKey) || false;
83080       var combinedAction = function(graph) {
83081         _actions.forEach(function(action) {
83082           graph = action(graph, shiftKeyPressed);
83083         });
83084         return graph;
83085       };
83086       context.perform(combinedAction, operation2.annotation());
83087       var extractedNodeIDs = _actions.map(function(action) {
83088         return action.getExtractedNodeID();
83089       });
83090       context.enter(modeSelect(context, extractedNodeIDs));
83091     };
83092     operation2.available = function() {
83093       return _actions.length && selectedIDs.length === _actions.length;
83094     };
83095     operation2.disabled = function() {
83096       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
83097         return "too_large";
83098       } else if (selectedIDs.some(function(entityID) {
83099         return context.graph().geometry(entityID) === "vertex" && context.hasHiddenConnections(entityID);
83100       })) {
83101         return "connected_to_hidden";
83102       }
83103       return false;
83104     };
83105     operation2.tooltip = function() {
83106       var disableReason = operation2.disabled();
83107       if (disableReason) {
83108         return _t.append("operations.extract." + disableReason + "." + _amount);
83109       } else {
83110         return _t.append("operations.extract.description." + _geometryID + "." + _amount);
83111       }
83112     };
83113     operation2.annotation = function() {
83114       return _t("operations.extract.annotation", { n: selectedIDs.length });
83115     };
83116     operation2.id = "extract";
83117     operation2.keys = [_t("operations.extract.key")];
83118     operation2.title = _t.append("operations.extract.title");
83119     operation2.behavior = behaviorOperation(context).which(operation2);
83120     return operation2;
83121   }
83122
83123   // modules/operations/merge.js
83124   function operationMerge(context, selectedIDs) {
83125     var _action = getAction();
83126     function getAction() {
83127       var join = actionJoin(selectedIDs);
83128       if (!join.disabled(context.graph())) return join;
83129       var merge3 = actionMerge(selectedIDs);
83130       if (!merge3.disabled(context.graph())) return merge3;
83131       var mergePolygon = actionMergePolygon(selectedIDs);
83132       if (!mergePolygon.disabled(context.graph())) return mergePolygon;
83133       var mergeNodes = actionMergeNodes(selectedIDs);
83134       if (!mergeNodes.disabled(context.graph())) return mergeNodes;
83135       if (join.disabled(context.graph()) !== "not_eligible") return join;
83136       if (merge3.disabled(context.graph()) !== "not_eligible") return merge3;
83137       if (mergePolygon.disabled(context.graph()) !== "not_eligible") return mergePolygon;
83138       return mergeNodes;
83139     }
83140     var operation2 = function() {
83141       if (operation2.disabled()) return;
83142       context.perform(_action, operation2.annotation());
83143       context.validator().validate();
83144       var resultIDs = selectedIDs.filter(context.hasEntity);
83145       if (resultIDs.length > 1) {
83146         var interestingIDs = resultIDs.filter(function(id2) {
83147           return context.entity(id2).hasInterestingTags();
83148         });
83149         if (interestingIDs.length) resultIDs = interestingIDs;
83150       }
83151       context.enter(modeSelect(context, resultIDs));
83152     };
83153     operation2.available = function() {
83154       return selectedIDs.length >= 2;
83155     };
83156     operation2.disabled = function() {
83157       var actionDisabled = _action.disabled(context.graph());
83158       if (actionDisabled) return actionDisabled;
83159       var osm = context.connection();
83160       if (osm && _action.resultingWayNodesLength && _action.resultingWayNodesLength(context.graph()) > osm.maxWayNodes()) {
83161         return "too_many_vertices";
83162       }
83163       return false;
83164     };
83165     operation2.tooltip = function() {
83166       var disabled = operation2.disabled();
83167       if (disabled) {
83168         if (disabled === "conflicting_relations") {
83169           return _t.append("operations.merge.conflicting_relations");
83170         }
83171         if (disabled === "restriction" || disabled === "connectivity") {
83172           return _t.append(
83173             "operations.merge.damage_relation",
83174             { relation: _mainPresetIndex.item("type/" + disabled).name() }
83175           );
83176         }
83177         return _t.append("operations.merge." + disabled);
83178       }
83179       return _t.append("operations.merge.description");
83180     };
83181     operation2.annotation = function() {
83182       return _t("operations.merge.annotation", { n: selectedIDs.length });
83183     };
83184     operation2.id = "merge";
83185     operation2.keys = [_t("operations.merge.key")];
83186     operation2.title = _t.append("operations.merge.title");
83187     operation2.behavior = behaviorOperation(context).which(operation2);
83188     return operation2;
83189   }
83190
83191   // modules/operations/paste.js
83192   function operationPaste(context) {
83193     var _pastePoint;
83194     var operation2 = function() {
83195       if (!_pastePoint) return;
83196       var oldIDs = context.copyIDs();
83197       if (!oldIDs.length) return;
83198       var projection2 = context.projection;
83199       var extent = geoExtent();
83200       var oldGraph = context.copyGraph();
83201       var newIDs = [];
83202       var action = actionCopyEntities(oldIDs, oldGraph);
83203       context.perform(action);
83204       var copies = action.copies();
83205       var originals = /* @__PURE__ */ new Set();
83206       Object.values(copies).forEach(function(entity) {
83207         originals.add(entity.id);
83208       });
83209       for (var id2 in copies) {
83210         var oldEntity = oldGraph.entity(id2);
83211         var newEntity = copies[id2];
83212         extent._extend(oldEntity.extent(oldGraph));
83213         var parents = context.graph().parentWays(newEntity);
83214         var parentCopied = parents.some(function(parent) {
83215           return originals.has(parent.id);
83216         });
83217         if (!parentCopied) {
83218           newIDs.push(newEntity.id);
83219         }
83220       }
83221       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
83222       var delta = geoVecSubtract(_pastePoint, copyPoint);
83223       context.replace(actionMove(newIDs, delta, projection2), operation2.annotation());
83224       context.enter(modeSelect(context, newIDs));
83225     };
83226     operation2.point = function(val) {
83227       _pastePoint = val;
83228       return operation2;
83229     };
83230     operation2.available = function() {
83231       return context.mode().id === "browse";
83232     };
83233     operation2.disabled = function() {
83234       return !context.copyIDs().length;
83235     };
83236     operation2.tooltip = function() {
83237       var oldGraph = context.copyGraph();
83238       var ids = context.copyIDs();
83239       if (!ids.length) {
83240         return _t.append("operations.paste.nothing_copied");
83241       }
83242       return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length });
83243     };
83244     operation2.annotation = function() {
83245       var ids = context.copyIDs();
83246       return _t("operations.paste.annotation", { n: ids.length });
83247     };
83248     operation2.id = "paste";
83249     operation2.keys = [uiCmd("\u2318V")];
83250     operation2.title = _t.append("operations.paste.title");
83251     return operation2;
83252   }
83253
83254   // modules/operations/reverse.js
83255   function operationReverse(context, selectedIDs) {
83256     var operation2 = function() {
83257       context.perform(function combinedReverseAction(graph) {
83258         actions().forEach(function(action) {
83259           graph = action(graph);
83260         });
83261         return graph;
83262       }, operation2.annotation());
83263       context.validator().validate();
83264     };
83265     function actions(situation) {
83266       return selectedIDs.map(function(entityID) {
83267         var entity = context.hasEntity(entityID);
83268         if (!entity) return null;
83269         if (situation === "toolbar") {
83270           if (entity.type === "way" && (!entity.isOneWay() && !entity.isSided())) return null;
83271         }
83272         var geometry = entity.geometry(context.graph());
83273         if (entity.type !== "node" && geometry !== "line") return null;
83274         var action = actionReverse(entityID);
83275         if (action.disabled(context.graph())) return null;
83276         return action;
83277       }).filter(Boolean);
83278     }
83279     function reverseTypeID() {
83280       var acts = actions();
83281       var nodeActionCount = acts.filter(function(act) {
83282         var entity = context.hasEntity(act.entityID());
83283         return entity && entity.type === "node";
83284       }).length;
83285       if (nodeActionCount === 0) return "line";
83286       if (nodeActionCount === acts.length) return "point";
83287       return "feature";
83288     }
83289     operation2.available = function(situation) {
83290       return actions(situation).length > 0;
83291     };
83292     operation2.disabled = function() {
83293       return false;
83294     };
83295     operation2.tooltip = function() {
83296       return _t.append("operations.reverse.description." + reverseTypeID());
83297     };
83298     operation2.annotation = function() {
83299       var acts = actions();
83300       return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length });
83301     };
83302     operation2.id = "reverse";
83303     operation2.keys = [_t("operations.reverse.key")];
83304     operation2.title = _t.append("operations.reverse.title");
83305     operation2.behavior = behaviorOperation(context).which(operation2);
83306     return operation2;
83307   }
83308
83309   // modules/operations/straighten.js
83310   function operationStraighten(context, selectedIDs) {
83311     var _wayIDs = selectedIDs.filter(function(id2) {
83312       return id2.charAt(0) === "w";
83313     });
83314     var _nodeIDs = selectedIDs.filter(function(id2) {
83315       return id2.charAt(0) === "n";
83316     });
83317     var _amount = (_wayIDs.length ? _wayIDs : _nodeIDs).length === 1 ? "single" : "multiple";
83318     var _nodes = utilGetAllNodes(selectedIDs, context.graph());
83319     var _coords = _nodes.map(function(n3) {
83320       return n3.loc;
83321     });
83322     var _extent = utilTotalExtent(selectedIDs, context.graph());
83323     var _action = chooseAction();
83324     var _geometry;
83325     function chooseAction() {
83326       if (_wayIDs.length === 0 && _nodeIDs.length > 2) {
83327         _geometry = "point";
83328         return actionStraightenNodes(_nodeIDs, context.projection);
83329       } else if (_wayIDs.length > 0 && (_nodeIDs.length === 0 || _nodeIDs.length === 2)) {
83330         var startNodeIDs = [];
83331         var endNodeIDs = [];
83332         for (var i3 = 0; i3 < selectedIDs.length; i3++) {
83333           var entity = context.entity(selectedIDs[i3]);
83334           if (entity.type === "node") {
83335             continue;
83336           } else if (entity.type !== "way" || entity.isClosed()) {
83337             return null;
83338           }
83339           startNodeIDs.push(entity.first());
83340           endNodeIDs.push(entity.last());
83341         }
83342         startNodeIDs = startNodeIDs.filter(function(n3) {
83343           return startNodeIDs.indexOf(n3) === startNodeIDs.lastIndexOf(n3);
83344         });
83345         endNodeIDs = endNodeIDs.filter(function(n3) {
83346           return endNodeIDs.indexOf(n3) === endNodeIDs.lastIndexOf(n3);
83347         });
83348         if (utilArrayDifference(startNodeIDs, endNodeIDs).length + utilArrayDifference(endNodeIDs, startNodeIDs).length !== 2) return null;
83349         var wayNodeIDs = utilGetAllNodes(_wayIDs, context.graph()).map(function(node) {
83350           return node.id;
83351         });
83352         if (wayNodeIDs.length <= 2) return null;
83353         if (_nodeIDs.length === 2 && (wayNodeIDs.indexOf(_nodeIDs[0]) === -1 || wayNodeIDs.indexOf(_nodeIDs[1]) === -1)) return null;
83354         if (_nodeIDs.length) {
83355           _extent = utilTotalExtent(_nodeIDs, context.graph());
83356         }
83357         _geometry = "line";
83358         return actionStraightenWay(selectedIDs, context.projection);
83359       }
83360       return null;
83361     }
83362     function operation2() {
83363       if (!_action) return;
83364       context.perform(_action, operation2.annotation());
83365       window.setTimeout(function() {
83366         context.validator().validate();
83367       }, 300);
83368     }
83369     operation2.available = function() {
83370       return Boolean(_action);
83371     };
83372     operation2.disabled = function() {
83373       var reason = _action.disabled(context.graph());
83374       if (reason) {
83375         return reason;
83376       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
83377         return "too_large";
83378       } else if (someMissing()) {
83379         return "not_downloaded";
83380       } else if (selectedIDs.some(context.hasHiddenConnections)) {
83381         return "connected_to_hidden";
83382       }
83383       return false;
83384       function someMissing() {
83385         if (context.inIntro()) return false;
83386         var osm = context.connection();
83387         if (osm) {
83388           var missing = _coords.filter(function(loc) {
83389             return !osm.isDataLoaded(loc);
83390           });
83391           if (missing.length) {
83392             missing.forEach(function(loc) {
83393               context.loadTileAtLoc(loc);
83394             });
83395             return true;
83396           }
83397         }
83398         return false;
83399       }
83400     };
83401     operation2.tooltip = function() {
83402       var disable = operation2.disabled();
83403       return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s"));
83404     };
83405     operation2.annotation = function() {
83406       return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length });
83407     };
83408     operation2.id = "straighten";
83409     operation2.keys = [_t("operations.straighten.key")];
83410     operation2.title = _t.append("operations.straighten.title");
83411     operation2.behavior = behaviorOperation(context).which(operation2);
83412     return operation2;
83413   }
83414
83415   // modules/modes/select.js
83416   function modeSelect(context, selectedIDs) {
83417     var mode = {
83418       id: "select",
83419       button: "browse"
83420     };
83421     var keybinding = utilKeybinding("select");
83422     var _breatheBehavior = behaviorBreathe(context);
83423     var _modeDragNode = modeDragNode(context);
83424     var _selectBehavior;
83425     var _behaviors = [];
83426     var _operations = [];
83427     var _newFeature = false;
83428     var _follow = false;
83429     var _focusedParentWayId;
83430     var _focusedVertexIds;
83431     function singular() {
83432       if (selectedIDs && selectedIDs.length === 1) {
83433         return context.hasEntity(selectedIDs[0]);
83434       }
83435     }
83436     function selectedEntities() {
83437       return selectedIDs.map(function(id2) {
83438         return context.hasEntity(id2);
83439       }).filter(Boolean);
83440     }
83441     function checkSelectedIDs() {
83442       var ids = [];
83443       if (Array.isArray(selectedIDs)) {
83444         ids = selectedIDs.filter(function(id2) {
83445           return context.hasEntity(id2);
83446         });
83447       }
83448       if (!ids.length) {
83449         context.enter(modeBrowse(context));
83450         return false;
83451       } else if (selectedIDs.length > 1 && ids.length === 1 || selectedIDs.length === 1 && ids.length > 1) {
83452         context.enter(modeSelect(context, ids));
83453         return false;
83454       }
83455       selectedIDs = ids;
83456       return true;
83457     }
83458     function parentWaysIdsOfSelection(onlyCommonParents) {
83459       var graph = context.graph();
83460       var parents = [];
83461       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
83462         var entity = context.hasEntity(selectedIDs[i3]);
83463         if (!entity || entity.geometry(graph) !== "vertex") {
83464           return [];
83465         }
83466         var currParents = graph.parentWays(entity).map(function(w2) {
83467           return w2.id;
83468         });
83469         if (!parents.length) {
83470           parents = currParents;
83471           continue;
83472         }
83473         parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
83474         if (!parents.length) {
83475           return [];
83476         }
83477       }
83478       return parents;
83479     }
83480     function childNodeIdsOfSelection(onlyCommon) {
83481       var graph = context.graph();
83482       var childs = [];
83483       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
83484         var entity = context.hasEntity(selectedIDs[i3]);
83485         if (!entity || !["area", "line"].includes(entity.geometry(graph))) {
83486           return [];
83487         }
83488         var currChilds = graph.childNodes(entity).map(function(node) {
83489           return node.id;
83490         });
83491         if (!childs.length) {
83492           childs = currChilds;
83493           continue;
83494         }
83495         childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
83496         if (!childs.length) {
83497           return [];
83498         }
83499       }
83500       return childs;
83501     }
83502     function checkFocusedParent() {
83503       if (_focusedParentWayId) {
83504         var parents = parentWaysIdsOfSelection(true);
83505         if (parents.indexOf(_focusedParentWayId) === -1) _focusedParentWayId = null;
83506       }
83507     }
83508     function parentWayIdForVertexNavigation() {
83509       var parentIds = parentWaysIdsOfSelection(true);
83510       if (_focusedParentWayId && parentIds.indexOf(_focusedParentWayId) !== -1) {
83511         return _focusedParentWayId;
83512       }
83513       return parentIds.length ? parentIds[0] : null;
83514     }
83515     mode.selectedIDs = function(val) {
83516       if (!arguments.length) return selectedIDs;
83517       selectedIDs = val;
83518       return mode;
83519     };
83520     mode.zoomToSelected = function() {
83521       context.map().zoomToEase(selectedEntities());
83522     };
83523     mode.newFeature = function(val) {
83524       if (!arguments.length) return _newFeature;
83525       _newFeature = val;
83526       return mode;
83527     };
83528     mode.selectBehavior = function(val) {
83529       if (!arguments.length) return _selectBehavior;
83530       _selectBehavior = val;
83531       return mode;
83532     };
83533     mode.follow = function(val) {
83534       if (!arguments.length) return _follow;
83535       _follow = val;
83536       return mode;
83537     };
83538     function loadOperations() {
83539       _operations.forEach(function(operation2) {
83540         if (operation2.behavior) {
83541           context.uninstall(operation2.behavior);
83542         }
83543       });
83544       _operations = Object.values(operations_exports).map(function(o2) {
83545         return o2(context, selectedIDs);
83546       }).filter(function(o2) {
83547         return o2.id !== "delete" && o2.id !== "downgrade" && o2.id !== "copy";
83548       }).concat([
83549         // group copy/downgrade/delete operation together at the end of the list
83550         operationCopy(context, selectedIDs),
83551         operationDowngrade(context, selectedIDs),
83552         operationDelete(context, selectedIDs)
83553       ]).filter(function(operation2) {
83554         return operation2.available();
83555       });
83556       _operations.forEach(function(operation2) {
83557         if (operation2.behavior) {
83558           context.install(operation2.behavior);
83559         }
83560       });
83561       context.ui().closeEditMenu();
83562     }
83563     mode.operations = function() {
83564       return _operations;
83565     };
83566     mode.enter = function() {
83567       if (!checkSelectedIDs()) return;
83568       context.features().forceVisible(selectedIDs);
83569       _modeDragNode.restoreSelectedIDs(selectedIDs);
83570       loadOperations();
83571       if (!_behaviors.length) {
83572         if (!_selectBehavior) _selectBehavior = behaviorSelect(context);
83573         _behaviors = [
83574           behaviorPaste(context),
83575           _breatheBehavior,
83576           behaviorHover(context).on("hover", context.ui().sidebar.hoverModeSelect),
83577           _selectBehavior,
83578           behaviorLasso(context),
83579           _modeDragNode.behavior,
83580           modeDragNote(context).behavior
83581         ];
83582       }
83583       _behaviors.forEach(context.install);
83584       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);
83585       select_default2(document).call(keybinding);
83586       context.ui().sidebar.select(selectedIDs, _newFeature);
83587       context.history().on("change.select", function() {
83588         loadOperations();
83589         selectElements();
83590       }).on("undone.select", checkSelectedIDs).on("redone.select", checkSelectedIDs);
83591       context.map().on("drawn.select", selectElements).on("crossEditableZoom.select", function() {
83592         selectElements();
83593         _breatheBehavior.restartIfNeeded(context.surface());
83594       });
83595       context.map().doubleUpHandler().on("doubleUp.modeSelect", didDoubleUp);
83596       selectElements();
83597       if (_follow) {
83598         var extent = geoExtent();
83599         var graph = context.graph();
83600         selectedIDs.forEach(function(id2) {
83601           var entity = context.entity(id2);
83602           extent._extend(entity.extent(graph));
83603         });
83604         var loc = extent.center();
83605         context.map().centerEase(loc);
83606         _follow = false;
83607       }
83608       function nudgeSelection(delta) {
83609         return function() {
83610           if (!context.map().withinEditableZoom()) return;
83611           var moveOp = operationMove(context, selectedIDs);
83612           if (moveOp.disabled()) {
83613             context.ui().flash.duration(4e3).iconName("#iD-operation-" + moveOp.id).iconClass("operation disabled").label(moveOp.tooltip())();
83614           } else {
83615             context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
83616             context.validator().validate();
83617           }
83618         };
83619       }
83620       function scaleSelection(factor) {
83621         return function() {
83622           if (!context.map().withinEditableZoom()) return;
83623           let nodes = utilGetAllNodes(selectedIDs, context.graph());
83624           let isUp = factor > 1;
83625           if (nodes.length <= 1) return;
83626           let extent2 = utilTotalExtent(selectedIDs, context.graph());
83627           function scalingDisabled() {
83628             if (tooSmall()) {
83629               return "too_small";
83630             } else if (extent2.percentContainedIn(context.map().extent()) < 0.8) {
83631               return "too_large";
83632             } else if (someMissing() || selectedIDs.some(incompleteRelation)) {
83633               return "not_downloaded";
83634             } else if (selectedIDs.some(context.hasHiddenConnections)) {
83635               return "connected_to_hidden";
83636             }
83637             return false;
83638             function tooSmall() {
83639               if (isUp) return false;
83640               let dLon = Math.abs(extent2[1][0] - extent2[0][0]);
83641               let dLat = Math.abs(extent2[1][1] - extent2[0][1]);
83642               return dLon < geoMetersToLon(1, extent2[1][1]) && dLat < geoMetersToLat(1);
83643             }
83644             function someMissing() {
83645               if (context.inIntro()) return false;
83646               let osm = context.connection();
83647               if (osm) {
83648                 let missing = nodes.filter(function(n3) {
83649                   return !osm.isDataLoaded(n3.loc);
83650                 });
83651                 if (missing.length) {
83652                   missing.forEach(function(loc2) {
83653                     context.loadTileAtLoc(loc2);
83654                   });
83655                   return true;
83656                 }
83657               }
83658               return false;
83659             }
83660             function incompleteRelation(id2) {
83661               let entity = context.entity(id2);
83662               return entity.type === "relation" && !entity.isComplete(context.graph());
83663             }
83664           }
83665           const disabled = scalingDisabled();
83666           if (disabled) {
83667             let multi = selectedIDs.length === 1 ? "single" : "multiple";
83668             context.ui().flash.duration(4e3).iconName("#iD-icon-no").iconClass("operation disabled").label(_t.append("operations.scale." + disabled + "." + multi))();
83669           } else {
83670             const pivot = context.projection(extent2.center());
83671             const annotation = _t("operations.scale.annotation." + (isUp ? "up" : "down") + ".feature", { n: selectedIDs.length });
83672             context.perform(actionScale(selectedIDs, pivot, factor, context.projection), annotation);
83673             context.validator().validate();
83674           }
83675         };
83676       }
83677       function didDoubleUp(d3_event, loc2) {
83678         if (!context.map().withinEditableZoom()) return;
83679         var target = select_default2(d3_event.target);
83680         var datum2 = target.datum();
83681         var entity = datum2 && datum2.properties && datum2.properties.entity;
83682         if (!entity) return;
83683         if (entity instanceof osmWay && target.classed("target")) {
83684           var choice = geoChooseEdge(context.graph().childNodes(entity), loc2, context.projection);
83685           var prev = entity.nodes[choice.index - 1];
83686           var next = entity.nodes[choice.index];
83687           context.perform(
83688             actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
83689             _t("operations.add.annotation.vertex")
83690           );
83691           context.validator().validate();
83692         } else if (entity.type === "midpoint") {
83693           context.perform(
83694             actionAddMidpoint({ loc: entity.loc, edge: entity.edge }, osmNode()),
83695             _t("operations.add.annotation.vertex")
83696           );
83697           context.validator().validate();
83698         }
83699       }
83700       function selectElements() {
83701         if (!checkSelectedIDs()) return;
83702         var surface = context.surface();
83703         surface.selectAll(".selected-member").classed("selected-member", false);
83704         surface.selectAll(".selected").classed("selected", false);
83705         surface.selectAll(".related").classed("related", false);
83706         checkFocusedParent();
83707         if (_focusedParentWayId) {
83708           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
83709         }
83710         if (context.map().withinEditableZoom()) {
83711           surface.selectAll(utilDeepMemberSelector(
83712             selectedIDs,
83713             context.graph(),
83714             true
83715             /* skipMultipolgonMembers */
83716           )).classed("selected-member", true);
83717           surface.selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())).classed("selected", true);
83718         }
83719       }
83720       function esc() {
83721         if (context.container().select(".combobox").size()) return;
83722         context.enter(modeBrowse(context));
83723       }
83724       function firstVertex(d3_event) {
83725         d3_event.preventDefault();
83726         var entity = singular();
83727         var parentId = parentWayIdForVertexNavigation();
83728         var way;
83729         if (entity && entity.type === "way") {
83730           way = entity;
83731         } else if (parentId) {
83732           way = context.entity(parentId);
83733         }
83734         _focusedParentWayId = way && way.id;
83735         if (way) {
83736           context.enter(
83737             mode.selectedIDs([way.first()]).follow(true)
83738           );
83739         }
83740       }
83741       function lastVertex(d3_event) {
83742         d3_event.preventDefault();
83743         var entity = singular();
83744         var parentId = parentWayIdForVertexNavigation();
83745         var way;
83746         if (entity && entity.type === "way") {
83747           way = entity;
83748         } else if (parentId) {
83749           way = context.entity(parentId);
83750         }
83751         _focusedParentWayId = way && way.id;
83752         if (way) {
83753           context.enter(
83754             mode.selectedIDs([way.last()]).follow(true)
83755           );
83756         }
83757       }
83758       function previousVertex(d3_event) {
83759         d3_event.preventDefault();
83760         var parentId = parentWayIdForVertexNavigation();
83761         _focusedParentWayId = parentId;
83762         if (!parentId) return;
83763         var way = context.entity(parentId);
83764         var length2 = way.nodes.length;
83765         var curr = way.nodes.indexOf(selectedIDs[0]);
83766         var index = -1;
83767         if (curr > 0) {
83768           index = curr - 1;
83769         } else if (way.isClosed()) {
83770           index = length2 - 2;
83771         }
83772         if (index !== -1) {
83773           context.enter(
83774             mode.selectedIDs([way.nodes[index]]).follow(true)
83775           );
83776         }
83777       }
83778       function nextVertex(d3_event) {
83779         d3_event.preventDefault();
83780         var parentId = parentWayIdForVertexNavigation();
83781         _focusedParentWayId = parentId;
83782         if (!parentId) return;
83783         var way = context.entity(parentId);
83784         var length2 = way.nodes.length;
83785         var curr = way.nodes.indexOf(selectedIDs[0]);
83786         var index = -1;
83787         if (curr < length2 - 1) {
83788           index = curr + 1;
83789         } else if (way.isClosed()) {
83790           index = 0;
83791         }
83792         if (index !== -1) {
83793           context.enter(
83794             mode.selectedIDs([way.nodes[index]]).follow(true)
83795           );
83796         }
83797       }
83798       function focusNextParent(d3_event) {
83799         d3_event.preventDefault();
83800         var parents = parentWaysIdsOfSelection(true);
83801         if (!parents || parents.length < 2) return;
83802         var index = parents.indexOf(_focusedParentWayId);
83803         if (index < 0 || index > parents.length - 2) {
83804           _focusedParentWayId = parents[0];
83805         } else {
83806           _focusedParentWayId = parents[index + 1];
83807         }
83808         var surface = context.surface();
83809         surface.selectAll(".related").classed("related", false);
83810         if (_focusedParentWayId) {
83811           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
83812         }
83813       }
83814       function selectParent(d3_event) {
83815         d3_event.preventDefault();
83816         var currentSelectedIds = mode.selectedIDs();
83817         var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
83818         if (!parentIds.length) return;
83819         context.enter(
83820           mode.selectedIDs(parentIds)
83821         );
83822         _focusedVertexIds = currentSelectedIds;
83823       }
83824       function selectChild(d3_event) {
83825         d3_event.preventDefault();
83826         var currentSelectedIds = mode.selectedIDs();
83827         var childIds = _focusedVertexIds ? _focusedVertexIds.filter((id2) => context.hasEntity(id2)) : childNodeIdsOfSelection(true);
83828         if (!childIds || !childIds.length) return;
83829         if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
83830         context.enter(
83831           mode.selectedIDs(childIds)
83832         );
83833       }
83834     };
83835     mode.exit = function() {
83836       _newFeature = false;
83837       _focusedVertexIds = null;
83838       _operations.forEach(function(operation2) {
83839         if (operation2.behavior) {
83840           context.uninstall(operation2.behavior);
83841         }
83842       });
83843       _operations = [];
83844       _behaviors.forEach(context.uninstall);
83845       select_default2(document).call(keybinding.unbind);
83846       context.ui().closeEditMenu();
83847       context.history().on("change.select", null).on("undone.select", null).on("redone.select", null);
83848       var surface = context.surface();
83849       surface.selectAll(".selected-member").classed("selected-member", false);
83850       surface.selectAll(".selected").classed("selected", false);
83851       surface.selectAll(".highlighted").classed("highlighted", false);
83852       surface.selectAll(".related").classed("related", false);
83853       context.map().on("drawn.select", null);
83854       context.ui().sidebar.hide();
83855       context.features().forceVisible([]);
83856       var entity = singular();
83857       if (_newFeature && entity && entity.type === "relation" && // no tags
83858       Object.keys(entity.tags).length === 0 && // no parent relations
83859       context.graph().parentRelations(entity).length === 0 && // no members or one member with no role
83860       (entity.members.length === 0 || entity.members.length === 1 && !entity.members[0].role)) {
83861         var deleteAction = actionDeleteRelation(
83862           entity.id,
83863           true
83864           /* don't delete untagged members */
83865         );
83866         context.perform(deleteAction, _t("operations.delete.annotation.relation"));
83867         context.validator().validate();
83868       }
83869     };
83870     return mode;
83871   }
83872
83873   // modules/behavior/lasso.js
83874   function behaviorLasso(context) {
83875     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
83876     var behavior = function(selection2) {
83877       var lasso;
83878       function pointerdown(d3_event) {
83879         var button = 0;
83880         if (d3_event.button === button && d3_event.shiftKey === true) {
83881           lasso = null;
83882           select_default2(window).on(_pointerPrefix + "move.lasso", pointermove).on(_pointerPrefix + "up.lasso", pointerup);
83883           d3_event.stopPropagation();
83884         }
83885       }
83886       function pointermove() {
83887         if (!lasso) {
83888           lasso = uiLasso(context);
83889           context.surface().call(lasso);
83890         }
83891         lasso.p(context.map().mouse());
83892       }
83893       function normalize2(a2, b2) {
83894         return [
83895           [Math.min(a2[0], b2[0]), Math.min(a2[1], b2[1])],
83896           [Math.max(a2[0], b2[0]), Math.max(a2[1], b2[1])]
83897         ];
83898       }
83899       function lassoed() {
83900         if (!lasso) return [];
83901         var graph = context.graph();
83902         var limitToNodes;
83903         if (context.map().editableDataEnabled(
83904           true
83905           /* skipZoomCheck */
83906         ) && context.map().isInWideSelection()) {
83907           limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
83908         } else if (!context.map().editableDataEnabled()) {
83909           return [];
83910         }
83911         var bounds = lasso.extent().map(context.projection.invert);
83912         var extent = geoExtent(normalize2(bounds[0], bounds[1]));
83913         var intersects2 = context.history().intersects(extent).filter(function(entity) {
83914           return entity.type === "node" && (!limitToNodes || limitToNodes.has(entity)) && geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) && !context.features().isHidden(entity, graph, entity.geometry(graph));
83915         });
83916         intersects2.sort(function(node1, node2) {
83917           var parents1 = graph.parentWays(node1);
83918           var parents2 = graph.parentWays(node2);
83919           if (parents1.length && parents2.length) {
83920             var sharedParents = utilArrayIntersection(parents1, parents2);
83921             if (sharedParents.length) {
83922               var sharedParentNodes = sharedParents[0].nodes;
83923               return sharedParentNodes.indexOf(node1.id) - sharedParentNodes.indexOf(node2.id);
83924             } else {
83925               return Number(parents1[0].id.slice(1)) - Number(parents2[0].id.slice(1));
83926             }
83927           } else if (parents1.length || parents2.length) {
83928             return parents1.length - parents2.length;
83929           }
83930           return node1.loc[0] - node2.loc[0];
83931         });
83932         return intersects2.map(function(entity) {
83933           return entity.id;
83934         });
83935       }
83936       function pointerup() {
83937         select_default2(window).on(_pointerPrefix + "move.lasso", null).on(_pointerPrefix + "up.lasso", null);
83938         if (!lasso) return;
83939         var ids = lassoed();
83940         lasso.close();
83941         if (ids.length) {
83942           context.enter(modeSelect(context, ids));
83943         }
83944       }
83945       selection2.on(_pointerPrefix + "down.lasso", pointerdown);
83946     };
83947     behavior.off = function(selection2) {
83948       selection2.on(_pointerPrefix + "down.lasso", null);
83949     };
83950     return behavior;
83951   }
83952
83953   // modules/modes/browse.js
83954   function modeBrowse(context) {
83955     var mode = {
83956       button: "browse",
83957       id: "browse",
83958       title: _t.append("modes.browse.title"),
83959       description: _t.append("modes.browse.description")
83960     };
83961     var sidebar;
83962     var _selectBehavior;
83963     var _behaviors = [];
83964     mode.selectBehavior = function(val) {
83965       if (!arguments.length) return _selectBehavior;
83966       _selectBehavior = val;
83967       return mode;
83968     };
83969     mode.enter = function() {
83970       if (!_behaviors.length) {
83971         if (!_selectBehavior) _selectBehavior = behaviorSelect(context);
83972         _behaviors = [
83973           behaviorPaste(context),
83974           behaviorHover(context).on("hover", context.ui().sidebar.hover),
83975           _selectBehavior,
83976           behaviorLasso(context),
83977           modeDragNode(context).behavior,
83978           modeDragNote(context).behavior
83979         ];
83980       }
83981       _behaviors.forEach(context.install);
83982       if (document.activeElement && document.activeElement.blur) {
83983         document.activeElement.blur();
83984       }
83985       if (sidebar) {
83986         context.ui().sidebar.show(sidebar);
83987       } else {
83988         context.ui().sidebar.select(null);
83989       }
83990     };
83991     mode.exit = function() {
83992       context.ui().sidebar.hover.cancel();
83993       _behaviors.forEach(context.uninstall);
83994       if (sidebar) {
83995         context.ui().sidebar.hide();
83996       }
83997     };
83998     mode.sidebar = function(_2) {
83999       if (!arguments.length) return sidebar;
84000       sidebar = _2;
84001       return mode;
84002     };
84003     mode.operations = function() {
84004       return [operationPaste(context)];
84005     };
84006     return mode;
84007   }
84008
84009   // modules/behavior/add_way.js
84010   function behaviorAddWay(context) {
84011     var dispatch14 = dispatch_default("start", "startFromWay", "startFromNode");
84012     var draw = behaviorDraw(context);
84013     function behavior(surface) {
84014       draw.on("click", function() {
84015         dispatch14.apply("start", this, arguments);
84016       }).on("clickWay", function() {
84017         dispatch14.apply("startFromWay", this, arguments);
84018       }).on("clickNode", function() {
84019         dispatch14.apply("startFromNode", this, arguments);
84020       }).on("cancel", behavior.cancel).on("finish", behavior.cancel);
84021       context.map().dblclickZoomEnable(false);
84022       surface.call(draw);
84023     }
84024     behavior.off = function(surface) {
84025       surface.call(draw.off);
84026     };
84027     behavior.cancel = function() {
84028       window.setTimeout(function() {
84029         context.map().dblclickZoomEnable(true);
84030       }, 1e3);
84031       context.enter(modeBrowse(context));
84032     };
84033     return utilRebind(behavior, dispatch14, "on");
84034   }
84035
84036   // modules/behavior/hash.js
84037   function behaviorHash(context) {
84038     var _cachedHash = null;
84039     var _latitudeLimit = 90 - 1e-8;
84040     function computedHashParameters() {
84041       var map2 = context.map();
84042       var center = map2.center();
84043       var zoom = map2.zoom();
84044       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
84045       var oldParams = utilObjectOmit(
84046         utilStringQs(window.location.hash),
84047         ["comment", "source", "hashtags", "walkthrough"]
84048       );
84049       var newParams = {};
84050       delete oldParams.id;
84051       var selected = context.selectedIDs().filter(function(id2) {
84052         return context.hasEntity(id2);
84053       });
84054       if (selected.length) {
84055         newParams.id = selected.join(",");
84056       } else if (context.selectedNoteID()) {
84057         newParams.id = "note/".concat(context.selectedNoteID());
84058       }
84059       newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
84060       return Object.assign(oldParams, newParams);
84061     }
84062     function computedHash() {
84063       return "#" + utilQsString(computedHashParameters(), true);
84064     }
84065     function computedTitle(includeChangeCount) {
84066       var baseTitle = context.documentTitleBase() || "iD";
84067       var contextual;
84068       var changeCount;
84069       var titleID;
84070       var selected = context.selectedIDs().filter(function(id2) {
84071         return context.hasEntity(id2);
84072       });
84073       if (selected.length) {
84074         var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph());
84075         if (selected.length > 1) {
84076           contextual = _t("title.labeled_and_more", {
84077             labeled: firstLabel,
84078             count: selected.length - 1
84079           });
84080         } else {
84081           contextual = firstLabel;
84082         }
84083         titleID = "context";
84084       }
84085       if (includeChangeCount) {
84086         changeCount = context.history().difference().summary().length;
84087         if (changeCount > 0) {
84088           titleID = contextual ? "changes_context" : "changes";
84089         }
84090       }
84091       if (titleID) {
84092         return _t("title.format." + titleID, {
84093           changes: changeCount,
84094           base: baseTitle,
84095           context: contextual
84096         });
84097       }
84098       return baseTitle;
84099     }
84100     function updateTitle(includeChangeCount) {
84101       if (!context.setsDocumentTitle()) return;
84102       var newTitle = computedTitle(includeChangeCount);
84103       if (document.title !== newTitle) {
84104         document.title = newTitle;
84105       }
84106     }
84107     function updateHashIfNeeded() {
84108       if (context.inIntro()) return;
84109       var latestHash = computedHash();
84110       if (_cachedHash !== latestHash) {
84111         _cachedHash = latestHash;
84112         window.history.replaceState(null, computedTitle(
84113           false
84114           /* includeChangeCount */
84115         ), latestHash);
84116         updateTitle(
84117           true
84118           /* includeChangeCount */
84119         );
84120         const q2 = utilStringQs(latestHash);
84121         if (q2.map) {
84122           corePreferences("map-location", q2.map);
84123         }
84124       }
84125     }
84126     var _throttledUpdate = throttle_default(updateHashIfNeeded, 500);
84127     var _throttledUpdateTitle = throttle_default(function() {
84128       updateTitle(
84129         true
84130         /* includeChangeCount */
84131       );
84132     }, 500);
84133     function hashchange() {
84134       if (window.location.hash === _cachedHash) return;
84135       _cachedHash = window.location.hash;
84136       var q2 = utilStringQs(_cachedHash);
84137       var mapArgs = (q2.map || "").split("/").map(Number);
84138       if (mapArgs.length < 3 || mapArgs.some(isNaN)) {
84139         updateHashIfNeeded();
84140       } else {
84141         if (_cachedHash === computedHash()) return;
84142         var mode = context.mode();
84143         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
84144         if (q2.id && mode) {
84145           var ids = q2.id.split(",").filter(function(id2) {
84146             return context.hasEntity(id2) || id2.startsWith("note/");
84147           });
84148           if (ids.length && ["browse", "select-note", "select"].includes(mode.id)) {
84149             if (ids.length === 1 && ids[0].startsWith("note/")) {
84150               context.enter(modeSelectNote(context, ids[0]));
84151             } else if (!utilArrayIdentical(mode.selectedIDs(), ids)) {
84152               context.enter(modeSelect(context, ids));
84153             }
84154             return;
84155           }
84156         }
84157         var center = context.map().center();
84158         var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]);
84159         var maxdist = 500;
84160         if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) {
84161           context.enter(modeBrowse(context));
84162           return;
84163         }
84164       }
84165     }
84166     function behavior() {
84167       context.map().on("move.behaviorHash", _throttledUpdate);
84168       context.history().on("change.behaviorHash", _throttledUpdateTitle);
84169       context.on("enter.behaviorHash", _throttledUpdate);
84170       select_default2(window).on("hashchange.behaviorHash", hashchange);
84171       var q2 = utilStringQs(window.location.hash);
84172       if (q2.id) {
84173         const selectIds = q2.id.split(",");
84174         if (selectIds.length === 1 && selectIds[0].startsWith("note/")) {
84175           const noteId = selectIds[0].split("/")[1];
84176           context.moveToNote(noteId, !q2.map);
84177         } else {
84178           context.zoomToEntities(
84179             // convert ids to short form id: node/123 -> n123
84180             selectIds.map((id2) => id2.replace(/([nwr])[^/]*\//, "$1")),
84181             !q2.map
84182           );
84183         }
84184       }
84185       if (q2.walkthrough === "true") {
84186         behavior.startWalkthrough = true;
84187       }
84188       if (q2.map) {
84189         behavior.hadLocation = true;
84190       } else if (!q2.id && corePreferences("map-location")) {
84191         const mapArgs = corePreferences("map-location").split("/").map(Number);
84192         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
84193         updateHashIfNeeded();
84194         behavior.hadLocation = true;
84195       }
84196       hashchange();
84197       updateTitle(false);
84198     }
84199     behavior.off = function() {
84200       _throttledUpdate.cancel();
84201       _throttledUpdateTitle.cancel();
84202       context.map().on("move.behaviorHash", null);
84203       context.on("enter.behaviorHash", null);
84204       select_default2(window).on("hashchange.behaviorHash", null);
84205       window.location.hash = "";
84206     };
84207     return behavior;
84208   }
84209
84210   // node_modules/d3-brush/src/brush.js
84211   var { abs: abs2, max: max2, min: min2 } = Math;
84212   function number1(e3) {
84213     return [+e3[0], +e3[1]];
84214   }
84215   function number22(e3) {
84216     return [number1(e3[0]), number1(e3[1])];
84217   }
84218   var X3 = {
84219     name: "x",
84220     handles: ["w", "e"].map(type),
84221     input: function(x2, e3) {
84222       return x2 == null ? null : [[+x2[0], e3[0][1]], [+x2[1], e3[1][1]]];
84223     },
84224     output: function(xy) {
84225       return xy && [xy[0][0], xy[1][0]];
84226     }
84227   };
84228   var Y3 = {
84229     name: "y",
84230     handles: ["n", "s"].map(type),
84231     input: function(y2, e3) {
84232       return y2 == null ? null : [[e3[0][0], +y2[0]], [e3[1][0], +y2[1]]];
84233     },
84234     output: function(xy) {
84235       return xy && [xy[0][1], xy[1][1]];
84236     }
84237   };
84238   var XY = {
84239     name: "xy",
84240     handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
84241     input: function(xy) {
84242       return xy == null ? null : number22(xy);
84243     },
84244     output: function(xy) {
84245       return xy;
84246     }
84247   };
84248   function type(t2) {
84249     return { type: t2 };
84250   }
84251
84252   // modules/index.js
84253   var debug = false;
84254   var setDebug = (newValue) => {
84255     debug = newValue;
84256   };
84257   var d3 = {
84258     dispatch: dispatch_default,
84259     geoMercator: mercator_default,
84260     geoProjection: projection,
84261     polygonArea: area_default3,
84262     polygonCentroid: centroid_default2,
84263     select: select_default2,
84264     selectAll: selectAll_default2,
84265     timerFlush
84266   };
84267
84268   // modules/id.js
84269   window.requestIdleCallback = window.requestIdleCallback || function(cb) {
84270     var start2 = Date.now();
84271     return window.requestAnimationFrame(function() {
84272       cb({
84273         didTimeout: false,
84274         timeRemaining: function() {
84275           return Math.max(0, 50 - (Date.now() - start2));
84276         }
84277       });
84278     });
84279   };
84280   window.cancelIdleCallback = window.cancelIdleCallback || function(id2) {
84281     window.cancelAnimationFrame(id2);
84282   };
84283   window.iD = index_exports;
84284 })();
84285 //# sourceMappingURL=iD.js.map