X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/71cb84bbe244d0ef471a385b02f1f432bc17b606..ddc252016a42c076c4f8dd8d0efd1caf055eb518:/vendor/assets/iD/iD.js?ds=inline diff --git a/vendor/assets/iD/iD.js b/vendor/assets/iD/iD.js index 9fc95e2fc..6d457ec6f 100644 --- a/vendor/assets/iD/iD.js +++ b/vendor/assets/iD/iD.js @@ -1,32 +1,11 @@ (() => { var __create = Object.create; var __defProp = Object.defineProperty; - var __defProps = Object.defineProperties; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; - var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropNames = Object.getOwnPropertyNames; - var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; - var __propIsEnum = Object.prototype.propertyIsEnumerable; - var __knownSymbol = (name, symbol) => { - if (symbol = Symbol[name]) - return symbol; - throw Error("Symbol." + name + " is not defined"); - }; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; - var __spreadValues = (a2, b2) => { - for (var prop in b2 || (b2 = {})) - if (__hasOwnProp.call(b2, prop)) - __defNormalProp(a2, prop, b2[prop]); - if (__getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(b2)) { - if (__propIsEnum.call(b2, prop)) - __defNormalProp(a2, prop, b2[prop]); - } - return a2; - }; - var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2)); var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, { get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2] }) : x2)(function(x2) { @@ -74,43 +53,6 @@ __accessCheck(obj, member, "access private method"); return method; }; - var __await = function(promise, isYieldStar) { - this[0] = promise; - this[1] = isYieldStar; - }; - var __yieldStar = (value) => { - var obj = value[__knownSymbol("asyncIterator")]; - var isAwait = false; - var method; - var it = {}; - if (obj == null) { - obj = value[__knownSymbol("iterator")](); - method = (k2) => it[k2] = (x2) => obj[k2](x2); - } else { - obj = obj.call(value); - method = (k2) => it[k2] = (v2) => { - if (isAwait) { - isAwait = false; - if (k2 === "throw") - throw v2; - return v2; - } - isAwait = true; - return { - done: false, - value: new __await(new Promise((resolve) => { - var x2 = obj[k2](v2); - if (!(x2 instanceof Object)) - throw TypeError("Object expected"); - resolve(x2); - }), 1) - }; - }; - } - return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x2) => { - throw x2; - }, "return" in obj && method("return"), it; - }; // node_modules/diacritics/index.js var require_diacritics = __commonJS({ @@ -513,15 +455,15 @@ var diacriticsMap = {}; for (i3 = 0; i3 < replacementList.length; i3 += 1) { chars = replacementList[i3].chars; - for (j3 = 0; j3 < chars.length; j3 += 1) { - diacriticsMap[chars[j3]] = replacementList[i3].base; + for (j2 = 0; j2 < chars.length; j2 += 1) { + diacriticsMap[chars[j2]] = replacementList[i3].base; } } var chars; - var j3; + var j2; var i3; - function removeDiacritics2(str2) { - return str2.replace(/[^\u0000-\u007e]/g, function(c2) { + function removeDiacritics2(str) { + return str.replace(/[^\u0000-\u007e]/g, function(c2) { return diacriticsMap[c2] || c2; }); } @@ -2884,8 +2826,8 @@ let normalForm = reference_1.ligatureList[v2]; if (normalForm !== "words") { let ligForms = Object.keys(unicode_ligatures_1.default[normalForm]); - for (let f3 = 0; f3 < ligForms.length; f3++) { - if (unicode_ligatures_1.default[normalForm][ligForms[f3]] === letter) { + for (let f2 = 0; f2 < ligForms.length; f2++) { + if (unicode_ligatures_1.default[normalForm][ligForms[f2]] === letter) { returnable += normalForm; return; } @@ -3096,10 +3038,10 @@ v2.isEmpty = !v2.major && !v2.minor && !v2.patch && !v2.build; v2.parsed = [v2.major, v2.minor, v2.patch, v2.build]; v2.text = v2.parsed.join("."); - v2.compare = compare; + v2.compare = compare2; return v2; } - function compare(v2) { + function compare2(v2) { if (typeof v2 === "string") { v2 = parseVersion3(v2); } @@ -3126,10 +3068,10 @@ typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.quickselect = factory(); })(exports2, function() { "use strict"; - function quickselect2(arr, k2, left, right, compare) { - quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare || defaultCompare); + function quickselect2(arr, k2, left, right, compare2) { + quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare2 || defaultCompare); } - function quickselectStep(arr, k2, left, right, compare) { + function quickselectStep(arr, k2, left, right, compare2) { while (right > left) { if (right - left > 600) { var n3 = right - left + 1; @@ -3139,39 +3081,39 @@ var sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1); var newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd)); var newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd)); - quickselectStep(arr, k2, newLeft, newRight, compare); + quickselectStep(arr, k2, newLeft, newRight, compare2); } var t2 = arr[k2]; var i3 = left; - var j3 = right; + var j2 = right; swap2(arr, left, k2); - if (compare(arr[right], t2) > 0) + if (compare2(arr[right], t2) > 0) swap2(arr, left, right); - while (i3 < j3) { - swap2(arr, i3, j3); + while (i3 < j2) { + swap2(arr, i3, j2); i3++; - j3--; - while (compare(arr[i3], t2) < 0) + j2--; + while (compare2(arr[i3], t2) < 0) i3++; - while (compare(arr[j3], t2) > 0) - j3--; + while (compare2(arr[j2], t2) > 0) + j2--; } - if (compare(arr[left], t2) === 0) - swap2(arr, left, j3); + if (compare2(arr[left], t2) === 0) + swap2(arr, left, j2); else { - j3++; - swap2(arr, j3, right); + j2++; + swap2(arr, j2, right); } - if (j3 <= k2) - left = j3 + 1; - if (k2 <= j3) - right = j3 - 1; + if (j2 <= k2) + left = j2 + 1; + if (k2 <= j2) + right = j2 - 1; } } - function swap2(arr, i3, j3) { + function swap2(arr, i3, j2) { var tmp = arr[i3]; - arr[i3] = arr[j3]; - arr[j3] = tmp; + arr[i3] = arr[j2]; + arr[j2] = tmp; } function defaultCompare(a2, b2) { return a2 < b2 ? -1 : a2 > b2 ? 1 : 0; @@ -3348,14 +3290,14 @@ node = createNode([]); node.leaf = false; node.height = height; - var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j3, right2, right3; + var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j2, right2, right3; multiSelect(items, left, right, N1, this.compareMinX); for (i3 = left; i3 <= right; i3 += N1) { right2 = Math.min(i3 + N1 - 1, right); multiSelect(items, i3, right2, N22, this.compareMinY); - for (j3 = i3; j3 <= right2; j3 += N22) { - right3 = Math.min(j3 + N22 - 1, right2); - node.children.push(this._build(items, j3, right3, height - 1)); + for (j2 = i3; j2 <= right2; j2 += N22) { + right3 = Math.min(j2 + N22 - 1, right2); + node.children.push(this._build(items, j2, right3, height - 1)); } } calcBBox(node, this.toBBox); @@ -3450,8 +3392,8 @@ node.children.sort(compareMinX); }, // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function(node, m2, M2, compare) { - node.children.sort(compare); + _allDistMargin: function(node, m2, M2, compare2) { + node.children.sort(compare2); var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m2, toBBox), rightBBox = distBBox(node, M2 - m2, M2, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i3, child; for (i3 = m2; i3 < M2 - m2; i3++) { child = node.children[i3]; @@ -3560,7 +3502,7 @@ maxY: -Infinity }; } - function multiSelect(arr, left, right, n3, compare) { + function multiSelect(arr, left, right, n3, compare2) { var stack = [left, right], mid; while (stack.length) { right = stack.pop(); @@ -3568,7 +3510,7 @@ if (right - left <= n3) continue; mid = left + Math.ceil((right - left) / n3 / 2) * n3; - quickselect2(arr, mid, left, right, compare); + quickselect2(arr, mid, left, right, compare2); stack.push(left, mid, mid, right); } } @@ -3688,8 +3630,8 @@ if (feature3.geometry.type === "Polygon") { bboxes.push(treeItem(coords, feature3.properties)); } else if (feature3.geometry.type === "MultiPolygon") { - for (var j3 = 0; j3 < coords.length; j3++) { - bboxes.push(treeItem(coords[j3], feature3.properties)); + for (var j2 = 0; j2 < coords.length; j2++) { + bboxes.push(treeItem(coords[j2], feature3.properties)); } } } @@ -3746,8 +3688,8 @@ var inside = false; for (var i3 = 0, len = rings.length; i3 < len; i3++) { var ring = rings[i3]; - for (var j3 = 0, len2 = ring.length, k2 = len2 - 1; j3 < len2; k2 = j3++) { - if (rayIntersect(p2, ring[j3], ring[k2])) + for (var j2 = 0, len2 = ring.length, k2 = len2 - 1; j2 < len2; k2 = j2++) { + if (rayIntersect(p2, ring[j2], ring[k2])) inside = !inside; } } @@ -4051,2797 +3993,772 @@ } }); - // node_modules/polygon-clipping/dist/polygon-clipping.umd.js - var require_polygon_clipping_umd = __commonJS({ - "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) { - (function(global2, factory) { - 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()); - })(exports2, function() { - "use strict"; - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); + // node_modules/geojson-precision/index.js + var require_geojson_precision = __commonJS({ + "node_modules/geojson-precision/index.js"(exports2, module2) { + (function() { + function parse(t2, coordinatePrecision, extrasPrecision) { + function point2(p2) { + return p2.map(function(e3, index) { + if (index < 2) { + return 1 * e3.toFixed(coordinatePrecision); + } else { + return 1 * e3.toFixed(extrasPrecision); + } + }); } - } - function _defineProperties(target, props) { - for (var i3 = 0; i3 < props.length; i3++) { - var descriptor = props[i3]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) - descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + function multi(l2) { + return l2.map(point2); + } + function poly(p2) { + return p2.map(multi); + } + function multiPoly(m2) { + return m2.map(poly); + } + function geometry(obj) { + if (!obj) { + return {}; + } + switch (obj.type) { + case "Point": + obj.coordinates = point2(obj.coordinates); + return obj; + case "LineString": + case "MultiPoint": + obj.coordinates = multi(obj.coordinates); + return obj; + case "Polygon": + case "MultiLineString": + obj.coordinates = poly(obj.coordinates); + return obj; + case "MultiPolygon": + obj.coordinates = multiPoly(obj.coordinates); + return obj; + case "GeometryCollection": + obj.geometries = obj.geometries.map(geometry); + return obj; + default: + return {}; + } + } + function feature3(obj) { + obj.geometry = geometry(obj.geometry); + return obj; + } + function featureCollection(f2) { + f2.features = f2.features.map(feature3); + return f2; + } + function geometryCollection(g3) { + g3.geometries = g3.geometries.map(geometry); + return g3; + } + if (!t2) { + return t2; + } + switch (t2.type) { + case "Feature": + return feature3(t2); + case "GeometryCollection": + return geometryCollection(t2); + case "FeatureCollection": + return featureCollection(t2); + case "Point": + case "LineString": + case "Polygon": + case "MultiPoint": + case "MultiPolygon": + case "MultiLineString": + return geometry(t2); + default: + return t2; } } - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) - _defineProperties(Constructor.prototype, protoProps); - if (staticProps) - _defineProperties(Constructor, staticProps); - return Constructor; + module2.exports = parse; + module2.exports.parse = parse; + })(); + } + }); + + // node_modules/@aitodotai/json-stringify-pretty-compact/index.js + var require_json_stringify_pretty_compact = __commonJS({ + "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) { + function isObject3(obj) { + return typeof obj === "object" && obj !== null; + } + function forEach(obj, cb) { + if (Array.isArray(obj)) { + obj.forEach(cb); + } else if (isObject3(obj)) { + Object.keys(obj).forEach(function(key) { + var val = obj[key]; + cb(val, key); + }); } - var Node = ( - /** @class */ - function() { - function Node2(key, data) { - this.next = null; - this.key = key; - this.data = data; - this.left = null; - this.right = null; + } + function getTreeDepth(obj) { + var depth = 0; + if (Array.isArray(obj) || isObject3(obj)) { + forEach(obj, function(val) { + if (Array.isArray(val) || isObject3(val)) { + var tmpDepth = getTreeDepth(val); + if (tmpDepth > depth) { + depth = tmpDepth; + } } - return Node2; - }() - ); - function DEFAULT_COMPARE(a2, b2) { - return a2 > b2 ? 1 : a2 < b2 ? -1 : 0; + }); + return depth + 1; } - function splay(i3, t2, comparator) { - var N2 = new Node(null, null); - var l2 = N2; - var r2 = N2; - while (true) { - var cmp2 = comparator(i3, t2.key); - if (cmp2 < 0) { - if (t2.left === null) - break; - if (comparator(i3, t2.left.key) < 0) { - var y2 = t2.left; - t2.left = y2.right; - y2.right = t2; - t2 = y2; - if (t2.left === null) - break; - } - r2.left = t2; - r2 = t2; - t2 = t2.left; - } else if (cmp2 > 0) { - if (t2.right === null) - break; - if (comparator(i3, t2.right.key) > 0) { - var y2 = t2.right; - t2.right = y2.left; - y2.left = t2; - t2 = y2; - if (t2.right === null) - break; + return depth; + } + function stringify3(obj, options2) { + options2 = options2 || {}; + var indent = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3); + var addMargin = get4(options2, "margins", false); + var addArrayMargin = get4(options2, "arrayMargins", false); + var addObjectMargin = get4(options2, "objectMargins", false); + var maxLength = indent === "" ? Infinity : get4(options2, "maxLength", 80); + var maxNesting = get4(options2, "maxNesting", Infinity); + return function _stringify(obj2, currentIndent, reserved) { + if (obj2 && typeof obj2.toJSON === "function") { + obj2 = obj2.toJSON(); + } + var string = JSON.stringify(obj2); + if (string === void 0) { + return string; + } + var length2 = maxLength - currentIndent.length - reserved; + var treeDepth = getTreeDepth(obj2); + if (treeDepth <= maxNesting && string.length <= length2) { + var prettified = prettify(string, { + addMargin, + addArrayMargin, + addObjectMargin + }); + if (prettified.length <= length2) { + return prettified; + } + } + if (isObject3(obj2)) { + var nextIndent = currentIndent + indent; + var items = []; + var delimiters; + var comma = function(array2, index2) { + return index2 === array2.length - 1 ? 0 : 1; + }; + if (Array.isArray(obj2)) { + for (var index = 0; index < obj2.length; index++) { + items.push( + _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null" + ); } - l2.right = t2; - l2 = t2; - t2 = t2.right; - } else - break; + delimiters = "[]"; + } else { + Object.keys(obj2).forEach(function(key, index2, array2) { + var keyPart = JSON.stringify(key) + ": "; + var value = _stringify( + obj2[key], + nextIndent, + keyPart.length + comma(array2, index2) + ); + if (value !== void 0) { + items.push(keyPart + value); + } + }); + delimiters = "{}"; + } + if (items.length > 0) { + return [ + delimiters[0], + indent + items.join(",\n" + nextIndent), + delimiters[1] + ].join("\n" + currentIndent); + } } - l2.right = t2.left; - r2.left = t2.right; - t2.left = N2.right; - t2.right = N2.left; - return t2; + return string; + }(obj, "", 0); + } + var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g; + function prettify(string, options2) { + options2 = options2 || {}; + var tokens = { + "{": "{", + "}": "}", + "[": "[", + "]": "]", + ",": ", ", + ":": ": " + }; + if (options2.addMargin || options2.addObjectMargin) { + tokens["{"] = "{ "; + tokens["}"] = " }"; } - function insert(i3, data, t2, comparator) { - var node = new Node(i3, data); - if (t2 === null) { - node.left = node.right = null; - return node; + if (options2.addMargin || options2.addArrayMargin) { + tokens["["] = "[ "; + tokens["]"] = " ]"; + } + return string.replace(stringOrChar, function(match, string2) { + return string2 ? match : tokens[match]; + }); + } + function get4(options2, name, defaultValue) { + return name in options2 ? options2[name] : defaultValue; + } + module2.exports = stringify3; + } + }); + + // node_modules/aes-js/index.js + var require_aes_js = __commonJS({ + "node_modules/aes-js/index.js"(exports2, module2) { + (function(root3) { + "use strict"; + function checkInt(value) { + return parseInt(value) === value; + } + function checkInts(arrayish) { + if (!checkInt(arrayish.length)) { + return false; } - t2 = splay(i3, t2, comparator); - var cmp2 = comparator(i3, t2.key); - if (cmp2 < 0) { - node.left = t2.left; - node.right = t2; - t2.left = null; - } else if (cmp2 >= 0) { - node.right = t2.right; - node.left = t2; - t2.right = null; + for (var i3 = 0; i3 < arrayish.length; i3++) { + if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) { + return false; + } } - return node; + return true; } - function split(key, v2, comparator) { - var left = null; - var right = null; - if (v2) { - v2 = splay(key, v2, comparator); - var cmp2 = comparator(v2.key, key); - if (cmp2 === 0) { - left = v2.left; - right = v2.right; - } else if (cmp2 < 0) { - right = v2.right; - v2.right = null; - left = v2; - } else { - left = v2.left; - v2.left = null; - right = v2; + function coerceArray(arg, copy2) { + if (arg.buffer && arg.name === "Uint8Array") { + if (copy2) { + if (arg.slice) { + arg = arg.slice(); + } else { + arg = Array.prototype.slice.call(arg); + } } + return arg; } - return { - left, - right - }; + if (Array.isArray(arg)) { + if (!checkInts(arg)) { + throw new Error("Array contains invalid value: " + arg); + } + return new Uint8Array(arg); + } + if (checkInt(arg.length) && checkInts(arg)) { + return new Uint8Array(arg); + } + throw new Error("unsupported array-like object"); } - function merge2(left, right, comparator) { - if (right === null) - return left; - if (left === null) - return right; - right = splay(left.key, right, comparator); - right.left = left; - return right; + function createArray(length2) { + return new Uint8Array(length2); } - function printRow(root3, prefix, isTail, out, printNode) { - if (root3) { - out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n"); - var indent2 = prefix + (isTail ? " " : "\u2502 "); - if (root3.left) - printRow(root3.left, indent2, false, out, printNode); - if (root3.right) - printRow(root3.right, indent2, true, out, printNode); + function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { + if (sourceStart != null || sourceEnd != null) { + if (sourceArray.slice) { + sourceArray = sourceArray.slice(sourceStart, sourceEnd); + } else { + sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); + } } + targetArray.set(sourceArray, targetStart); } - var Tree = ( - /** @class */ - function() { - function Tree2(comparator) { - if (comparator === void 0) { - comparator = DEFAULT_COMPARE; + var convertUtf8 = /* @__PURE__ */ function() { + function toBytes(text) { + var result = [], i3 = 0; + text = encodeURI(text); + while (i3 < text.length) { + var c2 = text.charCodeAt(i3++); + if (c2 === 37) { + result.push(parseInt(text.substr(i3, 2), 16)); + i3 += 2; + } else { + result.push(c2); } - this._root = null; - this._size = 0; - this._comparator = comparator; } - Tree2.prototype.insert = function(key, data) { - this._size++; - return this._root = insert(key, data, this._root, this._comparator); - }; - Tree2.prototype.add = function(key, data) { - var node = new Node(key, data); - if (this._root === null) { - node.left = node.right = null; - this._size++; - this._root = node; + return coerceArray(result); + } + function fromBytes(bytes) { + var result = [], i3 = 0; + while (i3 < bytes.length) { + var c2 = bytes[i3]; + if (c2 < 128) { + result.push(String.fromCharCode(c2)); + i3++; + } else if (c2 > 191 && c2 < 224) { + result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63)); + i3 += 2; + } else { + result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63)); + i3 += 3; } - var comparator = this._comparator; - var t2 = splay(key, this._root, comparator); - var cmp2 = comparator(key, t2.key); - if (cmp2 === 0) - this._root = t2; - else { - if (cmp2 < 0) { - node.left = t2.left; - node.right = t2; - t2.left = null; - } else if (cmp2 > 0) { - node.right = t2.right; - node.left = t2; - t2.right = null; - } - this._size++; - this._root = node; + } + return result.join(""); + } + return { + toBytes, + fromBytes + }; + }(); + var convertHex = /* @__PURE__ */ function() { + function toBytes(text) { + var result = []; + for (var i3 = 0; i3 < text.length; i3 += 2) { + result.push(parseInt(text.substr(i3, 2), 16)); + } + return result; + } + var Hex = "0123456789abcdef"; + function fromBytes(bytes) { + var result = []; + for (var i3 = 0; i3 < bytes.length; i3++) { + var v2 = bytes[i3]; + result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]); + } + return result.join(""); + } + return { + toBytes, + fromBytes + }; + }(); + var numberOfRounds = { 16: 10, 24: 12, 32: 14 }; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + 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]; + function convertToInt32(bytes) { + var result = []; + for (var i3 = 0; i3 < bytes.length; i3 += 4) { + result.push( + bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3] + ); + } + return result; + } + var AES = function(key) { + if (!(this instanceof AES)) { + throw Error("AES must be instanitated with `new`"); + } + Object.defineProperty(this, "key", { + value: coerceArray(key, true) + }); + this._prepare(); + }; + AES.prototype._prepare = function() { + var rounds = numberOfRounds[this.key.length]; + if (rounds == null) { + throw new Error("invalid key size (must be 16, 24 or 32 bytes)"); + } + this._Ke = []; + this._Kd = []; + for (var i3 = 0; i3 <= rounds; i3++) { + this._Ke.push([0, 0, 0, 0]); + this._Kd.push([0, 0, 0, 0]); + } + var roundKeyCount = (rounds + 1) * 4; + var KC = this.key.length / 4; + var tk = convertToInt32(this.key); + var index; + for (var i3 = 0; i3 < KC; i3++) { + index = i3 >> 2; + this._Ke[index][i3 % 4] = tk[i3]; + this._Kd[rounds - index][i3 % 4] = tk[i3]; + } + var rconpointer = 0; + var t2 = KC, tt2; + while (t2 < roundKeyCount) { + tt2 = tk[KC - 1]; + tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24; + rconpointer += 1; + if (KC != 8) { + for (var i3 = 1; i3 < KC; i3++) { + tk[i3] ^= tk[i3 - 1]; } - return this._root; - }; - Tree2.prototype.remove = function(key) { - this._root = this._remove(key, this._root, this._comparator); - }; - Tree2.prototype._remove = function(i3, t2, comparator) { - var x2; - if (t2 === null) - return null; - t2 = splay(i3, t2, comparator); - var cmp2 = comparator(i3, t2.key); - if (cmp2 === 0) { - if (t2.left === null) { - x2 = t2.right; - } else { - x2 = splay(i3, t2.left, comparator); - x2.right = t2.right; - } - this._size--; - return x2; - } - return t2; - }; - Tree2.prototype.pop = function() { - var node = this._root; - if (node) { - while (node.left) { - node = node.left; - } - this._root = splay(node.key, this._root, this._comparator); - this._root = this._remove(node.key, this._root, this._comparator); - return { - key: node.key, - data: node.data - }; - } - return null; - }; - Tree2.prototype.findStatic = function(key) { - var current = this._root; - var compare = this._comparator; - while (current) { - var cmp2 = compare(key, current.key); - if (cmp2 === 0) - return current; - else if (cmp2 < 0) - current = current.left; - else - current = current.right; - } - return null; - }; - Tree2.prototype.find = function(key) { - if (this._root) { - this._root = splay(key, this._root, this._comparator); - if (this._comparator(key, this._root.key) !== 0) - return null; - } - return this._root; - }; - Tree2.prototype.contains = function(key) { - var current = this._root; - var compare = this._comparator; - while (current) { - var cmp2 = compare(key, current.key); - if (cmp2 === 0) - return true; - else if (cmp2 < 0) - current = current.left; - else - current = current.right; - } - return false; - }; - Tree2.prototype.forEach = function(visitor, ctx) { - var current = this._root; - var Q2 = []; - var done = false; - while (!done) { - if (current !== null) { - Q2.push(current); - current = current.left; - } else { - if (Q2.length !== 0) { - current = Q2.pop(); - visitor.call(ctx, current); - current = current.right; - } else - done = true; - } - } - return this; - }; - Tree2.prototype.range = function(low, high, fn, ctx) { - var Q2 = []; - var compare = this._comparator; - var node = this._root; - var cmp2; - while (Q2.length !== 0 || node) { - if (node) { - Q2.push(node); - node = node.left; - } else { - node = Q2.pop(); - cmp2 = compare(node.key, high); - if (cmp2 > 0) { - break; - } else if (compare(node.key, low) >= 0) { - if (fn.call(ctx, node)) - return this; - } - node = node.right; - } - } - return this; - }; - Tree2.prototype.keys = function() { - var keys2 = []; - this.forEach(function(_a) { - var key = _a.key; - return keys2.push(key); - }); - return keys2; - }; - Tree2.prototype.values = function() { - var values = []; - this.forEach(function(_a) { - var data = _a.data; - return values.push(data); - }); - return values; - }; - Tree2.prototype.min = function() { - if (this._root) - return this.minNode(this._root).key; - return null; - }; - Tree2.prototype.max = function() { - if (this._root) - return this.maxNode(this._root).key; - return null; - }; - Tree2.prototype.minNode = function(t2) { - if (t2 === void 0) { - t2 = this._root; - } - if (t2) - while (t2.left) { - t2 = t2.left; - } - return t2; - }; - Tree2.prototype.maxNode = function(t2) { - if (t2 === void 0) { - t2 = this._root; - } - if (t2) - while (t2.right) { - t2 = t2.right; - } - return t2; - }; - Tree2.prototype.at = function(index2) { - var current = this._root; - var done = false; - var i3 = 0; - var Q2 = []; - while (!done) { - if (current) { - Q2.push(current); - current = current.left; - } else { - if (Q2.length > 0) { - current = Q2.pop(); - if (i3 === index2) - return current; - i3++; - current = current.right; - } else - done = true; - } - } - return null; - }; - Tree2.prototype.next = function(d2) { - var root3 = this._root; - var successor = null; - if (d2.right) { - successor = d2.right; - while (successor.left) { - successor = successor.left; - } - return successor; - } - var comparator = this._comparator; - while (root3) { - var cmp2 = comparator(d2.key, root3.key); - if (cmp2 === 0) - break; - else if (cmp2 < 0) { - successor = root3; - root3 = root3.left; - } else - root3 = root3.right; - } - return successor; - }; - Tree2.prototype.prev = function(d2) { - var root3 = this._root; - var predecessor = null; - if (d2.left !== null) { - predecessor = d2.left; - while (predecessor.right) { - predecessor = predecessor.right; - } - return predecessor; - } - var comparator = this._comparator; - while (root3) { - var cmp2 = comparator(d2.key, root3.key); - if (cmp2 === 0) - break; - else if (cmp2 < 0) - root3 = root3.left; - else { - predecessor = root3; - root3 = root3.right; - } - } - return predecessor; - }; - Tree2.prototype.clear = function() { - this._root = null; - this._size = 0; - return this; - }; - Tree2.prototype.toList = function() { - return toList(this._root); - }; - Tree2.prototype.load = function(keys2, values, presort) { - if (values === void 0) { - values = []; - } - if (presort === void 0) { - presort = false; - } - var size = keys2.length; - var comparator = this._comparator; - if (presort) - sort(keys2, values, 0, size - 1, comparator); - if (this._root === null) { - this._root = loadRecursive(keys2, values, 0, size); - this._size = size; - } else { - var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator); - size = this._size + size; - this._root = sortedListToBST({ - head: mergedList - }, 0, size); - } - return this; - }; - Tree2.prototype.isEmpty = function() { - return this._root === null; - }; - Object.defineProperty(Tree2.prototype, "size", { - get: function get4() { - return this._size; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Tree2.prototype, "root", { - get: function get4() { - return this._root; - }, - enumerable: true, - configurable: true - }); - Tree2.prototype.toString = function(printNode) { - if (printNode === void 0) { - printNode = function printNode2(n3) { - return String(n3.key); - }; + } else { + for (var i3 = 1; i3 < KC / 2; i3++) { + tk[i3] ^= tk[i3 - 1]; } - var out = []; - printRow(this._root, "", true, function(v2) { - return out.push(v2); - }, printNode); - return out.join(""); - }; - Tree2.prototype.update = function(key, newKey, newData) { - var comparator = this._comparator; - var _a = split(key, this._root, comparator), left = _a.left, right = _a.right; - if (comparator(key, newKey) < 0) { - right = insert(newKey, newData, right, comparator); - } else { - left = insert(newKey, newData, left, comparator); + tt2 = tk[KC / 2 - 1]; + tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24; + for (var i3 = KC / 2 + 1; i3 < KC; i3++) { + tk[i3] ^= tk[i3 - 1]; } - this._root = merge2(left, right, comparator); - }; - Tree2.prototype.split = function(key) { - return split(key, this._root, this._comparator); - }; - return Tree2; - }() - ); - function loadRecursive(keys2, values, start2, end) { - var size = end - start2; - if (size > 0) { - var middle = start2 + Math.floor(size / 2); - var key = keys2[middle]; - var data = values[middle]; - var node = new Node(key, data); - node.left = loadRecursive(keys2, values, start2, middle); - node.right = loadRecursive(keys2, values, middle + 1, end); - return node; - } - return null; - } - function createList(keys2, values) { - var head = new Node(null, null); - var p2 = head; - for (var i3 = 0; i3 < keys2.length; i3++) { - p2 = p2.next = new Node(keys2[i3], values[i3]); - } - p2.next = null; - return head.next; - } - function toList(root3) { - var current = root3; - var Q2 = []; - var done = false; - var head = new Node(null, null); - var p2 = head; - while (!done) { - if (current) { - Q2.push(current); - current = current.left; - } else { - if (Q2.length > 0) { - current = p2 = p2.next = Q2.pop(); - current = current.right; - } else - done = true; + } + var i3 = 0, r2, c2; + while (i3 < KC && t2 < roundKeyCount) { + r2 = t2 >> 2; + c2 = t2 % 4; + this._Ke[r2][c2] = tk[i3]; + this._Kd[rounds - r2][c2] = tk[i3++]; + t2++; } } - p2.next = null; - return head.next; - } - function sortedListToBST(list, start2, end) { - var size = end - start2; - if (size > 0) { - var middle = start2 + Math.floor(size / 2); - var left = sortedListToBST(list, start2, middle); - var root3 = list.head; - root3.left = left; - list.head = list.head.next; - root3.right = sortedListToBST(list, middle + 1, end); - return root3; - } - return null; - } - function mergeLists(l1, l2, compare) { - var head = new Node(null, null); - var p2 = head; - var p1 = l1; - var p22 = l2; - while (p1 !== null && p22 !== null) { - if (compare(p1.key, p22.key) < 0) { - p2.next = p1; - p1 = p1.next; - } else { - p2.next = p22; - p22 = p22.next; + for (var r2 = 1; r2 < rounds; r2++) { + for (var c2 = 0; c2 < 4; c2++) { + tt2 = this._Kd[r2][c2]; + this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255]; } - p2 = p2.next; } - if (p1 !== null) { - p2.next = p1; - } else if (p22 !== null) { - p2.next = p22; + }; + AES.prototype.encrypt = function(plaintext) { + if (plaintext.length != 16) { + throw new Error("invalid plaintext size (must be 16 bytes)"); } - return head.next; - } - function sort(keys2, values, left, right, compare) { - if (left >= right) - return; - var pivot = keys2[left + right >> 1]; - var i3 = left - 1; - var j3 = right + 1; - while (true) { - do { - i3++; - } while (compare(keys2[i3], pivot) < 0); - do { - j3--; - } while (compare(keys2[j3], pivot) > 0); - if (i3 >= j3) - break; - var tmp = keys2[i3]; - keys2[i3] = keys2[j3]; - keys2[j3] = tmp; - tmp = values[i3]; - values[i3] = values[j3]; - values[j3] = tmp; + var rounds = this._Ke.length - 1; + var a2 = [0, 0, 0, 0]; + var t2 = convertToInt32(plaintext); + for (var i3 = 0; i3 < 4; i3++) { + t2[i3] ^= this._Ke[0][i3]; } - sort(keys2, values, left, j3, compare); - sort(keys2, values, j3 + 1, right, compare); - } - var isInBbox = function isInBbox2(bbox2, point2) { - return bbox2.ll.x <= point2.x && point2.x <= bbox2.ur.x && bbox2.ll.y <= point2.y && point2.y <= bbox2.ur.y; - }; - var getBboxOverlap = function getBboxOverlap2(b1, b2) { - 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; - var lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x; - var upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x; - var lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y; - var upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y; - return { - ll: { - x: lowerX, - y: lowerY - }, - ur: { - x: upperX, - y: upperY - } - }; - }; - var epsilon3 = Number.EPSILON; - if (epsilon3 === void 0) - epsilon3 = Math.pow(2, -52); - var EPSILON_SQ = epsilon3 * epsilon3; - var cmp = function cmp2(a2, b2) { - if (-epsilon3 < a2 && a2 < epsilon3) { - if (-epsilon3 < b2 && b2 < epsilon3) { - return 0; + for (var r2 = 1; r2 < rounds; r2++) { + for (var i3 = 0; i3 < 4; i3++) { + 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]; } + t2 = a2.slice(); } - var ab = a2 - b2; - if (ab * ab < EPSILON_SQ * a2 * b2) { - return 0; + var result = createArray(16), tt2; + for (var i3 = 0; i3 < 4; i3++) { + tt2 = this._Ke[rounds][i3]; + result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255; + result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255; + result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255; + result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255; } - return a2 < b2 ? -1 : 1; + return result; }; - var PtRounder = /* @__PURE__ */ function() { - function PtRounder2() { - _classCallCheck(this, PtRounder2); - this.reset(); + AES.prototype.decrypt = function(ciphertext) { + if (ciphertext.length != 16) { + throw new Error("invalid ciphertext size (must be 16 bytes)"); } - _createClass(PtRounder2, [{ - key: "reset", - value: function reset() { - this.xRounder = new CoordRounder(); - this.yRounder = new CoordRounder(); - } - }, { - key: "round", - value: function round(x2, y2) { - return { - x: this.xRounder.round(x2), - y: this.yRounder.round(y2) - }; - } - }]); - return PtRounder2; - }(); - var CoordRounder = /* @__PURE__ */ function() { - function CoordRounder2() { - _classCallCheck(this, CoordRounder2); - this.tree = new Tree(); - this.round(0); + var rounds = this._Kd.length - 1; + var a2 = [0, 0, 0, 0]; + var t2 = convertToInt32(ciphertext); + for (var i3 = 0; i3 < 4; i3++) { + t2[i3] ^= this._Kd[0][i3]; } - _createClass(CoordRounder2, [{ - key: "round", - value: function round(coord2) { - var node = this.tree.add(coord2); - var prevNode = this.tree.prev(node); - if (prevNode !== null && cmp(node.key, prevNode.key) === 0) { - this.tree.remove(coord2); - return prevNode.key; - } - var nextNode = this.tree.next(node); - if (nextNode !== null && cmp(node.key, nextNode.key) === 0) { - this.tree.remove(coord2); - return nextNode.key; - } - return coord2; + for (var r2 = 1; r2 < rounds; r2++) { + for (var i3 = 0; i3 < 4; i3++) { + 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]; } - }]); - return CoordRounder2; - }(); - var rounder = new PtRounder(); - var crossProduct = function crossProduct2(a2, b2) { - return a2.x * b2.y - a2.y * b2.x; + t2 = a2.slice(); + } + var result = createArray(16), tt2; + for (var i3 = 0; i3 < 4; i3++) { + tt2 = this._Kd[rounds][i3]; + result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255; + result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255; + result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255; + result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255; + } + return result; }; - var dotProduct = function dotProduct2(a2, b2) { - return a2.x * b2.x + a2.y * b2.y; + var ModeOfOperationECB = function(key) { + if (!(this instanceof ModeOfOperationECB)) { + throw Error("AES must be instanitated with `new`"); + } + this.description = "Electronic Code Block"; + this.name = "ecb"; + this._aes = new AES(key); }; - var compareVectorAngles = function compareVectorAngles2(basePt, endPt1, endPt2) { - var v1 = { - x: endPt1.x - basePt.x, - y: endPt1.y - basePt.y - }; - var v2 = { - x: endPt2.x - basePt.x, - y: endPt2.y - basePt.y - }; - var kross = crossProduct(v1, v2); - return cmp(kross, 0); + ModeOfOperationECB.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + if (plaintext.length % 16 !== 0) { + throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); + } + var ciphertext = createArray(plaintext.length); + var block2 = createArray(16); + for (var i3 = 0; i3 < plaintext.length; i3 += 16) { + copyArray(plaintext, block2, 0, i3, i3 + 16); + block2 = this._aes.encrypt(block2); + copyArray(block2, ciphertext, i3); + } + return ciphertext; }; - var length = function length2(v2) { - return Math.sqrt(dotProduct(v2, v2)); + ModeOfOperationECB.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + if (ciphertext.length % 16 !== 0) { + throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); + } + var plaintext = createArray(ciphertext.length); + var block2 = createArray(16); + for (var i3 = 0; i3 < ciphertext.length; i3 += 16) { + copyArray(ciphertext, block2, 0, i3, i3 + 16); + block2 = this._aes.decrypt(block2); + copyArray(block2, plaintext, i3); + } + return plaintext; }; - var sineOfAngle = function sineOfAngle2(pShared, pBase, pAngle) { - var vBase = { - x: pBase.x - pShared.x, - y: pBase.y - pShared.y - }; - var vAngle = { - x: pAngle.x - pShared.x, - y: pAngle.y - pShared.y - }; - return crossProduct(vAngle, vBase) / length(vAngle) / length(vBase); + var ModeOfOperationCBC = function(key, iv) { + if (!(this instanceof ModeOfOperationCBC)) { + throw Error("AES must be instanitated with `new`"); + } + this.description = "Cipher Block Chaining"; + this.name = "cbc"; + if (!iv) { + iv = createArray(16); + } else if (iv.length != 16) { + throw new Error("invalid initialation vector size (must be 16 bytes)"); + } + this._lastCipherblock = coerceArray(iv, true); + this._aes = new AES(key); }; - var cosineOfAngle = function cosineOfAngle2(pShared, pBase, pAngle) { - var vBase = { - x: pBase.x - pShared.x, - y: pBase.y - pShared.y - }; - var vAngle = { - x: pAngle.x - pShared.x, - y: pAngle.y - pShared.y - }; - return dotProduct(vAngle, vBase) / length(vAngle) / length(vBase); - }; - var horizontalIntersection = function horizontalIntersection2(pt2, v2, y2) { - if (v2.y === 0) - return null; - return { - x: pt2.x + v2.x / v2.y * (y2 - pt2.y), - y: y2 - }; - }; - var verticalIntersection = function verticalIntersection2(pt2, v2, x2) { - if (v2.x === 0) - return null; - return { - x: x2, - y: pt2.y + v2.y / v2.x * (x2 - pt2.x) - }; - }; - var intersection = function intersection2(pt1, v1, pt2, v2) { - if (v1.x === 0) - return verticalIntersection(pt2, v2, pt1.x); - if (v2.x === 0) - return verticalIntersection(pt1, v1, pt2.x); - if (v1.y === 0) - return horizontalIntersection(pt2, v2, pt1.y); - if (v2.y === 0) - return horizontalIntersection(pt1, v1, pt2.y); - var kross = crossProduct(v1, v2); - if (kross == 0) - return null; - var ve2 = { - x: pt2.x - pt1.x, - y: pt2.y - pt1.y - }; - var d1 = crossProduct(ve2, v1) / kross; - var d2 = crossProduct(ve2, v2) / kross; - var x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x; - var y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y; - var x3 = (x12 + x2) / 2; - var y3 = (y12 + y2) / 2; - return { - x: x3, - y: y3 - }; - }; - var SweepEvent = /* @__PURE__ */ function() { - _createClass(SweepEvent2, null, [{ - key: "compare", - // for ordering sweep events in the sweep event queue - value: function compare(a2, b2) { - var ptCmp = SweepEvent2.comparePoints(a2.point, b2.point); - if (ptCmp !== 0) - return ptCmp; - if (a2.point !== b2.point) - a2.link(b2); - if (a2.isLeft !== b2.isLeft) - return a2.isLeft ? 1 : -1; - return Segment.compare(a2.segment, b2.segment); - } - // for ordering points in sweep line order - }, { - key: "comparePoints", - value: function comparePoints(aPt, bPt) { - if (aPt.x < bPt.x) - return -1; - if (aPt.x > bPt.x) - return 1; - if (aPt.y < bPt.y) - return -1; - if (aPt.y > bPt.y) - return 1; - return 0; - } - // Warning: 'point' input will be modified and re-used (for performance) - }]); - function SweepEvent2(point2, isLeft) { - _classCallCheck(this, SweepEvent2); - if (point2.events === void 0) - point2.events = [this]; - else - point2.events.push(this); - this.point = point2; - this.isLeft = isLeft; + ModeOfOperationCBC.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + if (plaintext.length % 16 !== 0) { + throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); } - _createClass(SweepEvent2, [{ - key: "link", - value: function link2(other) { - if (other.point === this.point) { - throw new Error("Tried to link already linked events"); - } - var otherEvents = other.point.events; - for (var i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) { - var evt = otherEvents[i3]; - this.point.events.push(evt); - evt.point = this.point; - } - this.checkForConsuming(); - } - /* Do a pass over our linked events and check to see if any pair - * of segments match, and should be consumed. */ - }, { - key: "checkForConsuming", - value: function checkForConsuming() { - var numEvents = this.point.events.length; - for (var i3 = 0; i3 < numEvents; i3++) { - var evt1 = this.point.events[i3]; - if (evt1.segment.consumedBy !== void 0) - continue; - for (var j3 = i3 + 1; j3 < numEvents; j3++) { - var evt2 = this.point.events[j3]; - if (evt2.consumedBy !== void 0) - continue; - if (evt1.otherSE.point.events !== evt2.otherSE.point.events) - continue; - evt1.segment.consume(evt2.segment); - } - } - } - }, { - key: "getAvailableLinkedEvents", - value: function getAvailableLinkedEvents() { - var events = []; - for (var i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) { - var evt = this.point.events[i3]; - if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) { - events.push(evt); - } - } - return events; - } - /** - * Returns a comparator function for sorting linked events that will - * favor the event that will give us the smallest left-side angle. - * All ring construction starts as low as possible heading to the right, - * so by always turning left as sharp as possible we'll get polygons - * without uncessary loops & holes. - * - * The comparator function has a compute cache such that it avoids - * re-computing already-computed values. - */ - }, { - key: "getLeftmostComparator", - value: function getLeftmostComparator(baseEvent) { - var _this = this; - var cache = /* @__PURE__ */ new Map(); - var fillCache = function fillCache2(linkedEvent) { - var nextEvent = linkedEvent.otherSE; - cache.set(linkedEvent, { - sine: sineOfAngle(_this.point, baseEvent.point, nextEvent.point), - cosine: cosineOfAngle(_this.point, baseEvent.point, nextEvent.point) - }); - }; - return function(a2, b2) { - if (!cache.has(a2)) - fillCache(a2); - if (!cache.has(b2)) - fillCache(b2); - var _cache$get = cache.get(a2), asine = _cache$get.sine, acosine = _cache$get.cosine; - var _cache$get2 = cache.get(b2), bsine = _cache$get2.sine, bcosine = _cache$get2.cosine; - if (asine >= 0 && bsine >= 0) { - if (acosine < bcosine) - return 1; - if (acosine > bcosine) - return -1; - return 0; - } - if (asine < 0 && bsine < 0) { - if (acosine < bcosine) - return -1; - if (acosine > bcosine) - return 1; - return 0; - } - if (bsine < asine) - return -1; - if (bsine > asine) - return 1; - return 0; - }; - } - }]); - return SweepEvent2; - }(); - var segmentId = 0; - var Segment = /* @__PURE__ */ function() { - _createClass(Segment2, null, [{ - key: "compare", - /* This compare() function is for ordering segments in the sweep - * line tree, and does so according to the following criteria: - * - * Consider the vertical line that lies an infinestimal step to the - * right of the right-more of the two left endpoints of the input - * segments. Imagine slowly moving a point up from negative infinity - * in the increasing y direction. Which of the two segments will that - * point intersect first? That segment comes 'before' the other one. - * - * If neither segment would be intersected by such a line, (if one - * or more of the segments are vertical) then the line to be considered - * is directly on the right-more of the two left inputs. - */ - value: function compare(a2, b2) { - var alx = a2.leftSE.point.x; - var blx = b2.leftSE.point.x; - var arx = a2.rightSE.point.x; - var brx = b2.rightSE.point.x; - if (brx < alx) - return 1; - if (arx < blx) - return -1; - var aly = a2.leftSE.point.y; - var bly = b2.leftSE.point.y; - var ary = a2.rightSE.point.y; - var bry = b2.rightSE.point.y; - if (alx < blx) { - if (bly < aly && bly < ary) - return 1; - if (bly > aly && bly > ary) - return -1; - var aCmpBLeft = a2.comparePoint(b2.leftSE.point); - if (aCmpBLeft < 0) - return 1; - if (aCmpBLeft > 0) - return -1; - var bCmpARight = b2.comparePoint(a2.rightSE.point); - if (bCmpARight !== 0) - return bCmpARight; - return -1; - } - if (alx > blx) { - if (aly < bly && aly < bry) - return -1; - if (aly > bly && aly > bry) - return 1; - var bCmpALeft = b2.comparePoint(a2.leftSE.point); - if (bCmpALeft !== 0) - return bCmpALeft; - var aCmpBRight = a2.comparePoint(b2.rightSE.point); - if (aCmpBRight < 0) - return 1; - if (aCmpBRight > 0) - return -1; - return 1; - } - if (aly < bly) - return -1; - if (aly > bly) - return 1; - if (arx < brx) { - var _bCmpARight = b2.comparePoint(a2.rightSE.point); - if (_bCmpARight !== 0) - return _bCmpARight; - } - if (arx > brx) { - var _aCmpBRight = a2.comparePoint(b2.rightSE.point); - if (_aCmpBRight < 0) - return 1; - if (_aCmpBRight > 0) - return -1; - } - if (arx !== brx) { - var ay = ary - aly; - var ax = arx - alx; - var by = bry - bly; - var bx = brx - blx; - if (ay > ax && by < bx) - return 1; - if (ay < ax && by > bx) - return -1; - } - if (arx > brx) - return 1; - if (arx < brx) - return -1; - if (ary < bry) - return -1; - if (ary > bry) - return 1; - if (a2.id < b2.id) - return -1; - if (a2.id > b2.id) - return 1; - return 0; + var ciphertext = createArray(plaintext.length); + var block2 = createArray(16); + for (var i3 = 0; i3 < plaintext.length; i3 += 16) { + copyArray(plaintext, block2, 0, i3, i3 + 16); + for (var j2 = 0; j2 < 16; j2++) { + block2[j2] ^= this._lastCipherblock[j2]; } - /* Warning: a reference to ringWindings input will be stored, - * and possibly will be later modified */ - }]); - function Segment2(leftSE, rightSE, rings, windings) { - _classCallCheck(this, Segment2); - this.id = ++segmentId; - this.leftSE = leftSE; - leftSE.segment = this; - leftSE.otherSE = rightSE; - this.rightSE = rightSE; - rightSE.segment = this; - rightSE.otherSE = leftSE; - this.rings = rings; - this.windings = windings; + this._lastCipherblock = this._aes.encrypt(block2); + copyArray(this._lastCipherblock, ciphertext, i3); } - _createClass(Segment2, [{ - key: "replaceRightSE", - /* When a segment is split, the rightSE is replaced with a new sweep event */ - value: function replaceRightSE(newRightSE) { - this.rightSE = newRightSE; - this.rightSE.segment = this; - this.rightSE.otherSE = this.leftSE; - this.leftSE.otherSE = this.rightSE; - } - }, { - key: "bbox", - value: function bbox2() { - var y12 = this.leftSE.point.y; - var y2 = this.rightSE.point.y; - return { - ll: { - x: this.leftSE.point.x, - y: y12 < y2 ? y12 : y2 - }, - ur: { - x: this.rightSE.point.x, - y: y12 > y2 ? y12 : y2 - } - }; - } - /* A vector from the left point to the right */ - }, { - key: "vector", - value: function vector() { - return { - x: this.rightSE.point.x - this.leftSE.point.x, - y: this.rightSE.point.y - this.leftSE.point.y - }; - } - }, { - key: "isAnEndpoint", - value: function isAnEndpoint(pt2) { - 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; - } - /* Compare this segment with a point. - * - * A point P is considered to be colinear to a segment if there - * exists a distance D such that if we travel along the segment - * from one * endpoint towards the other a distance D, we find - * ourselves at point P. - * - * Return value indicates: - * - * 1: point lies above the segment (to the left of vertical) - * 0: point is colinear to segment - * -1: point lies below the segment (to the right of vertical) - */ - }, { - key: "comparePoint", - value: function comparePoint(point2) { - if (this.isAnEndpoint(point2)) - return 0; - var lPt = this.leftSE.point; - var rPt = this.rightSE.point; - var v2 = this.vector(); - if (lPt.x === rPt.x) { - if (point2.x === lPt.x) - return 0; - return point2.x < lPt.x ? 1 : -1; - } - var yDist = (point2.y - lPt.y) / v2.y; - var xFromYDist = lPt.x + yDist * v2.x; - if (point2.x === xFromYDist) - return 0; - var xDist = (point2.x - lPt.x) / v2.x; - var yFromXDist = lPt.y + xDist * v2.y; - if (point2.y === yFromXDist) - return 0; - return point2.y < yFromXDist ? -1 : 1; - } - /** - * Given another segment, returns the first non-trivial intersection - * between the two segments (in terms of sweep line ordering), if it exists. - * - * A 'non-trivial' intersection is one that will cause one or both of the - * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection: - * - * * endpoint of segA with endpoint of segB --> trivial - * * endpoint of segA with point along segB --> non-trivial - * * endpoint of segB with point along segA --> non-trivial - * * point along segA with point along segB --> non-trivial - * - * If no non-trivial intersection exists, return null - * Else, return null. - */ - }, { - key: "getIntersection", - value: function getIntersection(other) { - var tBbox = this.bbox(); - var oBbox = other.bbox(); - var bboxOverlap = getBboxOverlap(tBbox, oBbox); - if (bboxOverlap === null) - return null; - var tlp = this.leftSE.point; - var trp = this.rightSE.point; - var olp = other.leftSE.point; - var orp = other.rightSE.point; - var touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0; - var touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0; - var touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0; - var touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0; - if (touchesThisLSE && touchesOtherLSE) { - if (touchesThisRSE && !touchesOtherRSE) - return trp; - if (!touchesThisRSE && touchesOtherRSE) - return orp; - return null; - } - if (touchesThisLSE) { - if (touchesOtherRSE) { - if (tlp.x === orp.x && tlp.y === orp.y) - return null; - } - return tlp; - } - if (touchesOtherLSE) { - if (touchesThisRSE) { - if (trp.x === olp.x && trp.y === olp.y) - return null; - } - return olp; - } - if (touchesThisRSE && touchesOtherRSE) - return null; - if (touchesThisRSE) - return trp; - if (touchesOtherRSE) - return orp; - var pt2 = intersection(tlp, this.vector(), olp, other.vector()); - if (pt2 === null) - return null; - if (!isInBbox(bboxOverlap, pt2)) - return null; - return rounder.round(pt2.x, pt2.y); - } - /** - * Split the given segment into multiple segments on the given points. - * * Each existing segment will retain its leftSE and a new rightSE will be - * generated for it. - * * A new segment will be generated which will adopt the original segment's - * rightSE, and a new leftSE will be generated for it. - * * If there are more than two points given to split on, new segments - * in the middle will be generated with new leftSE and rightSE's. - * * An array of the newly generated SweepEvents will be returned. - * - * Warning: input array of points is modified - */ - }, { - key: "split", - value: function split2(point2) { - var newEvents = []; - var alreadyLinked = point2.events !== void 0; - var newLeftSE = new SweepEvent(point2, true); - var newRightSE = new SweepEvent(point2, false); - var oldRightSE = this.rightSE; - this.replaceRightSE(newRightSE); - newEvents.push(newRightSE); - newEvents.push(newLeftSE); - var newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice()); - if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) { - newSeg.swapEvents(); - } - if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) { - this.swapEvents(); - } - if (alreadyLinked) { - newLeftSE.checkForConsuming(); - newRightSE.checkForConsuming(); - } - return newEvents; - } - /* Swap which event is left and right */ - }, { - key: "swapEvents", - value: function swapEvents() { - var tmpEvt = this.rightSE; - this.rightSE = this.leftSE; - this.leftSE = tmpEvt; - this.leftSE.isLeft = true; - this.rightSE.isLeft = false; - for (var i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) { - this.windings[i3] *= -1; - } - } - /* Consume another segment. We take their rings under our wing - * and mark them as consumed. Use for perfectly overlapping segments */ - }, { - key: "consume", - value: function consume(other) { - var consumer = this; - var consumee = other; - while (consumer.consumedBy) { - consumer = consumer.consumedBy; - } - while (consumee.consumedBy) { - consumee = consumee.consumedBy; - } - var cmp2 = Segment2.compare(consumer, consumee); - if (cmp2 === 0) - return; - if (cmp2 > 0) { - var tmp = consumer; - consumer = consumee; - consumee = tmp; - } - if (consumer.prev === consumee) { - var _tmp = consumer; - consumer = consumee; - consumee = _tmp; - } - for (var i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) { - var ring = consumee.rings[i3]; - var winding = consumee.windings[i3]; - var index2 = consumer.rings.indexOf(ring); - if (index2 === -1) { - consumer.rings.push(ring); - consumer.windings.push(winding); - } else - consumer.windings[index2] += winding; - } - consumee.rings = null; - consumee.windings = null; - consumee.consumedBy = consumer; - consumee.leftSE.consumedBy = consumer.leftSE; - consumee.rightSE.consumedBy = consumer.rightSE; - } - /* The first segment previous segment chain that is in the result */ - }, { - key: "prevInResult", - value: function prevInResult() { - if (this._prevInResult !== void 0) - return this._prevInResult; - if (!this.prev) - this._prevInResult = null; - else if (this.prev.isInResult()) - this._prevInResult = this.prev; - else - this._prevInResult = this.prev.prevInResult(); - return this._prevInResult; - } - }, { - key: "beforeState", - value: function beforeState() { - if (this._beforeState !== void 0) - return this._beforeState; - if (!this.prev) - this._beforeState = { - rings: [], - windings: [], - multiPolys: [] - }; - else { - var seg = this.prev.consumedBy || this.prev; - this._beforeState = seg.afterState(); - } - return this._beforeState; - } - }, { - key: "afterState", - value: function afterState() { - if (this._afterState !== void 0) - return this._afterState; - var beforeState = this.beforeState(); - this._afterState = { - rings: beforeState.rings.slice(0), - windings: beforeState.windings.slice(0), - multiPolys: [] - }; - var ringsAfter = this._afterState.rings; - var windingsAfter = this._afterState.windings; - var mpsAfter = this._afterState.multiPolys; - for (var i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) { - var ring = this.rings[i3]; - var winding = this.windings[i3]; - var index2 = ringsAfter.indexOf(ring); - if (index2 === -1) { - ringsAfter.push(ring); - windingsAfter.push(winding); - } else - windingsAfter[index2] += winding; - } - var polysAfter = []; - var polysExclude = []; - for (var _i = 0, _iMax = ringsAfter.length; _i < _iMax; _i++) { - if (windingsAfter[_i] === 0) - continue; - var _ring = ringsAfter[_i]; - var poly = _ring.poly; - if (polysExclude.indexOf(poly) !== -1) - continue; - if (_ring.isExterior) - polysAfter.push(poly); - else { - if (polysExclude.indexOf(poly) === -1) - polysExclude.push(poly); - var _index = polysAfter.indexOf(_ring.poly); - if (_index !== -1) - polysAfter.splice(_index, 1); - } - } - for (var _i2 = 0, _iMax2 = polysAfter.length; _i2 < _iMax2; _i2++) { - var mp = polysAfter[_i2].multiPoly; - if (mpsAfter.indexOf(mp) === -1) - mpsAfter.push(mp); - } - return this._afterState; - } - /* Is this segment part of the final result? */ - }, { - key: "isInResult", - value: function isInResult() { - if (this.consumedBy) - return false; - if (this._isInResult !== void 0) - return this._isInResult; - var mpsBefore = this.beforeState().multiPolys; - var mpsAfter = this.afterState().multiPolys; - switch (operation.type) { - case "union": { - var noBefores = mpsBefore.length === 0; - var noAfters = mpsAfter.length === 0; - this._isInResult = noBefores !== noAfters; - break; - } - case "intersection": { - var least; - var most; - if (mpsBefore.length < mpsAfter.length) { - least = mpsBefore.length; - most = mpsAfter.length; - } else { - least = mpsAfter.length; - most = mpsBefore.length; - } - this._isInResult = most === operation.numMultiPolys && least < most; - break; - } - case "xor": { - var diff = Math.abs(mpsBefore.length - mpsAfter.length); - this._isInResult = diff % 2 === 1; - break; - } - case "difference": { - var isJustSubject = function isJustSubject2(mps) { - return mps.length === 1 && mps[0].isSubject; - }; - this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter); - break; - } - default: - throw new Error("Unrecognized operation type found ".concat(operation.type)); - } - return this._isInResult; - } - }], [{ - key: "fromRing", - value: function fromRing(pt1, pt2, ring) { - var leftPt, rightPt, winding; - var cmpPts = SweepEvent.comparePoints(pt1, pt2); - if (cmpPts < 0) { - leftPt = pt1; - rightPt = pt2; - winding = 1; - } else if (cmpPts > 0) { - leftPt = pt2; - rightPt = pt1; - winding = -1; - } else - throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]")); - var leftSE = new SweepEvent(leftPt, true); - var rightSE = new SweepEvent(rightPt, false); - return new Segment2(leftSE, rightSE, [ring], [winding]); - } - }]); - return Segment2; - }(); - var RingIn = /* @__PURE__ */ function() { - function RingIn2(geomRing, poly, isExterior) { - _classCallCheck(this, RingIn2); - if (!Array.isArray(geomRing) || geomRing.length === 0) { - throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); - } - this.poly = poly; - this.isExterior = isExterior; - this.segments = []; - if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") { - throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); - } - var firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]); - this.bbox = { - ll: { - x: firstPoint.x, - y: firstPoint.y - }, - ur: { - x: firstPoint.x, - y: firstPoint.y - } - }; - var prevPoint = firstPoint; - for (var i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) { - if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") { - throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); - } - var point2 = rounder.round(geomRing[i3][0], geomRing[i3][1]); - if (point2.x === prevPoint.x && point2.y === prevPoint.y) - continue; - this.segments.push(Segment.fromRing(prevPoint, point2, this)); - if (point2.x < this.bbox.ll.x) - this.bbox.ll.x = point2.x; - if (point2.y < this.bbox.ll.y) - this.bbox.ll.y = point2.y; - if (point2.x > this.bbox.ur.x) - this.bbox.ur.x = point2.x; - if (point2.y > this.bbox.ur.y) - this.bbox.ur.y = point2.y; - prevPoint = point2; - } - if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) { - this.segments.push(Segment.fromRing(prevPoint, firstPoint, this)); - } + return ciphertext; + }; + ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + if (ciphertext.length % 16 !== 0) { + throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); } - _createClass(RingIn2, [{ - key: "getSweepEvents", - value: function getSweepEvents() { - var sweepEvents = []; - for (var i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) { - var segment = this.segments[i3]; - sweepEvents.push(segment.leftSE); - sweepEvents.push(segment.rightSE); - } - return sweepEvents; - } - }]); - return RingIn2; - }(); - var PolyIn = /* @__PURE__ */ function() { - function PolyIn2(geomPoly, multiPoly) { - _classCallCheck(this, PolyIn2); - if (!Array.isArray(geomPoly)) { - throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); - } - this.exteriorRing = new RingIn(geomPoly[0], this, true); - this.bbox = { - ll: { - x: this.exteriorRing.bbox.ll.x, - y: this.exteriorRing.bbox.ll.y - }, - ur: { - x: this.exteriorRing.bbox.ur.x, - y: this.exteriorRing.bbox.ur.y - } - }; - this.interiorRings = []; - for (var i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) { - var ring = new RingIn(geomPoly[i3], this, false); - if (ring.bbox.ll.x < this.bbox.ll.x) - this.bbox.ll.x = ring.bbox.ll.x; - if (ring.bbox.ll.y < this.bbox.ll.y) - this.bbox.ll.y = ring.bbox.ll.y; - if (ring.bbox.ur.x > this.bbox.ur.x) - this.bbox.ur.x = ring.bbox.ur.x; - if (ring.bbox.ur.y > this.bbox.ur.y) - this.bbox.ur.y = ring.bbox.ur.y; - this.interiorRings.push(ring); + var plaintext = createArray(ciphertext.length); + var block2 = createArray(16); + for (var i3 = 0; i3 < ciphertext.length; i3 += 16) { + copyArray(ciphertext, block2, 0, i3, i3 + 16); + block2 = this._aes.decrypt(block2); + for (var j2 = 0; j2 < 16; j2++) { + plaintext[i3 + j2] = block2[j2] ^ this._lastCipherblock[j2]; } - this.multiPoly = multiPoly; + copyArray(ciphertext, this._lastCipherblock, 0, i3, i3 + 16); } - _createClass(PolyIn2, [{ - key: "getSweepEvents", - value: function getSweepEvents() { - var sweepEvents = this.exteriorRing.getSweepEvents(); - for (var i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { - var ringSweepEvents = this.interiorRings[i3].getSweepEvents(); - for (var j3 = 0, jMax = ringSweepEvents.length; j3 < jMax; j3++) { - sweepEvents.push(ringSweepEvents[j3]); - } - } - return sweepEvents; - } - }]); - return PolyIn2; - }(); - var MultiPolyIn = /* @__PURE__ */ function() { - function MultiPolyIn2(geom, isSubject) { - _classCallCheck(this, MultiPolyIn2); - if (!Array.isArray(geom)) { - throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); - } - try { - if (typeof geom[0][0][0] === "number") - geom = [geom]; - } catch (ex) { - } - this.polys = []; - this.bbox = { - ll: { - x: Number.POSITIVE_INFINITY, - y: Number.POSITIVE_INFINITY - }, - ur: { - x: Number.NEGATIVE_INFINITY, - y: Number.NEGATIVE_INFINITY - } - }; - for (var i3 = 0, iMax = geom.length; i3 < iMax; i3++) { - var poly = new PolyIn(geom[i3], this); - if (poly.bbox.ll.x < this.bbox.ll.x) - this.bbox.ll.x = poly.bbox.ll.x; - if (poly.bbox.ll.y < this.bbox.ll.y) - this.bbox.ll.y = poly.bbox.ll.y; - if (poly.bbox.ur.x > this.bbox.ur.x) - this.bbox.ur.x = poly.bbox.ur.x; - if (poly.bbox.ur.y > this.bbox.ur.y) - this.bbox.ur.y = poly.bbox.ur.y; - this.polys.push(poly); - } - this.isSubject = isSubject; + return plaintext; + }; + var ModeOfOperationCFB = function(key, iv, segmentSize) { + if (!(this instanceof ModeOfOperationCFB)) { + throw Error("AES must be instanitated with `new`"); } - _createClass(MultiPolyIn2, [{ - key: "getSweepEvents", - value: function getSweepEvents() { - var sweepEvents = []; - for (var i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { - var polySweepEvents = this.polys[i3].getSweepEvents(); - for (var j3 = 0, jMax = polySweepEvents.length; j3 < jMax; j3++) { - sweepEvents.push(polySweepEvents[j3]); - } - } - return sweepEvents; - } - }]); - return MultiPolyIn2; - }(); - var RingOut = /* @__PURE__ */ function() { - _createClass(RingOut2, null, [{ - key: "factory", - /* Given the segments from the sweep line pass, compute & return a series - * of closed rings from all the segments marked to be part of the result */ - value: function factory(allSegments) { - var ringsOut = []; - for (var i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) { - var segment = allSegments[i3]; - if (!segment.isInResult() || segment.ringOut) - continue; - var prevEvent = null; - var event = segment.leftSE; - var nextEvent = segment.rightSE; - var events = [event]; - var startingPoint = event.point; - var intersectionLEs = []; - while (true) { - prevEvent = event; - event = nextEvent; - events.push(event); - if (event.point === startingPoint) - break; - while (true) { - var availableLEs = event.getAvailableLinkedEvents(); - if (availableLEs.length === 0) { - var firstPt = events[0].point; - var lastPt = events[events.length - 1].point; - 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, "].")); - } - if (availableLEs.length === 1) { - nextEvent = availableLEs[0].otherSE; - break; - } - var indexLE = null; - for (var j3 = 0, jMax = intersectionLEs.length; j3 < jMax; j3++) { - if (intersectionLEs[j3].point === event.point) { - indexLE = j3; - break; - } - } - if (indexLE !== null) { - var intersectionLE = intersectionLEs.splice(indexLE)[0]; - var ringEvents = events.splice(intersectionLE.index); - ringEvents.unshift(ringEvents[0].otherSE); - ringsOut.push(new RingOut2(ringEvents.reverse())); - continue; - } - intersectionLEs.push({ - index: events.length, - point: event.point - }); - var comparator = event.getLeftmostComparator(prevEvent); - nextEvent = availableLEs.sort(comparator)[0].otherSE; - break; - } - } - ringsOut.push(new RingOut2(events)); - } - return ringsOut; - } - }]); - function RingOut2(events) { - _classCallCheck(this, RingOut2); - this.events = events; - for (var i3 = 0, iMax = events.length; i3 < iMax; i3++) { - events[i3].segment.ringOut = this; - } - this.poly = null; + this.description = "Cipher Feedback"; + this.name = "cfb"; + if (!iv) { + iv = createArray(16); + } else if (iv.length != 16) { + throw new Error("invalid initialation vector size (must be 16 size)"); } - _createClass(RingOut2, [{ - key: "getGeom", - value: function getGeom2() { - var prevPt = this.events[0].point; - var points = [prevPt]; - for (var i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) { - var _pt = this.events[i3].point; - var _nextPt = this.events[i3 + 1].point; - if (compareVectorAngles(_pt, prevPt, _nextPt) === 0) - continue; - points.push(_pt); - prevPt = _pt; - } - if (points.length === 1) - return null; - var pt2 = points[0]; - var nextPt = points[1]; - if (compareVectorAngles(pt2, prevPt, nextPt) === 0) - points.shift(); - points.push(points[0]); - var step = this.isExteriorRing() ? 1 : -1; - var iStart = this.isExteriorRing() ? 0 : points.length - 1; - var iEnd = this.isExteriorRing() ? points.length : -1; - var orderedPoints = []; - for (var _i = iStart; _i != iEnd; _i += step) { - orderedPoints.push([points[_i].x, points[_i].y]); - } - return orderedPoints; - } - }, { - key: "isExteriorRing", - value: function isExteriorRing() { - if (this._isExteriorRing === void 0) { - var enclosing = this.enclosingRing(); - this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true; - } - return this._isExteriorRing; - } - }, { - key: "enclosingRing", - value: function enclosingRing() { - if (this._enclosingRing === void 0) { - this._enclosingRing = this._calcEnclosingRing(); - } - return this._enclosingRing; - } - /* Returns the ring that encloses this one, if any */ - }, { - key: "_calcEnclosingRing", - value: function _calcEnclosingRing() { - var leftMostEvt = this.events[0]; - for (var i3 = 1, iMax = this.events.length; i3 < iMax; i3++) { - var evt = this.events[i3]; - if (SweepEvent.compare(leftMostEvt, evt) > 0) - leftMostEvt = evt; - } - var prevSeg = leftMostEvt.segment.prevInResult(); - var prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; - while (true) { - if (!prevSeg) - return null; - if (!prevPrevSeg) - return prevSeg.ringOut; - if (prevPrevSeg.ringOut !== prevSeg.ringOut) { - if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) { - return prevSeg.ringOut; - } else - return prevSeg.ringOut.enclosingRing(); - } - prevSeg = prevPrevSeg.prevInResult(); - prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; - } - } - }]); - return RingOut2; - }(); - var PolyOut = /* @__PURE__ */ function() { - function PolyOut2(exteriorRing) { - _classCallCheck(this, PolyOut2); - this.exteriorRing = exteriorRing; - exteriorRing.poly = this; - this.interiorRings = []; + if (!segmentSize) { + segmentSize = 1; } - _createClass(PolyOut2, [{ - key: "addInterior", - value: function addInterior(ring) { - this.interiorRings.push(ring); - ring.poly = this; - } - }, { - key: "getGeom", - value: function getGeom2() { - var geom = [this.exteriorRing.getGeom()]; - if (geom[0] === null) - return null; - for (var i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { - var ringGeom = this.interiorRings[i3].getGeom(); - if (ringGeom === null) - continue; - geom.push(ringGeom); - } - return geom; - } - }]); - return PolyOut2; - }(); - var MultiPolyOut = /* @__PURE__ */ function() { - function MultiPolyOut2(rings) { - _classCallCheck(this, MultiPolyOut2); - this.rings = rings; - this.polys = this._composePolys(rings); + this.segmentSize = segmentSize; + this._shiftRegister = coerceArray(iv, true); + this._aes = new AES(key); + }; + ModeOfOperationCFB.prototype.encrypt = function(plaintext) { + if (plaintext.length % this.segmentSize != 0) { + throw new Error("invalid plaintext size (must be segmentSize bytes)"); } - _createClass(MultiPolyOut2, [{ - key: "getGeom", - value: function getGeom2() { - var geom = []; - for (var i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { - var polyGeom = this.polys[i3].getGeom(); - if (polyGeom === null) - continue; - geom.push(polyGeom); - } - return geom; - } - }, { - key: "_composePolys", - value: function _composePolys(rings) { - var polys = []; - for (var i3 = 0, iMax = rings.length; i3 < iMax; i3++) { - var ring = rings[i3]; - if (ring.poly) - continue; - if (ring.isExteriorRing()) - polys.push(new PolyOut(ring)); - else { - var enclosingRing = ring.enclosingRing(); - if (!enclosingRing.poly) - polys.push(new PolyOut(enclosingRing)); - enclosingRing.poly.addInterior(ring); - } - } - return polys; + var encrypted = coerceArray(plaintext, true); + var xorSegment; + for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + for (var j2 = 0; j2 < this.segmentSize; j2++) { + encrypted[i3 + j2] ^= xorSegment[j2]; } - }]); - return MultiPolyOut2; - }(); - var SweepLine = /* @__PURE__ */ function() { - function SweepLine2(queue) { - var comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment.compare; - _classCallCheck(this, SweepLine2); - this.queue = queue; - this.tree = new Tree(comparator); - this.segments = []; + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize); } - _createClass(SweepLine2, [{ - key: "process", - value: function process2(event) { - var segment = event.segment; - var newEvents = []; - if (event.consumedBy) { - if (event.isLeft) - this.queue.remove(event.otherSE); - else - this.tree.remove(segment); - return newEvents; - } - var node = event.isLeft ? this.tree.insert(segment) : this.tree.find(segment); - 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. Please submit a bug report."); - var prevNode = node; - var nextNode = node; - var prevSeg = void 0; - var nextSeg = void 0; - while (prevSeg === void 0) { - prevNode = this.tree.prev(prevNode); - if (prevNode === null) - prevSeg = null; - else if (prevNode.key.consumedBy === void 0) - prevSeg = prevNode.key; - } - while (nextSeg === void 0) { - nextNode = this.tree.next(nextNode); - if (nextNode === null) - nextSeg = null; - else if (nextNode.key.consumedBy === void 0) - nextSeg = nextNode.key; - } - if (event.isLeft) { - var prevMySplitter = null; - if (prevSeg) { - var prevInter = prevSeg.getIntersection(segment); - if (prevInter !== null) { - if (!segment.isAnEndpoint(prevInter)) - prevMySplitter = prevInter; - if (!prevSeg.isAnEndpoint(prevInter)) { - var newEventsFromSplit = this._splitSafely(prevSeg, prevInter); - for (var i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { - newEvents.push(newEventsFromSplit[i3]); - } - } - } - } - var nextMySplitter = null; - if (nextSeg) { - var nextInter = nextSeg.getIntersection(segment); - if (nextInter !== null) { - if (!segment.isAnEndpoint(nextInter)) - nextMySplitter = nextInter; - if (!nextSeg.isAnEndpoint(nextInter)) { - var _newEventsFromSplit = this._splitSafely(nextSeg, nextInter); - for (var _i = 0, _iMax = _newEventsFromSplit.length; _i < _iMax; _i++) { - newEvents.push(_newEventsFromSplit[_i]); - } - } - } - } - if (prevMySplitter !== null || nextMySplitter !== null) { - var mySplitter = null; - if (prevMySplitter === null) - mySplitter = nextMySplitter; - else if (nextMySplitter === null) - mySplitter = prevMySplitter; - else { - var cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter); - mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter; - } - this.queue.remove(segment.rightSE); - newEvents.push(segment.rightSE); - var _newEventsFromSplit2 = segment.split(mySplitter); - for (var _i2 = 0, _iMax2 = _newEventsFromSplit2.length; _i2 < _iMax2; _i2++) { - newEvents.push(_newEventsFromSplit2[_i2]); - } - } - if (newEvents.length > 0) { - this.tree.remove(segment); - newEvents.push(event); - } else { - this.segments.push(segment); - segment.prev = prevSeg; - } - } else { - if (prevSeg && nextSeg) { - var inter = prevSeg.getIntersection(nextSeg); - if (inter !== null) { - if (!prevSeg.isAnEndpoint(inter)) { - var _newEventsFromSplit3 = this._splitSafely(prevSeg, inter); - for (var _i3 = 0, _iMax3 = _newEventsFromSplit3.length; _i3 < _iMax3; _i3++) { - newEvents.push(_newEventsFromSplit3[_i3]); - } - } - if (!nextSeg.isAnEndpoint(inter)) { - var _newEventsFromSplit4 = this._splitSafely(nextSeg, inter); - for (var _i4 = 0, _iMax4 = _newEventsFromSplit4.length; _i4 < _iMax4; _i4++) { - newEvents.push(_newEventsFromSplit4[_i4]); - } - } - } - } - this.tree.remove(segment); - } - return newEvents; - } - /* Safely split a segment that is currently in the datastructures - * IE - a segment other than the one that is currently being processed. */ - }, { - key: "_splitSafely", - value: function _splitSafely(seg, pt2) { - this.tree.remove(seg); - var rightSE = seg.rightSE; - this.queue.remove(rightSE); - var newEvents = seg.split(pt2); - newEvents.push(rightSE); - if (seg.consumedBy === void 0) - this.tree.insert(seg); - return newEvents; - } - }]); - return SweepLine2; - }(); - var POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6; - var POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6; - var Operation = /* @__PURE__ */ function() { - function Operation2() { - _classCallCheck(this, Operation2); - } - _createClass(Operation2, [{ - key: "run", - value: function run(type2, geom, moreGeoms) { - operation.type = type2; - rounder.reset(); - var multipolys = [new MultiPolyIn(geom, true)]; - for (var i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) { - multipolys.push(new MultiPolyIn(moreGeoms[i3], false)); - } - operation.numMultiPolys = multipolys.length; - if (operation.type === "difference") { - var subject = multipolys[0]; - var _i = 1; - while (_i < multipolys.length) { - if (getBboxOverlap(multipolys[_i].bbox, subject.bbox) !== null) - _i++; - else - multipolys.splice(_i, 1); - } - } - if (operation.type === "intersection") { - for (var _i2 = 0, _iMax = multipolys.length; _i2 < _iMax; _i2++) { - var mpA = multipolys[_i2]; - for (var j3 = _i2 + 1, jMax = multipolys.length; j3 < jMax; j3++) { - if (getBboxOverlap(mpA.bbox, multipolys[j3].bbox) === null) - return []; - } - } - } - var queue = new Tree(SweepEvent.compare); - for (var _i3 = 0, _iMax2 = multipolys.length; _i3 < _iMax2; _i3++) { - var sweepEvents = multipolys[_i3].getSweepEvents(); - for (var _j = 0, _jMax = sweepEvents.length; _j < _jMax; _j++) { - queue.insert(sweepEvents[_j]); - if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) { - throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report."); - } - } - } - var sweepLine = new SweepLine(queue); - var prevQueueSize = queue.size; - var node = queue.pop(); - while (node) { - var evt = node.key; - if (queue.size === prevQueueSize) { - var seg = evt.segment; - 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. ") + "Please file a bug report."); - } - if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) { - throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report."); - } - if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) { - throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report."); - } - var newEvents = sweepLine.process(evt); - for (var _i4 = 0, _iMax3 = newEvents.length; _i4 < _iMax3; _i4++) { - var _evt = newEvents[_i4]; - if (_evt.consumedBy === void 0) - queue.insert(_evt); - } - prevQueueSize = queue.size; - node = queue.pop(); - } - rounder.reset(); - var ringsOut = RingOut.factory(sweepLine.segments); - var result = new MultiPolyOut(ringsOut); - return result.getGeom(); + return encrypted; + }; + ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { + if (ciphertext.length % this.segmentSize != 0) { + throw new Error("invalid ciphertext size (must be segmentSize bytes)"); + } + var plaintext = coerceArray(ciphertext, true); + var xorSegment; + for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + for (var j2 = 0; j2 < this.segmentSize; j2++) { + plaintext[i3 + j2] ^= xorSegment[j2]; } - }]); - return Operation2; - }(); - var operation = new Operation(); - var union = function union2(geom) { - for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - moreGeoms[_key - 1] = arguments[_key]; + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize); } - return operation.run("union", geom, moreGeoms); + return plaintext; }; - var intersection$1 = function intersection2(geom) { - for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - moreGeoms[_key2 - 1] = arguments[_key2]; + var ModeOfOperationOFB = function(key, iv) { + if (!(this instanceof ModeOfOperationOFB)) { + throw Error("AES must be instanitated with `new`"); } - return operation.run("intersection", geom, moreGeoms); - }; - var xor = function xor2(geom) { - for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - moreGeoms[_key3 - 1] = arguments[_key3]; + this.description = "Output Feedback"; + this.name = "ofb"; + if (!iv) { + iv = createArray(16); + } else if (iv.length != 16) { + throw new Error("invalid initialation vector size (must be 16 bytes)"); } - return operation.run("xor", geom, moreGeoms); + this._lastPrecipher = coerceArray(iv, true); + this._lastPrecipherIndex = 16; + this._aes = new AES(key); }; - var difference = function difference2(subjectGeom) { - for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - clippingGeoms[_key4 - 1] = arguments[_key4]; + ModeOfOperationOFB.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + for (var i3 = 0; i3 < encrypted.length; i3++) { + if (this._lastPrecipherIndex === 16) { + this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); + this._lastPrecipherIndex = 0; + } + encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++]; } - return operation.run("difference", subjectGeom, clippingGeoms); + return encrypted; }; - var index = { - union, - intersection: intersection$1, - xor, - difference + ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; + var Counter = function(initialValue) { + if (!(this instanceof Counter)) { + throw Error("Counter must be instanitated with `new`"); + } + if (initialValue !== 0 && !initialValue) { + initialValue = 1; + } + if (typeof initialValue === "number") { + this._counter = createArray(16); + this.setValue(initialValue); + } else { + this.setBytes(initialValue); + } }; - return index; - }); - } - }); - - // node_modules/geojson-precision/index.js - var require_geojson_precision = __commonJS({ - "node_modules/geojson-precision/index.js"(exports2, module2) { - (function() { - function parse(t2, coordinatePrecision, extrasPrecision) { - function point2(p2) { - return p2.map(function(e3, index) { - if (index < 2) { - return 1 * e3.toFixed(coordinatePrecision); - } else { - return 1 * e3.toFixed(extrasPrecision); - } - }); - } - function multi(l2) { - return l2.map(point2); - } - function poly(p2) { - return p2.map(multi); - } - function multiPoly(m2) { - return m2.map(poly); - } - function geometry(obj) { - if (!obj) { - return {}; - } - switch (obj.type) { - case "Point": - obj.coordinates = point2(obj.coordinates); - return obj; - case "LineString": - case "MultiPoint": - obj.coordinates = multi(obj.coordinates); - return obj; - case "Polygon": - case "MultiLineString": - obj.coordinates = poly(obj.coordinates); - return obj; - case "MultiPolygon": - obj.coordinates = multiPoly(obj.coordinates); - return obj; - case "GeometryCollection": - obj.geometries = obj.geometries.map(geometry); - return obj; - default: - return {}; - } - } - function feature3(obj) { - obj.geometry = geometry(obj.geometry); - return obj; - } - function featureCollection(f3) { - f3.features = f3.features.map(feature3); - return f3; - } - function geometryCollection(g3) { - g3.geometries = g3.geometries.map(geometry); - return g3; - } - if (!t2) { - return t2; - } - switch (t2.type) { - case "Feature": - return feature3(t2); - case "GeometryCollection": - return geometryCollection(t2); - case "FeatureCollection": - return featureCollection(t2); - case "Point": - case "LineString": - case "Polygon": - case "MultiPoint": - case "MultiPolygon": - case "MultiLineString": - return geometry(t2); - default: - return t2; + Counter.prototype.setValue = function(value) { + if (typeof value !== "number" || parseInt(value) != value) { + throw new Error("invalid counter value (must be an integer)"); } - } - module2.exports = parse; - module2.exports.parse = parse; - })(); - } - }); - - // node_modules/@aitodotai/json-stringify-pretty-compact/index.js - var require_json_stringify_pretty_compact = __commonJS({ - "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) { - function isObject3(obj) { - return typeof obj === "object" && obj !== null; - } - function forEach(obj, cb) { - if (Array.isArray(obj)) { - obj.forEach(cb); - } else if (isObject3(obj)) { - Object.keys(obj).forEach(function(key) { - var val = obj[key]; - cb(val, key); - }); - } - } - function getTreeDepth(obj) { - var depth = 0; - if (Array.isArray(obj) || isObject3(obj)) { - forEach(obj, function(val) { - if (Array.isArray(val) || isObject3(val)) { - var tmpDepth = getTreeDepth(val); - if (tmpDepth > depth) { - depth = tmpDepth; - } - } - }); - return depth + 1; - } - return depth; - } - function stringify3(obj, options2) { - options2 = options2 || {}; - var indent2 = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3); - var addMargin = get4(options2, "margins", false); - var addArrayMargin = get4(options2, "arrayMargins", false); - var addObjectMargin = get4(options2, "objectMargins", false); - var maxLength = indent2 === "" ? Infinity : get4(options2, "maxLength", 80); - var maxNesting = get4(options2, "maxNesting", Infinity); - return function _stringify(obj2, currentIndent, reserved) { - if (obj2 && typeof obj2.toJSON === "function") { - obj2 = obj2.toJSON(); + if (value > Number.MAX_SAFE_INTEGER) { + throw new Error("integer value out of safe range"); } - var string = JSON.stringify(obj2); - if (string === void 0) { - return string; + for (var index = 15; index >= 0; --index) { + this._counter[index] = value % 256; + value = parseInt(value / 256); } - var length = maxLength - currentIndent.length - reserved; - var treeDepth = getTreeDepth(obj2); - if (treeDepth <= maxNesting && string.length <= length) { - var prettified = prettify(string, { - addMargin, - addArrayMargin, - addObjectMargin - }); - if (prettified.length <= length) { - return prettified; - } + }; + Counter.prototype.setBytes = function(bytes) { + bytes = coerceArray(bytes, true); + if (bytes.length != 16) { + throw new Error("invalid counter bytes size (must be 16 bytes)"); } - if (isObject3(obj2)) { - var nextIndent = currentIndent + indent2; - var items = []; - var delimiters; - var comma = function(array2, index2) { - return index2 === array2.length - 1 ? 0 : 1; - }; - if (Array.isArray(obj2)) { - for (var index = 0; index < obj2.length; index++) { - items.push( - _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null" - ); - } - delimiters = "[]"; + this._counter = bytes; + }; + Counter.prototype.increment = function() { + for (var i3 = 15; i3 >= 0; i3--) { + if (this._counter[i3] === 255) { + this._counter[i3] = 0; } else { - Object.keys(obj2).forEach(function(key, index2, array2) { - var keyPart = JSON.stringify(key) + ": "; - var value = _stringify( - obj2[key], - nextIndent, - keyPart.length + comma(array2, index2) - ); - if (value !== void 0) { - items.push(keyPart + value); - } - }); - delimiters = "{}"; - } - if (items.length > 0) { - return [ - delimiters[0], - indent2 + items.join(",\n" + nextIndent), - delimiters[1] - ].join("\n" + currentIndent); + this._counter[i3]++; + break; } } - return string; - }(obj, "", 0); - } - var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g; - function prettify(string, options2) { - options2 = options2 || {}; - var tokens = { - "{": "{", - "}": "}", - "[": "[", - "]": "]", - ",": ", ", - ":": ": " }; - if (options2.addMargin || options2.addObjectMargin) { - tokens["{"] = "{ "; - tokens["}"] = " }"; - } - if (options2.addMargin || options2.addArrayMargin) { - tokens["["] = "[ "; - tokens["]"] = " ]"; - } - return string.replace(stringOrChar, function(match, string2) { - return string2 ? match : tokens[match]; - }); - } - function get4(options2, name, defaultValue) { - return name in options2 ? options2[name] : defaultValue; - } - module2.exports = stringify3; - } - }); - - // node_modules/aes-js/index.js - var require_aes_js = __commonJS({ - "node_modules/aes-js/index.js"(exports2, module2) { - (function(root3) { - "use strict"; - function checkInt(value) { - return parseInt(value) === value; - } - function checkInts(arrayish) { - if (!checkInt(arrayish.length)) { - return false; - } - for (var i3 = 0; i3 < arrayish.length; i3++) { - if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) { - return false; - } + var ModeOfOperationCTR = function(key, counter) { + if (!(this instanceof ModeOfOperationCTR)) { + throw Error("AES must be instanitated with `new`"); } - return true; - } - function coerceArray(arg, copy2) { - if (arg.buffer && arg.name === "Uint8Array") { - if (copy2) { - if (arg.slice) { - arg = arg.slice(); - } else { - arg = Array.prototype.slice.call(arg); - } - } - return arg; + this.description = "Counter"; + this.name = "ctr"; + if (!(counter instanceof Counter)) { + counter = new Counter(counter); } - if (Array.isArray(arg)) { - if (!checkInts(arg)) { - throw new Error("Array contains invalid value: " + arg); + this._counter = counter; + this._remainingCounter = null; + this._remainingCounterIndex = 16; + this._aes = new AES(key); + }; + ModeOfOperationCTR.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + for (var i3 = 0; i3 < encrypted.length; i3++) { + if (this._remainingCounterIndex === 16) { + this._remainingCounter = this._aes.encrypt(this._counter._counter); + this._remainingCounterIndex = 0; + this._counter.increment(); } - return new Uint8Array(arg); - } - if (checkInt(arg.length) && checkInts(arg)) { - return new Uint8Array(arg); + encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++]; } - throw new Error("unsupported array-like object"); - } - function createArray(length) { - return new Uint8Array(length); - } - function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { - if (sourceStart != null || sourceEnd != null) { - if (sourceArray.slice) { - sourceArray = sourceArray.slice(sourceStart, sourceEnd); - } else { - sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); - } + return encrypted; + }; + ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; + function pkcs7pad(data) { + data = coerceArray(data, true); + var padder = 16 - data.length % 16; + var result = createArray(data.length + padder); + copyArray(data, result); + for (var i3 = data.length; i3 < result.length; i3++) { + result[i3] = padder; } - targetArray.set(sourceArray, targetStart); + return result; } - var convertUtf8 = function() { - function toBytes(text2) { - var result = [], i3 = 0; - text2 = encodeURI(text2); - while (i3 < text2.length) { - var c2 = text2.charCodeAt(i3++); - if (c2 === 37) { - result.push(parseInt(text2.substr(i3, 2), 16)); - i3 += 2; - } else { - result.push(c2); - } - } - return coerceArray(result); - } - function fromBytes(bytes) { - var result = [], i3 = 0; - while (i3 < bytes.length) { - var c2 = bytes[i3]; - if (c2 < 128) { - result.push(String.fromCharCode(c2)); - i3++; - } else if (c2 > 191 && c2 < 224) { - result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63)); - i3 += 2; - } else { - result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63)); - i3 += 3; - } - } - return result.join(""); + function pkcs7strip(data) { + data = coerceArray(data, true); + if (data.length < 16) { + throw new Error("PKCS#7 invalid length"); } - return { - toBytes, - fromBytes - }; - }(); - var convertHex = function() { - function toBytes(text2) { - var result = []; - for (var i3 = 0; i3 < text2.length; i3 += 2) { - result.push(parseInt(text2.substr(i3, 2), 16)); - } - return result; + var padder = data[data.length - 1]; + if (padder > 16) { + throw new Error("PKCS#7 padding byte out of range"); } - var Hex = "0123456789abcdef"; - function fromBytes(bytes) { - var result = []; - for (var i3 = 0; i3 < bytes.length; i3++) { - var v2 = bytes[i3]; - result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]); + var length2 = data.length - padder; + for (var i3 = 0; i3 < padder; i3++) { + if (data[length2 + i3] !== padder) { + throw new Error("PKCS#7 invalid padding byte"); } - return result.join(""); - } - return { - toBytes, - fromBytes - }; - }(); - var numberOfRounds = { 16: 10, 24: 12, 32: 14 }; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - 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]; - function convertToInt32(bytes) { - var result = []; - for (var i3 = 0; i3 < bytes.length; i3 += 4) { - result.push( - bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3] - ); } + var result = createArray(length2); + copyArray(data, result, 0, 0, length2); return result; } - var AES = function(key) { - if (!(this instanceof AES)) { - throw Error("AES must be instanitated with `new`"); - } - Object.defineProperty(this, "key", { - value: coerceArray(key, true) - }); - this._prepare(); - }; - AES.prototype._prepare = function() { - var rounds = numberOfRounds[this.key.length]; - if (rounds == null) { - throw new Error("invalid key size (must be 16, 24 or 32 bytes)"); - } - this._Ke = []; - this._Kd = []; - for (var i3 = 0; i3 <= rounds; i3++) { - this._Ke.push([0, 0, 0, 0]); - this._Kd.push([0, 0, 0, 0]); - } - var roundKeyCount = (rounds + 1) * 4; - var KC = this.key.length / 4; - var tk = convertToInt32(this.key); - var index; - for (var i3 = 0; i3 < KC; i3++) { - index = i3 >> 2; - this._Ke[index][i3 % 4] = tk[i3]; - this._Kd[rounds - index][i3 % 4] = tk[i3]; - } - var rconpointer = 0; - var t2 = KC, tt2; - while (t2 < roundKeyCount) { - tt2 = tk[KC - 1]; - tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24; - rconpointer += 1; - if (KC != 8) { - for (var i3 = 1; i3 < KC; i3++) { - tk[i3] ^= tk[i3 - 1]; - } - } else { - for (var i3 = 1; i3 < KC / 2; i3++) { - tk[i3] ^= tk[i3 - 1]; - } - tt2 = tk[KC / 2 - 1]; - tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24; - for (var i3 = KC / 2 + 1; i3 < KC; i3++) { - tk[i3] ^= tk[i3 - 1]; - } - } - var i3 = 0, r2, c2; - while (i3 < KC && t2 < roundKeyCount) { - r2 = t2 >> 2; - c2 = t2 % 4; - this._Ke[r2][c2] = tk[i3]; - this._Kd[rounds - r2][c2] = tk[i3++]; - t2++; - } - } - for (var r2 = 1; r2 < rounds; r2++) { - for (var c2 = 0; c2 < 4; c2++) { - tt2 = this._Kd[r2][c2]; - this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255]; - } - } - }; - AES.prototype.encrypt = function(plaintext) { - if (plaintext.length != 16) { - throw new Error("invalid plaintext size (must be 16 bytes)"); - } - var rounds = this._Ke.length - 1; - var a2 = [0, 0, 0, 0]; - var t2 = convertToInt32(plaintext); - for (var i3 = 0; i3 < 4; i3++) { - t2[i3] ^= this._Ke[0][i3]; - } - for (var r2 = 1; r2 < rounds; r2++) { - for (var i3 = 0; i3 < 4; i3++) { - 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]; + var aesjs2 = { + AES, + Counter, + ModeOfOperation: { + ecb: ModeOfOperationECB, + cbc: ModeOfOperationCBC, + cfb: ModeOfOperationCFB, + ofb: ModeOfOperationOFB, + ctr: ModeOfOperationCTR + }, + utils: { + hex: convertHex, + utf8: convertUtf8 + }, + padding: { + pkcs7: { + pad: pkcs7pad, + strip: pkcs7strip } - t2 = a2.slice(); - } - var result = createArray(16), tt2; - for (var i3 = 0; i3 < 4; i3++) { - tt2 = this._Ke[rounds][i3]; - result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255; - result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255; - result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255; - result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255; + }, + _arrayTest: { + coerceArray, + createArray, + copyArray } - return result; }; - AES.prototype.decrypt = function(ciphertext) { - if (ciphertext.length != 16) { - throw new Error("invalid ciphertext size (must be 16 bytes)"); - } - var rounds = this._Kd.length - 1; - var a2 = [0, 0, 0, 0]; - var t2 = convertToInt32(ciphertext); - for (var i3 = 0; i3 < 4; i3++) { - t2[i3] ^= this._Kd[0][i3]; - } - for (var r2 = 1; r2 < rounds; r2++) { - for (var i3 = 0; i3 < 4; i3++) { - 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]; - } - t2 = a2.slice(); - } - var result = createArray(16), tt2; - for (var i3 = 0; i3 < 4; i3++) { - tt2 = this._Kd[rounds][i3]; - result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255; - result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255; - result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255; - result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255; - } - return result; - }; - var ModeOfOperationECB = function(key) { - if (!(this instanceof ModeOfOperationECB)) { - throw Error("AES must be instanitated with `new`"); - } - this.description = "Electronic Code Block"; - this.name = "ecb"; - this._aes = new AES(key); - }; - ModeOfOperationECB.prototype.encrypt = function(plaintext) { - plaintext = coerceArray(plaintext); - if (plaintext.length % 16 !== 0) { - throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); - } - var ciphertext = createArray(plaintext.length); - var block2 = createArray(16); - for (var i3 = 0; i3 < plaintext.length; i3 += 16) { - copyArray(plaintext, block2, 0, i3, i3 + 16); - block2 = this._aes.encrypt(block2); - copyArray(block2, ciphertext, i3); - } - return ciphertext; - }; - ModeOfOperationECB.prototype.decrypt = function(ciphertext) { - ciphertext = coerceArray(ciphertext); - if (ciphertext.length % 16 !== 0) { - throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); - } - var plaintext = createArray(ciphertext.length); - var block2 = createArray(16); - for (var i3 = 0; i3 < ciphertext.length; i3 += 16) { - copyArray(ciphertext, block2, 0, i3, i3 + 16); - block2 = this._aes.decrypt(block2); - copyArray(block2, plaintext, i3); - } - return plaintext; - }; - var ModeOfOperationCBC = function(key, iv) { - if (!(this instanceof ModeOfOperationCBC)) { - throw Error("AES must be instanitated with `new`"); - } - this.description = "Cipher Block Chaining"; - this.name = "cbc"; - if (!iv) { - iv = createArray(16); - } else if (iv.length != 16) { - throw new Error("invalid initialation vector size (must be 16 bytes)"); - } - this._lastCipherblock = coerceArray(iv, true); - this._aes = new AES(key); - }; - ModeOfOperationCBC.prototype.encrypt = function(plaintext) { - plaintext = coerceArray(plaintext); - if (plaintext.length % 16 !== 0) { - throw new Error("invalid plaintext size (must be multiple of 16 bytes)"); - } - var ciphertext = createArray(plaintext.length); - var block2 = createArray(16); - for (var i3 = 0; i3 < plaintext.length; i3 += 16) { - copyArray(plaintext, block2, 0, i3, i3 + 16); - for (var j3 = 0; j3 < 16; j3++) { - block2[j3] ^= this._lastCipherblock[j3]; - } - this._lastCipherblock = this._aes.encrypt(block2); - copyArray(this._lastCipherblock, ciphertext, i3); - } - return ciphertext; - }; - ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { - ciphertext = coerceArray(ciphertext); - if (ciphertext.length % 16 !== 0) { - throw new Error("invalid ciphertext size (must be multiple of 16 bytes)"); - } - var plaintext = createArray(ciphertext.length); - var block2 = createArray(16); - for (var i3 = 0; i3 < ciphertext.length; i3 += 16) { - copyArray(ciphertext, block2, 0, i3, i3 + 16); - block2 = this._aes.decrypt(block2); - for (var j3 = 0; j3 < 16; j3++) { - plaintext[i3 + j3] = block2[j3] ^ this._lastCipherblock[j3]; - } - copyArray(ciphertext, this._lastCipherblock, 0, i3, i3 + 16); - } - return plaintext; - }; - var ModeOfOperationCFB = function(key, iv, segmentSize) { - if (!(this instanceof ModeOfOperationCFB)) { - throw Error("AES must be instanitated with `new`"); - } - this.description = "Cipher Feedback"; - this.name = "cfb"; - if (!iv) { - iv = createArray(16); - } else if (iv.length != 16) { - throw new Error("invalid initialation vector size (must be 16 size)"); - } - if (!segmentSize) { - segmentSize = 1; - } - this.segmentSize = segmentSize; - this._shiftRegister = coerceArray(iv, true); - this._aes = new AES(key); - }; - ModeOfOperationCFB.prototype.encrypt = function(plaintext) { - if (plaintext.length % this.segmentSize != 0) { - throw new Error("invalid plaintext size (must be segmentSize bytes)"); - } - var encrypted = coerceArray(plaintext, true); - var xorSegment; - for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) { - xorSegment = this._aes.encrypt(this._shiftRegister); - for (var j3 = 0; j3 < this.segmentSize; j3++) { - encrypted[i3 + j3] ^= xorSegment[j3]; - } - copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); - copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize); - } - return encrypted; - }; - ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { - if (ciphertext.length % this.segmentSize != 0) { - throw new Error("invalid ciphertext size (must be segmentSize bytes)"); - } - var plaintext = coerceArray(ciphertext, true); - var xorSegment; - for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) { - xorSegment = this._aes.encrypt(this._shiftRegister); - for (var j3 = 0; j3 < this.segmentSize; j3++) { - plaintext[i3 + j3] ^= xorSegment[j3]; - } - copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); - copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize); - } - return plaintext; - }; - var ModeOfOperationOFB = function(key, iv) { - if (!(this instanceof ModeOfOperationOFB)) { - throw Error("AES must be instanitated with `new`"); - } - this.description = "Output Feedback"; - this.name = "ofb"; - if (!iv) { - iv = createArray(16); - } else if (iv.length != 16) { - throw new Error("invalid initialation vector size (must be 16 bytes)"); - } - this._lastPrecipher = coerceArray(iv, true); - this._lastPrecipherIndex = 16; - this._aes = new AES(key); - }; - ModeOfOperationOFB.prototype.encrypt = function(plaintext) { - var encrypted = coerceArray(plaintext, true); - for (var i3 = 0; i3 < encrypted.length; i3++) { - if (this._lastPrecipherIndex === 16) { - this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); - this._lastPrecipherIndex = 0; - } - encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++]; - } - return encrypted; - }; - ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; - var Counter = function(initialValue) { - if (!(this instanceof Counter)) { - throw Error("Counter must be instanitated with `new`"); - } - if (initialValue !== 0 && !initialValue) { - initialValue = 1; - } - if (typeof initialValue === "number") { - this._counter = createArray(16); - this.setValue(initialValue); - } else { - this.setBytes(initialValue); - } - }; - Counter.prototype.setValue = function(value) { - if (typeof value !== "number" || parseInt(value) != value) { - throw new Error("invalid counter value (must be an integer)"); - } - if (value > Number.MAX_SAFE_INTEGER) { - throw new Error("integer value out of safe range"); - } - for (var index = 15; index >= 0; --index) { - this._counter[index] = value % 256; - value = parseInt(value / 256); - } - }; - Counter.prototype.setBytes = function(bytes) { - bytes = coerceArray(bytes, true); - if (bytes.length != 16) { - throw new Error("invalid counter bytes size (must be 16 bytes)"); - } - this._counter = bytes; - }; - Counter.prototype.increment = function() { - for (var i3 = 15; i3 >= 0; i3--) { - if (this._counter[i3] === 255) { - this._counter[i3] = 0; - } else { - this._counter[i3]++; - break; - } - } - }; - var ModeOfOperationCTR = function(key, counter) { - if (!(this instanceof ModeOfOperationCTR)) { - throw Error("AES must be instanitated with `new`"); - } - this.description = "Counter"; - this.name = "ctr"; - if (!(counter instanceof Counter)) { - counter = new Counter(counter); - } - this._counter = counter; - this._remainingCounter = null; - this._remainingCounterIndex = 16; - this._aes = new AES(key); - }; - ModeOfOperationCTR.prototype.encrypt = function(plaintext) { - var encrypted = coerceArray(plaintext, true); - for (var i3 = 0; i3 < encrypted.length; i3++) { - if (this._remainingCounterIndex === 16) { - this._remainingCounter = this._aes.encrypt(this._counter._counter); - this._remainingCounterIndex = 0; - this._counter.increment(); - } - encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++]; - } - return encrypted; - }; - ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; - function pkcs7pad(data) { - data = coerceArray(data, true); - var padder = 16 - data.length % 16; - var result = createArray(data.length + padder); - copyArray(data, result); - for (var i3 = data.length; i3 < result.length; i3++) { - result[i3] = padder; - } - return result; - } - function pkcs7strip(data) { - data = coerceArray(data, true); - if (data.length < 16) { - throw new Error("PKCS#7 invalid length"); - } - var padder = data[data.length - 1]; - if (padder > 16) { - throw new Error("PKCS#7 padding byte out of range"); - } - var length = data.length - padder; - for (var i3 = 0; i3 < padder; i3++) { - if (data[length + i3] !== padder) { - throw new Error("PKCS#7 invalid padding byte"); - } - } - var result = createArray(length); - copyArray(data, result, 0, 0, length); - return result; - } - var aesjs2 = { - AES, - Counter, - ModeOfOperation: { - ecb: ModeOfOperationECB, - cbc: ModeOfOperationCBC, - cfb: ModeOfOperationCFB, - ofb: ModeOfOperationOFB, - ctr: ModeOfOperationCTR - }, - utils: { - hex: convertHex, - utf8: convertUtf8 - }, - padding: { - pkcs7: { - pad: pkcs7pad, - strip: pkcs7strip - } - }, - _arrayTest: { - coerceArray, - createArray, - copyArray - } - }; - if (typeof exports2 !== "undefined") { - module2.exports = aesjs2; - } else if (typeof define === "function" && define.amd) { - define([], function() { - return aesjs2; - }); - } else { - if (root3.aesjs) { - aesjs2._aesjs = root3.aesjs; + if (typeof exports2 !== "undefined") { + module2.exports = aesjs2; + } else if (typeof define === "function" && define.amd) { + define([], function() { + return aesjs2; + }); + } else { + if (root3.aesjs) { + aesjs2._aesjs = root3.aesjs; } root3.aesjs = aesjs2; } @@ -6866,7 +4783,7 @@ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "..."; var HOT_COUNT = 800, HOT_SPAN = 16; var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2, LAZY_WHILE_FLAG = 3; - var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER3 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0; + var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER4 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0; var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; var wrapFlags = [ ["ary", WRAP_ARY_FLAG], @@ -7208,16 +5125,16 @@ return func.apply(thisArg, args); } function arrayAggregator(array2, setter, iteratee, accumulator) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { var value = array2[index]; setter(accumulator, value, iteratee(value), array2); } return accumulator; } function arrayEach(array2, iteratee) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { if (iteratee(array2[index], index, array2) === false) { break; } @@ -7225,17 +5142,17 @@ return array2; } function arrayEachRight(array2, iteratee) { - var length = array2 == null ? 0 : array2.length; - while (length--) { - if (iteratee(array2[length], length, array2) === false) { + var length2 = array2 == null ? 0 : array2.length; + while (length2--) { + if (iteratee(array2[length2], length2, array2) === false) { break; } } return array2; } function arrayEvery(array2, predicate) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { if (!predicate(array2[index], index, array2)) { return false; } @@ -7243,8 +5160,8 @@ return true; } function arrayFilter2(array2, predicate) { - var index = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = []; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = []; + while (++index < length2) { var value = array2[index]; if (predicate(value, index, array2)) { result[resIndex++] = value; @@ -7253,12 +5170,12 @@ return result; } function arrayIncludes(array2, value) { - var length = array2 == null ? 0 : array2.length; - return !!length && baseIndexOf(array2, value, 0) > -1; + var length2 = array2 == null ? 0 : array2.length; + return !!length2 && baseIndexOf(array2, value, 0) > -1; } function arrayIncludesWith(array2, value, comparator) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { if (comparator(value, array2[index])) { return true; } @@ -7266,42 +5183,42 @@ return false; } function arrayMap2(array2, iteratee) { - var index = -1, length = array2 == null ? 0 : array2.length, result = Array(length); - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2); + while (++index < length2) { result[index] = iteratee(array2[index], index, array2); } return result; } function arrayPush2(array2, values) { - var index = -1, length = values.length, offset = array2.length; - while (++index < length) { + var index = -1, length2 = values.length, offset = array2.length; + while (++index < length2) { array2[offset + index] = values[index]; } return array2; } function arrayReduce(array2, iteratee, accumulator, initAccum) { - var index = -1, length = array2 == null ? 0 : array2.length; - if (initAccum && length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + if (initAccum && length2) { accumulator = array2[++index]; } - while (++index < length) { + while (++index < length2) { accumulator = iteratee(accumulator, array2[index], index, array2); } return accumulator; } function arrayReduceRight(array2, iteratee, accumulator, initAccum) { - var length = array2 == null ? 0 : array2.length; - if (initAccum && length) { - accumulator = array2[--length]; + var length2 = array2 == null ? 0 : array2.length; + if (initAccum && length2) { + accumulator = array2[--length2]; } - while (length--) { - accumulator = iteratee(accumulator, array2[length], length, array2); + while (length2--) { + accumulator = iteratee(accumulator, array2[length2], length2, array2); } return accumulator; } function arraySome2(array2, predicate) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { if (predicate(array2[index], index, array2)) { return true; } @@ -7326,8 +5243,8 @@ return result; } function baseFindIndex(array2, predicate, fromIndex, fromRight) { - var length = array2.length, index = fromIndex + (fromRight ? 1 : -1); - while (fromRight ? index-- : ++index < length) { + var length2 = array2.length, index = fromIndex + (fromRight ? 1 : -1); + while (fromRight ? index-- : ++index < length2) { if (predicate(array2[index], index, array2)) { return index; } @@ -7338,8 +5255,8 @@ return value === value ? strictIndexOf(array2, value, fromIndex) : baseFindIndex(array2, baseIsNaN, fromIndex); } function baseIndexOfWith(array2, value, fromIndex, comparator) { - var index = fromIndex - 1, length = array2.length; - while (++index < length) { + var index = fromIndex - 1, length2 = array2.length; + while (++index < length2) { if (comparator(array2[index], value)) { return index; } @@ -7350,8 +5267,8 @@ return value !== value; } function baseMean(array2, iteratee) { - var length = array2 == null ? 0 : array2.length; - return length ? baseSum(array2, iteratee) / length : NAN2; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? baseSum(array2, iteratee) / length2 : NAN2; } function baseProperty(key) { return function(object) { @@ -7370,16 +5287,16 @@ return accumulator; } function baseSortBy(array2, comparer) { - var length = array2.length; + var length2 = array2.length; array2.sort(comparer); - while (length--) { - array2[length] = array2[length].value; + while (length2--) { + array2[length2] = array2[length2].value; } return array2; } function baseSum(array2, iteratee) { - var result, index = -1, length = array2.length; - while (++index < length) { + var result, index = -1, length2 = array2.length; + while (++index < length2) { var current = iteratee(array2[index]); if (current !== undefined2) { result = result === undefined2 ? current : result + current; @@ -7416,8 +5333,8 @@ return cache.has(key); } function charsStartIndex(strSymbols, chrSymbols) { - var index = -1, length = strSymbols.length; - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) { + var index = -1, length2 = strSymbols.length; + while (++index < length2 && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) { } return index; } @@ -7428,9 +5345,9 @@ return index; } function countHolders(array2, placeholder) { - var length = array2.length, result = 0; - while (length--) { - if (array2[length] === placeholder) { + var length2 = array2.length, result = 0; + while (length2--) { + if (array2[length2] === placeholder) { ++result; } } @@ -7470,8 +5387,8 @@ }; } function replaceHolders(array2, placeholder) { - var index = -1, length = array2.length, resIndex = 0, result = []; - while (++index < length) { + var index = -1, length2 = array2.length, resIndex = 0, result = []; + while (++index < length2) { var value = array2[index]; if (value === placeholder || value === PLACEHOLDER) { array2[index] = PLACEHOLDER; @@ -7480,23 +5397,23 @@ } return result; } - function setToArray2(set3) { - var index = -1, result = Array(set3.size); - set3.forEach(function(value) { + function setToArray2(set4) { + var index = -1, result = Array(set4.size); + set4.forEach(function(value) { result[++index] = value; }); return result; } - function setToPairs(set3) { - var index = -1, result = Array(set3.size); - set3.forEach(function(value) { + function setToPairs(set4) { + var index = -1, result = Array(set4.size); + set4.forEach(function(value) { result[++index] = [value, value]; }); return result; } function strictIndexOf(array2, value, fromIndex) { - var index = fromIndex - 1, length = array2.length; - while (++index < length) { + var index = fromIndex - 1, length2 = array2.length; + while (++index < length2) { if (array2[index] === value) { return index; } @@ -7583,7 +5500,7 @@ } return new LodashWrapper(value); } - var baseCreate = function() { + var baseCreate = /* @__PURE__ */ function() { function object() { } return function(proto) { @@ -7688,13 +5605,13 @@ return result2; } function lazyValue() { - 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, length = end - start2, index = isRight ? end : start2 - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin2(length, this.__takeCount__); - if (!isArr || !isRight && arrLength == length && takeCount == length) { + 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__); + if (!isArr || !isRight && arrLength == length2 && takeCount == length2) { return baseWrapperValue(array2, this.__actions__); } var result2 = []; outer: - while (length-- && resIndex < takeCount) { + while (length2-- && resIndex < takeCount) { index += dir; var iterIndex = -1, value = array2[index]; while (++iterIndex < iterLength) { @@ -7716,9 +5633,9 @@ LazyWrapper.prototype = baseCreate(baseLodash.prototype); LazyWrapper.prototype.constructor = LazyWrapper; function Hash2(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -7756,9 +5673,9 @@ Hash2.prototype.has = hashHas2; Hash2.prototype.set = hashSet2; function ListCache2(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -7804,9 +5721,9 @@ ListCache2.prototype.has = listCacheHas2; ListCache2.prototype.set = listCacheSet2; function MapCache2(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -7842,9 +5759,9 @@ MapCache2.prototype.has = mapCacheHas2; MapCache2.prototype.set = mapCacheSet2; function SetCache2(values2) { - var index = -1, length = values2 == null ? 0 : values2.length; + var index = -1, length2 = values2 == null ? 0 : values2.length; this.__data__ = new MapCache2(); - while (++index < length) { + while (++index < length2) { this.add(values2[index]); } } @@ -7897,21 +5814,21 @@ Stack2.prototype.has = stackHas2; Stack2.prototype.set = stackSet2; function arrayLikeKeys2(value, inherited) { - 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) : [], length = result2.length; + 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; for (var key in value) { if ((inherited || hasOwnProperty10.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. - isIndex2(key, length)))) { + isIndex2(key, length2)))) { result2.push(key); } } return result2; } function arraySample(array2) { - var length = array2.length; - return length ? array2[baseRandom(0, length - 1)] : undefined2; + var length2 = array2.length; + return length2 ? array2[baseRandom(0, length2 - 1)] : undefined2; } function arraySampleSize(array2, n3) { return shuffleSelf(copyArray(array2), baseClamp(n3, 0, array2.length)); @@ -7931,10 +5848,10 @@ } } function assocIndexOf2(array2, key) { - var length = array2.length; - while (length--) { - if (eq2(array2[length][0], key)) { - return length; + var length2 = array2.length; + while (length2--) { + if (eq2(array2[length2][0], key)) { + return length2; } } return -1; @@ -7964,8 +5881,8 @@ } } function baseAt(object, paths) { - var index = -1, length = paths.length, result2 = Array2(length), skip = object == null; - while (++index < length) { + var index = -1, length2 = paths.length, result2 = Array2(length2), skip = object == null; + while (++index < length2) { result2[index] = skip ? undefined2 : get4(object, paths[index]); } return result2; @@ -7999,20 +5916,20 @@ return copyArray(value, result2); } } else { - var tag = getTag2(value), isFunc = tag == funcTag3 || tag == genTag2; + var tag2 = getTag2(value), isFunc = tag2 == funcTag3 || tag2 == genTag2; if (isBuffer2(value)) { return cloneBuffer(value, isDeep); } - if (tag == objectTag4 || tag == argsTag4 || isFunc && !object) { + if (tag2 == objectTag4 || tag2 == argsTag4 || isFunc && !object) { result2 = isFlat || isFunc ? {} : initCloneObject(value); if (!isDeep) { return isFlat ? copySymbolsIn(value, baseAssignIn(result2, value)) : copySymbols(value, baseAssign(result2, value)); } } else { - if (!cloneableTags[tag]) { + if (!cloneableTags[tag2]) { return object ? value : {}; } - result2 = initCloneByTag(value, tag, isDeep); + result2 = initCloneByTag(value, tag2, isDeep); } } stack || (stack = new Stack2()); @@ -8048,13 +5965,13 @@ }; } function baseConformsTo(object, source, props) { - var length = props.length; + var length2 = props.length; if (object == null) { - return !length; + return !length2; } object = Object2(object); - while (length--) { - var key = props[length], predicate = source[key], value = object[key]; + while (length2--) { + var key = props[length2], predicate = source[key], value = object[key]; if (value === undefined2 && !(key in object) || !predicate(value)) { return false; } @@ -8070,8 +5987,8 @@ }, wait); } function baseDifference(array2, values2, iteratee2, comparator) { - var index = -1, includes2 = arrayIncludes, isCommon = true, length = array2.length, result2 = [], valuesLength = values2.length; - if (!length) { + var index = -1, includes2 = arrayIncludes, isCommon = true, length2 = array2.length, result2 = [], valuesLength = values2.length; + if (!length2) { return result2; } if (iteratee2) { @@ -8086,7 +6003,7 @@ values2 = new SetCache2(values2); } outer: - while (++index < length) { + while (++index < length2) { var value = array2[index], computed = iteratee2 == null ? value : iteratee2(value); value = comparator || value !== 0 ? value : 0; if (isCommon && computed === computed) { @@ -8114,8 +6031,8 @@ return result2; } function baseExtremum(array2, iteratee2, comparator) { - var index = -1, length = array2.length; - while (++index < length) { + var index = -1, length2 = array2.length; + while (++index < length2) { var value = array2[index], current = iteratee2(value); if (current != null && (computed === undefined2 ? current === current && !isSymbol2(current) : comparator(current, computed))) { var computed = current, result2 = value; @@ -8124,14 +6041,14 @@ return result2; } function baseFill(array2, value, start2, end) { - var length = array2.length; + var length2 = array2.length; start2 = toInteger(start2); if (start2 < 0) { - start2 = -start2 > length ? 0 : length + start2; + start2 = -start2 > length2 ? 0 : length2 + start2; } - end = end === undefined2 || end > length ? length : toInteger(end); + end = end === undefined2 || end > length2 ? length2 : toInteger(end); if (end < 0) { - end += length; + end += length2; } end = start2 > end ? 0 : toLength(end); while (start2 < end) { @@ -8149,10 +6066,10 @@ return result2; } function baseFlatten(array2, depth, predicate, isStrict, result2) { - var index = -1, length = array2.length; + var index = -1, length2 = array2.length; predicate || (predicate = isFlattenable); result2 || (result2 = []); - while (++index < length) { + while (++index < length2) { var value = array2[index]; if (depth > 0 && predicate(value)) { if (depth > 1) { @@ -8181,11 +6098,11 @@ } function baseGet(object, path) { path = castPath(path, object); - var index = 0, length = path.length; - while (object != null && index < length) { + var index = 0, length2 = path.length; + while (object != null && index < length2) { object = object[toKey(path[index++])]; } - return index && index == length ? object : undefined2; + return index && index == length2 ? object : undefined2; } function baseGetAllKeys2(object, keysFunc, symbolsFunc) { var result2 = keysFunc(object); @@ -8210,19 +6127,19 @@ return number3 >= nativeMin2(start2, end) && number3 < nativeMax2(start2, end); } function baseIntersection(arrays, iteratee2, comparator) { - var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = []; + var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length2 = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = []; while (othIndex--) { var array2 = arrays[othIndex]; if (othIndex && iteratee2) { array2 = arrayMap2(array2, baseUnary2(iteratee2)); } maxLength = nativeMin2(array2.length, maxLength); - caches[othIndex] = !comparator && (iteratee2 || length >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2; + caches[othIndex] = !comparator && (iteratee2 || length2 >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2; } array2 = arrays[0]; var index = -1, seen = caches[0]; outer: - while (++index < length && result2.length < maxLength) { + while (++index < length2 && result2.length < maxLength) { var value = array2[index], computed = iteratee2 ? iteratee2(value) : value; value = comparator || value !== 0 ? value : 0; if (!(seen ? cacheHas2(seen, computed) : includes2(result2, computed, comparator))) { @@ -8305,9 +6222,9 @@ return isObjectLike2(value) && getTag2(value) == mapTag4; } function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, length = index, noCustomizer = !customizer; + var index = matchData.length, length2 = index, noCustomizer = !customizer; if (object == null) { - return !length; + return !length2; } object = Object2(object); while (index--) { @@ -8316,7 +6233,7 @@ return false; } } - while (++index < length) { + while (++index < length2) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (noCustomizer && data[2]) { @@ -8476,12 +6393,12 @@ assignMergeValue(object, key, newValue); } function baseNth(array2, n3) { - var length = array2.length; - if (!length) { + var length2 = array2.length; + if (!length2) { return; } - n3 += n3 < 0 ? length : 0; - return isIndex2(n3, length) ? array2[n3] : undefined2; + n3 += n3 < 0 ? length2 : 0; + return isIndex2(n3, length2) ? array2[n3] : undefined2; } function baseOrderBy(collection, iteratees, orders) { if (iteratees.length) { @@ -8514,8 +6431,8 @@ }); } function basePickBy(object, paths, predicate) { - var index = -1, length = paths.length, result2 = {}; - while (++index < length) { + var index = -1, length2 = paths.length, result2 = {}; + while (++index < length2) { var path = paths[index], value = baseGet(object, path); if (predicate(value, path)) { baseSet(result2, castPath(path, object), value); @@ -8529,14 +6446,14 @@ }; } function basePullAll(array2, values2, iteratee2, comparator) { - var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length = values2.length, seen = array2; + var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length2 = values2.length, seen = array2; if (array2 === values2) { values2 = copyArray(values2); } if (iteratee2) { seen = arrayMap2(array2, baseUnary2(iteratee2)); } - while (++index < length) { + while (++index < length2) { var fromIndex = 0, value = values2[index], computed = iteratee2 ? iteratee2(value) : value; while ((fromIndex = indexOf2(seen, computed, fromIndex, comparator)) > -1) { if (seen !== array2) { @@ -8548,10 +6465,10 @@ return array2; } function basePullAt(array2, indexes) { - var length = array2 ? indexes.length : 0, lastIndex = length - 1; - while (length--) { - var index = indexes[length]; - if (length == lastIndex || index !== previous) { + var length2 = array2 ? indexes.length : 0, lastIndex = length2 - 1; + while (length2--) { + var index = indexes[length2]; + if (length2 == lastIndex || index !== previous) { var previous = index; if (isIndex2(index)) { splice2.call(array2, index, 1); @@ -8566,16 +6483,16 @@ return lower2 + nativeFloor(nativeRandom() * (upper - lower2 + 1)); } function baseRange(start2, end, step, fromRight) { - var index = -1, length = nativeMax2(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length); - while (length--) { - result2[fromRight ? length : ++index] = start2; + var index = -1, length2 = nativeMax2(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length2); + while (length2--) { + result2[fromRight ? length2 : ++index] = start2; start2 += step; } return result2; } function baseRepeat(string, n3) { var result2 = ""; - if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER3) { + if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER4) { return result2; } do { @@ -8604,8 +6521,8 @@ return object; } path = castPath(path, object); - var index = -1, length = path.length, lastIndex = length - 1, nested = object; - while (nested != null && ++index < length) { + var index = -1, length2 = path.length, lastIndex = length2 - 1, nested = object; + while (nested != null && ++index < length2) { var key = toKey(path[index]), newValue = value; if (key === "__proto__" || key === "constructor" || key === "prototype") { return object; @@ -8638,18 +6555,18 @@ return shuffleSelf(values(collection)); } function baseSlice(array2, start2, end) { - var index = -1, length = array2.length; + var index = -1, length2 = array2.length; if (start2 < 0) { - start2 = -start2 > length ? 0 : length + start2; + start2 = -start2 > length2 ? 0 : length2 + start2; } - end = end > length ? length : end; + end = end > length2 ? length2 : end; if (end < 0) { - end += length; + end += length2; } - length = start2 > end ? 0 : end - start2 >>> 0; + length2 = start2 > end ? 0 : end - start2 >>> 0; start2 >>>= 0; - var result2 = Array2(length); - while (++index < length) { + var result2 = Array2(length2); + while (++index < length2) { result2[index] = array2[index + start2]; } return result2; @@ -8708,8 +6625,8 @@ return nativeMin2(high, MAX_ARRAY_INDEX); } function baseSortedUniq(array2, iteratee2) { - var index = -1, length = array2.length, resIndex = 0, result2 = []; - while (++index < length) { + var index = -1, length2 = array2.length, resIndex = 0, result2 = []; + while (++index < length2) { var value = array2[index], computed = iteratee2 ? iteratee2(value) : value; if (!index || !eq2(computed, seen)) { var seen = computed; @@ -8741,14 +6658,14 @@ return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2; } function baseUniq(array2, iteratee2, comparator) { - var index = -1, includes2 = arrayIncludes, length = array2.length, isCommon = true, result2 = [], seen = result2; + var index = -1, includes2 = arrayIncludes, length2 = array2.length, isCommon = true, result2 = [], seen = result2; if (comparator) { isCommon = false; includes2 = arrayIncludesWith; - } else if (length >= LARGE_ARRAY_SIZE2) { - var set4 = iteratee2 ? null : createSet(array2); - if (set4) { - return setToArray2(set4); + } else if (length2 >= LARGE_ARRAY_SIZE2) { + var set5 = iteratee2 ? null : createSet(array2); + if (set5) { + return setToArray2(set5); } isCommon = false; includes2 = cacheHas2; @@ -8757,7 +6674,7 @@ seen = iteratee2 ? [] : result2; } outer: - while (++index < length) { + while (++index < length2) { var value = array2[index], computed = iteratee2 ? iteratee2(value) : value; value = comparator || value !== 0 ? value : 0; if (isCommon && computed === computed) { @@ -8789,10 +6706,10 @@ return baseSet(object, path, updater(baseGet(object, path)), customizer); } function baseWhile(array2, predicate, isDrop, fromRight) { - var length = array2.length, index = fromRight ? length : -1; - while ((fromRight ? index-- : ++index < length) && predicate(array2[index], index, array2)) { + var length2 = array2.length, index = fromRight ? length2 : -1; + while ((fromRight ? index-- : ++index < length2) && predicate(array2[index], index, array2)) { } - return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length : index); + return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length2) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length2 : index); } function baseWrapperValue(value, actions) { var result2 = value; @@ -8804,14 +6721,14 @@ }, result2); } function baseXor(arrays, iteratee2, comparator) { - var length = arrays.length; - if (length < 2) { - return length ? baseUniq(arrays[0]) : []; + var length2 = arrays.length; + if (length2 < 2) { + return length2 ? baseUniq(arrays[0]) : []; } - var index = -1, result2 = Array2(length); - while (++index < length) { + var index = -1, result2 = Array2(length2); + while (++index < length2) { var array2 = arrays[index], othIndex = -1; - while (++othIndex < length) { + while (++othIndex < length2) { if (othIndex != index) { result2[index] = baseDifference(result2[index] || array2, arrays[othIndex], iteratee2, comparator); } @@ -8820,8 +6737,8 @@ return baseUniq(baseFlatten(result2, 1), iteratee2, comparator); } function baseZipObject(props, values2, assignFunc) { - var index = -1, length = props.length, valsLength = values2.length, result2 = {}; - while (++index < length) { + var index = -1, length2 = props.length, valsLength = values2.length, result2 = {}; + while (++index < length2) { var value = index < valsLength ? values2[index] : undefined2; assignFunc(result2, props[index], value); } @@ -8841,9 +6758,9 @@ } var castRest = baseRest; function castSlice(array2, start2, end) { - var length = array2.length; - end = end === undefined2 ? length : end; - return !start2 && end >= length ? array2 : baseSlice(array2, start2, end); + var length2 = array2.length; + end = end === undefined2 ? length2 : end; + return !start2 && end >= length2 ? array2 : baseSlice(array2, start2, end); } var clearTimeout2 = ctxClearTimeout || function(id2) { return root3.clearTimeout(id2); @@ -8852,7 +6769,7 @@ if (isDeep) { return buffer.slice(); } - var length = buffer.length, result2 = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + var length2 = buffer.length, result2 = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2); buffer.copy(result2); return result2; } @@ -8891,8 +6808,8 @@ return 0; } function compareMultiple(object, other, orders) { - var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length; - while (++index < length) { + var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length2 = objCriteria.length, ordersLength = orders.length; + while (++index < length2) { var result2 = compareAscending(objCriteria[index], othCriteria[index]); if (result2) { if (index >= ordersLength) { @@ -8936,9 +6853,9 @@ return result2; } function copyArray(source, array2) { - var index = -1, length = source.length; - array2 || (array2 = Array2(length)); - while (++index < length) { + var index = -1, length2 = source.length; + array2 || (array2 = Array2(length2)); + while (++index < length2) { array2[index] = source[index]; } return array2; @@ -8946,8 +6863,8 @@ function copyObject(source, props, object, customizer) { var isNew = !object; object || (object = {}); - var index = -1, length = props.length; - while (++index < length) { + var index = -1, length2 = props.length; + while (++index < length2) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined2; if (newValue === undefined2) { @@ -8975,14 +6892,14 @@ } function createAssigner(assigner) { return baseRest(function(object, sources) { - var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined2, guard = length > 2 ? sources[2] : undefined2; - customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : undefined2; + var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : undefined2, guard = length2 > 2 ? sources[2] : undefined2; + customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : undefined2; if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined2 : customizer; - length = 1; + customizer = length2 < 3 ? undefined2 : customizer; + length2 = 1; } object = Object2(object); - while (++index < length) { + while (++index < length2) { var source = sources[index]; if (source) { assigner(object, source, index, customizer); @@ -8999,8 +6916,8 @@ if (!isArrayLike2(collection)) { return eachFunc(collection, iteratee2); } - var length = collection.length, index = fromRight ? length : -1, iterable = Object2(collection); - while (fromRight ? index-- : ++index < length) { + var length2 = collection.length, index = fromRight ? length2 : -1, iterable = Object2(collection); + while (fromRight ? index-- : ++index < length2) { if (iteratee2(iterable[index], index, iterable) === false) { break; } @@ -9010,9 +6927,9 @@ } function createBaseFor(fromRight) { return function(object, iteratee2, keysFunc) { - var index = -1, iterable = Object2(object), props = keysFunc(object), length = props.length; - while (length--) { - var key = props[fromRight ? length : ++index]; + var index = -1, iterable = Object2(object), props = keysFunc(object), length2 = props.length; + while (length2--) { + var key = props[fromRight ? length2 : ++index]; if (iteratee2(iterable[key], key, iterable) === false) { break; } @@ -9070,13 +6987,13 @@ function createCurry(func, bitmask, arity) { var Ctor = createCtor(func); function wrapper() { - var length = arguments.length, args = Array2(length), index = length, placeholder = getHolder(wrapper); + var length2 = arguments.length, args = Array2(length2), index = length2, placeholder = getHolder(wrapper); while (index--) { args[index] = arguments[index]; } - var holders = length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder ? [] : replaceHolders(args, placeholder); - length -= holders.length; - if (length < arity) { + var holders = length2 < 3 && args[0] !== placeholder && args[length2 - 1] !== placeholder ? [] : replaceHolders(args, placeholder); + length2 -= holders.length; + if (length2 < arity) { return createRecurry( func, bitmask, @@ -9087,7 +7004,7 @@ holders, undefined2, undefined2, - arity - length + arity - length2 ); } var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func; @@ -9111,7 +7028,7 @@ } function createFlow(fromRight) { return flatRest(function(funcs) { - var length = funcs.length, index = length, prereq = LodashWrapper.prototype.thru; + var length2 = funcs.length, index = length2, prereq = LodashWrapper.prototype.thru; if (fromRight) { funcs.reverse(); } @@ -9124,8 +7041,8 @@ var wrapper = new LodashWrapper([], true); } } - index = wrapper ? index : length; - while (++index < length) { + index = wrapper ? index : length2; + while (++index < length2) { func = funcs[index]; var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined2; 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) { @@ -9139,8 +7056,8 @@ if (wrapper && args.length == 1 && isArray2(value)) { return wrapper.plant(value).value(); } - var index2 = 0, result2 = length ? funcs[index2].apply(this, args) : value; - while (++index2 < length) { + var index2 = 0, result2 = length2 ? funcs[index2].apply(this, args) : value; + while (++index2 < length2) { result2 = funcs[index2].call(this, result2); } return result2; @@ -9150,7 +7067,7 @@ function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) { 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); function wrapper() { - var length = arguments.length, args = Array2(length), index = length; + var length2 = arguments.length, args = Array2(length2), index = length2; while (index--) { args[index] = arguments[index]; } @@ -9163,8 +7080,8 @@ if (partialsRight) { args = composeArgsRight(args, partialsRight, holdersRight, isCurried); } - length -= holdersCount; - if (isCurried && length < arity) { + length2 -= holdersCount; + if (isCurried && length2 < arity) { var newHolders = replaceHolders(args, placeholder); return createRecurry( func, @@ -9176,17 +7093,17 @@ newHolders, argPos, ary2, - arity - length + arity - length2 ); } var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func; - length = args.length; + length2 = args.length; if (argPos) { args = reorder(args, argPos); - } else if (isFlip && length > 1) { + } else if (isFlip && length2 > 1) { args.reverse(); } - if (isAry && ary2 < length) { + if (isAry && ary2 < length2) { args.length = ary2; } if (this && this !== root3 && this instanceof wrapper) { @@ -9237,14 +7154,14 @@ }); }); } - function createPadding(length, chars) { + function createPadding(length2, chars) { chars = chars === undefined2 ? " " : baseToString2(chars); var charsLength = chars.length; if (charsLength < 2) { - return charsLength ? baseRepeat(chars, length) : chars; + return charsLength ? baseRepeat(chars, length2) : chars; } - var result2 = baseRepeat(chars, nativeCeil(length / stringSize(chars))); - return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length).join("") : result2.slice(0, length); + var result2 = baseRepeat(chars, nativeCeil(length2 / stringSize(chars))); + return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length2).join("") : result2.slice(0, length2); } function createPartial(func, bitmask, thisArg, partials) { var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func); @@ -9313,13 +7230,13 @@ } function createRound(methodName) { var func = Math2[methodName]; - return function(number3, precision2) { + return function(number3, precision3) { number3 = toNumber3(number3); - precision2 = precision2 == null ? 0 : nativeMin2(toInteger(precision2), 292); - if (precision2 && nativeIsFinite(number3)) { - var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision2)); + precision3 = precision3 == null ? 0 : nativeMin2(toInteger(precision3), 292); + if (precision3 && nativeIsFinite(number3)) { + var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision3)); pair3 = (toString2(value) + "e").split("e"); - return +(pair3[0] + "e" + (+pair3[1] - precision2)); + return +(pair3[0] + "e" + (+pair3[1] - precision3)); } return func(number3); }; @@ -9329,11 +7246,11 @@ }; function createToPairs(keysFunc) { return function(object) { - var tag = getTag2(object); - if (tag == mapTag4) { + var tag2 = getTag2(object); + if (tag2 == mapTag4) { return mapToArray2(object); } - if (tag == setTag4) { + if (tag2 == setTag4) { return setToPairs(object); } return baseToPairs(object, keysFunc(object)); @@ -9344,14 +7261,14 @@ if (!isBindKey && typeof func != "function") { throw new TypeError2(FUNC_ERROR_TEXT3); } - var length = partials ? partials.length : 0; - if (!length) { + var length2 = partials ? partials.length : 0; + if (!length2) { bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); partials = holders = undefined2; } ary2 = ary2 === undefined2 ? ary2 : nativeMax2(toInteger(ary2), 0); arity = arity === undefined2 ? arity : toInteger(arity); - length -= holders ? holders.length : 0; + length2 -= holders ? holders.length : 0; if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { var partialsRight = partials, holdersRight = holders; partials = holders = undefined2; @@ -9377,7 +7294,7 @@ thisArg = newData[2]; partials = newData[3]; holders = newData[4]; - arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax2(newData[9] - length, 0); + arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax2(newData[9] - length2, 0); if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); } @@ -9453,8 +7370,8 @@ stack["delete"](other); return result2; } - function equalByTag2(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { + function equalByTag2(object, other, tag2, bitmask, customizer, equalFunc, stack) { + switch (tag2) { case dataViewTag4: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; @@ -9555,9 +7472,9 @@ return metaMap.get(func); }; function getFuncName(func) { - var result2 = func.name + "", array2 = realNames[result2], length = hasOwnProperty10.call(realNames, result2) ? array2.length : 0; - while (length--) { - var data = array2[length], otherFunc = data.func; + var result2 = func.name + "", array2 = realNames[result2], length2 = hasOwnProperty10.call(realNames, result2) ? array2.length : 0; + while (length2--) { + var data = array2[length2], otherFunc = data.func; if (otherFunc == null || otherFunc == func) { return data.name; } @@ -9578,10 +7495,10 @@ return isKeyable2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } function getMatchData(object) { - var result2 = keys2(object), length = result2.length; - while (length--) { - var key = result2[length], value = object[key]; - result2[length] = [key, value, isStrictComparable(value)]; + var result2 = keys2(object), length2 = result2.length; + while (length2--) { + var key = result2[length2], value = object[key]; + result2[length2] = [key, value, isStrictComparable(value)]; } return result2; } @@ -9590,7 +7507,7 @@ return baseIsNative2(value) ? value : undefined2; } function getRawTag2(value) { - var isOwn = hasOwnProperty10.call(value, symToStringTag3), tag = value[symToStringTag3]; + var isOwn = hasOwnProperty10.call(value, symToStringTag3), tag2 = value[symToStringTag3]; try { value[symToStringTag3] = undefined2; var unmasked = true; @@ -9599,7 +7516,7 @@ var result2 = nativeObjectToString3.call(value); if (unmasked) { if (isOwn) { - value[symToStringTag3] = tag; + value[symToStringTag3] = tag2; } else { delete value[symToStringTag3]; } @@ -9645,8 +7562,8 @@ }; } function getView(start2, end, transforms) { - var index = -1, length = transforms.length; - while (++index < length) { + var index = -1, length2 = transforms.length; + while (++index < length2) { var data = transforms[index], size2 = data.size; switch (data.type) { case "drop": @@ -9671,23 +7588,23 @@ } function hasPath(object, path, hasFunc) { path = castPath(path, object); - var index = -1, length = path.length, result2 = false; - while (++index < length) { + var index = -1, length2 = path.length, result2 = false; + while (++index < length2) { var key = toKey(path[index]); if (!(result2 = object != null && hasFunc(object, key))) { break; } object = object[key]; } - if (result2 || ++index != length) { + if (result2 || ++index != length2) { return result2; } - length = object == null ? 0 : object.length; - return !!length && isLength2(length) && isIndex2(key, length) && (isArray2(object) || isArguments2(object)); + length2 = object == null ? 0 : object.length; + return !!length2 && isLength2(length2) && isIndex2(key, length2) && (isArray2(object) || isArguments2(object)); } function initCloneArray(array2) { - var length = array2.length, result2 = new array2.constructor(length); - if (length && typeof array2[0] == "string" && hasOwnProperty10.call(array2, "index")) { + var length2 = array2.length, result2 = new array2.constructor(length2); + if (length2 && typeof array2[0] == "string" && hasOwnProperty10.call(array2, "index")) { result2.index = array2.index; result2.input = array2.input; } @@ -9696,9 +7613,9 @@ function initCloneObject(object) { return typeof object.constructor == "function" && !isPrototype2(object) ? baseCreate(getPrototype(object)) : {}; } - function initCloneByTag(object, tag, isDeep) { + function initCloneByTag(object, tag2, isDeep) { var Ctor = object.constructor; - switch (tag) { + switch (tag2) { case arrayBufferTag3: return cloneArrayBuffer(object); case boolTag3: @@ -9730,22 +7647,22 @@ } } function insertWrapDetails(source, details) { - var length = details.length; - if (!length) { + var length2 = details.length; + if (!length2) { return source; } - var lastIndex = length - 1; - details[lastIndex] = (length > 1 ? "& " : "") + details[lastIndex]; - details = details.join(length > 2 ? ", " : " "); + var lastIndex = length2 - 1; + details[lastIndex] = (length2 > 1 ? "& " : "") + details[lastIndex]; + details = details.join(length2 > 2 ? ", " : " "); return source.replace(reWrapComment, "{\n/* [wrapped with " + details + "] */\n"); } function isFlattenable(value) { return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); } - function isIndex2(value, length) { + function isIndex2(value, length2) { var type2 = typeof value; - length = length == null ? MAX_SAFE_INTEGER3 : length; - return !!length && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length); + length2 = length2 == null ? MAX_SAFE_INTEGER4 : length2; + return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length2); } function isIterateeCall(value, index, object) { if (!isObject3(object)) { @@ -9862,8 +7779,8 @@ function overRest(func, start2, transform3) { start2 = nativeMax2(start2 === undefined2 ? func.length - 1 : start2, 0); return function() { - var args = arguments, index = -1, length = nativeMax2(args.length - start2, 0), array2 = Array2(length); - while (++index < length) { + var args = arguments, index = -1, length2 = nativeMax2(args.length - start2, 0), array2 = Array2(length2); + while (++index < length2) { array2[index] = args[start2 + index]; } index = -1; @@ -9879,10 +7796,10 @@ return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); } function reorder(array2, indexes) { - var arrLength = array2.length, length = nativeMin2(indexes.length, arrLength), oldArray = copyArray(array2); - while (length--) { - var index = indexes[length]; - array2[length] = isIndex2(index, arrLength) ? oldArray[index] : undefined2; + var arrLength = array2.length, length2 = nativeMin2(indexes.length, arrLength), oldArray = copyArray(array2); + while (length2--) { + var index = indexes[length2]; + array2[length2] = isIndex2(index, arrLength) ? oldArray[index] : undefined2; } return array2; } @@ -9920,8 +7837,8 @@ }; } function shuffleSelf(array2, size2) { - var index = -1, length = array2.length, lastIndex = length - 1; - size2 = size2 === undefined2 ? length : size2; + var index = -1, length2 = array2.length, lastIndex = length2 - 1; + size2 = size2 === undefined2 ? length2 : size2; while (++index < size2) { var rand = baseRandom(index, lastIndex), value = array2[rand]; array2[rand] = array2[index]; @@ -9935,8 +7852,8 @@ if (string.charCodeAt(0) === 46) { result2.push(""); } - string.replace(rePropName, function(match, number3, quote2, subString) { - result2.push(quote2 ? subString.replace(reEscapeChar, "$1") : number3 || match); + string.replace(rePropName, function(match, number3, quote, subString) { + result2.push(quote ? subString.replace(reEscapeChar, "$1") : number3 || match); }); return result2; }); @@ -9985,19 +7902,19 @@ } else { size2 = nativeMax2(toInteger(size2), 0); } - var length = array2 == null ? 0 : array2.length; - if (!length || size2 < 1) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2 || size2 < 1) { return []; } - var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length / size2)); - while (index < length) { + var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length2 / size2)); + while (index < length2) { result2[resIndex++] = baseSlice(array2, index, index += size2); } return result2; } function compact(array2) { - var index = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result2 = []; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result2 = []; + while (++index < length2) { var value = array2[index]; if (value) { result2[resIndex++] = value; @@ -10006,17 +7923,17 @@ return result2; } function concat() { - var length = arguments.length; - if (!length) { + var length2 = arguments.length; + if (!length2) { return []; } - var args = Array2(length - 1), array2 = arguments[0], index = length; + var args = Array2(length2 - 1), array2 = arguments[0], index = length2; while (index--) { args[index - 1] = arguments[index]; } return arrayPush2(isArray2(array2) ? copyArray(array2) : [array2], baseFlatten(args, 1)); } - var difference = baseRest(function(array2, values2) { + var difference2 = baseRest(function(array2, values2) { return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true)) : []; }); var differenceBy = baseRest(function(array2, values2) { @@ -10034,20 +7951,20 @@ return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), undefined2, comparator) : []; }); function drop(array2, n3, guard) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } n3 = guard || n3 === undefined2 ? 1 : toInteger(n3); - return baseSlice(array2, n3 < 0 ? 0 : n3, length); + return baseSlice(array2, n3 < 0 ? 0 : n3, length2); } function dropRight(array2, n3, guard) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } n3 = guard || n3 === undefined2 ? 1 : toInteger(n3); - n3 = length - n3; + n3 = length2 - n3; return baseSlice(array2, 0, n3 < 0 ? 0 : n3); } function dropRightWhile(array2, predicate) { @@ -10057,58 +7974,58 @@ return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true) : []; } function fill(array2, value, start2, end) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } if (start2 && typeof start2 != "number" && isIterateeCall(array2, value, start2)) { start2 = 0; - end = length; + end = length2; } return baseFill(array2, value, start2, end); } function findIndex(array2, predicate, fromIndex) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return -1; } var index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { - index = nativeMax2(length + index, 0); + index = nativeMax2(length2 + index, 0); } return baseFindIndex(array2, getIteratee(predicate, 3), index); } function findLastIndex(array2, predicate, fromIndex) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return -1; } - var index = length - 1; + var index = length2 - 1; if (fromIndex !== undefined2) { index = toInteger(fromIndex); - index = fromIndex < 0 ? nativeMax2(length + index, 0) : nativeMin2(index, length - 1); + index = fromIndex < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1); } return baseFindIndex(array2, getIteratee(predicate, 3), index, true); } function flatten2(array2) { - var length = array2 == null ? 0 : array2.length; - return length ? baseFlatten(array2, 1) : []; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? baseFlatten(array2, 1) : []; } function flattenDeep(array2) { - var length = array2 == null ? 0 : array2.length; - return length ? baseFlatten(array2, INFINITY2) : []; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? baseFlatten(array2, INFINITY2) : []; } function flattenDepth(array2, depth) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } depth = depth === undefined2 ? 1 : toInteger(depth); return baseFlatten(array2, depth); } function fromPairs(pairs2) { - var index = -1, length = pairs2 == null ? 0 : pairs2.length, result2 = {}; - while (++index < length) { + var index = -1, length2 = pairs2 == null ? 0 : pairs2.length, result2 = {}; + while (++index < length2) { var pair3 = pairs2[index]; result2[pair3[0]] = pair3[1]; } @@ -10118,21 +8035,21 @@ return array2 && array2.length ? array2[0] : undefined2; } function indexOf(array2, value, fromIndex) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return -1; } var index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { - index = nativeMax2(length + index, 0); + index = nativeMax2(length2 + index, 0); } return baseIndexOf(array2, value, index); } function initial(array2) { - var length = array2 == null ? 0 : array2.length; - return length ? baseSlice(array2, 0, -1) : []; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? baseSlice(array2, 0, -1) : []; } - var intersection = baseRest(function(arrays) { + var intersection2 = baseRest(function(arrays) { var mapped = arrayMap2(arrays, castArrayLikeObject); return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : []; }); @@ -10157,18 +8074,18 @@ return array2 == null ? "" : nativeJoin.call(array2, separator); } function last(array2) { - var length = array2 == null ? 0 : array2.length; - return length ? array2[length - 1] : undefined2; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? array2[length2 - 1] : undefined2; } function lastIndexOf(array2, value, fromIndex) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return -1; } - var index = length; + var index = length2; if (fromIndex !== undefined2) { index = toInteger(fromIndex); - index = index < 0 ? nativeMax2(length + index, 0) : nativeMin2(index, length - 1); + index = index < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1); } return value === value ? strictLastIndexOf(array2, value, index) : baseFindIndex(array2, baseIsNaN, index, true); } @@ -10186,9 +8103,9 @@ return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, undefined2, comparator) : array2; } var pullAt = flatRest(function(array2, indexes) { - var length = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes); + var length2 = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes); basePullAt(array2, arrayMap2(indexes, function(index) { - return isIndex2(index, length) ? +index : index; + return isIndex2(index, length2) ? +index : index; }).sort(compareAscending)); return result2; }); @@ -10197,9 +8114,9 @@ if (!(array2 && array2.length)) { return result2; } - var index = -1, indexes = [], length = array2.length; + var index = -1, indexes = [], length2 = array2.length; predicate = getIteratee(predicate, 3); - while (++index < length) { + while (++index < length2) { var value = array2[index]; if (predicate(value, index, array2)) { result2.push(value); @@ -10213,16 +8130,16 @@ return array2 == null ? array2 : nativeReverse.call(array2); } function slice(array2, start2, end) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } if (end && typeof end != "number" && isIterateeCall(array2, start2, end)) { start2 = 0; - end = length; + end = length2; } else { start2 = start2 == null ? 0 : toInteger(start2); - end = end === undefined2 ? length : toInteger(end); + end = end === undefined2 ? length2 : toInteger(end); } return baseSlice(array2, start2, end); } @@ -10233,10 +8150,10 @@ return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2)); } function sortedIndexOf(array2, value) { - var length = array2 == null ? 0 : array2.length; - if (length) { + var length2 = array2 == null ? 0 : array2.length; + if (length2) { var index = baseSortedIndex(array2, value); - if (index < length && eq2(array2[index], value)) { + if (index < length2 && eq2(array2[index], value)) { return index; } } @@ -10249,8 +8166,8 @@ return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2), true); } function sortedLastIndexOf(array2, value) { - var length = array2 == null ? 0 : array2.length; - if (length) { + var length2 = array2 == null ? 0 : array2.length; + if (length2) { var index = baseSortedIndex(array2, value, true) - 1; if (eq2(array2[index], value)) { return index; @@ -10265,8 +8182,8 @@ return array2 && array2.length ? baseSortedUniq(array2, getIteratee(iteratee2, 2)) : []; } function tail(array2) { - var length = array2 == null ? 0 : array2.length; - return length ? baseSlice(array2, 1, length) : []; + var length2 = array2 == null ? 0 : array2.length; + return length2 ? baseSlice(array2, 1, length2) : []; } function take(array2, n3, guard) { if (!(array2 && array2.length)) { @@ -10276,13 +8193,13 @@ return baseSlice(array2, 0, n3 < 0 ? 0 : n3); } function takeRight(array2, n3, guard) { - var length = array2 == null ? 0 : array2.length; - if (!length) { + var length2 = array2 == null ? 0 : array2.length; + if (!length2) { return []; } n3 = guard || n3 === undefined2 ? 1 : toInteger(n3); - n3 = length - n3; - return baseSlice(array2, n3 < 0 ? 0 : n3, length); + n3 = length2 - n3; + return baseSlice(array2, n3 < 0 ? 0 : n3, length2); } function takeRightWhile(array2, predicate) { return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), false, true) : []; @@ -10290,7 +8207,7 @@ function takeWhile(array2, predicate) { return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3)) : []; } - var union = baseRest(function(arrays) { + var union2 = baseRest(function(arrays) { return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); }); var unionBy = baseRest(function(arrays) { @@ -10319,14 +8236,14 @@ if (!(array2 && array2.length)) { return []; } - var length = 0; + var length2 = 0; array2 = arrayFilter2(array2, function(group) { if (isArrayLikeObject(group)) { - length = nativeMax2(group.length, length); + length2 = nativeMax2(group.length, length2); return true; } }); - return baseTimes2(length, function(index) { + return baseTimes2(length2, function(index) { return arrayMap2(array2, baseProperty(index)); }); } @@ -10368,7 +8285,7 @@ return baseZipObject(props || [], values2 || [], baseSet); } var zipWith = baseRest(function(arrays) { - var length = arrays.length, iteratee2 = length > 1 ? arrays[length - 1] : undefined2; + var length2 = arrays.length, iteratee2 = length2 > 1 ? arrays[length2 - 1] : undefined2; iteratee2 = typeof iteratee2 == "function" ? (arrays.pop(), iteratee2) : undefined2; return unzipWith(arrays, iteratee2); }); @@ -10385,20 +8302,20 @@ return interceptor(value); } var wrapperAt = flatRest(function(paths) { - var length = paths.length, start2 = length ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) { + var length2 = paths.length, start2 = length2 ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) { return baseAt(object, paths); }; - if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) { + if (length2 > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) { return this.thru(interceptor); } - value = value.slice(start2, +start2 + (length ? 1 : 0)); + value = value.slice(start2, +start2 + (length2 ? 1 : 0)); value.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined2 }); return new LodashWrapper(value, this.__chain__).thru(function(array2) { - if (length && !array2.length) { + if (length2 && !array2.length) { array2.push(undefined2); } return array2; @@ -10423,15 +8340,15 @@ function wrapperPlant(value) { var result2, parent2 = this; while (parent2 instanceof baseLodash) { - var clone2 = wrapperClone(parent2); - clone2.__index__ = 0; - clone2.__values__ = undefined2; + var clone3 = wrapperClone(parent2); + clone3.__index__ = 0; + clone3.__values__ = undefined2; if (result2) { - previous.__wrapped__ = clone2; + previous.__wrapped__ = clone3; } else { - result2 = clone2; + result2 = clone3; } - var previous = clone2; + var previous = clone3; parent2 = parent2.__wrapped__; } previous.__wrapped__ = value; @@ -10505,11 +8422,11 @@ function includes(collection, value, fromIndex, guard) { collection = isArrayLike2(collection) ? collection : values(collection); fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; - var length = collection.length; + var length2 = collection.length; if (fromIndex < 0) { - fromIndex = nativeMax2(length + fromIndex, 0); + fromIndex = nativeMax2(length2 + fromIndex, 0); } - return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; + return isString(collection) ? fromIndex <= length2 && collection.indexOf(value, fromIndex) > -1 : !!length2 && baseIndexOf(collection, value, fromIndex) > -1; } var invokeMap = baseRest(function(collection, path, args) { var index = -1, isFunc = typeof path == "function", result2 = isArrayLike2(collection) ? Array2(collection.length) : []; @@ -10579,8 +8496,8 @@ if (isArrayLike2(collection)) { return isString(collection) ? stringSize(collection) : collection.length; } - var tag = getTag2(collection); - if (tag == mapTag4 || tag == setTag4) { + var tag2 = getTag2(collection); + if (tag2 == mapTag4 || tag2 == setTag4) { return collection.size; } return baseKeys2(collection).length; @@ -10596,10 +8513,10 @@ if (collection == null) { return []; } - var length = iteratees.length; - if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + var length2 = iteratees.length; + if (length2 > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { iteratees = []; - } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + } else if (length2 > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { iteratees = [iteratees[0]]; } return baseOrderBy(collection, baseFlatten(iteratees, 1), []); @@ -10800,8 +8717,8 @@ transforms = transforms.length == 1 && isArray2(transforms[0]) ? arrayMap2(transforms[0], baseUnary2(getIteratee())) : arrayMap2(baseFlatten(transforms, 1), baseUnary2(getIteratee())); var funcsLength = transforms.length; return baseRest(function(args) { - var index = -1, length = nativeMin2(args.length, funcsLength); - while (++index < length) { + var index = -1, length2 = nativeMin2(args.length, funcsLength); + while (++index < length2) { args[index] = transforms[index].call(this, args[index]); } return apply(func, this, args); @@ -10866,7 +8783,7 @@ var value = arguments[0]; return isArray2(value) ? value : [value]; } - function clone(value) { + function clone2(value) { return baseClone(value, CLONE_SYMBOLS_FLAG); } function cloneWith(value, customizer) { @@ -10890,7 +8807,7 @@ var gte = createRelationalOperation(function(value, other) { return value >= other; }); - var isArguments2 = baseIsArguments2(function() { + var isArguments2 = baseIsArguments2(/* @__PURE__ */ function() { return arguments; }()) ? baseIsArguments2 : function(value) { return isObjectLike2(value) && hasOwnProperty10.call(value, "callee") && !propertyIsEnumerable3.call(value, "callee"); @@ -10918,8 +8835,8 @@ if (isArrayLike2(value) && (isArray2(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer2(value) || isTypedArray2(value) || isArguments2(value))) { return !value.length; } - var tag = getTag2(value); - if (tag == mapTag4 || tag == setTag4) { + var tag2 = getTag2(value); + if (tag2 == mapTag4 || tag2 == setTag4) { return !value.size; } if (isPrototype2(value)) { @@ -10944,8 +8861,8 @@ if (!isObjectLike2(value)) { return false; } - var tag = baseGetTag2(value); - return tag == errorTag3 || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value); + var tag2 = baseGetTag2(value); + return tag2 == errorTag3 || tag2 == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value); } function isFinite2(value) { return typeof value == "number" && nativeIsFinite(value); @@ -10954,14 +8871,14 @@ if (!isObject3(value)) { return false; } - var tag = baseGetTag2(value); - return tag == funcTag3 || tag == genTag2 || tag == asyncTag2 || tag == proxyTag2; + var tag2 = baseGetTag2(value); + return tag2 == funcTag3 || tag2 == genTag2 || tag2 == asyncTag2 || tag2 == proxyTag2; } function isInteger(value) { return typeof value == "number" && value == toInteger(value); } function isLength2(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER3; + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER4; } function isObject3(value) { var type2 = typeof value; @@ -11009,7 +8926,7 @@ } var isRegExp = nodeIsRegExp ? baseUnary2(nodeIsRegExp) : baseIsRegExp; function isSafeInteger(value) { - return isInteger(value) && value >= -MAX_SAFE_INTEGER3 && value <= MAX_SAFE_INTEGER3; + return isInteger(value) && value >= -MAX_SAFE_INTEGER4 && value <= MAX_SAFE_INTEGER4; } var isSet = nodeIsSet ? baseUnary2(nodeIsSet) : baseIsSet; function isString(value) { @@ -11042,7 +8959,7 @@ if (symIterator && value[symIterator]) { return iteratorToArray(value[symIterator]()); } - var tag = getTag2(value), func = tag == mapTag4 ? mapToArray2 : tag == setTag4 ? setToArray2 : values; + var tag2 = getTag2(value), func = tag2 == mapTag4 ? mapToArray2 : tag2 == setTag4 ? setToArray2 : values; return func(value); } function toFinite(value) { @@ -11085,7 +9002,7 @@ return copyObject(value, keysIn(value)); } function toSafeInteger(value) { - return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER3, MAX_SAFE_INTEGER3) : value === 0 ? value : 0; + return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER4, MAX_SAFE_INTEGER4) : value === 0 ? value : 0; } function toString2(value) { return value == null ? "" : baseToString2(value); @@ -11118,12 +9035,12 @@ var defaults = baseRest(function(object, sources) { object = Object2(object); var index = -1; - var length = sources.length; - var guard = length > 2 ? sources[2] : undefined2; + var length2 = sources.length; + var guard = length2 > 2 ? sources[2] : undefined2; if (guard && isIterateeCall(sources[0], sources[1], guard)) { - length = 1; + length2 = 1; } - while (++index < length) { + while (++index < length2) { var source = sources[index]; var props = keysIn(source); var propsIndex = -1; @@ -11236,9 +9153,9 @@ if (isDeep) { result2 = baseClone(result2, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); } - var length = paths.length; - while (length--) { - baseUnset(result2, paths[length]); + var length2 = paths.length; + while (length2--) { + baseUnset(result2, paths[length2]); } return result2; }); @@ -11262,22 +9179,22 @@ } function result(object, path, defaultValue) { path = castPath(path, object); - var index = -1, length = path.length; - if (!length) { - length = 1; + var index = -1, length2 = path.length; + if (!length2) { + length2 = 1; object = undefined2; } - while (++index < length) { + while (++index < length2) { var value = object == null ? undefined2 : object[toKey(path[index])]; if (value === undefined2) { - index = length; + index = length2; value = defaultValue; } object = isFunction2(value) ? value.call(object) : value; } return object; } - function set3(object, path, value) { + function set4(object, path, value) { return object == null ? object : baseSet(object, path, value); } function setWith(object, path, value, customizer) { @@ -11396,8 +9313,8 @@ function endsWith(string, target, position) { string = toString2(string); target = baseToString2(target); - var length = string.length; - position = position === undefined2 ? length : baseClamp(toInteger(position), 0, length); + var length2 = string.length; + position = position === undefined2 ? length2 : baseClamp(toInteger(position), 0, length2); var end = position; position -= target.length; return position >= 0 && string.slice(position, end) == target; @@ -11417,27 +9334,27 @@ return result2 + (index ? " " : "") + word.toLowerCase(); }); var lowerFirst = createCaseFirst("toLowerCase"); - function pad2(string, length, chars) { + function pad2(string, length2, chars) { string = toString2(string); - length = toInteger(length); - var strLength = length ? stringSize(string) : 0; - if (!length || strLength >= length) { + length2 = toInteger(length2); + var strLength = length2 ? stringSize(string) : 0; + if (!length2 || strLength >= length2) { return string; } - var mid = (length - strLength) / 2; + var mid = (length2 - strLength) / 2; return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil(mid), chars); } - function padEnd(string, length, chars) { + function padEnd(string, length2, chars) { string = toString2(string); - length = toInteger(length); - var strLength = length ? stringSize(string) : 0; - return length && strLength < length ? string + createPadding(length - strLength, chars) : string; + length2 = toInteger(length2); + var strLength = length2 ? stringSize(string) : 0; + return length2 && strLength < length2 ? string + createPadding(length2 - strLength, chars) : string; } - function padStart(string, length, chars) { + function padStart(string, length2, chars) { string = toString2(string); - length = toInteger(length); - var strLength = length ? stringSize(string) : 0; - return length && strLength < length ? createPadding(length - strLength, chars) + string : string; + length2 = toInteger(length2); + var strLength = length2 ? stringSize(string) : 0; + return length2 && strLength < length2 ? createPadding(length2 - strLength, chars) + string : string; } function parseInt2(string, radix, guard) { if (guard || radix == null) { @@ -11577,10 +9494,10 @@ return castSlice(strSymbols, start2).join(""); } function truncate(string, options2) { - var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; + var length2 = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; if (isObject3(options2)) { var separator = "separator" in options2 ? options2.separator : separator; - length = "length" in options2 ? toInteger(options2.length) : length; + length2 = "length" in options2 ? toInteger(options2.length) : length2; omission = "omission" in options2 ? baseToString2(options2.omission) : omission; } string = toString2(string); @@ -11589,10 +9506,10 @@ var strSymbols = stringToArray(string); strLength = strSymbols.length; } - if (length >= strLength) { + if (length2 >= strLength) { return string; } - var end = length - stringSize(omission); + var end = length2 - stringSize(omission); if (end < 1) { return omission; } @@ -11623,7 +9540,7 @@ } return result2 + omission; } - function unescape4(string) { + function unescape3(string) { string = toString2(string); return string && reHasEscapedHtml2.test(string) ? string.replace(reEscapedHtml2, unescapeHtmlChar2) : string; } @@ -11654,8 +9571,8 @@ return object; }); function cond(pairs2) { - var length = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee(); - pairs2 = !length ? [] : arrayMap2(pairs2, function(pair3) { + var length2 = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee(); + pairs2 = !length2 ? [] : arrayMap2(pairs2, function(pair3) { if (typeof pair3[1] != "function") { throw new TypeError2(FUNC_ERROR_TEXT3); } @@ -11663,7 +9580,7 @@ }); return baseRest(function(args) { var index = -1; - while (++index < length) { + while (++index < length2) { var pair3 = pairs2[index]; if (apply(pair3[0], this, args)) { return apply(pair3[1], this, args); @@ -11777,13 +9694,13 @@ } function times(n3, iteratee2) { n3 = toInteger(n3); - if (n3 < 1 || n3 > MAX_SAFE_INTEGER3) { + if (n3 < 1 || n3 > MAX_SAFE_INTEGER4) { return []; } - var index = MAX_ARRAY_LENGTH, length = nativeMin2(n3, MAX_ARRAY_LENGTH); + var index = MAX_ARRAY_LENGTH, length2 = nativeMin2(n3, MAX_ARRAY_LENGTH); iteratee2 = getIteratee(iteratee2); n3 -= MAX_ARRAY_LENGTH; - var result2 = baseTimes2(length, iteratee2); + var result2 = baseTimes2(length2, iteratee2); while (++index < n3) { iteratee2(index); } @@ -11866,7 +9783,7 @@ lodash.defaultsDeep = defaultsDeep; lodash.defer = defer; lodash.delay = delay; - lodash.difference = difference; + lodash.difference = difference2; lodash.differenceBy = differenceBy; lodash.differenceWith = differenceWith; lodash.drop = drop; @@ -11889,7 +9806,7 @@ lodash.functionsIn = functionsIn; lodash.groupBy = groupBy; lodash.initial = initial; - lodash.intersection = intersection; + lodash.intersection = intersection2; lodash.intersectionBy = intersectionBy; lodash.intersectionWith = intersectionWith; lodash.invert = invert; @@ -11940,7 +9857,7 @@ lodash.rest = rest; lodash.reverse = reverse; lodash.sampleSize = sampleSize; - lodash.set = set3; + lodash.set = set4; lodash.setWith = setWith; lodash.shuffle = shuffle; lodash.slice = slice; @@ -11964,7 +9881,7 @@ lodash.toPlainObject = toPlainObject; lodash.transform = transform2; lodash.unary = unary; - lodash.union = union; + lodash.union = union2; lodash.unionBy = unionBy; lodash.unionWith = unionWith; lodash.uniq = uniq; @@ -11998,7 +9915,7 @@ lodash.capitalize = capitalize; lodash.ceil = ceil; lodash.clamp = clamp3; - lodash.clone = clone; + lodash.clone = clone2; lodash.cloneDeep = cloneDeep; lodash.cloneDeepWith = cloneDeepWith; lodash.cloneWith = cloneWith; @@ -12137,7 +10054,7 @@ lodash.trimEnd = trimEnd; lodash.trimStart = trimStart; lodash.truncate = truncate; - lodash.unescape = unescape4; + lodash.unescape = unescape3; lodash.uniqueId = uniqueId; lodash.upperCase = upperCase; lodash.upperFirst = upperFirst; @@ -12339,12 +10256,12 @@ if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { if (a2.constructor !== b2.constructor) return false; - var length, i3, keys2; + var length2, i3, keys2; if (Array.isArray(a2)) { - length = a2.length; - if (length != b2.length) + length2 = a2.length; + if (length2 != b2.length) return false; - for (i3 = length; i3-- !== 0; ) + for (i3 = length2; i3-- !== 0; ) if (!equal(a2[i3], b2[i3])) return false; return true; @@ -12356,13 +10273,13 @@ if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); keys2 = Object.keys(a2); - length = keys2.length; - if (length !== Object.keys(b2).length) + length2 = keys2.length; + if (length2 !== Object.keys(b2).length) return false; - for (i3 = length; i3-- !== 0; ) + for (i3 = length2; i3-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b2, keys2[i3])) return false; - for (i3 = length; i3-- !== 0; ) { + for (i3 = length2; i3-- !== 0; ) { var key = keys2[i3]; if (!equal(a2[key], b2[key])) return false; @@ -12385,7 +10302,7 @@ !function t4(n4, r4, e6, a4, h4) { for (; a4 > e6; ) { if (a4 - e6 > 600) { - var o3 = a4 - e6 + 1, s3 = r4 - e6 + 1, l3 = Math.log(o3), f4 = 0.5 * Math.exp(2 * l3 / 3), u3 = 0.5 * Math.sqrt(l3 * f4 * (o3 - f4) / o3) * (s3 - o3 / 2 < 0 ? -1 : 1), m3 = Math.max(e6, Math.floor(r4 - s3 * f4 / o3 + u3)), c3 = Math.min(a4, Math.floor(r4 + (o3 - s3) * f4 / o3 + u3)); + var o3 = a4 - e6 + 1, s3 = r4 - e6 + 1, l3 = Math.log(o3), f3 = 0.5 * Math.exp(2 * l3 / 3), u3 = 0.5 * Math.sqrt(l3 * f3 * (o3 - f3) / o3) * (s3 - o3 / 2 < 0 ? -1 : 1), m3 = Math.max(e6, Math.floor(r4 - s3 * f3 / o3 + u3)), c3 = Math.min(a4, Math.floor(r4 + (o3 - s3) * f3 / o3 + u3)); t4(n4, r4, m3, c3, h4); } var p3 = n4[r4], d4 = e6, x2 = a4; @@ -12437,7 +10354,7 @@ function l2(t3, i4) { return t3.minY - i4.minY; } - function f3(t3) { + function f2(t3) { return (t3.maxX - t3.minX) * (t3.maxY - t3.minY); } function u2(t3) { @@ -12520,9 +10437,9 @@ return this; for (var n4, r3, a3, h3 = this.data, o3 = this.toBBox(t3), s3 = [], l3 = []; h3 || s3.length; ) { if (h3 || (h3 = s3.pop(), r3 = s3[s3.length - 1], n4 = l3.pop(), a3 = true), h3.leaf) { - var f4 = e3(t3, h3.children, i4); - if (-1 !== f4) - return h3.children.splice(f4, 1), s3.push(h3), this._condense(s3), this; + var f3 = e3(t3, h3.children, i4); + if (-1 !== f3) + return h3.children.splice(f3, 1), s3.push(h3), this._condense(s3), this; } a3 || h3.leaf || !m2(h3, o3) ? r3 ? (n4++, h3 = r3.children[n4], a3 = false) : h3 = null : (s3.push(h3), l3.push(n4), n4 = 0, r3 = h3, h3 = h3.children[0]); } @@ -12548,10 +10465,10 @@ r3 || (r3 = Math.ceil(Math.log(h3) / Math.log(o3)), o3 = Math.ceil(h3 / Math.pow(o3, r3 - 1))), (e4 = p2([])).leaf = false, e4.height = r3; var s3 = Math.ceil(h3 / o3), l3 = s3 * Math.ceil(Math.sqrt(o3)); d2(t3, i4, n4, l3, this.compareMinX); - for (var f4 = i4; f4 <= n4; f4 += l3) { - var u3 = Math.min(f4 + l3 - 1, n4); - d2(t3, f4, u3, s3, this.compareMinY); - for (var m3 = f4; m3 <= u3; m3 += s3) { + for (var f3 = i4; f3 <= n4; f3 += l3) { + var u3 = Math.min(f3 + l3 - 1, n4); + d2(t3, f3, u3, s3, this.compareMinY); + for (var m3 = f3; m3 <= u3; m3 += s3) { var c3 = Math.min(m3 + s3 - 1, u3); e4.children.push(this._build(t3, m3, c3, r3 - 1)); } @@ -12560,7 +10477,7 @@ }, r2.prototype._chooseSubtree = function(t3, i4, n4, r3) { for (; r3.push(i4), !i4.leaf && r3.length - 1 !== n4; ) { for (var e4 = 1 / 0, a3 = 1 / 0, h3 = void 0, o3 = 0; o3 < i4.children.length; o3++) { - var s3 = i4.children[o3], l3 = f3(s3), u3 = (m3 = t3, c3 = s3, (Math.max(c3.maxX, m3.maxX) - Math.min(c3.minX, m3.minX)) * (Math.max(c3.maxY, m3.maxY) - Math.min(c3.minY, m3.minY)) - l3); + var s3 = i4.children[o3], l3 = f2(s3), u3 = (m3 = t3, c3 = s3, (Math.max(c3.maxX, m3.maxX) - Math.min(c3.minX, m3.minX)) * (Math.max(c3.maxY, m3.maxY) - Math.min(c3.minY, m3.minY)) - l3); u3 < a3 ? (a3 = u3, e4 = l3 < e4 ? l3 : e4, h3 = s3) : u3 === a3 && l3 < e4 && (e4 = l3, h3 = s3); } i4 = h3 || i4.children[0]; @@ -12581,7 +10498,7 @@ this.data = p2([t3, i4]), this.data.height = t3.height + 1, this.data.leaf = false, a2(this.data, this.toBBox); }, r2.prototype._chooseSplitIndex = function(t3, i4, n4) { for (var r3, e4, a3, o3, s3, l3, u3, m3 = 1 / 0, c3 = 1 / 0, p3 = i4; p3 <= n4 - i4; p3++) { - var d4 = h2(t3, 0, p3, this.toBBox), x2 = h2(t3, p3, n4, this.toBBox), v2 = (e4 = d4, a3 = x2, o3 = void 0, s3 = void 0, l3 = void 0, u3 = void 0, o3 = Math.max(e4.minX, a3.minX), s3 = Math.max(e4.minY, a3.minY), l3 = Math.min(e4.maxX, a3.maxX), u3 = Math.min(e4.maxY, a3.maxY), Math.max(0, l3 - o3) * Math.max(0, u3 - s3)), M2 = f3(d4) + f3(x2); + var d4 = h2(t3, 0, p3, this.toBBox), x2 = h2(t3, p3, n4, this.toBBox), v2 = (e4 = d4, a3 = x2, o3 = void 0, s3 = void 0, l3 = void 0, u3 = void 0, o3 = Math.max(e4.minX, a3.minX), s3 = Math.max(e4.minY, a3.minY), l3 = Math.min(e4.maxX, a3.maxX), u3 = Math.min(e4.maxY, a3.maxY), Math.max(0, l3 - o3) * Math.max(0, u3 - s3)), M2 = f2(d4) + f2(x2); v2 < m3 ? (m3 = v2, r3 = p3, c3 = M2 < c3 ? M2 : c3) : v2 === m3 && M2 < c3 && (c3 = M2, r3 = p3); } return r3 || n4 - i4; @@ -12590,8 +10507,8 @@ this._allDistMargin(t3, i4, n4, r3) < this._allDistMargin(t3, i4, n4, e4) && t3.children.sort(r3); }, r2.prototype._allDistMargin = function(t3, i4, n4, r3) { t3.children.sort(r3); - for (var e4 = this.toBBox, a3 = h2(t3, 0, i4, e4), s3 = h2(t3, n4 - i4, n4, e4), l3 = u2(a3) + u2(s3), f4 = i4; f4 < n4 - i4; f4++) { - var m3 = t3.children[f4]; + for (var e4 = this.toBBox, a3 = h2(t3, 0, i4, e4), s3 = h2(t3, n4 - i4, n4, e4), l3 = u2(a3) + u2(s3), f3 = i4; f3 < n4 - i4; f3++) { + var m3 = t3.children[f3]; o2(a3, t3.leaf ? e4(m3) : m3), l3 += u2(a3); } for (var c3 = n4 - i4 - 1; c3 >= i4; c3--) { @@ -12721,9 +10638,9 @@ readFields: function(readField, result, end) { end = end || this.length; while (this.pos < end) { - var val = this.readVarint(), tag = val >> 3, startPos = this.pos; + var val = this.readVarint(), tag2 = val >> 3, startPos = this.pos; this.type = val & 7; - readField(tag, result, this); + readField(tag2, result, this); if (this.pos === startPos) this.skip(val); } @@ -12906,18 +10823,18 @@ throw new Error("Unimplemented type: " + type2); }, // === WRITING ================================================================= - writeTag: function(tag, type2) { - this.writeVarint(tag << 3 | type2); + writeTag: function(tag2, type2) { + this.writeVarint(tag2 << 3 | type2); }, realloc: function(min3) { - var length = this.length || 16; - while (length < this.pos + min3) - length *= 2; - if (length !== this.length) { - var buf = new Uint8Array(length); + var length2 = this.length || 16; + while (length2 < this.pos + min3) + length2 *= 2; + if (length2 !== this.length) { + var buf = new Uint8Array(length2); buf.set(this.buf); this.buf = buf; - this.length = length; + this.length = length2; } }, finish: function() { @@ -12971,12 +10888,12 @@ writeBoolean: function(val) { this.writeVarint(Boolean(val)); }, - writeString: function(str2) { - str2 = String(str2); - this.realloc(str2.length * 4); + writeString: function(str) { + str = String(str); + this.realloc(str.length * 4); this.pos++; var startPos = this.pos; - this.pos = writeUtf8(this.buf, str2, this.pos); + this.pos = writeUtf8(this.buf, str, this.pos); var len = this.pos - startPos; if (len >= 128) makeRoomForExtraLength(startPos, len, this); @@ -13012,88 +10929,88 @@ this.writeVarint(len); this.pos += len; }, - writeMessage: function(tag, fn, obj) { - this.writeTag(tag, Pbf.Bytes); + writeMessage: function(tag2, fn, obj) { + this.writeTag(tag2, Pbf.Bytes); this.writeRawMessage(fn, obj); }, - writePackedVarint: function(tag, arr) { + writePackedVarint: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedVarint, arr); + this.writeMessage(tag2, writePackedVarint, arr); }, - writePackedSVarint: function(tag, arr) { + writePackedSVarint: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedSVarint, arr); + this.writeMessage(tag2, writePackedSVarint, arr); }, - writePackedBoolean: function(tag, arr) { + writePackedBoolean: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedBoolean, arr); + this.writeMessage(tag2, writePackedBoolean, arr); }, - writePackedFloat: function(tag, arr) { + writePackedFloat: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedFloat, arr); + this.writeMessage(tag2, writePackedFloat, arr); }, - writePackedDouble: function(tag, arr) { + writePackedDouble: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedDouble, arr); + this.writeMessage(tag2, writePackedDouble, arr); }, - writePackedFixed32: function(tag, arr) { + writePackedFixed32: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedFixed32, arr); + this.writeMessage(tag2, writePackedFixed32, arr); }, - writePackedSFixed32: function(tag, arr) { + writePackedSFixed32: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedSFixed32, arr); + this.writeMessage(tag2, writePackedSFixed32, arr); }, - writePackedFixed64: function(tag, arr) { + writePackedFixed64: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedFixed64, arr); + this.writeMessage(tag2, writePackedFixed64, arr); }, - writePackedSFixed64: function(tag, arr) { + writePackedSFixed64: function(tag2, arr) { if (arr.length) - this.writeMessage(tag, writePackedSFixed64, arr); + this.writeMessage(tag2, writePackedSFixed64, arr); }, - writeBytesField: function(tag, buffer) { - this.writeTag(tag, Pbf.Bytes); + writeBytesField: function(tag2, buffer) { + this.writeTag(tag2, Pbf.Bytes); this.writeBytes(buffer); }, - writeFixed32Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); + writeFixed32Field: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed32); this.writeFixed32(val); }, - writeSFixed32Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); + writeSFixed32Field: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed32); this.writeSFixed32(val); }, - writeFixed64Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); + writeFixed64Field: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed64); this.writeFixed64(val); }, - writeSFixed64Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); + writeSFixed64Field: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed64); this.writeSFixed64(val); }, - writeVarintField: function(tag, val) { - this.writeTag(tag, Pbf.Varint); + writeVarintField: function(tag2, val) { + this.writeTag(tag2, Pbf.Varint); this.writeVarint(val); }, - writeSVarintField: function(tag, val) { - this.writeTag(tag, Pbf.Varint); + writeSVarintField: function(tag2, val) { + this.writeTag(tag2, Pbf.Varint); this.writeSVarint(val); }, - writeStringField: function(tag, str2) { - this.writeTag(tag, Pbf.Bytes); - this.writeString(str2); + writeStringField: function(tag2, str) { + this.writeTag(tag2, Pbf.Bytes); + this.writeString(str); }, - writeFloatField: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); + writeFloatField: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed32); this.writeFloat(val); }, - writeDoubleField: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); + writeDoubleField: function(tag2, val) { + this.writeTag(tag2, Pbf.Fixed64); this.writeDouble(val); }, - writeBooleanField: function(tag, val) { - this.writeVarintField(tag, Boolean(val)); + writeBooleanField: function(tag2, val) { + this.writeVarintField(tag2, Boolean(val)); } }; function readVarintRemainder(l2, s2, p2) { @@ -13240,7 +11157,7 @@ return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24); } function readUtf8(buf, pos, end) { - var str2 = ""; + var str = ""; var i3 = pos; while (i3 < end) { var b0 = buf[i3]; @@ -13286,20 +11203,20 @@ bytesPerSequence = 1; } else if (c2 > 65535) { c2 -= 65536; - str2 += String.fromCharCode(c2 >>> 10 & 1023 | 55296); + str += String.fromCharCode(c2 >>> 10 & 1023 | 55296); c2 = 56320 | c2 & 1023; } - str2 += String.fromCharCode(c2); + str += String.fromCharCode(c2); i3 += bytesPerSequence; } - return str2; + return str; } function readUtf8TextDecoder(buf, pos, end) { return utf8TextDecoder.decode(buf.subarray(pos, end)); } - function writeUtf8(buf, str2, pos) { - for (var i3 = 0, c2, lead; i3 < str2.length; i3++) { - c2 = str2.charCodeAt(i3); + function writeUtf8(buf, str, pos) { + for (var i3 = 0, c2, lead; i3 < str.length; i3++) { + c2 = str.charCodeAt(i3); if (c2 > 55295 && c2 < 57344) { if (lead) { if (c2 < 56320) { @@ -13313,7 +11230,7 @@ lead = null; } } else { - if (c2 > 56319 || i3 + 1 === str2.length) { + if (c2 > 56319 || i3 + 1 === str.length) { buf[pos++] = 239; buf[pos++] = 191; buf[pos++] = 189; @@ -13642,14 +11559,14 @@ this._values = values; pbf.readFields(readFeature, this, end); } - function readFeature(tag, feature3, pbf) { - if (tag == 1) + function readFeature(tag2, feature3, pbf) { + if (tag2 == 1) feature3.id = pbf.readVarint(); - else if (tag == 2) + else if (tag2 == 2) readTag(pbf, feature3); - else if (tag == 3) + else if (tag2 == 3) feature3.type = pbf.readVarint(); - else if (tag == 4) + else if (tag2 == 4) feature3._geometry = pbf.pos; } function readTag(pbf, feature3) { @@ -13658,1215 +11575,2642 @@ var key = feature3._keys[pbf.readVarint()], value = feature3._values[pbf.readVarint()]; feature3.properties[key] = value; } - } - VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"]; - VectorTileFeature.prototype.loadGeometry = function() { - var pbf = this._pbf; - pbf.pos = this._geometry; - var end = pbf.readVarint() + pbf.pos, cmd = 1, length = 0, x2 = 0, y2 = 0, lines = [], line; - while (pbf.pos < end) { - if (length <= 0) { - var cmdLen = pbf.readVarint(); - cmd = cmdLen & 7; - length = cmdLen >> 3; + } + VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"]; + VectorTileFeature.prototype.loadGeometry = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, lines = [], line; + while (pbf.pos < end) { + if (length2 <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 7; + length2 = cmdLen >> 3; + } + length2--; + if (cmd === 1 || cmd === 2) { + x2 += pbf.readSVarint(); + y2 += pbf.readSVarint(); + if (cmd === 1) { + if (line) + lines.push(line); + line = []; + } + line.push(new Point(x2, y2)); + } else if (cmd === 7) { + if (line) { + line.push(line[0].clone()); + } + } else { + throw new Error("unknown command " + cmd); + } + } + if (line) + lines.push(line); + return lines; + }; + VectorTileFeature.prototype.bbox = function() { + var pbf = this._pbf; + pbf.pos = this._geometry; + var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity; + while (pbf.pos < end) { + if (length2 <= 0) { + var cmdLen = pbf.readVarint(); + cmd = cmdLen & 7; + length2 = cmdLen >> 3; + } + length2--; + if (cmd === 1 || cmd === 2) { + x2 += pbf.readSVarint(); + y2 += pbf.readSVarint(); + if (x2 < x12) + x12 = x2; + if (x2 > x22) + x22 = x2; + if (y2 < y12) + y12 = y2; + if (y2 > y22) + y22 = y2; + } else if (cmd !== 7) { + throw new Error("unknown command " + cmd); + } + } + return [x12, y12, x22, y22]; + }; + VectorTileFeature.prototype.toGeoJSON = function(x2, y2, z2) { + var size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, coords = this.loadGeometry(), type2 = VectorTileFeature.types[this.type], i3, j2; + function project(line) { + for (var j3 = 0; j3 < line.length; j3++) { + var p2 = line[j3], y22 = 180 - (p2.y + y05) * 360 / size; + line[j3] = [ + (p2.x + x05) * 360 / size - 180, + 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90 + ]; + } + } + switch (this.type) { + case 1: + var points = []; + for (i3 = 0; i3 < coords.length; i3++) { + points[i3] = coords[i3][0]; + } + coords = points; + project(coords); + break; + case 2: + for (i3 = 0; i3 < coords.length; i3++) { + project(coords[i3]); + } + break; + case 3: + coords = classifyRings(coords); + for (i3 = 0; i3 < coords.length; i3++) { + for (j2 = 0; j2 < coords[i3].length; j2++) { + project(coords[i3][j2]); + } + } + break; + } + if (coords.length === 1) { + coords = coords[0]; + } else { + type2 = "Multi" + type2; + } + var result = { + type: "Feature", + geometry: { + type: type2, + coordinates: coords + }, + properties: this.properties + }; + if ("id" in this) { + result.id = this.id; + } + return result; + }; + function classifyRings(rings) { + var len = rings.length; + if (len <= 1) + return [rings]; + var polygons = [], polygon2, ccw; + for (var i3 = 0; i3 < len; i3++) { + var area = signedArea(rings[i3]); + if (area === 0) + continue; + if (ccw === void 0) + ccw = area < 0; + if (ccw === area < 0) { + if (polygon2) + polygons.push(polygon2); + polygon2 = [rings[i3]]; + } else { + polygon2.push(rings[i3]); + } + } + if (polygon2) + polygons.push(polygon2); + return polygons; + } + function signedArea(ring) { + var sum = 0; + for (var i3 = 0, len = ring.length, j2 = len - 1, p1, p2; i3 < len; j2 = i3++) { + p1 = ring[i3]; + p2 = ring[j2]; + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + return sum; + } + } + }); + + // node_modules/@mapbox/vector-tile/lib/vectortilelayer.js + var require_vectortilelayer = __commonJS({ + "node_modules/@mapbox/vector-tile/lib/vectortilelayer.js"(exports2, module2) { + "use strict"; + var VectorTileFeature = require_vectortilefeature(); + module2.exports = VectorTileLayer; + function VectorTileLayer(pbf, end) { + this.version = 1; + this.name = null; + this.extent = 4096; + this.length = 0; + this._pbf = pbf; + this._keys = []; + this._values = []; + this._features = []; + pbf.readFields(readLayer, this, end); + this.length = this._features.length; + } + function readLayer(tag2, layer, pbf) { + if (tag2 === 15) + layer.version = pbf.readVarint(); + else if (tag2 === 1) + layer.name = pbf.readString(); + else if (tag2 === 5) + layer.extent = pbf.readVarint(); + else if (tag2 === 2) + layer._features.push(pbf.pos); + else if (tag2 === 3) + layer._keys.push(pbf.readString()); + else if (tag2 === 4) + layer._values.push(readValueMessage(pbf)); + } + function readValueMessage(pbf) { + var value = null, end = pbf.readVarint() + pbf.pos; + while (pbf.pos < end) { + var tag2 = pbf.readVarint() >> 3; + 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; + } + return value; + } + VectorTileLayer.prototype.feature = function(i3) { + if (i3 < 0 || i3 >= this._features.length) + throw new Error("feature index out of bounds"); + this._pbf.pos = this._features[i3]; + var end = this._pbf.readVarint() + this._pbf.pos; + return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); + }; + } + }); + + // node_modules/@mapbox/vector-tile/lib/vectortile.js + var require_vectortile = __commonJS({ + "node_modules/@mapbox/vector-tile/lib/vectortile.js"(exports2, module2) { + "use strict"; + var VectorTileLayer = require_vectortilelayer(); + module2.exports = VectorTile3; + function VectorTile3(pbf, end) { + this.layers = pbf.readFields(readTile, {}, end); + } + function readTile(tag2, layers, pbf) { + if (tag2 === 3) { + var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos); + if (layer.length) + layers[layer.name] = layer; + } + } + } + }); + + // node_modules/@mapbox/vector-tile/index.js + var require_vector_tile = __commonJS({ + "node_modules/@mapbox/vector-tile/index.js"(exports2, module2) { + module2.exports.VectorTile = require_vectortile(); + module2.exports.VectorTileFeature = require_vectortilefeature(); + module2.exports.VectorTileLayer = require_vectortilelayer(); + } + }); + + // node_modules/fast-json-stable-stringify/index.js + var require_fast_json_stable_stringify = __commonJS({ + "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) { + "use strict"; + module2.exports = function(data, opts) { + if (!opts) + opts = {}; + if (typeof opts === "function") + opts = { cmp: opts }; + var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false; + var cmp = opts.cmp && /* @__PURE__ */ function(f2) { + return function(node) { + return function(a2, b2) { + var aobj = { key: a2, value: node[a2] }; + var bobj = { key: b2, value: node[b2] }; + return f2(aobj, bobj); + }; + }; + }(opts.cmp); + var seen = []; + return function stringify3(node) { + if (node && node.toJSON && typeof node.toJSON === "function") { + node = node.toJSON(); + } + if (node === void 0) + return; + if (typeof node == "number") + return isFinite(node) ? "" + node : "null"; + if (typeof node !== "object") + return JSON.stringify(node); + var i3, out; + if (Array.isArray(node)) { + out = "["; + for (i3 = 0; i3 < node.length; i3++) { + if (i3) + out += ","; + out += stringify3(node[i3]) || "null"; + } + return out + "]"; + } + if (node === null) + return "null"; + if (seen.indexOf(node) !== -1) { + if (cycles) + return JSON.stringify("__cycle__"); + throw new TypeError("Converting circular structure to JSON"); + } + var seenIndex = seen.push(node) - 1; + var keys2 = Object.keys(node).sort(cmp && cmp(node)); + out = ""; + for (i3 = 0; i3 < keys2.length; i3++) { + var key = keys2[i3]; + var value = stringify3(node[key]); + if (!value) + continue; + if (out) + out += ","; + out += JSON.stringify(key) + ":" + value; + } + seen.splice(seenIndex, 1); + return "{" + out + "}"; + }(data); + }; + } + }); + + // node_modules/@mapbox/sexagesimal/index.js + var require_sexagesimal = __commonJS({ + "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) { + module2.exports = element; + module2.exports.pair = pair3; + module2.exports.format = format2; + module2.exports.formatPair = formatPair; + module2.exports.coordToDMS = coordToDMS; + function element(input, dims) { + var result = search(input, dims); + return result === null ? null : result.val; + } + function formatPair(input) { + return format2(input.lat, "lat") + " " + format2(input.lon, "lon"); + } + function format2(input, dim) { + var dms = coordToDMS(input, dim); + return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir; + } + function coordToDMS(input, dim) { + var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || ""; + var dir = dirs[input >= 0 ? 0 : 1]; + var abs3 = Math.abs(input); + var whole = Math.floor(abs3); + var fraction = abs3 - whole; + var fractionMinutes = fraction * 60; + var minutes = Math.floor(fractionMinutes); + var seconds = Math.floor((fractionMinutes - minutes) * 60); + return { + whole, + minutes, + seconds, + dir + }; + } + function search(input, dims) { + if (!dims) + dims = "NSEW"; + if (typeof input !== "string") + return null; + input = input.toUpperCase(); + var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/; + var m2 = input.match(regex); + if (!m2) + return null; + var matched = m2[0]; + var dim; + if (m2[1] && m2[5]) { + dim = m2[1]; + matched = matched.slice(0, -1); + } else { + dim = m2[1] || m2[5]; + } + if (dim && dims.indexOf(dim) === -1) + return null; + var deg = m2[2] ? parseFloat(m2[2]) : 0; + var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0; + var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0; + var sign2 = deg < 0 ? -1 : 1; + if (dim === "S" || dim === "W") + sign2 *= -1; + return { + val: (Math.abs(deg) + min3 + sec) * sign2, + dim, + matched, + remain: input.slice(matched.length) + }; + } + function pair3(input, dims) { + input = input.trim(); + var one2 = search(input, dims); + if (!one2) + return null; + input = one2.remain.trim(); + var two = search(input, dims); + if (!two || two.remain) + return null; + if (one2.dim) { + return swapdim(one2.val, two.val, one2.dim); + } else { + return [one2.val, two.val]; + } + } + function swapdim(a2, b2, dim) { + if (dim === "N" || dim === "S") + return [a2, b2]; + if (dim === "W" || dim === "E") + return [b2, a2]; + } + } + }); + + // node_modules/polygon-clipping/dist/polygon-clipping.umd.js + var require_polygon_clipping_umd = __commonJS({ + "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) { + (function(global2, factory) { + 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()); + })(exports2, function() { + "use strict"; + function __generator(thisArg, body) { + var _2 = { + label: 0, + sent: function() { + if (t2[0] & 1) + throw t2[1]; + return t2[1]; + }, + trys: [], + ops: [] + }, f2, y2, t2, g3; + return g3 = { + next: verb(0), + "throw": verb(1), + "return": verb(2) + }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { + return this; + }), g3; + function verb(n3) { + return function(v2) { + return step([n3, v2]); + }; + } + function step(op) { + if (f2) + throw new TypeError("Generator is already executing."); + while (_2) + try { + 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; + if (y2 = 0, t2) + op = [op[0] & 2, t2.value]; + switch (op[0]) { + case 0: + case 1: + t2 = op; + break; + case 4: + _2.label++; + return { + value: op[1], + done: false + }; + case 5: + _2.label++; + y2 = op[1]; + op = [0]; + continue; + case 7: + op = _2.ops.pop(); + _2.trys.pop(); + continue; + default: + if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { + _2 = 0; + continue; + } + if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { + _2.label = op[1]; + break; + } + if (op[0] === 6 && _2.label < t2[1]) { + _2.label = t2[1]; + t2 = op; + break; + } + if (t2 && _2.label < t2[2]) { + _2.label = t2[2]; + _2.ops.push(op); + break; + } + if (t2[2]) + _2.ops.pop(); + _2.trys.pop(); + continue; + } + op = body.call(thisArg, _2); + } catch (e3) { + op = [6, e3]; + y2 = 0; + } finally { + f2 = t2 = 0; + } + if (op[0] & 5) + throw op[1]; + return { + value: op[0] ? op[1] : void 0, + done: true + }; + } + } + var Node = ( + /** @class */ + /* @__PURE__ */ function() { + function Node2(key, data) { + this.next = null; + this.key = key; + this.data = data; + this.left = null; + this.right = null; + } + return Node2; + }() + ); + function DEFAULT_COMPARE(a2, b2) { + return a2 > b2 ? 1 : a2 < b2 ? -1 : 0; + } + function splay(i3, t2, comparator) { + var N2 = new Node(null, null); + var l2 = N2; + var r2 = N2; + while (true) { + var cmp2 = comparator(i3, t2.key); + if (cmp2 < 0) { + if (t2.left === null) + break; + if (comparator(i3, t2.left.key) < 0) { + var y2 = t2.left; + t2.left = y2.right; + y2.right = t2; + t2 = y2; + if (t2.left === null) + break; + } + r2.left = t2; + r2 = t2; + t2 = t2.left; + } else if (cmp2 > 0) { + if (t2.right === null) + break; + if (comparator(i3, t2.right.key) > 0) { + var y2 = t2.right; + t2.right = y2.left; + y2.left = t2; + t2 = y2; + if (t2.right === null) + break; + } + l2.right = t2; + l2 = t2; + t2 = t2.right; + } else + break; + } + l2.right = t2.left; + r2.left = t2.right; + t2.left = N2.right; + t2.right = N2.left; + return t2; + } + function insert(i3, data, t2, comparator) { + var node = new Node(i3, data); + if (t2 === null) { + node.left = node.right = null; + return node; + } + t2 = splay(i3, t2, comparator); + var cmp2 = comparator(i3, t2.key); + if (cmp2 < 0) { + node.left = t2.left; + node.right = t2; + t2.left = null; + } else if (cmp2 >= 0) { + node.right = t2.right; + node.left = t2; + t2.right = null; + } + return node; + } + function split(key, v2, comparator) { + var left = null; + var right = null; + if (v2) { + v2 = splay(key, v2, comparator); + var cmp2 = comparator(v2.key, key); + if (cmp2 === 0) { + left = v2.left; + right = v2.right; + } else if (cmp2 < 0) { + right = v2.right; + v2.right = null; + left = v2; + } else { + left = v2.left; + v2.left = null; + right = v2; + } + } + return { + left, + right + }; + } + function merge2(left, right, comparator) { + if (right === null) + return left; + if (left === null) + return right; + right = splay(left.key, right, comparator); + right.left = left; + return right; + } + function printRow(root3, prefix, isTail, out, printNode) { + if (root3) { + out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n"); + var indent = prefix + (isTail ? " " : "\u2502 "); + if (root3.left) + printRow(root3.left, indent, false, out, printNode); + if (root3.right) + printRow(root3.right, indent, true, out, printNode); + } + } + var Tree = ( + /** @class */ + function() { + function Tree2(comparator) { + if (comparator === void 0) { + comparator = DEFAULT_COMPARE; + } + this._root = null; + this._size = 0; + this._comparator = comparator; + } + Tree2.prototype.insert = function(key, data) { + this._size++; + return this._root = insert(key, data, this._root, this._comparator); + }; + Tree2.prototype.add = function(key, data) { + var node = new Node(key, data); + if (this._root === null) { + node.left = node.right = null; + this._size++; + this._root = node; + } + var comparator = this._comparator; + var t2 = splay(key, this._root, comparator); + var cmp2 = comparator(key, t2.key); + if (cmp2 === 0) + this._root = t2; + else { + if (cmp2 < 0) { + node.left = t2.left; + node.right = t2; + t2.left = null; + } else if (cmp2 > 0) { + node.right = t2.right; + node.left = t2; + t2.right = null; + } + this._size++; + this._root = node; + } + return this._root; + }; + Tree2.prototype.remove = function(key) { + this._root = this._remove(key, this._root, this._comparator); + }; + Tree2.prototype._remove = function(i3, t2, comparator) { + var x2; + if (t2 === null) + return null; + t2 = splay(i3, t2, comparator); + var cmp2 = comparator(i3, t2.key); + if (cmp2 === 0) { + if (t2.left === null) { + x2 = t2.right; + } else { + x2 = splay(i3, t2.left, comparator); + x2.right = t2.right; + } + this._size--; + return x2; + } + return t2; + }; + Tree2.prototype.pop = function() { + var node = this._root; + if (node) { + while (node.left) + node = node.left; + this._root = splay(node.key, this._root, this._comparator); + this._root = this._remove(node.key, this._root, this._comparator); + return { + key: node.key, + data: node.data + }; + } + return null; + }; + Tree2.prototype.findStatic = function(key) { + var current = this._root; + var compare2 = this._comparator; + while (current) { + var cmp2 = compare2(key, current.key); + if (cmp2 === 0) + return current; + else if (cmp2 < 0) + current = current.left; + else + current = current.right; + } + return null; + }; + Tree2.prototype.find = function(key) { + if (this._root) { + this._root = splay(key, this._root, this._comparator); + if (this._comparator(key, this._root.key) !== 0) + return null; + } + return this._root; + }; + Tree2.prototype.contains = function(key) { + var current = this._root; + var compare2 = this._comparator; + while (current) { + var cmp2 = compare2(key, current.key); + if (cmp2 === 0) + return true; + else if (cmp2 < 0) + current = current.left; + else + current = current.right; + } + return false; + }; + Tree2.prototype.forEach = function(visitor, ctx) { + var current = this._root; + var Q2 = []; + var done = false; + while (!done) { + if (current !== null) { + Q2.push(current); + current = current.left; + } else { + if (Q2.length !== 0) { + current = Q2.pop(); + visitor.call(ctx, current); + current = current.right; + } else + done = true; + } + } + return this; + }; + Tree2.prototype.range = function(low, high, fn, ctx) { + var Q2 = []; + var compare2 = this._comparator; + var node = this._root; + var cmp2; + while (Q2.length !== 0 || node) { + if (node) { + Q2.push(node); + node = node.left; + } else { + node = Q2.pop(); + cmp2 = compare2(node.key, high); + if (cmp2 > 0) { + break; + } else if (compare2(node.key, low) >= 0) { + if (fn.call(ctx, node)) + return this; + } + node = node.right; + } + } + return this; + }; + Tree2.prototype.keys = function() { + var keys2 = []; + this.forEach(function(_a2) { + var key = _a2.key; + return keys2.push(key); + }); + return keys2; + }; + Tree2.prototype.values = function() { + var values = []; + this.forEach(function(_a2) { + var data = _a2.data; + return values.push(data); + }); + return values; + }; + Tree2.prototype.min = function() { + if (this._root) + return this.minNode(this._root).key; + return null; + }; + Tree2.prototype.max = function() { + if (this._root) + return this.maxNode(this._root).key; + return null; + }; + Tree2.prototype.minNode = function(t2) { + if (t2 === void 0) { + t2 = this._root; + } + if (t2) + while (t2.left) + t2 = t2.left; + return t2; + }; + Tree2.prototype.maxNode = function(t2) { + if (t2 === void 0) { + t2 = this._root; + } + if (t2) + while (t2.right) + t2 = t2.right; + return t2; + }; + Tree2.prototype.at = function(index2) { + var current = this._root; + var done = false; + var i3 = 0; + var Q2 = []; + while (!done) { + if (current) { + Q2.push(current); + current = current.left; + } else { + if (Q2.length > 0) { + current = Q2.pop(); + if (i3 === index2) + return current; + i3++; + current = current.right; + } else + done = true; + } + } + return null; + }; + Tree2.prototype.next = function(d2) { + var root3 = this._root; + var successor = null; + if (d2.right) { + successor = d2.right; + while (successor.left) + successor = successor.left; + return successor; + } + var comparator = this._comparator; + while (root3) { + var cmp2 = comparator(d2.key, root3.key); + if (cmp2 === 0) + break; + else if (cmp2 < 0) { + successor = root3; + root3 = root3.left; + } else + root3 = root3.right; + } + return successor; + }; + Tree2.prototype.prev = function(d2) { + var root3 = this._root; + var predecessor = null; + if (d2.left !== null) { + predecessor = d2.left; + while (predecessor.right) + predecessor = predecessor.right; + return predecessor; + } + var comparator = this._comparator; + while (root3) { + var cmp2 = comparator(d2.key, root3.key); + if (cmp2 === 0) + break; + else if (cmp2 < 0) + root3 = root3.left; + else { + predecessor = root3; + root3 = root3.right; + } + } + return predecessor; + }; + Tree2.prototype.clear = function() { + this._root = null; + this._size = 0; + return this; + }; + Tree2.prototype.toList = function() { + return toList(this._root); + }; + Tree2.prototype.load = function(keys2, values, presort) { + if (values === void 0) { + values = []; + } + if (presort === void 0) { + presort = false; + } + var size = keys2.length; + var comparator = this._comparator; + if (presort) + sort(keys2, values, 0, size - 1, comparator); + if (this._root === null) { + this._root = loadRecursive(keys2, values, 0, size); + this._size = size; + } else { + var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator); + size = this._size + size; + this._root = sortedListToBST({ + head: mergedList + }, 0, size); + } + return this; + }; + Tree2.prototype.isEmpty = function() { + return this._root === null; + }; + Object.defineProperty(Tree2.prototype, "size", { + get: function() { + return this._size; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Tree2.prototype, "root", { + get: function() { + return this._root; + }, + enumerable: true, + configurable: true + }); + Tree2.prototype.toString = function(printNode) { + if (printNode === void 0) { + printNode = function(n3) { + return String(n3.key); + }; + } + var out = []; + printRow(this._root, "", true, function(v2) { + return out.push(v2); + }, printNode); + return out.join(""); + }; + Tree2.prototype.update = function(key, newKey, newData) { + var comparator = this._comparator; + var _a2 = split(key, this._root, comparator), left = _a2.left, right = _a2.right; + if (comparator(key, newKey) < 0) { + right = insert(newKey, newData, right, comparator); + } else { + left = insert(newKey, newData, left, comparator); + } + this._root = merge2(left, right, comparator); + }; + Tree2.prototype.split = function(key) { + return split(key, this._root, this._comparator); + }; + Tree2.prototype[Symbol.iterator] = function() { + var current, Q2, done; + return __generator(this, function(_a2) { + switch (_a2.label) { + case 0: + current = this._root; + Q2 = []; + done = false; + _a2.label = 1; + case 1: + if (!!done) + return [3, 6]; + if (!(current !== null)) + return [3, 2]; + Q2.push(current); + current = current.left; + return [3, 5]; + case 2: + if (!(Q2.length !== 0)) + return [3, 4]; + current = Q2.pop(); + return [4, current]; + case 3: + _a2.sent(); + current = current.right; + return [3, 5]; + case 4: + done = true; + _a2.label = 5; + case 5: + return [3, 1]; + case 6: + return [ + 2 + /*return*/ + ]; + } + }); + }; + return Tree2; + }() + ); + function loadRecursive(keys2, values, start2, end) { + var size = end - start2; + if (size > 0) { + var middle = start2 + Math.floor(size / 2); + var key = keys2[middle]; + var data = values[middle]; + var node = new Node(key, data); + node.left = loadRecursive(keys2, values, start2, middle); + node.right = loadRecursive(keys2, values, middle + 1, end); + return node; + } + return null; + } + function createList(keys2, values) { + var head = new Node(null, null); + var p2 = head; + for (var i3 = 0; i3 < keys2.length; i3++) { + p2 = p2.next = new Node(keys2[i3], values[i3]); } - length--; - if (cmd === 1 || cmd === 2) { - x2 += pbf.readSVarint(); - y2 += pbf.readSVarint(); - if (cmd === 1) { - if (line) - lines.push(line); - line = []; - } - line.push(new Point(x2, y2)); - } else if (cmd === 7) { - if (line) { - line.push(line[0].clone()); + p2.next = null; + return head.next; + } + function toList(root3) { + var current = root3; + var Q2 = []; + var done = false; + var head = new Node(null, null); + var p2 = head; + while (!done) { + if (current) { + Q2.push(current); + current = current.left; + } else { + if (Q2.length > 0) { + current = p2 = p2.next = Q2.pop(); + current = current.right; + } else + done = true; } - } else { - throw new Error("unknown command " + cmd); } + p2.next = null; + return head.next; } - if (line) - lines.push(line); - return lines; - }; - VectorTileFeature.prototype.bbox = function() { - var pbf = this._pbf; - pbf.pos = this._geometry; - var end = pbf.readVarint() + pbf.pos, cmd = 1, length = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity; - while (pbf.pos < end) { - if (length <= 0) { - var cmdLen = pbf.readVarint(); - cmd = cmdLen & 7; - length = cmdLen >> 3; + function sortedListToBST(list2, start2, end) { + var size = end - start2; + if (size > 0) { + var middle = start2 + Math.floor(size / 2); + var left = sortedListToBST(list2, start2, middle); + var root3 = list2.head; + root3.left = left; + list2.head = list2.head.next; + root3.right = sortedListToBST(list2, middle + 1, end); + return root3; } - length--; - if (cmd === 1 || cmd === 2) { - x2 += pbf.readSVarint(); - y2 += pbf.readSVarint(); - if (x2 < x12) - x12 = x2; - if (x2 > x22) - x22 = x2; - if (y2 < y12) - y12 = y2; - if (y2 > y22) - y22 = y2; - } else if (cmd !== 7) { - throw new Error("unknown command " + cmd); + return null; + } + function mergeLists(l1, l2, compare2) { + var head = new Node(null, null); + var p2 = head; + var p1 = l1; + var p22 = l2; + while (p1 !== null && p22 !== null) { + if (compare2(p1.key, p22.key) < 0) { + p2.next = p1; + p1 = p1.next; + } else { + p2.next = p22; + p22 = p22.next; + } + p2 = p2.next; + } + if (p1 !== null) { + p2.next = p1; + } else if (p22 !== null) { + p2.next = p22; } + return head.next; } - return [x12, y12, x22, y22]; - }; - VectorTileFeature.prototype.toGeoJSON = function(x2, y2, z2) { - var size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, coords = this.loadGeometry(), type2 = VectorTileFeature.types[this.type], i3, j3; - function project(line) { - for (var j4 = 0; j4 < line.length; j4++) { - var p2 = line[j4], y22 = 180 - (p2.y + y05) * 360 / size; - line[j4] = [ - (p2.x + x05) * 360 / size - 180, - 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90 - ]; + function sort(keys2, values, left, right, compare2) { + if (left >= right) + return; + var pivot = keys2[left + right >> 1]; + var i3 = left - 1; + var j2 = right + 1; + while (true) { + do + i3++; + while (compare2(keys2[i3], pivot) < 0); + do + j2--; + while (compare2(keys2[j2], pivot) > 0); + if (i3 >= j2) + break; + var tmp = keys2[i3]; + keys2[i3] = keys2[j2]; + keys2[j2] = tmp; + tmp = values[i3]; + values[i3] = values[j2]; + values[j2] = tmp; } + sort(keys2, values, left, j2, compare2); + sort(keys2, values, j2 + 1, right, compare2); } - switch (this.type) { - case 1: - var points = []; - for (i3 = 0; i3 < coords.length; i3++) { - points[i3] = coords[i3][0]; - } - coords = points; - project(coords); - break; - case 2: - for (i3 = 0; i3 < coords.length; i3++) { - project(coords[i3]); + const isInBbox2 = (bbox2, point2) => { + return bbox2.ll.x <= point2.x && point2.x <= bbox2.ur.x && bbox2.ll.y <= point2.y && point2.y <= bbox2.ur.y; + }; + const getBboxOverlap2 = (b1, b2) => { + 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; + const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x; + const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x; + const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y; + const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y; + return { + ll: { + x: lowerX, + y: lowerY + }, + ur: { + x: upperX, + y: upperY } - break; - case 3: - coords = classifyRings(coords); - for (i3 = 0; i3 < coords.length; i3++) { - for (j3 = 0; j3 < coords[i3].length; j3++) { - project(coords[i3][j3]); - } + }; + }; + let epsilon$1 = Number.EPSILON; + if (epsilon$1 === void 0) + epsilon$1 = Math.pow(2, -52); + const EPSILON_SQ = epsilon$1 * epsilon$1; + const cmp = (a2, b2) => { + if (-epsilon$1 < a2 && a2 < epsilon$1) { + if (-epsilon$1 < b2 && b2 < epsilon$1) { + return 0; } - break; - } - if (coords.length === 1) { - coords = coords[0]; - } else { - type2 = "Multi" + type2; - } - var result = { - type: "Feature", - geometry: { - type: type2, - coordinates: coords - }, - properties: this.properties + } + const ab = a2 - b2; + if (ab * ab < EPSILON_SQ * a2 * b2) { + return 0; + } + return a2 < b2 ? -1 : 1; }; - if ("id" in this) { - result.id = this.id; - } - return result; - }; - function classifyRings(rings) { - var len = rings.length; - if (len <= 1) - return [rings]; - var polygons = [], polygon2, ccw; - for (var i3 = 0; i3 < len; i3++) { - var area = signedArea(rings[i3]); - if (area === 0) - continue; - if (ccw === void 0) - ccw = area < 0; - if (ccw === area < 0) { - if (polygon2) - polygons.push(polygon2); - polygon2 = [rings[i3]]; - } else { - polygon2.push(rings[i3]); + class PtRounder { + constructor() { + this.reset(); } - } - if (polygon2) - polygons.push(polygon2); - return polygons; - } - function signedArea(ring) { - var sum = 0; - for (var i3 = 0, len = ring.length, j3 = len - 1, p1, p2; i3 < len; j3 = i3++) { - p1 = ring[i3]; - p2 = ring[j3]; - sum += (p2.x - p1.x) * (p1.y + p2.y); - } - return sum; - } - } - }); - - // node_modules/@mapbox/vector-tile/lib/vectortilelayer.js - var require_vectortilelayer = __commonJS({ - "node_modules/@mapbox/vector-tile/lib/vectortilelayer.js"(exports2, module2) { - "use strict"; - var VectorTileFeature = require_vectortilefeature(); - module2.exports = VectorTileLayer; - function VectorTileLayer(pbf, end) { - this.version = 1; - this.name = null; - this.extent = 4096; - this.length = 0; - this._pbf = pbf; - this._keys = []; - this._values = []; - this._features = []; - pbf.readFields(readLayer, this, end); - this.length = this._features.length; - } - function readLayer(tag, layer, pbf) { - if (tag === 15) - layer.version = pbf.readVarint(); - else if (tag === 1) - layer.name = pbf.readString(); - else if (tag === 5) - layer.extent = pbf.readVarint(); - else if (tag === 2) - layer._features.push(pbf.pos); - else if (tag === 3) - layer._keys.push(pbf.readString()); - else if (tag === 4) - layer._values.push(readValueMessage(pbf)); - } - function readValueMessage(pbf) { - var value = null, end = pbf.readVarint() + pbf.pos; - while (pbf.pos < end) { - var tag = pbf.readVarint() >> 3; - value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null; - } - return value; - } - VectorTileLayer.prototype.feature = function(i3) { - if (i3 < 0 || i3 >= this._features.length) - throw new Error("feature index out of bounds"); - this._pbf.pos = this._features[i3]; - var end = this._pbf.readVarint() + this._pbf.pos; - return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); - }; - } - }); - - // node_modules/@mapbox/vector-tile/lib/vectortile.js - var require_vectortile = __commonJS({ - "node_modules/@mapbox/vector-tile/lib/vectortile.js"(exports2, module2) { - "use strict"; - var VectorTileLayer = require_vectortilelayer(); - module2.exports = VectorTile3; - function VectorTile3(pbf, end) { - this.layers = pbf.readFields(readTile, {}, end); - } - function readTile(tag, layers, pbf) { - if (tag === 3) { - var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos); - if (layer.length) - layers[layer.name] = layer; - } - } - } - }); - - // node_modules/@mapbox/vector-tile/index.js - var require_vector_tile = __commonJS({ - "node_modules/@mapbox/vector-tile/index.js"(exports2, module2) { - module2.exports.VectorTile = require_vectortile(); - module2.exports.VectorTileFeature = require_vectortilefeature(); - module2.exports.VectorTileLayer = require_vectortilelayer(); - } - }); - - // node_modules/fast-json-stable-stringify/index.js - var require_fast_json_stable_stringify = __commonJS({ - "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) { - "use strict"; - module2.exports = function(data, opts) { - if (!opts) - opts = {}; - if (typeof opts === "function") - opts = { cmp: opts }; - var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false; - var cmp = opts.cmp && function(f3) { - return function(node) { - return function(a2, b2) { - var aobj = { key: a2, value: node[a2] }; - var bobj = { key: b2, value: node[b2] }; - return f3(aobj, bobj); - }; - }; - }(opts.cmp); - var seen = []; - return function stringify3(node) { - if (node && node.toJSON && typeof node.toJSON === "function") { - node = node.toJSON(); + reset() { + this.xRounder = new CoordRounder(); + this.yRounder = new CoordRounder(); } - if (node === void 0) - return; - if (typeof node == "number") - return isFinite(node) ? "" + node : "null"; - if (typeof node !== "object") - return JSON.stringify(node); - var i3, out; - if (Array.isArray(node)) { - out = "["; - for (i3 = 0; i3 < node.length; i3++) { - if (i3) - out += ","; - out += stringify3(node[i3]) || "null"; - } - return out + "]"; + round(x2, y2) { + return { + x: this.xRounder.round(x2), + y: this.yRounder.round(y2) + }; } - if (node === null) - return "null"; - if (seen.indexOf(node) !== -1) { - if (cycles) - return JSON.stringify("__cycle__"); - throw new TypeError("Converting circular structure to JSON"); + } + class CoordRounder { + constructor() { + this.tree = new Tree(); + this.round(0); } - var seenIndex = seen.push(node) - 1; - var keys2 = Object.keys(node).sort(cmp && cmp(node)); - out = ""; - for (i3 = 0; i3 < keys2.length; i3++) { - var key = keys2[i3]; - var value = stringify3(node[key]); - if (!value) - continue; - if (out) - out += ","; - out += JSON.stringify(key) + ":" + value; + // Note: this can rounds input values backwards or forwards. + // You might ask, why not restrict this to just rounding + // forwards? Wouldn't that allow left endpoints to always + // remain left endpoints during splitting (never change to + // right). No - it wouldn't, because we snap intersections + // to endpoints (to establish independence from the segment + // angle for t-intersections). + round(coord2) { + const node = this.tree.add(coord2); + const prevNode = this.tree.prev(node); + if (prevNode !== null && cmp(node.key, prevNode.key) === 0) { + this.tree.remove(coord2); + return prevNode.key; + } + const nextNode = this.tree.next(node); + if (nextNode !== null && cmp(node.key, nextNode.key) === 0) { + this.tree.remove(coord2); + return nextNode.key; + } + return coord2; + } + } + const rounder = new PtRounder(); + const epsilon3 = 11102230246251565e-32; + const splitter = 134217729; + const resulterrbound = (3 + 8 * epsilon3) * epsilon3; + function sum(elen, e3, flen, f2, h2) { + let Q2, Qnew, hh, bvirt; + let enow = e3[0]; + let fnow = f2[0]; + let eindex = 0; + let findex = 0; + if (fnow > enow === fnow > -enow) { + Q2 = enow; + enow = e3[++eindex]; + } else { + Q2 = fnow; + fnow = f2[++findex]; + } + let hindex = 0; + if (eindex < elen && findex < flen) { + if (fnow > enow === fnow > -enow) { + Qnew = enow + Q2; + hh = Q2 - (Qnew - enow); + enow = e3[++eindex]; + } else { + Qnew = fnow + Q2; + hh = Q2 - (Qnew - fnow); + fnow = f2[++findex]; + } + Q2 = Qnew; + if (hh !== 0) { + h2[hindex++] = hh; + } + while (eindex < elen && findex < flen) { + if (fnow > enow === fnow > -enow) { + Qnew = Q2 + enow; + bvirt = Qnew - Q2; + hh = Q2 - (Qnew - bvirt) + (enow - bvirt); + enow = e3[++eindex]; + } else { + Qnew = Q2 + fnow; + bvirt = Qnew - Q2; + hh = Q2 - (Qnew - bvirt) + (fnow - bvirt); + fnow = f2[++findex]; + } + Q2 = Qnew; + if (hh !== 0) { + h2[hindex++] = hh; + } + } } - seen.splice(seenIndex, 1); - return "{" + out + "}"; - }(data); - }; - } - }); - - // node_modules/@mapbox/sexagesimal/index.js - var require_sexagesimal = __commonJS({ - "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) { - module2.exports = element; - module2.exports.pair = pair3; - module2.exports.format = format2; - module2.exports.formatPair = formatPair; - module2.exports.coordToDMS = coordToDMS; - function element(input, dims) { - var result = search(input, dims); - return result === null ? null : result.val; - } - function formatPair(input) { - return format2(input.lat, "lat") + " " + format2(input.lon, "lon"); - } - function format2(input, dim) { - var dms = coordToDMS(input, dim); - return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir; - } - function coordToDMS(input, dim) { - var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || ""; - var dir = dirs[input >= 0 ? 0 : 1]; - var abs3 = Math.abs(input); - var whole = Math.floor(abs3); - var fraction = abs3 - whole; - var fractionMinutes = fraction * 60; - var minutes = Math.floor(fractionMinutes); - var seconds = Math.floor((fractionMinutes - minutes) * 60); - return { - whole, - minutes, - seconds, - dir + while (eindex < elen) { + Qnew = Q2 + enow; + bvirt = Qnew - Q2; + hh = Q2 - (Qnew - bvirt) + (enow - bvirt); + enow = e3[++eindex]; + Q2 = Qnew; + if (hh !== 0) { + h2[hindex++] = hh; + } + } + while (findex < flen) { + Qnew = Q2 + fnow; + bvirt = Qnew - Q2; + hh = Q2 - (Qnew - bvirt) + (fnow - bvirt); + fnow = f2[++findex]; + Q2 = Qnew; + if (hh !== 0) { + h2[hindex++] = hh; + } + } + if (Q2 !== 0 || hindex === 0) { + h2[hindex++] = Q2; + } + return hindex; + } + function estimate(elen, e3) { + let Q2 = e3[0]; + for (let i3 = 1; i3 < elen; i3++) + Q2 += e3[i3]; + return Q2; + } + function vec(n3) { + return new Float64Array(n3); + } + const ccwerrboundA = (3 + 16 * epsilon3) * epsilon3; + const ccwerrboundB = (2 + 12 * epsilon3) * epsilon3; + const ccwerrboundC = (9 + 64 * epsilon3) * epsilon3 * epsilon3; + const B2 = vec(4); + const C1 = vec(8); + const C2 = vec(12); + const D2 = vec(16); + const u2 = vec(4); + function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) { + let acxtail, acytail, bcxtail, bcytail; + let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3; + const acx = ax - cx; + const bcx = bx - cx; + const acy = ay - cy; + const bcy = by - cy; + s1 = acx * bcy; + c2 = splitter * acx; + ahi = c2 - (c2 - acx); + alo = acx - ahi; + c2 = splitter * bcy; + bhi = c2 - (c2 - bcy); + blo = bcy - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acy * bcx; + c2 = splitter * acy; + ahi = c2 - (c2 - acy); + alo = acy - ahi; + c2 = splitter * bcx; + bhi = c2 - (c2 - bcx); + blo = bcx - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + B2[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + B2[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + B2[2] = _j - (u3 - bvirt) + (_i - bvirt); + B2[3] = u3; + let det = estimate(4, B2); + let errbound = ccwerrboundB * detsum; + if (det >= errbound || -det >= errbound) { + return det; + } + bvirt = ax - acx; + acxtail = ax - (acx + bvirt) + (bvirt - cx); + bvirt = bx - bcx; + bcxtail = bx - (bcx + bvirt) + (bvirt - cx); + bvirt = ay - acy; + acytail = ay - (acy + bvirt) + (bvirt - cy); + bvirt = by - bcy; + bcytail = by - (bcy + bvirt) + (bvirt - cy); + if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) { + return det; + } + errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det); + det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail); + if (det >= errbound || -det >= errbound) + return det; + s1 = acxtail * bcy; + c2 = splitter * acxtail; + ahi = c2 - (c2 - acxtail); + alo = acxtail - ahi; + c2 = splitter * bcy; + bhi = c2 - (c2 - bcy); + blo = bcy - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acytail * bcx; + c2 = splitter * acytail; + ahi = c2 - (c2 - acytail); + alo = acytail - ahi; + c2 = splitter * bcx; + bhi = c2 - (c2 - bcx); + blo = bcx - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u2[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u2[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u2[2] = _j - (u3 - bvirt) + (_i - bvirt); + u2[3] = u3; + const C1len = sum(4, B2, 4, u2, C1); + s1 = acx * bcytail; + c2 = splitter * acx; + ahi = c2 - (c2 - acx); + alo = acx - ahi; + c2 = splitter * bcytail; + bhi = c2 - (c2 - bcytail); + blo = bcytail - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acy * bcxtail; + c2 = splitter * acy; + ahi = c2 - (c2 - acy); + alo = acy - ahi; + c2 = splitter * bcxtail; + bhi = c2 - (c2 - bcxtail); + blo = bcxtail - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u2[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u2[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u2[2] = _j - (u3 - bvirt) + (_i - bvirt); + u2[3] = u3; + const C2len = sum(C1len, C1, 4, u2, C2); + s1 = acxtail * bcytail; + c2 = splitter * acxtail; + ahi = c2 - (c2 - acxtail); + alo = acxtail - ahi; + c2 = splitter * bcytail; + bhi = c2 - (c2 - bcytail); + blo = bcytail - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acytail * bcxtail; + c2 = splitter * acytail; + ahi = c2 - (c2 - acytail); + alo = acytail - ahi; + c2 = splitter * bcxtail; + bhi = c2 - (c2 - bcxtail); + blo = bcxtail - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u2[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u2[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u2[2] = _j - (u3 - bvirt) + (_i - bvirt); + u2[3] = u3; + const Dlen = sum(C2len, C2, 4, u2, D2); + return D2[Dlen - 1]; + } + function orient2d(ax, ay, bx, by, cx, cy) { + const detleft = (ay - cy) * (bx - cx); + const detright = (ax - cx) * (by - cy); + const det = detleft - detright; + const detsum = Math.abs(detleft + detright); + if (Math.abs(det) >= ccwerrboundA * detsum) + return det; + return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum); + } + const crossProduct2 = (a2, b2) => a2.x * b2.y - a2.y * b2.x; + const dotProduct2 = (a2, b2) => a2.x * b2.x + a2.y * b2.y; + const compareVectorAngles = (basePt, endPt1, endPt2) => { + const res = orient2d(basePt.x, basePt.y, endPt1.x, endPt1.y, endPt2.x, endPt2.y); + if (res > 0) + return -1; + if (res < 0) + return 1; + return 0; }; - } - function search(input, dims) { - if (!dims) - dims = "NSEW"; - if (typeof input !== "string") - return null; - input = input.toUpperCase(); - var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/; - var m2 = input.match(regex); - if (!m2) - return null; - var matched = m2[0]; - var dim; - if (m2[1] && m2[5]) { - dim = m2[1]; - matched = matched.slice(0, -1); - } else { - dim = m2[1] || m2[5]; - } - if (dim && dims.indexOf(dim) === -1) - return null; - var deg = m2[2] ? parseFloat(m2[2]) : 0; - var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0; - var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0; - var sign2 = deg < 0 ? -1 : 1; - if (dim === "S" || dim === "W") - sign2 *= -1; - return { - val: (Math.abs(deg) + min3 + sec) * sign2, - dim, - matched, - remain: input.slice(matched.length) + const length2 = (v2) => Math.sqrt(dotProduct2(v2, v2)); + const sineOfAngle2 = (pShared, pBase, pAngle) => { + const vBase = { + x: pBase.x - pShared.x, + y: pBase.y - pShared.y + }; + const vAngle = { + x: pAngle.x - pShared.x, + y: pAngle.y - pShared.y + }; + return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase); }; - } - function pair3(input, dims) { - input = input.trim(); - var one2 = search(input, dims); - if (!one2) - return null; - input = one2.remain.trim(); - var two = search(input, dims); - if (!two || two.remain) - return null; - if (one2.dim) { - return swapdim(one2.val, two.val, one2.dim); - } else { - return [one2.val, two.val]; - } - } - function swapdim(a2, b2, dim) { - if (dim === "N" || dim === "S") - return [a2, b2]; - if (dim === "W" || dim === "E") - return [b2, a2]; - } - } - }); - - // node_modules/store/src/util.js - var require_util = __commonJS({ - "node_modules/store/src/util.js"(exports2, module2) { - var assign = make_assign(); - var create2 = make_create(); - var trim = make_trim(); - var Global = typeof window !== "undefined" ? window : global; - module2.exports = { - assign, - create: create2, - trim, - bind, - slice, - each, - map: map2, - pluck, - isList, - isFunction: isFunction2, - isObject: isObject3, - Global - }; - function make_assign() { - if (Object.assign) { - return Object.assign; - } else { - return function shimAssign(obj, props1, props2, etc) { - for (var i3 = 1; i3 < arguments.length; i3++) { - each(Object(arguments[i3]), function(val, key) { - obj[key] = val; - }); - } - return obj; + const cosineOfAngle2 = (pShared, pBase, pAngle) => { + const vBase = { + x: pBase.x - pShared.x, + y: pBase.y - pShared.y }; - } - } - function make_create() { - if (Object.create) { - return function create3(obj, assignProps1, assignProps2, etc) { - var assignArgsList = slice(arguments, 1); - return assign.apply(this, [Object.create(obj)].concat(assignArgsList)); + const vAngle = { + x: pAngle.x - pShared.x, + y: pAngle.y - pShared.y }; - } else { - let F3 = function() { + return dotProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase); + }; + const horizontalIntersection2 = (pt2, v2, y2) => { + if (v2.y === 0) + return null; + return { + x: pt2.x + v2.x / v2.y * (y2 - pt2.y), + y: y2 }; - var F2 = F3; - return function create3(obj, assignProps1, assignProps2, etc) { - var assignArgsList = slice(arguments, 1); - F3.prototype = obj; - return assign.apply(this, [new F3()].concat(assignArgsList)); + }; + const verticalIntersection2 = (pt2, v2, x2) => { + if (v2.x === 0) + return null; + return { + x: x2, + y: pt2.y + v2.y / v2.x * (x2 - pt2.x) }; - } - } - function make_trim() { - if (String.prototype.trim) { - return function trim2(str2) { - return String.prototype.trim.call(str2); + }; + const intersection$1 = (pt1, v1, pt2, v2) => { + if (v1.x === 0) + return verticalIntersection2(pt2, v2, pt1.x); + if (v2.x === 0) + return verticalIntersection2(pt1, v1, pt2.x); + if (v1.y === 0) + return horizontalIntersection2(pt2, v2, pt1.y); + if (v2.y === 0) + return horizontalIntersection2(pt1, v1, pt2.y); + const kross = crossProduct2(v1, v2); + if (kross == 0) + return null; + const ve2 = { + x: pt2.x - pt1.x, + y: pt2.y - pt1.y }; - } else { - return function trim2(str2) { - return str2.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); + const d1 = crossProduct2(ve2, v1) / kross; + const d2 = crossProduct2(ve2, v2) / kross; + const x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x; + const y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y; + const x3 = (x12 + x2) / 2; + const y3 = (y12 + y2) / 2; + return { + x: x3, + y: y3 }; - } - } - function bind(obj, fn) { - return function() { - return fn.apply(obj, Array.prototype.slice.call(arguments, 0)); }; - } - function slice(arr, index) { - return Array.prototype.slice.call(arr, index || 0); - } - function each(obj, fn) { - pluck(obj, function(val, key) { - fn(val, key); - return false; - }); - } - function map2(obj, fn) { - var res = isList(obj) ? [] : {}; - pluck(obj, function(v2, k2) { - res[k2] = fn(v2, k2); - return false; - }); - return res; - } - function pluck(obj, fn) { - if (isList(obj)) { - for (var i3 = 0; i3 < obj.length; i3++) { - if (fn(obj[i3], i3)) { - return obj[i3]; + class SweepEvent2 { + // for ordering sweep events in the sweep event queue + static compare(a2, b2) { + const ptCmp = SweepEvent2.comparePoints(a2.point, b2.point); + if (ptCmp !== 0) + return ptCmp; + if (a2.point !== b2.point) + a2.link(b2); + if (a2.isLeft !== b2.isLeft) + return a2.isLeft ? 1 : -1; + return Segment2.compare(a2.segment, b2.segment); + } + // for ordering points in sweep line order + static comparePoints(aPt, bPt) { + if (aPt.x < bPt.x) + return -1; + if (aPt.x > bPt.x) + return 1; + if (aPt.y < bPt.y) + return -1; + if (aPt.y > bPt.y) + return 1; + return 0; + } + // Warning: 'point' input will be modified and re-used (for performance) + constructor(point2, isLeft) { + if (point2.events === void 0) + point2.events = [this]; + else + point2.events.push(this); + this.point = point2; + this.isLeft = isLeft; + } + link(other) { + if (other.point === this.point) { + throw new Error("Tried to link already linked events"); + } + const otherEvents = other.point.events; + for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) { + const evt = otherEvents[i3]; + this.point.events.push(evt); + evt.point = this.point; + } + this.checkForConsuming(); + } + /* Do a pass over our linked events and check to see if any pair + * of segments match, and should be consumed. */ + checkForConsuming() { + const numEvents = this.point.events.length; + for (let i3 = 0; i3 < numEvents; i3++) { + const evt1 = this.point.events[i3]; + if (evt1.segment.consumedBy !== void 0) + continue; + for (let j2 = i3 + 1; j2 < numEvents; j2++) { + const evt2 = this.point.events[j2]; + if (evt2.consumedBy !== void 0) + continue; + if (evt1.otherSE.point.events !== evt2.otherSE.point.events) + continue; + evt1.segment.consume(evt2.segment); + } } } - } else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - if (fn(obj[key], key)) { - return obj[key]; + getAvailableLinkedEvents() { + const events = []; + for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) { + const evt = this.point.events[i3]; + if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) { + events.push(evt); } } + return events; + } + /** + * Returns a comparator function for sorting linked events that will + * favor the event that will give us the smallest left-side angle. + * All ring construction starts as low as possible heading to the right, + * so by always turning left as sharp as possible we'll get polygons + * without uncessary loops & holes. + * + * The comparator function has a compute cache such that it avoids + * re-computing already-computed values. + */ + getLeftmostComparator(baseEvent) { + const cache = /* @__PURE__ */ new Map(); + const fillCache = (linkedEvent) => { + const nextEvent = linkedEvent.otherSE; + cache.set(linkedEvent, { + sine: sineOfAngle2(this.point, baseEvent.point, nextEvent.point), + cosine: cosineOfAngle2(this.point, baseEvent.point, nextEvent.point) + }); + }; + return (a2, b2) => { + if (!cache.has(a2)) + fillCache(a2); + if (!cache.has(b2)) + fillCache(b2); + const { + sine: asine, + cosine: acosine + } = cache.get(a2); + const { + sine: bsine, + cosine: bcosine + } = cache.get(b2); + if (asine >= 0 && bsine >= 0) { + if (acosine < bcosine) + return 1; + if (acosine > bcosine) + return -1; + return 0; + } + if (asine < 0 && bsine < 0) { + if (acosine < bcosine) + return -1; + if (acosine > bcosine) + return 1; + return 0; + } + if (bsine < asine) + return -1; + if (bsine > asine) + return 1; + return 0; + }; } } - } - function isList(val) { - return val != null && typeof val != "function" && typeof val.length == "number"; - } - function isFunction2(val) { - return val && {}.toString.call(val) === "[object Function]"; - } - function isObject3(val) { - return val && {}.toString.call(val) === "[object Object]"; - } - } - }); - - // node_modules/store/src/store-engine.js - var require_store_engine = __commonJS({ - "node_modules/store/src/store-engine.js"(exports2, module2) { - var util = require_util(); - var slice = util.slice; - var pluck = util.pluck; - var each = util.each; - var bind = util.bind; - var create2 = util.create; - var isList = util.isList; - var isFunction2 = util.isFunction; - var isObject3 = util.isObject; - module2.exports = { - createStore - }; - var storeAPI = { - version: "2.0.12", - enabled: false, - // get returns the value of the given key. If that value - // is undefined, it returns optionalDefaultValue instead. - get: function(key, optionalDefaultValue) { - var data = this.storage.read(this._namespacePrefix + key); - return this._deserialize(data, optionalDefaultValue); - }, - // set will store the given value at key and returns value. - // Calling set with value === undefined is equivalent to calling remove. - set: function(key, value) { - if (value === void 0) { - return this.remove(key); - } - this.storage.write(this._namespacePrefix + key, this._serialize(value)); - return value; - }, - // remove deletes the key and value stored at the given key. - remove: function(key) { - this.storage.remove(this._namespacePrefix + key); - }, - // each will call the given callback once for each key-value pair - // in this store. - each: function(callback) { - var self2 = this; - this.storage.each(function(val, namespacedKey) { - callback.call(self2, self2._deserialize(val), (namespacedKey || "").replace(self2._namespaceRegexp, "")); - }); - }, - // clearAll will remove all the stored key-value pairs in this store. - clearAll: function() { - this.storage.clearAll(); - }, - // additional functionality that can't live in plugins - // --------------------------------------------------- - // hasNamespace returns true if this store instance has the given namespace. - hasNamespace: function(namespace) { - return this._namespacePrefix == "__storejs_" + namespace + "_"; - }, - // createStore creates a store.js instance with the first - // functioning storage in the list of storage candidates, - // and applies the the given mixins to the instance. - createStore: function() { - return createStore.apply(this, arguments); - }, - addPlugin: function(plugin) { - this._addPlugin(plugin); - }, - namespace: function(namespace) { - return createStore(this.storage, this.plugins, namespace); - } - }; - function _warn() { - var _console = typeof console == "undefined" ? null : console; - if (!_console) { - return; - } - var fn = _console.warn ? _console.warn : _console.log; - fn.apply(_console, arguments); - } - function createStore(storages, plugins, namespace) { - if (!namespace) { - namespace = ""; - } - if (storages && !isList(storages)) { - storages = [storages]; - } - if (plugins && !isList(plugins)) { - plugins = [plugins]; - } - var namespacePrefix = namespace ? "__storejs_" + namespace + "_" : ""; - var namespaceRegexp = namespace ? new RegExp("^" + namespacePrefix) : null; - var legalNamespaces = /^[a-zA-Z0-9_\-]*$/; - if (!legalNamespaces.test(namespace)) { - throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes"); - } - var _privateStoreProps = { - _namespacePrefix: namespacePrefix, - _namespaceRegexp: namespaceRegexp, - _testStorage: function(storage) { - try { - var testStr = "__storejs__test__"; - storage.write(testStr, testStr); - var ok = storage.read(testStr) === testStr; - storage.remove(testStr); - return ok; - } catch (e3) { - return false; + let segmentId2 = 0; + class Segment2 { + /* This compare() function is for ordering segments in the sweep + * line tree, and does so according to the following criteria: + * + * Consider the vertical line that lies an infinestimal step to the + * right of the right-more of the two left endpoints of the input + * segments. Imagine slowly moving a point up from negative infinity + * in the increasing y direction. Which of the two segments will that + * point intersect first? That segment comes 'before' the other one. + * + * If neither segment would be intersected by such a line, (if one + * or more of the segments are vertical) then the line to be considered + * is directly on the right-more of the two left inputs. + */ + static compare(a2, b2) { + const alx = a2.leftSE.point.x; + const blx = b2.leftSE.point.x; + const arx = a2.rightSE.point.x; + const brx = b2.rightSE.point.x; + if (brx < alx) + return 1; + if (arx < blx) + return -1; + const aly = a2.leftSE.point.y; + const bly = b2.leftSE.point.y; + const ary = a2.rightSE.point.y; + const bry = b2.rightSE.point.y; + if (alx < blx) { + if (bly < aly && bly < ary) + return 1; + if (bly > aly && bly > ary) + return -1; + const aCmpBLeft = a2.comparePoint(b2.leftSE.point); + if (aCmpBLeft < 0) + return 1; + if (aCmpBLeft > 0) + return -1; + const bCmpARight = b2.comparePoint(a2.rightSE.point); + if (bCmpARight !== 0) + return bCmpARight; + return -1; } - }, - _assignPluginFnProp: function(pluginFnProp, propName) { - var oldFn = this[propName]; - this[propName] = function pluginFn() { - var args = slice(arguments, 0); - var self2 = this; - function super_fn() { - if (!oldFn) { - return; - } - each(arguments, function(arg, i3) { - args[i3] = arg; - }); - return oldFn.apply(self2, args); + if (alx > blx) { + if (aly < bly && aly < bry) + return -1; + if (aly > bly && aly > bry) + return 1; + const bCmpALeft = b2.comparePoint(a2.leftSE.point); + if (bCmpALeft !== 0) + return bCmpALeft; + const aCmpBRight = a2.comparePoint(b2.rightSE.point); + if (aCmpBRight < 0) + return 1; + if (aCmpBRight > 0) + return -1; + return 1; + } + if (aly < bly) + return -1; + if (aly > bly) + return 1; + if (arx < brx) { + const bCmpARight = b2.comparePoint(a2.rightSE.point); + if (bCmpARight !== 0) + return bCmpARight; + } + if (arx > brx) { + const aCmpBRight = a2.comparePoint(b2.rightSE.point); + if (aCmpBRight < 0) + return 1; + if (aCmpBRight > 0) + return -1; + } + if (arx !== brx) { + const ay = ary - aly; + const ax = arx - alx; + const by = bry - bly; + const bx = brx - blx; + if (ay > ax && by < bx) + return 1; + if (ay < ax && by > bx) + return -1; + } + if (arx > brx) + return 1; + if (arx < brx) + return -1; + if (ary < bry) + return -1; + if (ary > bry) + return 1; + if (a2.id < b2.id) + return -1; + if (a2.id > b2.id) + return 1; + return 0; + } + /* Warning: a reference to ringWindings input will be stored, + * and possibly will be later modified */ + constructor(leftSE, rightSE, rings, windings) { + this.id = ++segmentId2; + this.leftSE = leftSE; + leftSE.segment = this; + leftSE.otherSE = rightSE; + this.rightSE = rightSE; + rightSE.segment = this; + rightSE.otherSE = leftSE; + this.rings = rings; + this.windings = windings; + } + static fromRing(pt1, pt2, ring) { + let leftPt, rightPt, winding; + const cmpPts = SweepEvent2.comparePoints(pt1, pt2); + if (cmpPts < 0) { + leftPt = pt1; + rightPt = pt2; + winding = 1; + } else if (cmpPts > 0) { + leftPt = pt2; + rightPt = pt1; + winding = -1; + } else + throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]")); + const leftSE = new SweepEvent2(leftPt, true); + const rightSE = new SweepEvent2(rightPt, false); + return new Segment2(leftSE, rightSE, [ring], [winding]); + } + /* When a segment is split, the rightSE is replaced with a new sweep event */ + replaceRightSE(newRightSE) { + this.rightSE = newRightSE; + this.rightSE.segment = this; + this.rightSE.otherSE = this.leftSE; + this.leftSE.otherSE = this.rightSE; + } + bbox() { + const y12 = this.leftSE.point.y; + const y2 = this.rightSE.point.y; + return { + ll: { + x: this.leftSE.point.x, + y: y12 < y2 ? y12 : y2 + }, + ur: { + x: this.rightSE.point.x, + y: y12 > y2 ? y12 : y2 } - var newFnArgs = [super_fn].concat(args); - return pluginFnProp.apply(self2, newFnArgs); }; - }, - _serialize: function(obj) { - return JSON.stringify(obj); - }, - _deserialize: function(strVal, defaultVal) { - if (!strVal) { - return defaultVal; - } - var val = ""; - try { - val = JSON.parse(strVal); - } catch (e3) { - val = strVal; + } + /* A vector from the left point to the right */ + vector() { + return { + x: this.rightSE.point.x - this.leftSE.point.x, + y: this.rightSE.point.y - this.leftSE.point.y + }; + } + isAnEndpoint(pt2) { + 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; + } + /* Compare this segment with a point. + * + * A point P is considered to be colinear to a segment if there + * exists a distance D such that if we travel along the segment + * from one * endpoint towards the other a distance D, we find + * ourselves at point P. + * + * Return value indicates: + * + * 1: point lies above the segment (to the left of vertical) + * 0: point is colinear to segment + * -1: point lies below the segment (to the right of vertical) + */ + comparePoint(point2) { + if (this.isAnEndpoint(point2)) + return 0; + const lPt = this.leftSE.point; + const rPt = this.rightSE.point; + const v2 = this.vector(); + if (lPt.x === rPt.x) { + if (point2.x === lPt.x) + return 0; + return point2.x < lPt.x ? 1 : -1; } - return val !== void 0 ? val : defaultVal; - }, - _addStorage: function(storage) { - if (this.enabled) { - return; + const yDist = (point2.y - lPt.y) / v2.y; + const xFromYDist = lPt.x + yDist * v2.x; + if (point2.x === xFromYDist) + return 0; + const xDist = (point2.x - lPt.x) / v2.x; + const yFromXDist = lPt.y + xDist * v2.y; + if (point2.y === yFromXDist) + return 0; + return point2.y < yFromXDist ? -1 : 1; + } + /** + * Given another segment, returns the first non-trivial intersection + * between the two segments (in terms of sweep line ordering), if it exists. + * + * A 'non-trivial' intersection is one that will cause one or both of the + * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection: + * + * * endpoint of segA with endpoint of segB --> trivial + * * endpoint of segA with point along segB --> non-trivial + * * endpoint of segB with point along segA --> non-trivial + * * point along segA with point along segB --> non-trivial + * + * If no non-trivial intersection exists, return null + * Else, return null. + */ + getIntersection(other) { + const tBbox = this.bbox(); + const oBbox = other.bbox(); + const bboxOverlap = getBboxOverlap2(tBbox, oBbox); + if (bboxOverlap === null) + return null; + const tlp = this.leftSE.point; + const trp = this.rightSE.point; + const olp = other.leftSE.point; + const orp = other.rightSE.point; + const touchesOtherLSE = isInBbox2(tBbox, olp) && this.comparePoint(olp) === 0; + const touchesThisLSE = isInBbox2(oBbox, tlp) && other.comparePoint(tlp) === 0; + const touchesOtherRSE = isInBbox2(tBbox, orp) && this.comparePoint(orp) === 0; + const touchesThisRSE = isInBbox2(oBbox, trp) && other.comparePoint(trp) === 0; + if (touchesThisLSE && touchesOtherLSE) { + if (touchesThisRSE && !touchesOtherRSE) + return trp; + if (!touchesThisRSE && touchesOtherRSE) + return orp; + return null; } - if (this._testStorage(storage)) { - this.storage = storage; - this.enabled = true; + if (touchesThisLSE) { + if (touchesOtherRSE) { + if (tlp.x === orp.x && tlp.y === orp.y) + return null; + } + return tlp; } - }, - _addPlugin: function(plugin) { - var self2 = this; - if (isList(plugin)) { - each(plugin, function(plugin2) { - self2._addPlugin(plugin2); - }); - return; + if (touchesOtherLSE) { + if (touchesThisRSE) { + if (trp.x === olp.x && trp.y === olp.y) + return null; + } + return olp; } - var seenPlugin = pluck(this.plugins, function(seenPlugin2) { - return plugin === seenPlugin2; - }); - if (seenPlugin) { + if (touchesThisRSE && touchesOtherRSE) + return null; + if (touchesThisRSE) + return trp; + if (touchesOtherRSE) + return orp; + const pt2 = intersection$1(tlp, this.vector(), olp, other.vector()); + if (pt2 === null) + return null; + if (!isInBbox2(bboxOverlap, pt2)) + return null; + return rounder.round(pt2.x, pt2.y); + } + /** + * Split the given segment into multiple segments on the given points. + * * Each existing segment will retain its leftSE and a new rightSE will be + * generated for it. + * * A new segment will be generated which will adopt the original segment's + * rightSE, and a new leftSE will be generated for it. + * * If there are more than two points given to split on, new segments + * in the middle will be generated with new leftSE and rightSE's. + * * An array of the newly generated SweepEvents will be returned. + * + * Warning: input array of points is modified + */ + split(point2) { + const newEvents = []; + const alreadyLinked = point2.events !== void 0; + const newLeftSE = new SweepEvent2(point2, true); + const newRightSE = new SweepEvent2(point2, false); + const oldRightSE = this.rightSE; + this.replaceRightSE(newRightSE); + newEvents.push(newRightSE); + newEvents.push(newLeftSE); + const newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice()); + if (SweepEvent2.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) { + newSeg.swapEvents(); + } + if (SweepEvent2.comparePoints(this.leftSE.point, this.rightSE.point) > 0) { + this.swapEvents(); + } + if (alreadyLinked) { + newLeftSE.checkForConsuming(); + newRightSE.checkForConsuming(); + } + return newEvents; + } + /* Swap which event is left and right */ + swapEvents() { + const tmpEvt = this.rightSE; + this.rightSE = this.leftSE; + this.leftSE = tmpEvt; + this.leftSE.isLeft = true; + this.rightSE.isLeft = false; + for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) { + this.windings[i3] *= -1; + } + } + /* Consume another segment. We take their rings under our wing + * and mark them as consumed. Use for perfectly overlapping segments */ + consume(other) { + let consumer = this; + let consumee = other; + while (consumer.consumedBy) + consumer = consumer.consumedBy; + while (consumee.consumedBy) + consumee = consumee.consumedBy; + const cmp2 = Segment2.compare(consumer, consumee); + if (cmp2 === 0) return; + if (cmp2 > 0) { + const tmp = consumer; + consumer = consumee; + consumee = tmp; + } + if (consumer.prev === consumee) { + const tmp = consumer; + consumer = consumee; + consumee = tmp; + } + for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) { + const ring = consumee.rings[i3]; + const winding = consumee.windings[i3]; + const index2 = consumer.rings.indexOf(ring); + if (index2 === -1) { + consumer.rings.push(ring); + consumer.windings.push(winding); + } else + consumer.windings[index2] += winding; } - this.plugins.push(plugin); - if (!isFunction2(plugin)) { - throw new Error("Plugins must be function values that return objects"); + consumee.rings = null; + consumee.windings = null; + consumee.consumedBy = consumer; + consumee.leftSE.consumedBy = consumer.leftSE; + consumee.rightSE.consumedBy = consumer.rightSE; + } + /* The first segment previous segment chain that is in the result */ + prevInResult() { + if (this._prevInResult !== void 0) + return this._prevInResult; + if (!this.prev) + this._prevInResult = null; + else if (this.prev.isInResult()) + this._prevInResult = this.prev; + else + this._prevInResult = this.prev.prevInResult(); + return this._prevInResult; + } + beforeState() { + if (this._beforeState !== void 0) + return this._beforeState; + if (!this.prev) + this._beforeState = { + rings: [], + windings: [], + multiPolys: [] + }; + else { + const seg = this.prev.consumedBy || this.prev; + this._beforeState = seg.afterState(); } - var pluginProperties = plugin.call(this); - if (!isObject3(pluginProperties)) { - throw new Error("Plugins must return an object of function properties"); + return this._beforeState; + } + afterState() { + if (this._afterState !== void 0) + return this._afterState; + const beforeState = this.beforeState(); + this._afterState = { + rings: beforeState.rings.slice(0), + windings: beforeState.windings.slice(0), + multiPolys: [] + }; + const ringsAfter = this._afterState.rings; + const windingsAfter = this._afterState.windings; + const mpsAfter = this._afterState.multiPolys; + for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) { + const ring = this.rings[i3]; + const winding = this.windings[i3]; + const index2 = ringsAfter.indexOf(ring); + if (index2 === -1) { + ringsAfter.push(ring); + windingsAfter.push(winding); + } else + windingsAfter[index2] += winding; } - each(pluginProperties, function(pluginFnProp, propName) { - if (!isFunction2(pluginFnProp)) { - throw new Error("Bad plugin property: " + propName + " from plugin " + plugin.name + ". Plugins should only return functions."); + const polysAfter = []; + const polysExclude = []; + for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) { + if (windingsAfter[i3] === 0) + continue; + const ring = ringsAfter[i3]; + const poly = ring.poly; + if (polysExclude.indexOf(poly) !== -1) + continue; + if (ring.isExterior) + polysAfter.push(poly); + else { + if (polysExclude.indexOf(poly) === -1) + polysExclude.push(poly); + const index2 = polysAfter.indexOf(ring.poly); + if (index2 !== -1) + polysAfter.splice(index2, 1); } - self2._assignPluginFnProp(pluginFnProp, propName); - }); - }, - // Put deprecated properties in the private API, so as to not expose it to accidential - // discovery through inspection of the store object. - // Deprecated: addStorage - addStorage: function(storage) { - _warn("store.addStorage(storage) is deprecated. Use createStore([storages])"); - this._addStorage(storage); + } + for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) { + const mp = polysAfter[i3].multiPoly; + if (mpsAfter.indexOf(mp) === -1) + mpsAfter.push(mp); + } + return this._afterState; } - }; - var store2 = create2(_privateStoreProps, storeAPI, { - plugins: [] - }); - store2.raw = {}; - each(store2, function(prop, propName) { - if (isFunction2(prop)) { - store2.raw[propName] = bind(store2, prop); + /* Is this segment part of the final result? */ + isInResult() { + if (this.consumedBy) + return false; + if (this._isInResult !== void 0) + return this._isInResult; + const mpsBefore = this.beforeState().multiPolys; + const mpsAfter = this.afterState().multiPolys; + switch (operation2.type) { + case "union": { + const noBefores = mpsBefore.length === 0; + const noAfters = mpsAfter.length === 0; + this._isInResult = noBefores !== noAfters; + break; + } + case "intersection": { + let least; + let most; + if (mpsBefore.length < mpsAfter.length) { + least = mpsBefore.length; + most = mpsAfter.length; + } else { + least = mpsAfter.length; + most = mpsBefore.length; + } + this._isInResult = most === operation2.numMultiPolys && least < most; + break; + } + case "xor": { + const diff = Math.abs(mpsBefore.length - mpsAfter.length); + this._isInResult = diff % 2 === 1; + break; + } + case "difference": { + const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject; + this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter); + break; + } + default: + throw new Error("Unrecognized operation type found ".concat(operation2.type)); + } + return this._isInResult; } - }); - each(storages, function(storage) { - store2._addStorage(storage); - }); - each(plugins, function(plugin) { - store2._addPlugin(plugin); - }); - return store2; - } - } - }); - - // node_modules/store/storages/localStorage.js - var require_localStorage = __commonJS({ - "node_modules/store/storages/localStorage.js"(exports2, module2) { - var util = require_util(); - var Global = util.Global; - module2.exports = { - name: "localStorage", - read, - write, - each, - remove: remove2, - clearAll - }; - function localStorage2() { - return Global.localStorage; - } - function read(key) { - return localStorage2().getItem(key); - } - function write(key, data) { - return localStorage2().setItem(key, data); - } - function each(fn) { - for (var i3 = localStorage2().length - 1; i3 >= 0; i3--) { - var key = localStorage2().key(i3); - fn(read(key), key); - } - } - function remove2(key) { - return localStorage2().removeItem(key); - } - function clearAll() { - return localStorage2().clear(); - } - } - }); - - // node_modules/store/storages/oldFF-globalStorage.js - var require_oldFF_globalStorage = __commonJS({ - "node_modules/store/storages/oldFF-globalStorage.js"(exports2, module2) { - var util = require_util(); - var Global = util.Global; - module2.exports = { - name: "oldFF-globalStorage", - read, - write, - each, - remove: remove2, - clearAll - }; - var globalStorage = Global.globalStorage; - function read(key) { - return globalStorage[key]; - } - function write(key, data) { - globalStorage[key] = data; - } - function each(fn) { - for (var i3 = globalStorage.length - 1; i3 >= 0; i3--) { - var key = globalStorage.key(i3); - fn(globalStorage[key], key); } - } - function remove2(key) { - return globalStorage.removeItem(key); - } - function clearAll() { - each(function(key, _2) { - delete globalStorage[key]; - }); - } - } - }); - - // node_modules/store/storages/oldIE-userDataStorage.js - var require_oldIE_userDataStorage = __commonJS({ - "node_modules/store/storages/oldIE-userDataStorage.js"(exports2, module2) { - var util = require_util(); - var Global = util.Global; - module2.exports = { - name: "oldIE-userDataStorage", - write, - read, - each, - remove: remove2, - clearAll - }; - var storageName = "storejs"; - var doc = Global.document; - var _withStorageEl = _makeIEStorageElFunction(); - var disable = (Global.navigator ? Global.navigator.userAgent : "").match(/ (MSIE 8|MSIE 9|MSIE 10)\./); - function write(unfixedKey, data) { - if (disable) { - return; - } - var fixedKey = fixKey(unfixedKey); - _withStorageEl(function(storageEl) { - storageEl.setAttribute(fixedKey, data); - storageEl.save(storageName); - }); - } - function read(unfixedKey) { - if (disable) { - return; - } - var fixedKey = fixKey(unfixedKey); - var res = null; - _withStorageEl(function(storageEl) { - res = storageEl.getAttribute(fixedKey); - }); - return res; - } - function each(callback) { - _withStorageEl(function(storageEl) { - var attributes = storageEl.XMLDocument.documentElement.attributes; - for (var i3 = attributes.length - 1; i3 >= 0; i3--) { - var attr = attributes[i3]; - callback(storageEl.getAttribute(attr.name), attr.name); + class RingIn2 { + constructor(geomRing, poly, isExterior) { + if (!Array.isArray(geomRing) || geomRing.length === 0) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + this.poly = poly; + this.isExterior = isExterior; + this.segments = []; + if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]); + this.bbox = { + ll: { + x: firstPoint.x, + y: firstPoint.y + }, + ur: { + x: firstPoint.x, + y: firstPoint.y + } + }; + let prevPoint = firstPoint; + for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) { + if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + let point2 = rounder.round(geomRing[i3][0], geomRing[i3][1]); + if (point2.x === prevPoint.x && point2.y === prevPoint.y) + continue; + this.segments.push(Segment2.fromRing(prevPoint, point2, this)); + if (point2.x < this.bbox.ll.x) + this.bbox.ll.x = point2.x; + if (point2.y < this.bbox.ll.y) + this.bbox.ll.y = point2.y; + if (point2.x > this.bbox.ur.x) + this.bbox.ur.x = point2.x; + if (point2.y > this.bbox.ur.y) + this.bbox.ur.y = point2.y; + prevPoint = point2; + } + if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) { + this.segments.push(Segment2.fromRing(prevPoint, firstPoint, this)); + } } - }); - } - function remove2(unfixedKey) { - var fixedKey = fixKey(unfixedKey); - _withStorageEl(function(storageEl) { - storageEl.removeAttribute(fixedKey); - storageEl.save(storageName); - }); - } - function clearAll() { - _withStorageEl(function(storageEl) { - var attributes = storageEl.XMLDocument.documentElement.attributes; - storageEl.load(storageName); - for (var i3 = attributes.length - 1; i3 >= 0; i3--) { - storageEl.removeAttribute(attributes[i3].name); + getSweepEvents() { + const sweepEvents = []; + for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) { + const segment = this.segments[i3]; + sweepEvents.push(segment.leftSE); + sweepEvents.push(segment.rightSE); + } + return sweepEvents; } - storageEl.save(storageName); - }); - } - var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g"); - function fixKey(key) { - return key.replace(/^\d/, "___$&").replace(forbiddenCharsRegex, "___"); - } - function _makeIEStorageElFunction() { - if (!doc || !doc.documentElement || !doc.documentElement.addBehavior) { - return null; - } - var scriptTag = "script", storageOwner, storageContainer, storageEl; - try { - storageContainer = new ActiveXObject("htmlfile"); - storageContainer.open(); - storageContainer.write("<" + scriptTag + ">document.w=window'); - storageContainer.close(); - storageOwner = storageContainer.w.frames[0].document; - storageEl = storageOwner.createElement("div"); - } catch (e3) { - storageEl = doc.createElement("div"); - storageOwner = doc.body; - } - return function(storeFunction) { - var args = [].slice.call(arguments, 0); - args.unshift(storageEl); - storageOwner.appendChild(storageEl); - storageEl.addBehavior("#default#userData"); - storageEl.load(storageName); - storeFunction.apply(this, args); - storageOwner.removeChild(storageEl); - return; - }; - } - } - }); - - // node_modules/store/storages/cookieStorage.js - var require_cookieStorage = __commonJS({ - "node_modules/store/storages/cookieStorage.js"(exports2, module2) { - var util = require_util(); - var Global = util.Global; - var trim = util.trim; - module2.exports = { - name: "cookieStorage", - read, - write, - each, - remove: remove2, - clearAll - }; - var doc = Global.document; - function read(key) { - if (!key || !_has(key)) { - return null; } - var regexpStr = "(?:^|.*;\\s*)" + escape(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"; - return unescape(doc.cookie.replace(new RegExp(regexpStr), "$1")); - } - function each(callback) { - var cookies = doc.cookie.split(/; ?/g); - for (var i3 = cookies.length - 1; i3 >= 0; i3--) { - if (!trim(cookies[i3])) { - continue; + class PolyIn2 { + constructor(geomPoly, multiPoly) { + if (!Array.isArray(geomPoly)) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + this.exteriorRing = new RingIn2(geomPoly[0], this, true); + this.bbox = { + ll: { + x: this.exteriorRing.bbox.ll.x, + y: this.exteriorRing.bbox.ll.y + }, + ur: { + x: this.exteriorRing.bbox.ur.x, + y: this.exteriorRing.bbox.ur.y + } + }; + this.interiorRings = []; + for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) { + const ring = new RingIn2(geomPoly[i3], this, false); + if (ring.bbox.ll.x < this.bbox.ll.x) + this.bbox.ll.x = ring.bbox.ll.x; + if (ring.bbox.ll.y < this.bbox.ll.y) + this.bbox.ll.y = ring.bbox.ll.y; + if (ring.bbox.ur.x > this.bbox.ur.x) + this.bbox.ur.x = ring.bbox.ur.x; + if (ring.bbox.ur.y > this.bbox.ur.y) + this.bbox.ur.y = ring.bbox.ur.y; + this.interiorRings.push(ring); + } + this.multiPoly = multiPoly; + } + getSweepEvents() { + const sweepEvents = this.exteriorRing.getSweepEvents(); + for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { + const ringSweepEvents = this.interiorRings[i3].getSweepEvents(); + for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) { + sweepEvents.push(ringSweepEvents[j2]); + } + } + return sweepEvents; } - var kvp = cookies[i3].split("="); - var key = unescape(kvp[0]); - var val = unescape(kvp[1]); - callback(val, key); - } - } - function write(key, data) { - if (!key) { - return; } - doc.cookie = escape(key) + "=" + escape(data) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"; - } - function remove2(key) { - if (!key || !_has(key)) { - return; + class MultiPolyIn2 { + constructor(geom, isSubject) { + if (!Array.isArray(geom)) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + try { + if (typeof geom[0][0][0] === "number") + geom = [geom]; + } catch (ex) { + } + this.polys = []; + this.bbox = { + ll: { + x: Number.POSITIVE_INFINITY, + y: Number.POSITIVE_INFINITY + }, + ur: { + x: Number.NEGATIVE_INFINITY, + y: Number.NEGATIVE_INFINITY + } + }; + for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) { + const poly = new PolyIn2(geom[i3], this); + if (poly.bbox.ll.x < this.bbox.ll.x) + this.bbox.ll.x = poly.bbox.ll.x; + if (poly.bbox.ll.y < this.bbox.ll.y) + this.bbox.ll.y = poly.bbox.ll.y; + if (poly.bbox.ur.x > this.bbox.ur.x) + this.bbox.ur.x = poly.bbox.ur.x; + if (poly.bbox.ur.y > this.bbox.ur.y) + this.bbox.ur.y = poly.bbox.ur.y; + this.polys.push(poly); + } + this.isSubject = isSubject; + } + getSweepEvents() { + const sweepEvents = []; + for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { + const polySweepEvents = this.polys[i3].getSweepEvents(); + for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) { + sweepEvents.push(polySweepEvents[j2]); + } + } + return sweepEvents; + } } - doc.cookie = escape(key) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; - } - function clearAll() { - each(function(_2, key) { - remove2(key); - }); - } - function _has(key) { - return new RegExp("(?:^|;\\s*)" + escape(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=").test(doc.cookie); - } - } - }); - - // node_modules/store/storages/sessionStorage.js - var require_sessionStorage = __commonJS({ - "node_modules/store/storages/sessionStorage.js"(exports2, module2) { - var util = require_util(); - var Global = util.Global; - module2.exports = { - name: "sessionStorage", - read, - write, - each, - remove: remove2, - clearAll - }; - function sessionStorage() { - return Global.sessionStorage; - } - function read(key) { - return sessionStorage().getItem(key); - } - function write(key, data) { - return sessionStorage().setItem(key, data); - } - function each(fn) { - for (var i3 = sessionStorage().length - 1; i3 >= 0; i3--) { - var key = sessionStorage().key(i3); - fn(read(key), key); + class RingOut2 { + /* Given the segments from the sweep line pass, compute & return a series + * of closed rings from all the segments marked to be part of the result */ + static factory(allSegments) { + const ringsOut = []; + for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) { + const segment = allSegments[i3]; + if (!segment.isInResult() || segment.ringOut) + continue; + let prevEvent = null; + let event = segment.leftSE; + let nextEvent = segment.rightSE; + const events = [event]; + const startingPoint = event.point; + const intersectionLEs = []; + while (true) { + prevEvent = event; + event = nextEvent; + events.push(event); + if (event.point === startingPoint) + break; + while (true) { + const availableLEs = event.getAvailableLinkedEvents(); + if (availableLEs.length === 0) { + const firstPt = events[0].point; + const lastPt = events[events.length - 1].point; + 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, "].")); + } + if (availableLEs.length === 1) { + nextEvent = availableLEs[0].otherSE; + break; + } + let indexLE = null; + for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) { + if (intersectionLEs[j2].point === event.point) { + indexLE = j2; + break; + } + } + if (indexLE !== null) { + const intersectionLE = intersectionLEs.splice(indexLE)[0]; + const ringEvents = events.splice(intersectionLE.index); + ringEvents.unshift(ringEvents[0].otherSE); + ringsOut.push(new RingOut2(ringEvents.reverse())); + continue; + } + intersectionLEs.push({ + index: events.length, + point: event.point + }); + const comparator = event.getLeftmostComparator(prevEvent); + nextEvent = availableLEs.sort(comparator)[0].otherSE; + break; + } + } + ringsOut.push(new RingOut2(events)); + } + return ringsOut; + } + constructor(events) { + this.events = events; + for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) { + events[i3].segment.ringOut = this; + } + this.poly = null; + } + getGeom() { + let prevPt = this.events[0].point; + const points = [prevPt]; + for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) { + const pt3 = this.events[i3].point; + const nextPt2 = this.events[i3 + 1].point; + if (compareVectorAngles(pt3, prevPt, nextPt2) === 0) + continue; + points.push(pt3); + prevPt = pt3; + } + if (points.length === 1) + return null; + const pt2 = points[0]; + const nextPt = points[1]; + if (compareVectorAngles(pt2, prevPt, nextPt) === 0) + points.shift(); + points.push(points[0]); + const step = this.isExteriorRing() ? 1 : -1; + const iStart = this.isExteriorRing() ? 0 : points.length - 1; + const iEnd = this.isExteriorRing() ? points.length : -1; + const orderedPoints = []; + for (let i3 = iStart; i3 != iEnd; i3 += step) + orderedPoints.push([points[i3].x, points[i3].y]); + return orderedPoints; + } + isExteriorRing() { + if (this._isExteriorRing === void 0) { + const enclosing = this.enclosingRing(); + this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true; + } + return this._isExteriorRing; + } + enclosingRing() { + if (this._enclosingRing === void 0) { + this._enclosingRing = this._calcEnclosingRing(); + } + return this._enclosingRing; + } + /* Returns the ring that encloses this one, if any */ + _calcEnclosingRing() { + let leftMostEvt = this.events[0]; + for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) { + const evt = this.events[i3]; + if (SweepEvent2.compare(leftMostEvt, evt) > 0) + leftMostEvt = evt; + } + let prevSeg = leftMostEvt.segment.prevInResult(); + let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; + while (true) { + if (!prevSeg) + return null; + if (!prevPrevSeg) + return prevSeg.ringOut; + if (prevPrevSeg.ringOut !== prevSeg.ringOut) { + if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) { + return prevSeg.ringOut; + } else + return prevSeg.ringOut.enclosingRing(); + } + prevSeg = prevPrevSeg.prevInResult(); + prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; + } + } } - } - function remove2(key) { - return sessionStorage().removeItem(key); - } - function clearAll() { - return sessionStorage().clear(); - } - } - }); - - // node_modules/store/storages/memoryStorage.js - var require_memoryStorage = __commonJS({ - "node_modules/store/storages/memoryStorage.js"(exports2, module2) { - module2.exports = { - name: "memoryStorage", - read, - write, - each, - remove: remove2, - clearAll - }; - var memoryStorage = {}; - function read(key) { - return memoryStorage[key]; - } - function write(key, data) { - memoryStorage[key] = data; - } - function each(callback) { - for (var key in memoryStorage) { - if (memoryStorage.hasOwnProperty(key)) { - callback(memoryStorage[key], key); + class PolyOut2 { + constructor(exteriorRing) { + this.exteriorRing = exteriorRing; + exteriorRing.poly = this; + this.interiorRings = []; + } + addInterior(ring) { + this.interiorRings.push(ring); + ring.poly = this; + } + getGeom() { + const geom = [this.exteriorRing.getGeom()]; + if (geom[0] === null) + return null; + for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { + const ringGeom = this.interiorRings[i3].getGeom(); + if (ringGeom === null) + continue; + geom.push(ringGeom); + } + return geom; } } - } - function remove2(key) { - delete memoryStorage[key]; - } - function clearAll(key) { - memoryStorage = {}; - } - } - }); - - // node_modules/store/storages/all.js - var require_all = __commonJS({ - "node_modules/store/storages/all.js"(exports2, module2) { - module2.exports = [ - // Listed in order of usage preference - require_localStorage(), - require_oldFF_globalStorage(), - require_oldIE_userDataStorage(), - require_cookieStorage(), - require_sessionStorage(), - require_memoryStorage() - ]; - } - }); - - // node_modules/store/plugins/lib/json2.js - var require_json2 = __commonJS({ - "node_modules/store/plugins/lib/json2.js"(exports, module) { - if (typeof JSON !== "object") { - JSON = {}; - } - (function() { - "use strict"; - var rx_one = /^[\],:{}\s]*$/; - var rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; - var rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; - var rx_four = /(?:^|:|,)(?:\s*\[)+/g; - var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - var rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - function f(n3) { - return n3 < 10 ? "0" + n3 : n3; - } - function this_value() { - return this.valueOf(); - } - if (typeof Date.prototype.toJSON !== "function") { - Date.prototype.toJSON = function() { - return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z" : null; - }; - Boolean.prototype.toJSON = this_value; - Number.prototype.toJSON = this_value; - String.prototype.toJSON = this_value; - } - var gap; - var indent; - var meta; - var rep; - function quote(string) { - rx_escapable.lastIndex = 0; - return rx_escapable.test(string) ? '"' + string.replace(rx_escapable, function(a2) { - var c2 = meta[a2]; - return typeof c2 === "string" ? c2 : "\\u" + ("0000" + a2.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; - } - function str(key, holder) { - var i3; - var k2; - var v2; - var length; - var mind = gap; - var partial; - var value = holder[key]; - if (value && typeof value === "object" && typeof value.toJSON === "function") { - value = value.toJSON(key); - } - if (typeof rep === "function") { - value = rep.call(holder, key, value); - } - switch (typeof value) { - case "string": - return quote(value); - case "number": - return isFinite(value) ? String(value) : "null"; - case "boolean": - case "null": - return String(value); - case "object": - if (!value) { - return "null"; + class MultiPolyOut2 { + constructor(rings) { + this.rings = rings; + this.polys = this._composePolys(rings); + } + getGeom() { + const geom = []; + for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { + const polyGeom = this.polys[i3].getGeom(); + if (polyGeom === null) + continue; + geom.push(polyGeom); + } + return geom; + } + _composePolys(rings) { + const polys = []; + for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) { + const ring = rings[i3]; + if (ring.poly) + continue; + if (ring.isExteriorRing()) + polys.push(new PolyOut2(ring)); + else { + const enclosingRing = ring.enclosingRing(); + if (!enclosingRing.poly) + polys.push(new PolyOut2(enclosingRing)); + enclosingRing.poly.addInterior(ring); } - gap += indent; - partial = []; - if (Object.prototype.toString.apply(value) === "[object Array]") { - length = value.length; - for (i3 = 0; i3 < length; i3 += 1) { - partial[i3] = str(i3, value) || "null"; + } + return polys; + } + } + class SweepLine2 { + constructor(queue) { + let comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment2.compare; + this.queue = queue; + this.tree = new Tree(comparator); + this.segments = []; + } + process(event) { + const segment = event.segment; + const newEvents = []; + if (event.consumedBy) { + if (event.isLeft) + this.queue.remove(event.otherSE); + else + this.tree.remove(segment); + return newEvents; + } + const node = event.isLeft ? this.tree.add(segment) : this.tree.find(segment); + 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."); + let prevNode = node; + let nextNode = node; + let prevSeg = void 0; + let nextSeg = void 0; + while (prevSeg === void 0) { + prevNode = this.tree.prev(prevNode); + if (prevNode === null) + prevSeg = null; + else if (prevNode.key.consumedBy === void 0) + prevSeg = prevNode.key; + } + while (nextSeg === void 0) { + nextNode = this.tree.next(nextNode); + if (nextNode === null) + nextSeg = null; + else if (nextNode.key.consumedBy === void 0) + nextSeg = nextNode.key; + } + if (event.isLeft) { + let prevMySplitter = null; + if (prevSeg) { + const prevInter = prevSeg.getIntersection(segment); + if (prevInter !== null) { + if (!segment.isAnEndpoint(prevInter)) + prevMySplitter = prevInter; + if (!prevSeg.isAnEndpoint(prevInter)) { + const newEventsFromSplit = this._splitSafely(prevSeg, prevInter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } } - v2 = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]"; - gap = mind; - return v2; } - if (rep && typeof rep === "object") { - length = rep.length; - for (i3 = 0; i3 < length; i3 += 1) { - if (typeof rep[i3] === "string") { - k2 = rep[i3]; - v2 = str(k2, value); - if (v2) { - partial.push(quote(k2) + (gap ? ": " : ":") + v2); + let nextMySplitter = null; + if (nextSeg) { + const nextInter = nextSeg.getIntersection(segment); + if (nextInter !== null) { + if (!segment.isAnEndpoint(nextInter)) + nextMySplitter = nextInter; + if (!nextSeg.isAnEndpoint(nextInter)) { + const newEventsFromSplit = this._splitSafely(nextSeg, nextInter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); } } } + } + if (prevMySplitter !== null || nextMySplitter !== null) { + let mySplitter = null; + if (prevMySplitter === null) + mySplitter = nextMySplitter; + else if (nextMySplitter === null) + mySplitter = prevMySplitter; + else { + const cmpSplitters = SweepEvent2.comparePoints(prevMySplitter, nextMySplitter); + mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter; + } + this.queue.remove(segment.rightSE); + newEvents.push(segment.rightSE); + const newEventsFromSplit = segment.split(mySplitter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + if (newEvents.length > 0) { + this.tree.remove(segment); + newEvents.push(event); } else { - for (k2 in value) { - if (Object.prototype.hasOwnProperty.call(value, k2)) { - v2 = str(k2, value); - if (v2) { - partial.push(quote(k2) + (gap ? ": " : ":") + v2); + this.segments.push(segment); + segment.prev = prevSeg; + } + } else { + if (prevSeg && nextSeg) { + const inter = prevSeg.getIntersection(nextSeg); + if (inter !== null) { + if (!prevSeg.isAnEndpoint(inter)) { + const newEventsFromSplit = this._splitSafely(prevSeg, inter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + if (!nextSeg.isAnEndpoint(inter)) { + const newEventsFromSplit = this._splitSafely(nextSeg, inter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); } } } } - v2 = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}"; - gap = mind; - return v2; - } - } - if (typeof JSON.stringify !== "function") { - meta = { - // table of character substitutions - "\b": "\\b", - " ": "\\t", - "\n": "\\n", - "\f": "\\f", - "\r": "\\r", - '"': '\\"', - "\\": "\\\\" - }; - JSON.stringify = function(value, replacer, space) { - var i3; - gap = ""; - indent = ""; - if (typeof space === "number") { - for (i3 = 0; i3 < space; i3 += 1) { - indent += " "; + this.tree.remove(segment); + } + return newEvents; + } + /* Safely split a segment that is currently in the datastructures + * IE - a segment other than the one that is currently being processed. */ + _splitSafely(seg, pt2) { + this.tree.remove(seg); + const rightSE = seg.rightSE; + this.queue.remove(rightSE); + const newEvents = seg.split(pt2); + newEvents.push(rightSE); + if (seg.consumedBy === void 0) + this.tree.add(seg); + return newEvents; + } + } + const POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6; + const POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6; + class Operation2 { + run(type2, geom, moreGeoms) { + operation2.type = type2; + rounder.reset(); + const multipolys = [new MultiPolyIn2(geom, true)]; + for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) { + multipolys.push(new MultiPolyIn2(moreGeoms[i3], false)); + } + operation2.numMultiPolys = multipolys.length; + if (operation2.type === "difference") { + const subject = multipolys[0]; + let i3 = 1; + while (i3 < multipolys.length) { + if (getBboxOverlap2(multipolys[i3].bbox, subject.bbox) !== null) + i3++; + else + multipolys.splice(i3, 1); } - } else if (typeof space === "string") { - indent = space; - } - rep = replacer; - if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) { - throw new Error("JSON.stringify"); } - return str("", { "": value }); - }; - } - if (typeof JSON.parse !== "function") { - JSON.parse = function(text, reviver) { - var j; - function walk(holder, key) { - var k2; - var v2; - var value = holder[key]; - if (value && typeof value === "object") { - for (k2 in value) { - if (Object.prototype.hasOwnProperty.call(value, k2)) { - v2 = walk(value, k2); - if (v2 !== void 0) { - value[k2] = v2; - } else { - delete value[k2]; - } - } + if (operation2.type === "intersection") { + for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) { + const mpA = multipolys[i3]; + for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) { + if (getBboxOverlap2(mpA.bbox, multipolys[j2].bbox) === null) + return []; } } - return reviver.call(holder, key, value); } - text = String(text); - rx_dangerous.lastIndex = 0; - if (rx_dangerous.test(text)) { - text = text.replace(rx_dangerous, function(a2) { - return "\\u" + ("0000" + a2.charCodeAt(0).toString(16)).slice(-4); - }); + const queue = new Tree(SweepEvent2.compare); + for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) { + const sweepEvents = multipolys[i3].getSweepEvents(); + for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) { + queue.insert(sweepEvents[j2]); + if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) { + throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big)."); + } + } } - if (rx_one.test( - text.replace(rx_two, "@").replace(rx_three, "]").replace(rx_four, "") - )) { - j = eval("(" + text + ")"); - return typeof reviver === "function" ? walk({ "": j }, "") : j; + const sweepLine = new SweepLine2(queue); + let prevQueueSize = queue.size; + let node = queue.pop(); + while (node) { + const evt = node.key; + if (queue.size === prevQueueSize) { + const seg = evt.segment; + 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.")); + } + if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) { + throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big)."); + } + if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) { + throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments)."); + } + const newEvents = sweepLine.process(evt); + for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) { + const evt2 = newEvents[i3]; + if (evt2.consumedBy === void 0) + queue.insert(evt2); + } + prevQueueSize = queue.size; + node = queue.pop(); } - throw new SyntaxError("JSON.parse"); - }; + rounder.reset(); + const ringsOut = RingOut2.factory(sweepLine.segments); + const result = new MultiPolyOut2(ringsOut); + return result.getGeom(); + } } - })(); - } - }); - - // node_modules/store/plugins/json2.js - var require_json22 = __commonJS({ - "node_modules/store/plugins/json2.js"(exports2, module2) { - module2.exports = json2Plugin; - function json2Plugin() { - require_json2(); - return {}; - } - } - }); - - // node_modules/store/dist/store.legacy.js - var require_store_legacy = __commonJS({ - "node_modules/store/dist/store.legacy.js"(exports2, module2) { - var engine = require_store_engine(); - var storages = require_all(); - var plugins = [require_json22()]; - module2.exports = engine.createStore(storages, plugins); + const operation2 = new Operation2(); + const union2 = function(geom) { + for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + moreGeoms[_key - 1] = arguments[_key]; + } + return operation2.run("union", geom, moreGeoms); + }; + const intersection2 = function(geom) { + for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + moreGeoms[_key2 - 1] = arguments[_key2]; + } + return operation2.run("intersection", geom, moreGeoms); + }; + const xor = function(geom) { + for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + moreGeoms[_key3 - 1] = arguments[_key3]; + } + return operation2.run("xor", geom, moreGeoms); + }; + const difference2 = function(subjectGeom) { + for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + clippingGeoms[_key4 - 1] = arguments[_key4]; + } + return operation2.run("difference", subjectGeom, clippingGeoms); + }; + var index = { + union: union2, + intersection: intersection2, + xor, + difference: difference2 + }; + return index; + }); } }); @@ -15275,6 +14619,7 @@ }; Response.error = function() { var response = new Response(null, { status: 200, statusText: "" }); + response.ok = false; response.status = 0; response.type = "error"; return response; @@ -15311,10 +14656,14 @@ } xhr.onload = function() { var options2 = { - status: xhr.status, statusText: xhr.statusText, headers: parseHeaders(xhr.getAllResponseHeaders() || "") }; + if (request3.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) { + options2.status = 200; + } else { + options2.status = xhr.status; + } options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL"); var body = "response" in xhr ? xhr.response : xhr.responseText; setTimeout(function() { @@ -15328,7 +14677,7 @@ }; xhr.ontimeout = function() { setTimeout(function() { - reject(new TypeError("Network request failed")); + reject(new TypeError("Network request timed out")); }, 0); }; xhr.onabort = function() { @@ -15857,6 +15206,8 @@ coreValidator: () => coreValidator, d3: () => d3, debug: () => debug, + dmsCoordinatePair: () => dmsCoordinatePair, + dmsMatcher: () => dmsMatcher, fileFetcher: () => _mainFileFetcher, geoAngle: () => geoAngle, geoChooseEdge: () => geoChooseEdge, @@ -15946,15 +15297,12 @@ osmInferRestriction: () => osmInferRestriction, osmIntersection: () => osmIntersection, osmIsInterestingTag: () => osmIsInterestingTag, - osmIsOldMultipolygonOuterMember: () => osmIsOldMultipolygonOuterMember, osmJoinWays: () => osmJoinWays, osmLanes: () => osmLanes, osmLifecyclePrefixes: () => osmLifecyclePrefixes, osmNode: () => osmNode, osmNodeGeometriesForTags: () => osmNodeGeometriesForTags, osmNote: () => osmNote, - osmOldMultipolygonOuterMember: () => osmOldMultipolygonOuterMember, - osmOldMultipolygonOuterMemberOfRelation: () => osmOldMultipolygonOuterMemberOfRelation, osmOneWayTags: () => osmOneWayTags, osmPavedTags: () => osmPavedTags, osmPointTags: () => osmPointTags, @@ -16226,6 +15574,7 @@ validationMismatchedGeometry: () => validationMismatchedGeometry, validationMissingRole: () => validationMissingRole, validationMissingTag: () => validationMissingTag, + validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags, validationOutdatedTags: () => validationOutdatedTags, validationPrivateData: () => validationPrivateData, validationSuspiciousName: () => validationSuspiciousName, @@ -16265,6 +15614,11 @@ forwards: "backward", backwards: "forward" }; + const valueReplacementsExceptions = { + "side": [ + { highway: "cyclist_waiting_aid" } + ] + }; var roleReplacements = { forward: "backward", backward: "forward", @@ -16303,7 +15657,7 @@ } return key; } - function reverseValue(key, value, includeAbsolute) { + function reverseValue(key, value, includeAbsolute, allTags) { if (ignoreKey.test(key)) return value; if (turn_lanes.test(key)) { @@ -16331,6 +15685,14 @@ } }).join(";"); } + if (valueReplacementsExceptions[key] && valueReplacementsExceptions[key].some( + (exceptionTags) => Object.keys(exceptionTags).every((k2) => { + const v2 = exceptionTags[k2]; + return allTags[k2] && (v2 === "*" || allTags[k2] === v2); + }) + )) { + return value; + } return valueReplacements[value] || value; } function reverseNodeTags(graph, nodeIDs) { @@ -16340,7 +15702,7 @@ continue; var tags = {}; for (var key in node.tags) { - tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID); + tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags); } graph = graph.replace(node.update({ tags })); } @@ -16351,7 +15713,7 @@ var tags = {}; var role; for (var key in way.tags) { - tags[reverseKey(key)] = reverseValue(key, way.tags[key]); + tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags); } graph.parentRelations(way).forEach(function(relation) { relation.members.forEach(function(member, index) { @@ -16376,7 +15738,7 @@ return false; for (var key in entity.tags) { var value = entity.tags[key]; - if (reverseKey(key) !== key || reverseValue(key, value, true) !== value) { + if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) { return false; } } @@ -16388,261 +15750,6 @@ return action; } - // modules/osm/tags.js - function osmIsInterestingTag(key) { - return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon - key.indexOf("tiger:") !== 0; - } - var osmLifecyclePrefixes = { - // nonexistent, might be built - proposed: true, - planned: true, - // under maintentance or between groundbreaking and opening - construction: true, - // existent but not functional - disused: true, - // dilapidated to nonexistent - abandoned: true, - was: true, - // nonexistent, still may appear in imagery - dismantled: true, - razed: true, - demolished: true, - destroyed: true, - removed: true, - obliterated: true, - // existent occasionally, e.g. stormwater drainage basin - intermittent: true - }; - function osmRemoveLifecyclePrefix(key) { - const keySegments = key.split(":"); - if (keySegments.length === 1) - return key; - if (keySegments[0] in osmLifecyclePrefixes) { - return key.slice(keySegments[0].length + 1); - } - return key; - } - var osmAreaKeys = {}; - function osmSetAreaKeys(value) { - osmAreaKeys = value; - } - var osmAreaKeysExceptions = { - highway: { - elevator: true, - rest_area: true, - services: true - }, - public_transport: { - platform: true - }, - railway: { - platform: true, - roundhouse: true, - station: true, - traverser: true, - turntable: true, - wash: true - }, - traffic_calming: { - island: true - }, - waterway: { - dam: true - } - }; - function osmTagSuggestingArea(tags) { - if (tags.area === "yes") - return { area: "yes" }; - if (tags.area === "no") - return null; - var returnTags = {}; - for (var realKey in tags) { - const key = osmRemoveLifecyclePrefix(realKey); - if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) { - returnTags[realKey] = tags[realKey]; - return returnTags; - } - if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) { - returnTags[realKey] = tags[realKey]; - return returnTags; - } - } - return null; - } - var osmLineTags = {}; - function osmSetLineTags(value) { - osmLineTags = value; - } - var osmPointTags = {}; - function osmSetPointTags(value) { - osmPointTags = value; - } - var osmVertexTags = {}; - function osmSetVertexTags(value) { - osmVertexTags = value; - } - function osmNodeGeometriesForTags(nodeTags) { - var geometries = {}; - for (var key in nodeTags) { - if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) { - geometries.point = true; - } - if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) { - geometries.vertex = true; - } - if (geometries.point && geometries.vertex) - break; - } - return geometries; - } - var osmOneWayTags = { - "aerialway": { - "chair_lift": true, - "drag_lift": true, - "j-bar": true, - "magic_carpet": true, - "mixed_lift": true, - "platter": true, - "rope_tow": true, - "t-bar": true, - "zip_line": true - }, - "highway": { - "motorway": true - }, - "junction": { - "circular": true, - "roundabout": true - }, - "man_made": { - "goods_conveyor": true, - "piste:halfpipe": true - }, - "piste:type": { - "downhill": true, - "sled": true, - "yes": true - }, - "seamark:type": { - "two-way_route": true, - "recommended_traffic_lane": true, - "separation_lane": true, - "separation_roundabout": true - }, - "waterway": { - "canal": true, - "ditch": true, - "drain": true, - "fish_pass": true, - "pressurised": true, - "river": true, - "spillway": true, - "stream": true, - "tidal_channel": true - } - }; - var osmPavedTags = { - "surface": { - "paved": true, - "asphalt": true, - "concrete": true, - "chipseal": true, - "concrete:lanes": true, - "concrete:plates": true - }, - "tracktype": { - "grade1": true - } - }; - var osmSemipavedTags = { - "surface": { - "cobblestone": true, - "cobblestone:flattened": true, - "unhewn_cobblestone": true, - "sett": true, - "paving_stones": true, - "metal": true, - "wood": true - } - }; - var osmRightSideIsInsideTags = { - "natural": { - "cliff": true, - "coastline": "coastline" - }, - "barrier": { - "retaining_wall": true, - "kerb": true, - "guard_rail": true, - "city_wall": true - }, - "man_made": { - "embankment": true, - "quay": true - }, - "waterway": { - "weir": true - } - }; - var osmRoutableHighwayTagValues = { - motorway: true, - trunk: true, - primary: true, - secondary: true, - tertiary: true, - residential: true, - motorway_link: true, - trunk_link: true, - primary_link: true, - secondary_link: true, - tertiary_link: true, - unclassified: true, - road: true, - service: true, - track: true, - living_street: true, - bus_guideway: true, - path: true, - footway: true, - cycleway: true, - bridleway: true, - pedestrian: true, - corridor: true, - steps: true - }; - var osmPathHighwayTagValues = { - path: true, - footway: true, - cycleway: true, - bridleway: true, - pedestrian: true, - corridor: true, - steps: true - }; - var osmRailwayTrackTagValues = { - rail: true, - light_rail: true, - tram: true, - subway: true, - monorail: true, - funicular: true, - miniature: true, - narrow_gauge: true, - disused: true, - preserved: true - }; - var osmFlowingWaterwayTagValues = { - canal: true, - ditch: true, - drain: true, - fish_pass: true, - river: true, - stream: true, - tidal_channel: true - }; - 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/; - // node_modules/d3-array/src/ascending.js function ascending(a2, b2) { return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN; @@ -16654,16 +15761,16 @@ } // node_modules/d3-array/src/bisector.js - function bisector(f3) { + function bisector(f2) { let compare1, compare2, delta; - if (f3.length !== 2) { + if (f2.length !== 2) { compare1 = ascending; - compare2 = (d2, x2) => ascending(f3(d2), x2); - delta = (d2, x2) => f3(d2) - x2; + compare2 = (d2, x2) => ascending(f2(d2), x2); + delta = (d2, x2) => f2(d2) - x2; } else { - compare1 = f3 === ascending || f3 === descending ? f3 : zero; - compare2 = f3; - delta = f3; + compare1 = f2 === ascending || f2 === descending ? f2 : zero; + compare2 = f2; + delta = f2; } function left(a2, x2, lo = 0, hi = a2.length) { if (lo < hi) { @@ -16740,8 +15847,8 @@ add(x2) { const p2 = this._partials; let i3 = 0; - for (let j3 = 0; j3 < this._n && j3 < 32; j3++) { - const y2 = p2[j3], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2); + for (let j2 = 0; j2 < this._n && j2 < 32; j2++) { + const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2); if (lo) p2[i3++] = lo; x2 = hi; @@ -16775,16 +15882,16 @@ }; // node_modules/d3-array/src/sort.js - function compareDefined(compare = ascending) { - if (compare === ascending) + function compareDefined(compare2 = ascending) { + if (compare2 === ascending) return ascendingDefined; - if (typeof compare !== "function") + if (typeof compare2 !== "function") throw new TypeError("compare is not a function"); return (a2, b2) => { - const x2 = compare(a2, b2); + const x2 = compare2(a2, b2); if (x2 || x2 === 0) return x2; - return (compare(b2, b2) === 0) - (compare(a2, a2) === 0); + return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0); }; } function ascendingDefined(a2, b2) { @@ -16884,8 +15991,8 @@ } // node_modules/d3-array/src/quickselect.js - function quickselect(array2, k2, left = 0, right = array2.length - 1, compare) { - compare = compare === void 0 ? ascendingDefined : compareDefined(compare); + function quickselect(array2, k2, left = 0, right = array2.length - 1, compare2) { + compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2); while (right > left) { if (right - left > 600) { const n3 = right - left + 1; @@ -16895,36 +16002,36 @@ const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1); const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd)); const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd)); - quickselect(array2, k2, newLeft, newRight, compare); + quickselect(array2, k2, newLeft, newRight, compare2); } const t2 = array2[k2]; let i3 = left; - let j3 = right; + let j2 = right; swap(array2, left, k2); - if (compare(array2[right], t2) > 0) + if (compare2(array2[right], t2) > 0) swap(array2, left, right); - while (i3 < j3) { - swap(array2, i3, j3), ++i3, --j3; - while (compare(array2[i3], t2) < 0) + while (i3 < j2) { + swap(array2, i3, j2), ++i3, --j2; + while (compare2(array2[i3], t2) < 0) ++i3; - while (compare(array2[j3], t2) > 0) - --j3; + while (compare2(array2[j2], t2) > 0) + --j2; } - if (compare(array2[left], t2) === 0) - swap(array2, left, j3); + if (compare2(array2[left], t2) === 0) + swap(array2, left, j2); else - ++j3, swap(array2, j3, right); - if (j3 <= k2) - left = j3 + 1; - if (k2 <= j3) - right = j3 - 1; + ++j2, swap(array2, j2, right); + if (j2 <= k2) + left = j2 + 1; + if (k2 <= j2) + right = j2 - 1; } return array2; } - function swap(array2, i3, j3) { + function swap(array2, i3, j2) { const t2 = array2[i3]; - array2[i3] = array2[j3]; - array2[j3] = t2; + array2[i3] = array2[j2]; + array2[j2] = t2; } // node_modules/d3-array/src/quantile.js @@ -16948,7 +16055,7 @@ // node_modules/d3-array/src/merge.js function* flatten(arrays) { for (const array2 of arrays) { - yield* __yieldStar(array2); + yield* array2; } } function merge(arrays) { @@ -17547,16 +16654,16 @@ if (!(m2 = (ring = polygon2[i3]).length)) continue; var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02); - for (var j3 = 0; j3 < m2; ++j3, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) { - var point1 = ring[j3], 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; + for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) { + 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; sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta))); angle2 += antimeridian ? delta + sign2 * tau : delta; if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) { var arc = cartesianCross(cartesian(point0), cartesian(point1)); cartesianNormalizeInPlace(arc); - var intersection = cartesianCross(normal, arc); - cartesianNormalizeInPlace(intersection); - var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]); + var intersection2 = cartesianCross(normal, arc); + cartesianNormalizeInPlace(intersection2); + var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]); if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) { winding += antimeridian ^ delta >= 0 ? 1 : -1; } @@ -17972,8 +17079,8 @@ function polygonInside() { var winding = 0; for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) { - for (var ring2 = polygon2[i3], j3 = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b0 = point3[0], b1 = point3[1]; j3 < m2; ++j3) { - a0 = b0, a1 = b1, point3 = ring2[j3], b0 = point3[0], b1 = point3[1]; + for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b0 = point3[0], b1 = point3[1]; j2 < m2; ++j2) { + a0 = b0, a1 = b1, point3 = ring2[j2], b0 = point3[0], b1 = point3[1]; if (a1 <= y12) { if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0)) ++winding; @@ -18318,9 +17425,9 @@ lengthRing = null; }, result: function() { - var length = +lengthSum2; + var length2 = +lengthSum2; lengthSum2 = new Adder(); - return length; + return length2; } }; function lengthPointFirst2(x2, y2) { @@ -18974,6 +18081,15 @@ }, toParam: function() { return this.rectangle().join(","); + }, + split: function() { + const center = this.center(); + return [ + geoExtent(this[0], center), + geoExtent([center[0], this[0][1]], [this[1][0], center[1]]), + geoExtent(center, this[1]), + geoExtent([this[0][0], center[1]], [center[0], this[1][1]]) + ]; } }); @@ -19074,9 +18190,9 @@ return x2 * x2 + y2 * y2; } function geoVecNormalize(a2) { - var length = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]); - if (length !== 0) { - return geoVecScale(a2, 1 / length); + var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]); + if (length2 !== 0) { + return geoVecScale(a2, 1 / length2); } return [0, 0]; } @@ -19190,24 +18306,24 @@ function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) { var actives = []; var inactives = []; - var j3, k2, n1, n22, segment; - for (j3 = 0; j3 < activeNodes.length - 1; j3++) { - n1 = activeNodes[j3]; - n22 = activeNodes[j3 + 1]; + var j2, k2, n1, n22, segment; + for (j2 = 0; j2 < activeNodes.length - 1; j2++) { + n1 = activeNodes[j2]; + n22 = activeNodes[j2 + 1]; segment = [n1.loc, n22.loc]; if (n1.id === activeID || n22.id === activeID) { actives.push(segment); } } - for (j3 = 0; j3 < inactiveNodes.length - 1; j3++) { - n1 = inactiveNodes[j3]; - n22 = inactiveNodes[j3 + 1]; + for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) { + n1 = inactiveNodes[j2]; + n22 = inactiveNodes[j2 + 1]; segment = [n1.loc, n22.loc]; inactives.push(segment); } - for (j3 = 0; j3 < actives.length; j3++) { + for (j2 = 0; j2 < actives.length; j2++) { for (k2 = 0; k2 < inactives.length; k2++) { - var p2 = actives[j3]; + var p2 = actives[j2]; var q2 = inactives[k2]; var hit = geoLineIntersection(p2, q2); if (hit) { @@ -19220,10 +18336,10 @@ function geoHasSelfIntersections(nodes, activeID) { var actives = []; var inactives = []; - var j3, k2; - for (j3 = 0; j3 < nodes.length - 1; j3++) { - var n1 = nodes[j3]; - var n22 = nodes[j3 + 1]; + var j2, k2; + for (j2 = 0; j2 < nodes.length - 1; j2++) { + var n1 = nodes[j2]; + var n22 = nodes[j2 + 1]; var segment = [n1.loc, n22.loc]; if (n1.id === activeID || n22.id === activeID) { actives.push(segment); @@ -19231,9 +18347,9 @@ inactives.push(segment); } } - for (j3 = 0; j3 < actives.length; j3++) { + for (j2 = 0; j2 < actives.length; j2++) { for (k2 = 0; k2 < inactives.length; k2++) { - var p2 = actives[j3]; + var p2 = actives[j2]; var q2 = inactives[k2]; if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) { continue; @@ -19272,9 +18388,9 @@ function geoPathIntersections(path1, path2) { var intersections = []; for (var i3 = 0; i3 < path1.length - 1; i3++) { - for (var j3 = 0; j3 < path2.length - 1; j3++) { + for (var j2 = 0; j2 < path2.length - 1; j2++) { var a2 = [path1[i3], path1[i3 + 1]]; - var b2 = [path2[j3], path2[j3 + 1]]; + var b2 = [path2[j2], path2[j2 + 1]]; var hit = geoLineIntersection(a2, b2); if (hit) { intersections.push(hit); @@ -19285,9 +18401,9 @@ } function geoPathHasIntersections(path1, path2) { for (var i3 = 0; i3 < path1.length - 1; i3++) { - for (var j3 = 0; j3 < path2.length - 1; j3++) { + for (var j2 = 0; j2 < path2.length - 1; j2++) { var a2 = [path1[i3], path1[i3 + 1]]; - var b2 = [path2[j3], path2[j3 + 1]]; + var b2 = [path2[j2], path2[j2 + 1]]; var hit = geoLineIntersection(a2, b2); if (hit) { return true; @@ -19300,11 +18416,11 @@ var x2 = point2[0]; var y2 = point2[1]; var inside = false; - for (var i3 = 0, j3 = polygon2.length - 1; i3 < polygon2.length; j3 = i3++) { + for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) { var xi = polygon2[i3][0]; var yi = polygon2[i3][1]; - var xj = polygon2[j3][0]; - var yj = polygon2[j3][1]; + var xj = polygon2[j2][0]; + var yj = polygon2[j2][1]; var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi; if (intersect2) inside = !inside; @@ -19352,11 +18468,11 @@ }; } function geoPathLength(path) { - var length = 0; + var length2 = 0; for (var i3 = 0; i3 < path.length - 1; i3++) { - length += geoVecLength(path[i3], path[i3 + 1]); + length2 += geoVecLength(path[i3], path[i3 + 1]); } - return length; + return length2; } function geoViewportEdge(point2, dimensions) { var pad2 = [80, 20, 50, 20]; @@ -19516,8 +18632,8 @@ function select_default(select) { if (typeof select !== "function") select = selector_default(select); - for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, subgroup = subgroups[j3] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) { if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) { if ("__data__" in node) subnode.__data__ = node.__data__; @@ -19554,8 +18670,8 @@ select = arrayAll(select); else select = selectorAll_default(select); - for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { if (node = group[i3]) { subgroups.push(select.call(node, node.__data__, i3, group)); parents.push(node); @@ -19609,8 +18725,8 @@ function filter_default(match) { if (typeof match !== "function") match = matcher_default(match); - for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, subgroup = subgroups[j3] = [], node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) { if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) { subgroup.push(node); } @@ -19712,8 +18828,8 @@ var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups; if (typeof value !== "function") value = constant_default(value); - for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j3 = 0; j3 < m2; ++j3) { - var parent = parents[j3], group = groups[j3], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j3, parents)), dataLength = data.length, enterGroup = enter[j3] = new Array(dataLength), updateGroup = update[j3] = new Array(dataLength), exitGroup = exit[j3] = new Array(groupLength); + for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) { + 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); bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { if (previous = enterGroup[i0]) { @@ -19764,23 +18880,23 @@ // node_modules/d3-selection/src/selection/merge.js function merge_default(context) { var selection2 = context.selection ? context.selection() : context; - for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j3 = 0; j3 < m2; ++j3) { - for (var group0 = groups0[j3], group1 = groups1[j3], n3 = group0.length, merge2 = merges[j3] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { + 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) { + for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { if (node = group0[i3] || group1[i3]) { merge2[i3] = node; } } } - for (; j3 < m0; ++j3) { - merges[j3] = groups0[j3]; + for (; j2 < m0; ++j2) { + merges[j2] = groups0[j2]; } return new Selection(merges, this._parents); } // node_modules/d3-selection/src/selection/order.js function order_default() { - for (var groups = this._groups, j3 = -1, m2 = groups.length; ++j3 < m2; ) { - for (var group = groups[j3], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) { + for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) { + for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) { if (node = group[i3]) { if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); @@ -19792,14 +18908,14 @@ } // node_modules/d3-selection/src/selection/sort.js - function sort_default(compare) { - if (!compare) - compare = ascending2; + function sort_default(compare2) { + if (!compare2) + compare2 = ascending2; function compareNode(a2, b2) { - return a2 && b2 ? compare(a2.__data__, b2.__data__) : !a2 - !b2; + return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2; } - for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, sortgroup = sortgroups[j3] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { if (node = group[i3]) { sortgroup[i3] = node; } @@ -19827,8 +18943,8 @@ // node_modules/d3-selection/src/selection/node.js function node_default() { - for (var groups = this._groups, j3 = 0, m2 = groups.length; j3 < m2; ++j3) { - for (var group = groups[j3], i3 = 0, n3 = group.length; i3 < n3; ++i3) { + for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) { + for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) { var node = group[i3]; if (node) return node; @@ -19852,8 +18968,8 @@ // node_modules/d3-selection/src/selection/each.js function each_default(callback) { - for (var groups = this._groups, j3 = 0, m2 = groups.length; j3 < m2; ++j3) { - for (var group = groups[j3], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) { + for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) { + for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) { if (node = group[i3]) callback.call(node, node.__data__, i3, group); } @@ -19996,14 +19112,14 @@ } }; function classedAdd(node, names) { - var list = classList(node), i3 = -1, n3 = names.length; + var list2 = classList(node), i3 = -1, n3 = names.length; while (++i3 < n3) - list.add(names[i3]); + list2.add(names[i3]); } function classedRemove(node, names) { - var list = classList(node), i3 = -1, n3 = names.length; + var list2 = classList(node), i3 = -1, n3 = names.length; while (++i3 < n3) - list.remove(names[i3]); + list2.remove(names[i3]); } function classedTrue(names) { return function() { @@ -20023,9 +19139,9 @@ function classed_default(name, value) { var names = classArray(name + ""); if (arguments.length < 2) { - var list = classList(this.node()), i3 = -1, n3 = names.length; + var list2 = classList(this.node()), i3 = -1, n3 = names.length; while (++i3 < n3) - if (!list.contains(names[i3])) + if (!list2.contains(names[i3])) return false; return true; } @@ -20119,12 +19235,12 @@ // node_modules/d3-selection/src/selection/clone.js function selection_cloneShallow() { - var clone = this.cloneNode(false), parent = this.parentNode; - return parent ? parent.insertBefore(clone, this.nextSibling) : clone; + var clone2 = this.cloneNode(false), parent = this.parentNode; + return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2; } function selection_cloneDeep() { - var clone = this.cloneNode(true), parent = this.parentNode; - return parent ? parent.insertBefore(clone, this.nextSibling) : clone; + var clone2 = this.cloneNode(true), parent = this.parentNode; + return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2; } function clone_default(deep) { return this.select(deep ? selection_cloneDeep : selection_cloneShallow); @@ -20154,8 +19270,8 @@ var on = this.__on; if (!on) return; - for (var j3 = 0, i3 = -1, m2 = on.length, o2; j3 < m2; ++j3) { - if (o2 = on[j3], (!typename.type || o2.type === typename.type) && o2.name === typename.name) { + for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) { + if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) { this.removeEventListener(o2.type, o2.listener, o2.options); } else { on[++i3] = o2; @@ -20171,8 +19287,8 @@ return function() { var on = this.__on, o2, listener = contextListener(value); if (on) - for (var j3 = 0, m2 = on.length; j3 < m2; ++j3) { - if ((o2 = on[j3]).type === typename.type && o2.name === typename.name) { + for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) { + if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) { this.removeEventListener(o2.type, o2.listener, o2.options); this.addEventListener(o2.type, o2.listener = listener, o2.options = options2); o2.value = value; @@ -20192,8 +19308,8 @@ if (arguments.length < 2) { var on = this.node().__on; if (on) - for (var j3 = 0, m2 = on.length, o2; j3 < m2; ++j3) { - for (i3 = 0, o2 = on[j3]; i3 < n3; ++i3) { + for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) { + for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) { if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) { return o2.value; } @@ -20237,8 +19353,8 @@ // node_modules/d3-selection/src/selection/iterator.js function* iterator_default() { - for (var groups = this._groups, j3 = 0, m2 = groups.length; j3 < m2; ++j3) { - for (var group = groups[j3], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) { + for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) { + for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) { if (node = group[i3]) yield node; } @@ -21142,7 +20258,7 @@ scaleX: 1, scaleY: 1 }; - function decompose_default(a2, b2, c2, d2, e3, f3) { + function decompose_default(a2, b2, c2, d2, e3, f2) { var scaleX, scaleY, skewX; if (scaleX = Math.sqrt(a2 * a2 + b2 * b2)) a2 /= scaleX, b2 /= scaleX; @@ -21154,7 +20270,7 @@ a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX; return { translateX: e3, - translateY: f3, + translateY: f2, rotate: Math.atan2(b2, a2) * degrees2, skewX: Math.atan(skewX) * degrees2, scaleX, @@ -21302,8 +20418,8 @@ var clockNow = 0; var clockSkew = 0; var clock = typeof performance === "object" && performance.now ? performance : Date; - var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f3) { - setTimeout(f3, 17); + var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) { + setTimeout(f2, 17); }; function now() { return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); @@ -21476,7 +20592,7 @@ start2(elapsed - self2.delay); } function start2(elapsed) { - var i3, j3, n3, o2; + var i3, j2, n3, o2; if (self2.state !== SCHEDULED) return stop(); for (i3 in schedules) { @@ -21510,12 +20626,12 @@ return; self2.state = STARTED; tween = new Array(n3 = self2.tween.length); - for (i3 = 0, j3 = -1; i3 < n3; ++i3) { + for (i3 = 0, j2 = -1; i3 < n3; ++i3) { if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) { - tween[++j3] = o2; + tween[++j2] = o2; } } - tween.length = j3 + 1; + tween.length = j2 + 1; } function tick(elapsed) { 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; @@ -21795,8 +20911,8 @@ function filter_default2(match) { if (typeof match !== "function") match = matcher_default(match); - for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, subgroup = subgroups[j3] = [], node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) { if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) { subgroup.push(node); } @@ -21809,15 +20925,15 @@ function merge_default2(transition2) { if (transition2._id !== this._id) throw new Error(); - for (var groups0 = this._groups, groups1 = transition2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j3 = 0; j3 < m2; ++j3) { - for (var group0 = groups0[j3], group1 = groups1[j3], n3 = group0.length, merge2 = merges[j3] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { + 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) { + for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) { if (node = group0[i3] || group1[i3]) { merge2[i3] = node; } } } - for (; j3 < m0; ++j3) { - merges[j3] = groups0[j3]; + for (; j2 < m0; ++j2) { + merges[j2] = groups0[j2]; } return new Transition(merges, this._parents, this._name, this._id); } @@ -21865,8 +20981,8 @@ var name = this._name, id2 = this._id; if (typeof select !== "function") select = selector_default(select); - for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, subgroup = subgroups[j3] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) { if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) { if ("__data__" in node) subnode.__data__ = node.__data__; @@ -21883,8 +20999,8 @@ var name = this._name, id2 = this._id; if (typeof select !== "function") select = selectorAll_default(select); - for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { if (node = group[i3]) { for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) { if (child = children2[k2]) { @@ -22023,8 +21139,8 @@ // node_modules/d3-transition/src/transition/transition.js function transition_default() { var name = this._name, id0 = this._id, id1 = newId(); - for (var groups = this._groups, m2 = groups.length, j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { if (node = group[i3]) { var inherit2 = get2(node, id0); schedule_default(node, name, id1, i3, group, { @@ -22142,8 +21258,8 @@ } else { id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + ""; } - for (var groups = this._groups, m2 = groups.length, j3 = 0; j3 < m2; ++j3) { - for (var group = groups[j3], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { + for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) { + for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) { if (node = group[i3]) { schedule_default(node, name, id2, i3, group, timing || inherit(node, id2)); } @@ -22709,6 +21825,280 @@ return score; } + // modules/osm/tags.js + function osmIsInterestingTag(key) { + return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon + key.indexOf("tiger:") !== 0; + } + var osmLifecyclePrefixes = { + // nonexistent, might be built + proposed: true, + planned: true, + // under maintentance or between groundbreaking and opening + construction: true, + // existent but not functional + disused: true, + // dilapidated to nonexistent + abandoned: true, + was: true, + // nonexistent, still may appear in imagery + dismantled: true, + razed: true, + demolished: true, + destroyed: true, + removed: true, + obliterated: true, + // existent occasionally, e.g. stormwater drainage basin + intermittent: true + }; + function osmRemoveLifecyclePrefix(key) { + const keySegments = key.split(":"); + if (keySegments.length === 1) + return key; + if (keySegments[0] in osmLifecyclePrefixes) { + return key.slice(keySegments[0].length + 1); + } + return key; + } + var osmAreaKeys = {}; + function osmSetAreaKeys(value) { + osmAreaKeys = value; + } + var osmAreaKeysExceptions = { + highway: { + elevator: true, + rest_area: true, + services: true + }, + public_transport: { + platform: true + }, + railway: { + platform: true, + roundhouse: true, + station: true, + traverser: true, + turntable: true, + wash: true + }, + waterway: { + dam: true + }, + amenity: { + bicycle_parking: true + } + }; + function osmTagSuggestingArea(tags) { + if (tags.area === "yes") + return { area: "yes" }; + if (tags.area === "no") + return null; + var returnTags = {}; + for (var realKey in tags) { + const key = osmRemoveLifecyclePrefix(realKey); + if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) { + returnTags[realKey] = tags[realKey]; + return returnTags; + } + if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) { + returnTags[realKey] = tags[realKey]; + return returnTags; + } + } + return null; + } + var osmLineTags = {}; + function osmSetLineTags(value) { + osmLineTags = value; + } + var osmPointTags = {}; + function osmSetPointTags(value) { + osmPointTags = value; + } + var osmVertexTags = {}; + function osmSetVertexTags(value) { + osmVertexTags = value; + } + function osmNodeGeometriesForTags(nodeTags) { + var geometries = {}; + for (var key in nodeTags) { + if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) { + geometries.point = true; + } + if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) { + geometries.vertex = true; + } + if (geometries.point && geometries.vertex) + break; + } + return geometries; + } + var osmOneWayTags = { + "aerialway": { + "chair_lift": true, + "drag_lift": true, + "j-bar": true, + "magic_carpet": true, + "mixed_lift": true, + "platter": true, + "rope_tow": true, + "t-bar": true, + "zip_line": true + }, + "highway": { + "motorway": true + }, + "junction": { + "circular": true, + "roundabout": true + }, + "man_made": { + "goods_conveyor": true, + "piste:halfpipe": true + }, + "piste:type": { + "downhill": true, + "sled": true, + "yes": true + }, + "seamark:type": { + "two-way_route": true, + "recommended_traffic_lane": true, + "separation_lane": true, + "separation_roundabout": true + }, + "waterway": { + "canal": true, + "ditch": true, + "drain": true, + "fish_pass": true, + "pressurised": true, + "river": true, + "spillway": true, + "stream": true, + "tidal_channel": true + } + }; + var osmPavedTags = { + "surface": { + "paved": true, + "asphalt": true, + "concrete": true, + "chipseal": true, + "concrete:lanes": true, + "concrete:plates": true + }, + "tracktype": { + "grade1": true + } + }; + var osmSemipavedTags = { + "surface": { + "cobblestone": true, + "cobblestone:flattened": true, + "unhewn_cobblestone": true, + "sett": true, + "paving_stones": true, + "metal": true, + "wood": true + } + }; + var osmRightSideIsInsideTags = { + "natural": { + "cliff": true, + "coastline": "coastline" + }, + "barrier": { + "retaining_wall": true, + "kerb": true, + "guard_rail": true, + "city_wall": true + }, + "man_made": { + "embankment": true, + "quay": true + }, + "waterway": { + "weir": true + } + }; + var osmRoutableHighwayTagValues = { + motorway: true, + trunk: true, + primary: true, + secondary: true, + tertiary: true, + residential: true, + motorway_link: true, + trunk_link: true, + primary_link: true, + secondary_link: true, + tertiary_link: true, + unclassified: true, + road: true, + service: true, + track: true, + living_street: true, + bus_guideway: true, + busway: true, + path: true, + footway: true, + cycleway: true, + bridleway: true, + pedestrian: true, + corridor: true, + steps: true + }; + var osmPathHighwayTagValues = { + path: true, + footway: true, + cycleway: true, + bridleway: true, + pedestrian: true, + corridor: true, + steps: true + }; + var osmRailwayTrackTagValues = { + rail: true, + light_rail: true, + tram: true, + subway: true, + monorail: true, + funicular: true, + miniature: true, + narrow_gauge: true, + disused: true, + preserved: true + }; + var osmFlowingWaterwayTagValues = { + canal: true, + ditch: true, + drain: true, + fish_pass: true, + river: true, + stream: true, + tidal_channel: true + }; + 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/; + function isColourValid(value) { + if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) { + return false; + } + if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) { + return false; + } + return true; + } + var osmMutuallyExclusiveTagPairs = [ + ["noname", "name"], + ["noref", "ref"], + ["nohousenumber", "addr:housenumber"], + ["noaddress", "addr:housenumber"], + ["noaddress", "addr:housename"], + ["noaddress", "addr:unit"], + ["addr:nostreet", "addr:street"] + ]; + // modules/util/array.js function utilArrayIdentical(a2, b2) { if (a2 === b2) @@ -22822,9 +22212,9 @@ var _storage; try { _storage = localStorage; - } catch (e3) { + } catch { } - _storage = _storage || (() => { + _storage = _storage || /* @__PURE__ */ (() => { let s2 = {}; return { getItem: (k2) => s2[k2], @@ -22845,7 +22235,7 @@ _listeners[k2].forEach((handler) => handler(v2)); } return true; - } catch (e3) { + } catch { if (typeof console !== "undefined") { console.error("localStorage quota exceeded"); } @@ -22882,6 +22272,7 @@ if (false) { osmApiConnections.push({ url: null, + apiUrl: ENV__ID_API_CONNECTION_API_URL, client_id: null, client_secret: null }); @@ -22893,11 +22284,12 @@ } var taginfoApiUrl = "https://taginfo.openstreetmap.org/api/4/"; var nominatimApiUrl = "https://nominatim.openstreetmap.org/"; + var showDonationMessage = true; // package.json var package_default = { name: "iD", - version: "2.27.3", + version: "2.29.0", description: "A friendly editor for OpenStreetMap", main: "dist/iD.min.js", repository: "github:openstreetmap/iD", @@ -22925,13 +22317,13 @@ "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', "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg", "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', - "dist:svg:mapillary:signs": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-sprite.svg node_modules/mapillary_sprite_source/package_signs/*.svg", - "dist:svg:mapillary:objects": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-object-sprite.svg node_modules/mapillary_sprite_source/package_objects/*.svg", + "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", + "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", "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', "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', imagery: "node scripts/update_imagery.js", - lint: "eslint config scripts test/spec modules --ext js,mjs", - "lint:fix": "eslint scripts test/spec modules --fix", + lint: "eslint config scripts test/spec modules -c config/eslint.config.mjs", + "lint:fix": "eslint scripts test/spec modules -c config/eslint.config.mjs --fix", start: "run-s start:watch", "start:single-build": "run-p build:js start:server", "start:watch": "run-p build:js:watch start:server", @@ -22944,72 +22336,72 @@ "@mapbox/geojson-area": "^0.2.2", "@mapbox/sexagesimal": "1.2.0", "@mapbox/vector-tile": "^1.3.1", - "@rapideditor/country-coder": "~5.2.0", - "@rapideditor/location-conflation": "~1.2.1", + "@rapideditor/country-coder": "~5.2.2", + "@rapideditor/location-conflation": "~1.3.0", "@tmcw/togeojson": "^5.8.1", "@turf/bbox": "^6.0.0", "@turf/bbox-clip": "^6.0.0", "abortcontroller-polyfill": "^1.7.5", "aes-js": "^3.1.2", "alif-toolkit": "^1.2.9", - "core-js-bundle": "^3.33.2", + "core-js-bundle": "^3.37.0", diacritics: "1.3.0", exifr: "^7.1.3", "fast-deep-equal": "~3.1.1", "fast-json-stable-stringify": "2.1.0", "lodash-es": "~4.17.15", - marked: "~7.0.3", + marked: "~12.0.2", "node-diff3": "~3.1.0", - "osm-auth": "~2.2.0", + "osm-auth": "~2.4.0", pannellum: "2.5.6", pbf: "^3.2.1", - "polygon-clipping": "~0.15.1", + "polygon-clipping": "~0.15.7", rbush: "3.0.1", - "whatwg-fetch": "^3.6.17", + "whatwg-fetch": "^3.6.20", "which-polygon": "2.2.1" }, devDependencies: { - "@fortawesome/fontawesome-svg-core": "~6.4.2", - "@fortawesome/free-brands-svg-icons": "~6.4.2", - "@fortawesome/free-regular-svg-icons": "~6.4.2", - "@fortawesome/free-solid-svg-icons": "~6.4.2", + "@fortawesome/fontawesome-svg-core": "~6.5.2", + "@fortawesome/free-brands-svg-icons": "~6.5.2", + "@fortawesome/free-regular-svg-icons": "~6.5.2", + "@fortawesome/free-solid-svg-icons": "~6.5.2", "@mapbox/maki": "^8.0.1", - "@openstreetmap/id-tagging-schema": "^6.4.1", - "@rapideditor/temaki": "^5.6.0", - "@transifex/api": "^5.4.0", - autoprefixer: "^10.4.15", - "browserslist-to-esbuild": "^1.2.0", - chai: "^4.3.10", + "@openstreetmap/id-tagging-schema": "^6.7.3", + "@rapideditor/mapillary_sprite_source": "^1.8.0", + "@rapideditor/temaki": "^5.8.0", + "@transifex/api": "^7.1.0", + autoprefixer: "^10.4.19", + browserslist: "^4.23.0", + "browserslist-to-esbuild": "^2.1.1", + chai: "^4.4.1", chalk: "^4.1.2", - "cldr-core": "^43.0.0", - "cldr-localenames-full": "^43.1.0", + "cldr-core": "^45.0.0", + "cldr-localenames-full": "^45.0.0", "concat-files": "^0.1.1", - d3: "~7.8.5", - dotenv: "^16.3.1", + d3: "~7.9.0", + dotenv: "^16.4.5", "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages", - esbuild: "^0.19.2", - "esbuild-visualizer": "^0.4.1", - eslint: "^8.47.0", + esbuild: "^0.20.2", + "esbuild-visualizer": "^0.6.0", + eslint: "^9.1.1", "fetch-mock": "^9.11.0", gaze: "^1.1.3", - glob: "^10.3.3", + glob: "^10.3.12", happen: "^0.3.2", "js-yaml": "^4.0.0", "json-stringify-pretty-compact": "^3.0.0", - karma: "^6.4.2", + karma: "^6.4.3", "karma-chrome-launcher": "^3.2.0", "karma-coverage": "2.1.1", "karma-mocha": "^2.0.1", "karma-remap-istanbul": "^0.6.0", - mapillary_sprite_source: "^1.8.0", - "mapillary-js": "4.1.1", + "mapillary-js": "4.1.2", minimist: "^1.2.8", - mocha: "^10.2.0", + mocha: "^10.4.0", "name-suggestion-index": "~6.0", - "node-fetch": "^2.7.0", "npm-run-all": "^4.0.0", - "osm-community-index": "~5.6.0", - postcss: "^8.4.31", + "osm-community-index": "~5.6.2", + postcss: "^8.4.38", "postcss-selector-prepend": "^0.5.0", shelljs: "^0.8.0", shx: "^0.3.0", @@ -23017,14 +22409,14 @@ "sinon-chai": "^3.7.0", smash: "0.0", "static-server": "^2.2.1", - "svg-sprite": "2.0.2", + "svg-sprite": "2.0.4", vparse: "~1.1.0" }, engines: { - node: ">=16.14" + node: ">=18" }, browserslist: [ - "> 0.3%, last 6 major versions, Firefox ESR, maintained node versions" + "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions" ] }; @@ -23538,431 +22930,3626 @@ if (s2.charAt(0) === ".") { return s2.toUpperCase(); } else { - return s2.replace(idFilterRegex, "").toUpperCase(); + return s2.replace(idFilterRegex, "").toUpperCase(); + } + } + var levels = [ + "subterritory", + "territory", + "subcountryGroup", + "country", + "sharedLandform", + "intermediateRegion", + "subregion", + "region", + "subunion", + "union", + "unitedNations", + "world" + ]; + loadDerivedDataAndCaches(borders); + function loadDerivedDataAndCaches(borders2) { + const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"]; + let geometryFeatures = []; + for (const feature22 of borders2.features) { + const props = feature22.properties; + props.id = props.iso1A2 || props.m49 || props.wikidata; + loadM49(feature22); + loadTLD(feature22); + loadIsoStatus(feature22); + loadLevel(feature22); + loadGroups(feature22); + loadFlag(feature22); + cacheFeatureByIDs(feature22); + if (feature22.geometry) { + geometryFeatures.push(feature22); + } + } + for (const feature22 of borders2.features) { + feature22.properties.groups = feature22.properties.groups.map((groupID) => { + return _featuresByCode[groupID].properties.id; + }); + loadMembersForGroupsOf(feature22); + } + for (const feature22 of borders2.features) { + loadRoadSpeedUnit(feature22); + loadRoadHeightUnit(feature22); + loadDriveSide(feature22); + loadCallingCodes(feature22); + loadGroupGroups(feature22); + } + for (const feature22 of borders2.features) { + feature22.properties.groups.sort((groupID1, groupID2) => { + return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level); + }); + if (feature22.properties.members) { + feature22.properties.members.sort((id1, id2) => { + const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level); + if (diff === 0) { + return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]); + } + return diff; + }); + } + } + const geometryOnlyCollection = { + type: "FeatureCollection", + features: geometryFeatures + }; + _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection); + function loadGroups(feature22) { + const props = feature22.properties; + if (!props.groups) { + props.groups = []; + } + if (feature22.geometry && props.country) { + props.groups.push(props.country); + } + if (props.m49 !== "001") { + props.groups.push("001"); + } + } + function loadM49(feature22) { + const props = feature22.properties; + if (!props.m49 && props.iso1N3) { + props.m49 = props.iso1N3; + } + } + function loadTLD(feature22) { + const props = feature22.properties; + if (props.level === "unitedNations") + return; + if (!props.ccTLD && props.iso1A2) { + props.ccTLD = "." + props.iso1A2.toLowerCase(); + } + } + function loadIsoStatus(feature22) { + const props = feature22.properties; + if (!props.isoStatus && props.iso1A2) { + props.isoStatus = "official"; + } + } + function loadLevel(feature22) { + const props = feature22.properties; + if (props.level) + return; + if (!props.country) { + props.level = "country"; + } else if (!props.iso1A2 || props.isoStatus === "official") { + props.level = "territory"; + } else { + props.level = "subterritory"; + } + } + function loadGroupGroups(feature22) { + const props = feature22.properties; + if (feature22.geometry || !props.members) + return; + const featureLevelIndex = levels.indexOf(props.level); + let sharedGroups = []; + props.members.forEach((memberID, index) => { + const member = _featuresByCode[memberID]; + const memberGroups = member.properties.groups.filter((groupID) => { + return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level); + }); + if (index === 0) { + sharedGroups = memberGroups; + } else { + sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1); + } + }); + props.groups = props.groups.concat( + sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1) + ); + for (const groupID of sharedGroups) { + const groupFeature = _featuresByCode[groupID]; + if (groupFeature.properties.members.indexOf(props.id) === -1) { + groupFeature.properties.members.push(props.id); + } + } + } + function loadRoadSpeedUnit(feature22) { + const props = feature22.properties; + if (feature22.geometry) { + if (!props.roadSpeedUnit) + props.roadSpeedUnit = "km/h"; + } else if (props.members) { + const vals = Array.from( + new Set( + props.members.map((id2) => { + const member = _featuresByCode[id2]; + if (member.geometry) + return member.properties.roadSpeedUnit || "km/h"; + }).filter(Boolean) + ) + ); + if (vals.length === 1) + props.roadSpeedUnit = vals[0]; + } + } + function loadRoadHeightUnit(feature22) { + const props = feature22.properties; + if (feature22.geometry) { + if (!props.roadHeightUnit) + props.roadHeightUnit = "m"; + } else if (props.members) { + const vals = Array.from( + new Set( + props.members.map((id2) => { + const member = _featuresByCode[id2]; + if (member.geometry) + return member.properties.roadHeightUnit || "m"; + }).filter(Boolean) + ) + ); + if (vals.length === 1) + props.roadHeightUnit = vals[0]; + } + } + function loadDriveSide(feature22) { + const props = feature22.properties; + if (feature22.geometry) { + if (!props.driveSide) + props.driveSide = "right"; + } else if (props.members) { + const vals = Array.from( + new Set( + props.members.map((id2) => { + const member = _featuresByCode[id2]; + if (member.geometry) + return member.properties.driveSide || "right"; + }).filter(Boolean) + ) + ); + if (vals.length === 1) + props.driveSide = vals[0]; + } + } + function loadCallingCodes(feature22) { + const props = feature22.properties; + if (!feature22.geometry && props.members) { + props.callingCodes = Array.from( + new Set( + props.members.reduce((array2, id2) => { + const member = _featuresByCode[id2]; + if (member.geometry && member.properties.callingCodes) { + return array2.concat(member.properties.callingCodes); + } + return array2; + }, []) + ) + ); + } + } + function loadFlag(feature22) { + if (!feature22.properties.iso1A2) + return; + const flag = feature22.properties.iso1A2.replace(/./g, function(char) { + return String.fromCodePoint(char.charCodeAt(0) + 127397); + }); + feature22.properties.emojiFlag = flag; + } + function loadMembersForGroupsOf(feature22) { + for (const groupID of feature22.properties.groups) { + const groupFeature = _featuresByCode[groupID]; + if (!groupFeature.properties.members) { + groupFeature.properties.members = []; + } + groupFeature.properties.members.push(feature22.properties.id); + } + } + function cacheFeatureByIDs(feature22) { + let ids = []; + for (const prop of identifierProps) { + const id2 = feature22.properties[prop]; + if (id2) { + ids.push(id2); + } + } + for (const alias of feature22.properties.aliases || []) { + ids.push(alias); + } + for (const id2 of ids) { + const cid = canonicalID(id2); + _featuresByCode[cid] = feature22; + } + } + } + function locArray(loc) { + if (Array.isArray(loc)) { + return loc; + } else if (loc.coordinates) { + return loc.coordinates; + } + return loc.geometry.coordinates; + } + function smallestFeature(loc) { + const query = locArray(loc); + const featureProperties = _whichPolygon(query); + if (!featureProperties) + return null; + return _featuresByCode[featureProperties.id]; + } + function countryFeature(loc) { + const feature22 = smallestFeature(loc); + if (!feature22) + return null; + const countryCode = feature22.properties.country || feature22.properties.iso1A2; + return _featuresByCode[countryCode] || null; + } + var defaultOpts = { + level: void 0, + maxLevel: void 0, + withProp: void 0 + }; + function featureForLoc(loc, opts) { + const targetLevel = opts.level || "country"; + const maxLevel = opts.maxLevel || "world"; + const withProp = opts.withProp; + const targetLevelIndex = levels.indexOf(targetLevel); + if (targetLevelIndex === -1) + return null; + const maxLevelIndex = levels.indexOf(maxLevel); + if (maxLevelIndex === -1) + return null; + if (maxLevelIndex < targetLevelIndex) + return null; + if (targetLevel === "country") { + const fastFeature = countryFeature(loc); + if (fastFeature) { + if (!withProp || fastFeature.properties[withProp]) { + return fastFeature; + } + } + } + const features = featuresContaining(loc); + const match = features.find((feature22) => { + let levelIndex = levels.indexOf(feature22.properties.level); + if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up + levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) { + if (!withProp || feature22.properties[withProp]) { + return feature22; + } + } + return false; + }); + return match || null; + } + function featureForID(id2) { + let stringID; + if (typeof id2 === "number") { + stringID = id2.toString(); + if (stringID.length === 1) { + stringID = "00" + stringID; + } else if (stringID.length === 2) { + stringID = "0" + stringID; + } + } else { + stringID = canonicalID(id2); + } + return _featuresByCode[stringID] || null; + } + function smallestFeaturesForBbox(bbox2) { + return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]); + } + function smallestOrMatchingFeature(query) { + if (typeof query === "object") { + return smallestFeature(query); + } + return featureForID(query); + } + function feature(query, opts = defaultOpts) { + if (typeof query === "object") { + return featureForLoc(query, opts); + } + return featureForID(query); + } + function iso1A2Code(query, opts = defaultOpts) { + opts.withProp = "iso1A2"; + const match = feature(query, opts); + if (!match) + return null; + return match.properties.iso1A2 || null; + } + function propertiesForQuery(query, property) { + const features = featuresContaining(query, false); + return features.map((feature22) => feature22.properties[property]).filter(Boolean); + } + function iso1A2Codes(query) { + return propertiesForQuery(query, "iso1A2"); + } + function featuresContaining(query, strict) { + let matchingFeatures; + if (Array.isArray(query) && query.length === 4) { + matchingFeatures = smallestFeaturesForBbox(query); + } else { + const smallestOrMatching = smallestOrMatchingFeature(query); + matchingFeatures = smallestOrMatching ? [smallestOrMatching] : []; + } + if (!matchingFeatures.length) + return []; + let returnFeatures; + if (!strict || typeof query === "object") { + returnFeatures = matchingFeatures.slice(); + } else { + returnFeatures = []; + } + for (const feature22 of matchingFeatures) { + const properties = feature22.properties; + for (const groupID of properties.groups) { + const groupFeature = _featuresByCode[groupID]; + if (returnFeatures.indexOf(groupFeature) === -1) { + returnFeatures.push(groupFeature); + } + } } + return returnFeatures; } - var levels = [ - "subterritory", - "territory", - "subcountryGroup", - "country", - "sharedLandform", - "intermediateRegion", - "subregion", - "region", - "subunion", - "union", - "unitedNations", - "world" - ]; - loadDerivedDataAndCaches(borders); - function loadDerivedDataAndCaches(borders2) { - const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"]; - let geometryFeatures = []; - for (const feature22 of borders2.features) { - const props = feature22.properties; - props.id = props.iso1A2 || props.m49 || props.wikidata; - loadM49(feature22); - loadTLD(feature22); - loadIsoStatus(feature22); - loadLevel(feature22); - loadGroups(feature22); - loadFlag(feature22); - cacheFeatureByIDs(feature22); - if (feature22.geometry) { - geometryFeatures.push(feature22); + function featuresIn(id2, strict) { + const feature22 = featureForID(id2); + if (!feature22) + return []; + let features = []; + if (!strict) { + features.push(feature22); + } + const properties = feature22.properties; + for (const memberID of properties.members || []) { + features.push(_featuresByCode[memberID]); + } + return features; + } + function aggregateFeature(id2) { + var _a2; + const features = featuresIn(id2, false); + if (features.length === 0) + return null; + let aggregateCoordinates = []; + for (const feature22 of features) { + if (((_a2 = feature22.geometry) == null ? void 0 : _a2.type) === "MultiPolygon" && feature22.geometry.coordinates) { + aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates); } } - for (const feature22 of borders2.features) { - feature22.properties.groups = feature22.properties.groups.map((groupID) => { - return _featuresByCode[groupID].properties.id; - }); - loadMembersForGroupsOf(feature22); + return { + type: "Feature", + properties: features[0].properties, + geometry: { + type: "MultiPolygon", + coordinates: aggregateCoordinates + } + }; + } + function roadSpeedUnit(query) { + const feature22 = smallestOrMatchingFeature(query); + return feature22 && feature22.properties.roadSpeedUnit || null; + } + function roadHeightUnit(query) { + const feature22 = smallestOrMatchingFeature(query); + return feature22 && feature22.properties.roadHeightUnit || null; + } + + // node_modules/polyclip-ts/dist/constant.js + var constant_default5 = (x2) => { + return () => { + return x2; + }; + }; + + // node_modules/polyclip-ts/dist/compare.js + var compare_default = (eps) => { + const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default5(false); + return (a2, b2) => { + if (almostEqual(a2, b2)) + return 0; + return a2.comparedTo(b2); + }; + }; + + // node_modules/polyclip-ts/dist/orient.js + function orient_default(eps) { + const almostCollinear = eps ? (area2, ax, ay, cx, cy) => area2.exponentiatedBy(2).isLessThanOrEqualTo(cx.minus(ax).exponentiatedBy(2).plus(cy.minus(ay).exponentiatedBy(2)).times(eps)) : constant_default5(false); + return (a2, b2, c2) => { + const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y; + const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy))); + if (almostCollinear(area2, ax, ay, cx, cy)) + return 0; + return area2.comparedTo(0); + }; + } + + // node_modules/bignumber.js/bignumber.mjs + var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i; + var mathceil = Math.ceil; + var mathfloor = Math.floor; + var bignumberError = "[BigNumber Error] "; + var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: "; + var BASE = 1e14; + var LOG_BASE = 14; + var MAX_SAFE_INTEGER = 9007199254740991; + var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13]; + var SQRT_BASE = 1e7; + var MAX = 1e9; + function clone(configObject) { + 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 = { + prefix: "", + groupSize: 3, + secondaryGroupSize: 0, + groupSeparator: ",", + decimalSeparator: ".", + fractionGroupSize: 0, + fractionGroupSeparator: "\xA0", + // non-breaking space + suffix: "" + }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true; + function BigNumber2(v2, b2) { + var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this; + if (!(x2 instanceof BigNumber2)) + return new BigNumber2(v2, b2); + if (b2 == null) { + if (v2 && v2._isBigNumber === true) { + x2.s = v2.s; + if (!v2.c || v2.e > MAX_EXP) { + x2.c = x2.e = null; + } else if (v2.e < MIN_EXP) { + x2.c = [x2.e = 0]; + } else { + x2.e = v2.e; + x2.c = v2.c.slice(); + } + return; + } + if ((isNum = typeof v2 == "number") && v2 * 0 == 0) { + x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1; + if (v2 === ~~v2) { + for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++) + ; + if (e3 > MAX_EXP) { + x2.c = x2.e = null; + } else { + x2.e = e3; + x2.c = [v2]; + } + return; + } + str = String(v2); + } else { + if (!isNumeric.test(str = String(v2))) + return parseNumeric2(x2, str, isNum); + x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; + } + if ((e3 = str.indexOf(".")) > -1) + str = str.replace(".", ""); + if ((i3 = str.search(/e/i)) > 0) { + if (e3 < 0) + e3 = i3; + e3 += +str.slice(i3 + 1); + str = str.substring(0, i3); + } else if (e3 < 0) { + e3 = str.length; + } + } else { + intCheck(b2, 2, ALPHABET.length, "Base"); + if (b2 == 10 && alphabetHasNormalDecimalDigits) { + x2 = new BigNumber2(v2); + return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE); + } + str = String(v2); + if (isNum = typeof v2 == "number") { + if (v2 * 0 != 0) + return parseNumeric2(x2, str, isNum, b2); + x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1; + if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) { + throw Error(tooManyDigits + v2); + } + } else { + x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; + } + alphabet = ALPHABET.slice(0, b2); + e3 = i3 = 0; + for (len = str.length; i3 < len; i3++) { + if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) { + if (c2 == ".") { + if (i3 > e3) { + e3 = len; + continue; + } + } else if (!caseChanged) { + if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) { + caseChanged = true; + i3 = -1; + e3 = 0; + continue; + } + } + return parseNumeric2(x2, String(v2), isNum, b2); + } + } + isNum = false; + str = convertBase(str, b2, 10, x2.s); + if ((e3 = str.indexOf(".")) > -1) + str = str.replace(".", ""); + else + e3 = str.length; + } + for (i3 = 0; str.charCodeAt(i3) === 48; i3++) + ; + for (len = str.length; str.charCodeAt(--len) === 48; ) + ; + if (str = str.slice(i3, ++len)) { + len -= i3; + if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER || v2 !== mathfloor(v2))) { + throw Error(tooManyDigits + x2.s * v2); + } + if ((e3 = e3 - i3 - 1) > MAX_EXP) { + x2.c = x2.e = null; + } else if (e3 < MIN_EXP) { + x2.c = [x2.e = 0]; + } else { + x2.e = e3; + x2.c = []; + i3 = (e3 + 1) % LOG_BASE; + if (e3 < 0) + i3 += LOG_BASE; + if (i3 < len) { + if (i3) + x2.c.push(+str.slice(0, i3)); + for (len -= LOG_BASE; i3 < len; ) { + x2.c.push(+str.slice(i3, i3 += LOG_BASE)); + } + i3 = LOG_BASE - (str = str.slice(i3)).length; + } else { + i3 -= len; + } + for (; i3--; str += "0") + ; + x2.c.push(+str); + } + } else { + x2.c = [x2.e = 0]; + } + } + BigNumber2.clone = clone; + BigNumber2.ROUND_UP = 0; + BigNumber2.ROUND_DOWN = 1; + BigNumber2.ROUND_CEIL = 2; + BigNumber2.ROUND_FLOOR = 3; + BigNumber2.ROUND_HALF_UP = 4; + BigNumber2.ROUND_HALF_DOWN = 5; + BigNumber2.ROUND_HALF_EVEN = 6; + BigNumber2.ROUND_HALF_CEIL = 7; + BigNumber2.ROUND_HALF_FLOOR = 8; + BigNumber2.EUCLID = 9; + BigNumber2.config = BigNumber2.set = function(obj) { + var p2, v2; + if (obj != null) { + if (typeof obj == "object") { + if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) { + v2 = obj[p2]; + intCheck(v2, 0, MAX, p2); + DECIMAL_PLACES = v2; + } + if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) { + v2 = obj[p2]; + intCheck(v2, 0, 8, p2); + ROUNDING_MODE = v2; + } + if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) { + v2 = obj[p2]; + if (v2 && v2.pop) { + intCheck(v2[0], -MAX, 0, p2); + intCheck(v2[1], 0, MAX, p2); + TO_EXP_NEG = v2[0]; + TO_EXP_POS = v2[1]; + } else { + intCheck(v2, -MAX, MAX, p2); + TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2); + } + } + if (obj.hasOwnProperty(p2 = "RANGE")) { + v2 = obj[p2]; + if (v2 && v2.pop) { + intCheck(v2[0], -MAX, -1, p2); + intCheck(v2[1], 1, MAX, p2); + MIN_EXP = v2[0]; + MAX_EXP = v2[1]; + } else { + intCheck(v2, -MAX, MAX, p2); + if (v2) { + MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2); + } else { + throw Error(bignumberError + p2 + " cannot be zero: " + v2); + } + } + } + if (obj.hasOwnProperty(p2 = "CRYPTO")) { + v2 = obj[p2]; + if (v2 === !!v2) { + if (v2) { + if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) { + CRYPTO = v2; + } else { + CRYPTO = !v2; + throw Error(bignumberError + "crypto unavailable"); + } + } else { + CRYPTO = v2; + } + } else { + throw Error(bignumberError + p2 + " not true or false: " + v2); + } + } + if (obj.hasOwnProperty(p2 = "MODULO_MODE")) { + v2 = obj[p2]; + intCheck(v2, 0, 9, p2); + MODULO_MODE = v2; + } + if (obj.hasOwnProperty(p2 = "POW_PRECISION")) { + v2 = obj[p2]; + intCheck(v2, 0, MAX, p2); + POW_PRECISION = v2; + } + if (obj.hasOwnProperty(p2 = "FORMAT")) { + v2 = obj[p2]; + if (typeof v2 == "object") + FORMAT = v2; + else + throw Error(bignumberError + p2 + " not an object: " + v2); + } + if (obj.hasOwnProperty(p2 = "ALPHABET")) { + v2 = obj[p2]; + if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) { + alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789"; + ALPHABET = v2; + } else { + throw Error(bignumberError + p2 + " invalid: " + v2); + } + } + } else { + throw Error(bignumberError + "Object expected: " + obj); + } + } + return { + DECIMAL_PLACES, + ROUNDING_MODE, + EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], + RANGE: [MIN_EXP, MAX_EXP], + CRYPTO, + MODULO_MODE, + POW_PRECISION, + FORMAT, + ALPHABET + }; + }; + BigNumber2.isBigNumber = function(v2) { + if (!v2 || v2._isBigNumber !== true) + return false; + if (!BigNumber2.DEBUG) + return true; + var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s; + out: + if ({}.toString.call(c2) == "[object Array]") { + if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) { + if (c2[0] === 0) { + if (e3 === 0 && c2.length === 1) + return true; + break out; + } + i3 = (e3 + 1) % LOG_BASE; + if (i3 < 1) + i3 += LOG_BASE; + if (String(c2[0]).length == i3) { + for (i3 = 0; i3 < c2.length; i3++) { + n3 = c2[i3]; + if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3)) + break out; + } + if (n3 !== 0) + return true; + } + } + } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) { + return true; + } + throw Error(bignumberError + "Invalid BigNumber: " + v2); + }; + BigNumber2.maximum = BigNumber2.max = function() { + return maxOrMin(arguments, -1); + }; + BigNumber2.minimum = BigNumber2.min = function() { + return maxOrMin(arguments, 1); + }; + BigNumber2.random = function() { + var pow2_53 = 9007199254740992; + var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() { + return mathfloor(Math.random() * pow2_53); + } : function() { + return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0); + }; + return function(dp) { + var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE); + if (dp == null) + dp = DECIMAL_PLACES; + else + intCheck(dp, 0, MAX); + k2 = mathceil(dp / LOG_BASE); + if (CRYPTO) { + if (crypto.getRandomValues) { + a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2)); + for (; i3 < k2; ) { + v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11); + if (v2 >= 9e15) { + b2 = crypto.getRandomValues(new Uint32Array(2)); + a2[i3] = b2[0]; + a2[i3 + 1] = b2[1]; + } else { + c2.push(v2 % 1e14); + i3 += 2; + } + } + i3 = k2 / 2; + } else if (crypto.randomBytes) { + a2 = crypto.randomBytes(k2 *= 7); + for (; i3 < k2; ) { + 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]; + if (v2 >= 9e15) { + crypto.randomBytes(7).copy(a2, i3); + } else { + c2.push(v2 % 1e14); + i3 += 7; + } + } + i3 = k2 / 7; + } else { + CRYPTO = false; + throw Error(bignumberError + "crypto unavailable"); + } + } + if (!CRYPTO) { + for (; i3 < k2; ) { + v2 = random53bitInt(); + if (v2 < 9e15) + c2[i3++] = v2 % 1e14; + } + } + k2 = c2[--i3]; + dp %= LOG_BASE; + if (k2 && dp) { + v2 = POWS_TEN[LOG_BASE - dp]; + c2[i3] = mathfloor(k2 / v2) * v2; + } + for (; c2[i3] === 0; c2.pop(), i3--) + ; + if (i3 < 0) { + c2 = [e3 = 0]; + } else { + for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE) + ; + for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++) + ; + if (i3 < LOG_BASE) + e3 -= LOG_BASE - i3; + } + rand.e = e3; + rand.c = c2; + return rand; + }; + }(); + BigNumber2.sum = function() { + var i3 = 1, args = arguments, sum = new BigNumber2(args[0]); + for (; i3 < args.length; ) + sum = sum.plus(args[i3++]); + return sum; + }; + convertBase = /* @__PURE__ */ function() { + var decimal = "0123456789"; + function toBaseOut(str, baseIn, baseOut, alphabet) { + var j2, arr = [0], arrL, i3 = 0, len = str.length; + for (; i3 < len; ) { + for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) + ; + arr[0] += alphabet.indexOf(str.charAt(i3++)); + for (j2 = 0; j2 < arr.length; j2++) { + if (arr[j2] > baseOut - 1) { + if (arr[j2 + 1] == null) + arr[j2 + 1] = 0; + arr[j2 + 1] += arr[j2] / baseOut | 0; + arr[j2] %= baseOut; + } + } + } + return arr.reverse(); + } + return function(str, baseIn, baseOut, sign2, callerIsToString) { + var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE; + if (i3 >= 0) { + k2 = POW_PRECISION; + POW_PRECISION = 0; + str = str.replace(".", ""); + y2 = new BigNumber2(baseIn); + x2 = y2.pow(str.length - i3); + POW_PRECISION = k2; + y2.c = toBaseOut( + toFixedPoint(coeffToString(x2.c), x2.e, "0"), + 10, + baseOut, + decimal + ); + y2.e = y2.c.length; + } + xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET)); + e3 = k2 = xc.length; + for (; xc[--k2] == 0; xc.pop()) + ; + if (!xc[0]) + return alphabet.charAt(0); + if (i3 < 0) { + --e3; + } else { + x2.c = xc; + x2.e = e3; + x2.s = sign2; + x2 = div(x2, y2, dp, rm, baseOut); + xc = x2.c; + r2 = x2.r; + e3 = x2.e; + } + d2 = e3 + dp + 1; + i3 = xc[d2]; + k2 = baseOut / 2; + r2 = r2 || d2 < 0 || xc[d2 + 1] != null; + 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)); + if (d2 < 1 || !xc[0]) { + str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0); + } else { + xc.length = d2; + if (r2) { + for (--baseOut; ++xc[--d2] > baseOut; ) { + xc[d2] = 0; + if (!d2) { + ++e3; + xc = [1].concat(xc); + } + } + } + for (k2 = xc.length; !xc[--k2]; ) + ; + for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++])) + ; + str = toFixedPoint(str, e3, alphabet.charAt(0)); + } + return str; + }; + }(); + div = /* @__PURE__ */ function() { + function multiply(x2, k2, base) { + var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0; + for (x2 = x2.slice(); i3--; ) { + xlo = x2[i3] % SQRT_BASE; + xhi = x2[i3] / SQRT_BASE | 0; + m2 = khi * xlo + xhi * klo; + temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry; + carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi; + x2[i3] = temp % base; + } + if (carry) + x2 = [carry].concat(x2); + return x2; + } + function compare2(a2, b2, aL, bL) { + var i3, cmp; + if (aL != bL) { + cmp = aL > bL ? 1 : -1; + } else { + for (i3 = cmp = 0; i3 < aL; i3++) { + if (a2[i3] != b2[i3]) { + cmp = a2[i3] > b2[i3] ? 1 : -1; + break; + } + } + } + return cmp; + } + function subtract(a2, b2, aL, base) { + var i3 = 0; + for (; aL--; ) { + a2[aL] -= i3; + i3 = a2[aL] < b2[aL] ? 1 : 0; + a2[aL] = i3 * base + a2[aL] - b2[aL]; + } + for (; !a2[0] && a2.length > 1; a2.splice(0, 1)) + ; + } + return function(x2, y2, dp, rm, base) { + 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; + if (!xc || !xc[0] || !yc || !yc[0]) { + return new BigNumber2( + // Return NaN if either NaN, or both Infinity or 0. + !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : ( + // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. + xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0 + ) + ); + } + q2 = new BigNumber2(s2); + qc = q2.c = []; + e3 = x2.e - y2.e; + s2 = dp + e3 + 1; + if (!base) { + base = BASE; + e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE); + s2 = s2 / LOG_BASE | 0; + } + for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++) + ; + if (yc[i3] > (xc[i3] || 0)) + e3--; + if (s2 < 0) { + qc.push(1); + more = true; + } else { + xL = xc.length; + yL = yc.length; + i3 = 0; + s2 += 2; + n3 = mathfloor(base / (yc[0] + 1)); + if (n3 > 1) { + yc = multiply(yc, n3, base); + xc = multiply(xc, n3, base); + yL = yc.length; + xL = xc.length; + } + xi = yL; + rem = xc.slice(0, yL); + remL = rem.length; + for (; remL < yL; rem[remL++] = 0) + ; + yz = yc.slice(); + yz = [0].concat(yz); + yc0 = yc[0]; + if (yc[1] >= base / 2) + yc0++; + do { + n3 = 0; + cmp = compare2(yc, rem, yL, remL); + if (cmp < 0) { + rem0 = rem[0]; + if (yL != remL) + rem0 = rem0 * base + (rem[1] || 0); + n3 = mathfloor(rem0 / yc0); + if (n3 > 1) { + if (n3 >= base) + n3 = base - 1; + prod = multiply(yc, n3, base); + prodL = prod.length; + remL = rem.length; + while (compare2(prod, rem, prodL, remL) == 1) { + n3--; + subtract(prod, yL < prodL ? yz : yc, prodL, base); + prodL = prod.length; + cmp = 1; + } + } else { + if (n3 == 0) { + cmp = n3 = 1; + } + prod = yc.slice(); + prodL = prod.length; + } + if (prodL < remL) + prod = [0].concat(prod); + subtract(rem, prod, remL, base); + remL = rem.length; + if (cmp == -1) { + while (compare2(yc, rem, yL, remL) < 1) { + n3++; + subtract(rem, yL < remL ? yz : yc, remL, base); + remL = rem.length; + } + } + } else if (cmp === 0) { + n3++; + rem = [0]; + } + qc[i3++] = n3; + if (rem[0]) { + rem[remL++] = xc[xi] || 0; + } else { + rem = [xc[xi]]; + remL = 1; + } + } while ((xi++ < xL || rem[0] != null) && s2--); + more = rem[0] != null; + if (!qc[0]) + qc.splice(0, 1); + } + if (base == BASE) { + for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++) + ; + round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more); + } else { + q2.e = e3; + q2.r = +more; + } + return q2; + }; + }(); + function format2(n3, i3, rm, id2) { + var c0, e3, ne2, len, str; + if (rm == null) + rm = ROUNDING_MODE; + else + intCheck(rm, 0, 8); + if (!n3.c) + return n3.toString(); + c0 = n3.c[0]; + ne2 = n3.e; + if (i3 == null) { + str = coeffToString(n3.c); + str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0"); + } else { + n3 = round(new BigNumber2(n3), i3, rm); + e3 = n3.e; + str = coeffToString(n3.c); + len = str.length; + if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) { + for (; len < i3; str += "0", len++) + ; + str = toExponential(str, e3); + } else { + i3 -= ne2; + str = toFixedPoint(str, e3, "0"); + if (e3 + 1 > len) { + if (--i3 > 0) + for (str += "."; i3--; str += "0") + ; + } else { + i3 += e3 - len; + if (i3 > 0) { + if (e3 + 1 == len) + str += "."; + for (; i3--; str += "0") + ; + } + } + } + } + return n3.s < 0 && c0 ? "-" + str : str; } - for (const feature22 of borders2.features) { - loadRoadSpeedUnit(feature22); - loadRoadHeightUnit(feature22); - loadDriveSide(feature22); - loadCallingCodes(feature22); - loadGroupGroups(feature22); + function maxOrMin(args, n3) { + var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]); + for (; i3 < args.length; i3++) { + y2 = new BigNumber2(args[i3]); + if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) { + x2 = y2; + } + } + return x2; } - for (const feature22 of borders2.features) { - feature22.properties.groups.sort((groupID1, groupID2) => { - return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level); - }); - if (feature22.properties.members) { - feature22.properties.members.sort((id1, id2) => { - const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level); - if (diff === 0) { - return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]); + function normalise(n3, c2, e3) { + var i3 = 1, j2 = c2.length; + for (; !c2[--j2]; c2.pop()) + ; + for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++) + ; + if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) { + n3.c = n3.e = null; + } else if (e3 < MIN_EXP) { + n3.c = [n3.e = 0]; + } else { + n3.e = e3; + n3.c = c2; + } + return n3; + } + parseNumeric2 = /* @__PURE__ */ function() { + var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; + return function(x2, str, isNum, b2) { + var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, ""); + if (isInfinityOrNaN.test(s2)) { + x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1; + } else { + if (!isNum) { + s2 = s2.replace(basePrefix, function(m2, p1, p2) { + base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8; + return !b2 || b2 == base ? p1 : m2; + }); + if (b2) { + base = b2; + s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1"); + } + if (str != s2) + return new BigNumber2(s2, base); } - return diff; - }); + if (BigNumber2.DEBUG) { + throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str); + } + x2.s = null; + } + x2.c = x2.e = null; + }; + }(); + function round(x2, sd, rm, r2) { + var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN; + if (xc) { + out: { + for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++) + ; + i3 = sd - d2; + if (i3 < 0) { + i3 += LOG_BASE; + j2 = sd; + n3 = xc[ni = 0]; + rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10); + } else { + ni = mathceil((i3 + 1) / LOG_BASE); + if (ni >= xc.length) { + if (r2) { + for (; xc.length <= ni; xc.push(0)) + ; + n3 = rd = 0; + d2 = 1; + i3 %= LOG_BASE; + j2 = i3 - LOG_BASE + 1; + } else { + break out; + } + } else { + n3 = k2 = xc[ni]; + for (d2 = 1; k2 >= 10; k2 /= 10, d2++) + ; + i3 %= LOG_BASE; + j2 = i3 - LOG_BASE + d2; + rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10); + } + } + r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit? + // The expression n % pows10[d - j - 1] returns all digits of n to the right + // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. + xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]); + 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. + (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7)); + if (sd < 1 || !xc[0]) { + xc.length = 0; + if (r2) { + sd -= x2.e + 1; + xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; + x2.e = -sd || 0; + } else { + xc[0] = x2.e = 0; + } + return x2; + } + if (i3 == 0) { + xc.length = ni; + k2 = 1; + ni--; + } else { + xc.length = ni + 1; + k2 = pows10[LOG_BASE - i3]; + xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0; + } + if (r2) { + for (; ; ) { + if (ni == 0) { + for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++) + ; + j2 = xc[0] += k2; + for (k2 = 1; j2 >= 10; j2 /= 10, k2++) + ; + if (i3 != k2) { + x2.e++; + if (xc[0] == BASE) + xc[0] = 1; + } + break; + } else { + xc[ni] += k2; + if (xc[ni] != BASE) + break; + xc[ni--] = 0; + k2 = 1; + } + } + } + for (i3 = xc.length; xc[--i3] === 0; xc.pop()) + ; + } + if (x2.e > MAX_EXP) { + x2.c = x2.e = null; + } else if (x2.e < MIN_EXP) { + x2.c = [x2.e = 0]; + } } + return x2; } - const geometryOnlyCollection = { - type: "FeatureCollection", - features: geometryFeatures + function valueOf(n3) { + var str, e3 = n3.e; + if (e3 === null) + return n3.toString(); + str = coeffToString(n3.c); + str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0"); + return n3.s < 0 ? "-" + str : str; + } + P2.absoluteValue = P2.abs = function() { + var x2 = new BigNumber2(this); + if (x2.s < 0) + x2.s = 1; + return x2; }; - _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection); - function loadGroups(feature22) { - const props = feature22.properties; - if (!props.groups) { - props.groups = []; + P2.comparedTo = function(y2, b2) { + return compare(this, new BigNumber2(y2, b2)); + }; + P2.decimalPlaces = P2.dp = function(dp, rm) { + var c2, n3, v2, x2 = this; + if (dp != null) { + intCheck(dp, 0, MAX); + if (rm == null) + rm = ROUNDING_MODE; + else + intCheck(rm, 0, 8); + return round(new BigNumber2(x2), dp + x2.e + 1, rm); } - if (feature22.geometry && props.country) { - props.groups.push(props.country); + if (!(c2 = x2.c)) + return null; + n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; + if (v2 = c2[v2]) + for (; v2 % 10 == 0; v2 /= 10, n3--) + ; + if (n3 < 0) + n3 = 0; + return n3; + }; + P2.dividedBy = P2.div = function(y2, b2) { + return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE); + }; + P2.dividedToIntegerBy = P2.idiv = function(y2, b2) { + return div(this, new BigNumber2(y2, b2), 0, 1); + }; + P2.exponentiatedBy = P2.pow = function(n3, m2) { + var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this; + n3 = new BigNumber2(n3); + if (n3.c && !n3.isInteger()) { + throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3)); + } + if (m2 != null) + m2 = new BigNumber2(m2); + nIsBig = n3.e > 14; + if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) { + y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3))); + return m2 ? y2.mod(m2) : y2; + } + nIsNeg = n3.s < 0; + if (m2) { + if (m2.c ? !m2.c[0] : !m2.s) + return new BigNumber2(NaN); + isModExp = !nIsNeg && x2.isInteger() && m2.isInteger(); + if (isModExp) + x2 = x2.mod(m2); + } 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))) { + k2 = x2.s < 0 && isOdd(n3) ? -0 : 0; + if (x2.e > -1) + k2 = 1 / k2; + return new BigNumber2(nIsNeg ? 1 / k2 : k2); + } else if (POW_PRECISION) { + k2 = mathceil(POW_PRECISION / LOG_BASE + 2); + } + if (nIsBig) { + half = new BigNumber2(0.5); + if (nIsNeg) + n3.s = 1; + nIsOdd = isOdd(n3); + } else { + i3 = Math.abs(+valueOf(n3)); + nIsOdd = i3 % 2; + } + y2 = new BigNumber2(ONE); + for (; ; ) { + if (nIsOdd) { + y2 = y2.times(x2); + if (!y2.c) + break; + if (k2) { + if (y2.c.length > k2) + y2.c.length = k2; + } else if (isModExp) { + y2 = y2.mod(m2); + } + } + if (i3) { + i3 = mathfloor(i3 / 2); + if (i3 === 0) + break; + nIsOdd = i3 % 2; + } else { + n3 = n3.times(half); + round(n3, n3.e + 1, 1); + if (n3.e > 14) { + nIsOdd = isOdd(n3); + } else { + i3 = +valueOf(n3); + if (i3 === 0) + break; + nIsOdd = i3 % 2; + } + } + x2 = x2.times(x2); + if (k2) { + if (x2.c && x2.c.length > k2) + x2.c.length = k2; + } else if (isModExp) { + x2 = x2.mod(m2); + } } - if (props.m49 !== "001") { - props.groups.push("001"); + if (isModExp) + return y2; + if (nIsNeg) + y2 = ONE.div(y2); + return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2; + }; + P2.integerValue = function(rm) { + var n3 = new BigNumber2(this); + if (rm == null) + rm = ROUNDING_MODE; + else + intCheck(rm, 0, 8); + return round(n3, n3.e + 1, rm); + }; + P2.isEqualTo = P2.eq = function(y2, b2) { + return compare(this, new BigNumber2(y2, b2)) === 0; + }; + P2.isFinite = function() { + return !!this.c; + }; + P2.isGreaterThan = P2.gt = function(y2, b2) { + return compare(this, new BigNumber2(y2, b2)) > 0; + }; + P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) { + return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0; + }; + P2.isInteger = function() { + return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; + }; + P2.isLessThan = P2.lt = function(y2, b2) { + return compare(this, new BigNumber2(y2, b2)) < 0; + }; + P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) { + return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0; + }; + P2.isNaN = function() { + return !this.s; + }; + P2.isNegative = function() { + return this.s < 0; + }; + P2.isPositive = function() { + return this.s > 0; + }; + P2.isZero = function() { + return !!this.c && this.c[0] == 0; + }; + P2.minus = function(y2, b2) { + var i3, j2, t2, xLTy, x2 = this, a2 = x2.s; + y2 = new BigNumber2(y2, b2); + b2 = y2.s; + if (!a2 || !b2) + return new BigNumber2(NaN); + if (a2 != b2) { + y2.s = -b2; + return x2.plus(y2); + } + var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c; + if (!xe2 || !ye2) { + if (!xc || !yc) + return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN); + if (!xc[0] || !yc[0]) { + return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : ( + // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + ROUNDING_MODE == 3 ? -0 : 0 + )); + } + } + xe2 = bitFloor(xe2); + ye2 = bitFloor(ye2); + xc = xc.slice(); + if (a2 = xe2 - ye2) { + if (xLTy = a2 < 0) { + a2 = -a2; + t2 = xc; + } else { + ye2 = xe2; + t2 = yc; + } + t2.reverse(); + for (b2 = a2; b2--; t2.push(0)) + ; + t2.reverse(); + } else { + j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2; + for (a2 = b2 = 0; b2 < j2; b2++) { + if (xc[b2] != yc[b2]) { + xLTy = xc[b2] < yc[b2]; + break; + } + } + } + if (xLTy) { + t2 = xc; + xc = yc; + yc = t2; + y2.s = -y2.s; + } + b2 = (j2 = yc.length) - (i3 = xc.length); + if (b2 > 0) + for (; b2--; xc[i3++] = 0) + ; + b2 = BASE - 1; + for (; j2 > a2; ) { + if (xc[--j2] < yc[j2]) { + for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2) + ; + --xc[i3]; + xc[j2] += BASE; + } + xc[j2] -= yc[j2]; + } + for (; xc[0] == 0; xc.splice(0, 1), --ye2) + ; + if (!xc[0]) { + y2.s = ROUNDING_MODE == 3 ? -1 : 1; + y2.c = [y2.e = 0]; + return y2; + } + return normalise(y2, xc, ye2); + }; + P2.modulo = P2.mod = function(y2, b2) { + var q2, s2, x2 = this; + y2 = new BigNumber2(y2, b2); + if (!x2.c || !y2.s || y2.c && !y2.c[0]) { + return new BigNumber2(NaN); + } else if (!y2.c || x2.c && !x2.c[0]) { + return new BigNumber2(x2); + } + if (MODULO_MODE == 9) { + s2 = y2.s; + y2.s = 1; + q2 = div(x2, y2, 0, 3); + y2.s = s2; + q2.s *= s2; + } else { + q2 = div(x2, y2, 0, MODULO_MODE); + } + y2 = x2.minus(q2.times(y2)); + if (!y2.c[0] && MODULO_MODE == 1) + y2.s = x2.s; + return y2; + }; + P2.multipliedBy = P2.times = function(y2, b2) { + 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; + if (!xc || !yc || !xc[0] || !yc[0]) { + if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { + y2.c = y2.e = y2.s = null; + } else { + y2.s *= x2.s; + if (!xc || !yc) { + y2.c = y2.e = null; + } else { + y2.c = [0]; + y2.e = 0; + } + } + return y2; + } + e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE); + y2.s *= x2.s; + xcL = xc.length; + ycL = yc.length; + if (xcL < ycL) { + zc = xc; + xc = yc; + yc = zc; + i3 = xcL; + xcL = ycL; + ycL = i3; + } + for (i3 = xcL + ycL, zc = []; i3--; zc.push(0)) + ; + base = BASE; + sqrtBase = SQRT_BASE; + for (i3 = ycL; --i3 >= 0; ) { + c2 = 0; + ylo = yc[i3] % sqrtBase; + yhi = yc[i3] / sqrtBase | 0; + for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) { + xlo = xc[--k2] % sqrtBase; + xhi = xc[k2] / sqrtBase | 0; + m2 = yhi * xlo + xhi * ylo; + xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2; + c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi; + zc[j2--] = xlo % base; + } + zc[j2] = c2; + } + if (c2) { + ++e3; + } else { + zc.splice(0, 1); + } + return normalise(y2, zc, e3); + }; + P2.negated = function() { + var x2 = new BigNumber2(this); + x2.s = -x2.s || null; + return x2; + }; + P2.plus = function(y2, b2) { + var t2, x2 = this, a2 = x2.s; + y2 = new BigNumber2(y2, b2); + b2 = y2.s; + if (!a2 || !b2) + return new BigNumber2(NaN); + if (a2 != b2) { + y2.s = -b2; + return x2.minus(y2); + } + var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c; + if (!xe2 || !ye2) { + if (!xc || !yc) + return new BigNumber2(a2 / 0); + if (!xc[0] || !yc[0]) + return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0); + } + xe2 = bitFloor(xe2); + ye2 = bitFloor(ye2); + xc = xc.slice(); + if (a2 = xe2 - ye2) { + if (a2 > 0) { + ye2 = xe2; + t2 = yc; + } else { + a2 = -a2; + t2 = xc; + } + t2.reverse(); + for (; a2--; t2.push(0)) + ; + t2.reverse(); + } + a2 = xc.length; + b2 = yc.length; + if (a2 - b2 < 0) { + t2 = yc; + yc = xc; + xc = t2; + b2 = a2; + } + for (a2 = 0; b2; ) { + a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0; + xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE; + } + if (a2) { + xc = [a2].concat(xc); + ++ye2; + } + return normalise(y2, xc, ye2); + }; + P2.precision = P2.sd = function(sd, rm) { + var c2, n3, v2, x2 = this; + if (sd != null && sd !== !!sd) { + intCheck(sd, 1, MAX); + if (rm == null) + rm = ROUNDING_MODE; + else + intCheck(rm, 0, 8); + return round(new BigNumber2(x2), sd, rm); + } + if (!(c2 = x2.c)) + return null; + v2 = c2.length - 1; + n3 = v2 * LOG_BASE + 1; + if (v2 = c2[v2]) { + for (; v2 % 10 == 0; v2 /= 10, n3--) + ; + for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++) + ; + } + if (sd && x2.e + 1 > n3) + n3 = x2.e + 1; + return n3; + }; + P2.shiftedBy = function(k2) { + intCheck(k2, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); + return this.times("1e" + k2); + }; + P2.squareRoot = P2.sqrt = function() { + 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"); + if (s2 !== 1 || !c2 || !c2[0]) { + return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0); + } + s2 = Math.sqrt(+valueOf(x2)); + if (s2 == 0 || s2 == 1 / 0) { + n3 = coeffToString(c2); + if ((n3.length + e3) % 2 == 0) + n3 += "0"; + s2 = Math.sqrt(+n3); + e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2); + if (s2 == 1 / 0) { + n3 = "5e" + e3; + } else { + n3 = s2.toExponential(); + n3 = n3.slice(0, n3.indexOf("e") + 1) + e3; + } + r2 = new BigNumber2(n3); + } else { + r2 = new BigNumber2(s2 + ""); + } + if (r2.c[0]) { + e3 = r2.e; + s2 = e3 + dp; + if (s2 < 3) + s2 = 0; + for (; ; ) { + t2 = r2; + r2 = half.times(t2.plus(div(x2, t2, dp, 1))); + if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) { + if (r2.e < e3) + --s2; + n3 = n3.slice(s2 - 3, s2 + 1); + if (n3 == "9999" || !rep && n3 == "4999") { + if (!rep) { + round(t2, t2.e + DECIMAL_PLACES + 2, 0); + if (t2.times(t2).eq(x2)) { + r2 = t2; + break; + } + } + dp += 4; + s2 += 4; + rep = 1; + } else { + if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") { + round(r2, r2.e + DECIMAL_PLACES + 2, 1); + m2 = !r2.times(r2).eq(x2); + } + break; + } + } + } + } + return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2); + }; + P2.toExponential = function(dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp++; + } + return format2(this, dp, rm, 1); + }; + P2.toFixed = function(dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp = dp + this.e + 1; + } + return format2(this, dp, rm); + }; + P2.toFormat = function(dp, rm, format3) { + var str, x2 = this; + if (format3 == null) { + if (dp != null && rm && typeof rm == "object") { + format3 = rm; + rm = null; + } else if (dp && typeof dp == "object") { + format3 = dp; + dp = rm = null; + } else { + format3 = FORMAT; + } + } else if (typeof format3 != "object") { + throw Error(bignumberError + "Argument not an object: " + format3); + } + str = x2.toFixed(dp, rm); + if (x2.c) { + 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; + if (g22) { + i3 = g1; + g1 = g22; + g22 = i3; + len -= i3; + } + if (g1 > 0 && len > 0) { + i3 = len % g1 || g1; + intPart = intDigits.substr(0, i3); + for (; i3 < len; i3 += g1) + intPart += groupSeparator + intDigits.substr(i3, g1); + if (g22 > 0) + intPart += groupSeparator + intDigits.slice(i3); + if (isNeg) + intPart = "-" + intPart; + } + str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace( + new RegExp("\\d{" + g22 + "}\\B", "g"), + "$&" + (format3.fractionGroupSeparator || "") + ) : fractionPart) : intPart; + } + return (format3.prefix || "") + str + (format3.suffix || ""); + }; + P2.toFraction = function(md) { + var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c; + if (md != null) { + n3 = new BigNumber2(md); + if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) { + throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3)); + } + } + if (!xc) + return new BigNumber2(x2); + d2 = new BigNumber2(ONE); + n1 = d0 = new BigNumber2(ONE); + d1 = n0 = new BigNumber2(ONE); + s2 = coeffToString(xc); + e3 = d2.e = s2.length - x2.e - 1; + d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2]; + md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3; + exp2 = MAX_EXP; + MAX_EXP = 1 / 0; + n3 = new BigNumber2(s2); + n0.c[0] = 0; + for (; ; ) { + q2 = div(n3, d2, 0, 1); + d22 = d0.plus(q2.times(d1)); + if (d22.comparedTo(md) == 1) + break; + d0 = d1; + d1 = d22; + n1 = n0.plus(q2.times(d22 = n1)); + n0 = d22; + d2 = n3.minus(q2.times(d22 = d2)); + n3 = d22; + } + d22 = div(md.minus(d0), d1, 0, 1); + n0 = n0.plus(d22.times(n1)); + d0 = d0.plus(d22.times(d1)); + n0.s = n1.s = x2.s; + e3 = e3 * 2; + r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo( + div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs() + ) < 1 ? [n1, d1] : [n0, d0]; + MAX_EXP = exp2; + return r2; + }; + P2.toNumber = function() { + return +valueOf(this); + }; + P2.toPrecision = function(sd, rm) { + if (sd != null) + intCheck(sd, 1, MAX); + return format2(this, sd, rm, 2); + }; + P2.toString = function(b2) { + var str, n3 = this, s2 = n3.s, e3 = n3.e; + if (e3 === null) { + if (s2) { + str = "Infinity"; + if (s2 < 0) + str = "-" + str; + } else { + str = "NaN"; + } + } else { + if (b2 == null) { + str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0"); + } else if (b2 === 10 && alphabetHasNormalDecimalDigits) { + n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE); + str = toFixedPoint(coeffToString(n3.c), n3.e, "0"); + } else { + intCheck(b2, 2, ALPHABET.length, "Base"); + str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true); + } + if (s2 < 0 && n3.c[0]) + str = "-" + str; + } + return str; + }; + P2.valueOf = P2.toJSON = function() { + return valueOf(this); + }; + P2._isBigNumber = true; + P2[Symbol.toStringTag] = "BigNumber"; + P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf; + if (configObject != null) + BigNumber2.set(configObject); + return BigNumber2; + } + function bitFloor(n3) { + var i3 = n3 | 0; + return n3 > 0 || n3 === i3 ? i3 : i3 - 1; + } + function coeffToString(a2) { + var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + ""; + for (; i3 < j2; ) { + s2 = a2[i3++] + ""; + z2 = LOG_BASE - s2.length; + for (; z2--; s2 = "0" + s2) + ; + r2 += s2; + } + for (j2 = r2.length; r2.charCodeAt(--j2) === 48; ) + ; + return r2.slice(0, j2 + 1 || 1); + } + function compare(x2, y2) { + var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e; + if (!i3 || !j2) + return null; + a2 = xc && !xc[0]; + b2 = yc && !yc[0]; + if (a2 || b2) + return a2 ? b2 ? 0 : -j2 : i3; + if (i3 != j2) + return i3; + a2 = i3 < 0; + b2 = k2 == l2; + if (!xc || !yc) + return b2 ? 0 : !xc ^ a2 ? 1 : -1; + if (!b2) + return k2 > l2 ^ a2 ? 1 : -1; + j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2; + for (i3 = 0; i3 < j2; i3++) + if (xc[i3] != yc[i3]) + return xc[i3] > yc[i3] ^ a2 ? 1 : -1; + return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1; + } + function intCheck(n3, min3, max3, name) { + if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) { + throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3)); + } + } + function isOdd(n3) { + var k2 = n3.c.length - 1; + return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0; + } + function toExponential(str, e3) { + return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3; + } + function toFixedPoint(str, e3, z2) { + var len, zs; + if (e3 < 0) { + for (zs = z2 + "."; ++e3; zs += z2) + ; + str = zs + str; + } else { + len = str.length; + if (++e3 > len) { + for (zs = z2, e3 -= len; --e3; zs += z2) + ; + str += zs; + } else if (e3 < len) { + str = str.slice(0, e3) + "." + str.slice(e3); } } - function loadM49(feature22) { - const props = feature22.properties; - if (!props.m49 && props.iso1N3) { - props.m49 = props.iso1N3; + return str; + } + var BigNumber = clone(); + var bignumber_default = BigNumber; + + // node_modules/splaytree-ts/dist/index.js + var SplayTreeNode = class { + constructor(key) { + __publicField(this, "key"); + __publicField(this, "left", null); + __publicField(this, "right", null); + this.key = key; + } + }; + var SplayTreeSetNode = class extends SplayTreeNode { + constructor(key) { + super(key); + } + }; + var SplayTree = class { + constructor() { + __publicField(this, "size", 0); + __publicField(this, "modificationCount", 0); + __publicField(this, "splayCount", 0); + } + splay(key) { + const root3 = this.root; + if (root3 == null) { + this.compare(key, key); + return -1; + } + let right = null; + let newTreeRight = null; + let left = null; + let newTreeLeft = null; + let current = root3; + const compare2 = this.compare; + let comp; + while (true) { + comp = compare2(current.key, key); + if (comp > 0) { + let currentLeft = current.left; + if (currentLeft == null) + break; + comp = compare2(currentLeft.key, key); + if (comp > 0) { + current.left = currentLeft.right; + currentLeft.right = current; + current = currentLeft; + currentLeft = current.left; + if (currentLeft == null) + break; + } + if (right == null) { + newTreeRight = current; + } else { + right.left = current; + } + right = current; + current = currentLeft; + } else if (comp < 0) { + let currentRight = current.right; + if (currentRight == null) + break; + comp = compare2(currentRight.key, key); + if (comp < 0) { + current.right = currentRight.left; + currentRight.left = current; + current = currentRight; + currentRight = current.right; + if (currentRight == null) + break; + } + if (left == null) { + newTreeLeft = current; + } else { + left.right = current; + } + left = current; + current = currentRight; + } else { + break; + } + } + if (left != null) { + left.right = current.left; + current.left = newTreeLeft; + } + if (right != null) { + right.left = current.right; + current.right = newTreeRight; + } + if (this.root !== current) { + this.root = current; + this.splayCount++; } + return comp; } - function loadTLD(feature22) { - const props = feature22.properties; - if (props.level === "unitedNations") - return; - if (!props.ccTLD && props.iso1A2) { - props.ccTLD = "." + props.iso1A2.toLowerCase(); + splayMin(node) { + let current = node; + let nextLeft = current.left; + while (nextLeft != null) { + const left = nextLeft; + current.left = left.right; + left.right = current; + current = left; + nextLeft = current.left; } + return current; } - function loadIsoStatus(feature22) { - const props = feature22.properties; - if (!props.isoStatus && props.iso1A2) { - props.isoStatus = "official"; + splayMax(node) { + let current = node; + let nextRight = current.right; + while (nextRight != null) { + const right = nextRight; + current.right = right.left; + right.left = current; + current = right; + nextRight = current.right; } + return current; } - function loadLevel(feature22) { - const props = feature22.properties; - if (props.level) - return; - if (!props.country) { - props.level = "country"; - } else if (!props.iso1A2 || props.isoStatus === "official") { - props.level = "territory"; + _delete(key) { + if (this.root == null) + return null; + const comp = this.splay(key); + if (comp != 0) + return null; + let root3 = this.root; + const result = root3; + const left = root3.left; + this.size--; + if (left == null) { + this.root = root3.right; } else { - props.level = "subterritory"; + const right = root3.right; + root3 = this.splayMax(left); + root3.right = right; + this.root = root3; } + this.modificationCount++; + return result; } - function loadGroupGroups(feature22) { - const props = feature22.properties; - if (feature22.geometry || !props.members) + addNewRoot(node, comp) { + this.size++; + this.modificationCount++; + const root3 = this.root; + if (root3 == null) { + this.root = node; return; - const featureLevelIndex = levels.indexOf(props.level); - let sharedGroups = []; - props.members.forEach((memberID, index) => { - const member = _featuresByCode[memberID]; - const memberGroups = member.properties.groups.filter((groupID) => { - return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level); - }); - if (index === 0) { - sharedGroups = memberGroups; - } else { - sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1); - } - }); - props.groups = props.groups.concat( - sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1) - ); - for (const groupID of sharedGroups) { - const groupFeature = _featuresByCode[groupID]; - if (groupFeature.properties.members.indexOf(props.id) === -1) { - groupFeature.properties.members.push(props.id); + } + if (comp < 0) { + node.left = root3; + node.right = root3.right; + root3.right = null; + } else { + node.right = root3; + node.left = root3.left; + root3.left = null; + } + this.root = node; + } + _first() { + const root3 = this.root; + if (root3 == null) + return null; + this.root = this.splayMin(root3); + return this.root; + } + _last() { + const root3 = this.root; + if (root3 == null) + return null; + this.root = this.splayMax(root3); + return this.root; + } + clear() { + this.root = null; + this.size = 0; + this.modificationCount++; + } + has(key) { + return this.validKey(key) && this.splay(key) == 0; + } + defaultCompare() { + return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0; + } + wrap() { + return { + getRoot: () => { + return this.root; + }, + setRoot: (root3) => { + this.root = root3; + }, + getSize: () => { + return this.size; + }, + getModificationCount: () => { + return this.modificationCount; + }, + getSplayCount: () => { + return this.splayCount; + }, + setSplayCount: (count) => { + this.splayCount = count; + }, + splay: (key) => { + return this.splay(key); + }, + has: (key) => { + return this.has(key); } + }; + } + }; + var _a; + var _SplayTreeSet = class _SplayTreeSet extends SplayTree { + constructor(compare2, isValidKey) { + super(); + __publicField(this, "root", null); + __publicField(this, "compare"); + __publicField(this, "validKey"); + __publicField(this, _a, "[object Set]"); + this.compare = compare2 != null ? compare2 : this.defaultCompare(); + this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0; + } + delete(element) { + if (!this.validKey(element)) + return false; + return this._delete(element) != null; + } + deleteAll(elements) { + for (const element of elements) { + this.delete(element); } } - function loadRoadSpeedUnit(feature22) { - const props = feature22.properties; - if (feature22.geometry) { - if (!props.roadSpeedUnit) - props.roadSpeedUnit = "km/h"; - } else if (props.members) { - const vals = Array.from( - new Set( - props.members.map((id2) => { - const member = _featuresByCode[id2]; - if (member.geometry) - return member.properties.roadSpeedUnit || "km/h"; - }).filter(Boolean) - ) - ); - if (vals.length === 1) - props.roadSpeedUnit = vals[0]; + forEach(f2) { + const nodes = this[Symbol.iterator](); + let result; + while (result = nodes.next(), !result.done) { + f2(result.value, result.value, this); + } + } + add(element) { + const compare2 = this.splay(element); + if (compare2 != 0) + this.addNewRoot(new SplayTreeSetNode(element), compare2); + return this; + } + addAndReturn(element) { + const compare2 = this.splay(element); + if (compare2 != 0) + this.addNewRoot(new SplayTreeSetNode(element), compare2); + return this.root.key; + } + addAll(elements) { + for (const element of elements) { + this.add(element); + } + } + isEmpty() { + return this.root == null; + } + isNotEmpty() { + return this.root != null; + } + single() { + if (this.size == 0) + throw "Bad state: No element"; + if (this.size > 1) + throw "Bad state: Too many element"; + return this.root.key; + } + first() { + if (this.size == 0) + throw "Bad state: No element"; + return this._first().key; + } + last() { + if (this.size == 0) + throw "Bad state: No element"; + return this._last().key; + } + lastBefore(element) { + if (element == null) + throw "Invalid arguments(s)"; + if (this.root == null) + return null; + const comp = this.splay(element); + if (comp < 0) + return this.root.key; + let node = this.root.left; + if (node == null) + return null; + let nodeRight = node.right; + while (nodeRight != null) { + node = nodeRight; + nodeRight = node.right; } + return node.key; } - function loadRoadHeightUnit(feature22) { - const props = feature22.properties; - if (feature22.geometry) { - if (!props.roadHeightUnit) - props.roadHeightUnit = "m"; - } else if (props.members) { - const vals = Array.from( - new Set( - props.members.map((id2) => { - const member = _featuresByCode[id2]; - if (member.geometry) - return member.properties.roadHeightUnit || "m"; - }).filter(Boolean) - ) - ); - if (vals.length === 1) - props.roadHeightUnit = vals[0]; + firstAfter(element) { + if (element == null) + throw "Invalid arguments(s)"; + if (this.root == null) + return null; + const comp = this.splay(element); + if (comp > 0) + return this.root.key; + let node = this.root.right; + if (node == null) + return null; + let nodeLeft = node.left; + while (nodeLeft != null) { + node = nodeLeft; + nodeLeft = node.left; } + return node.key; } - function loadDriveSide(feature22) { - const props = feature22.properties; - if (feature22.geometry) { - if (!props.driveSide) - props.driveSide = "right"; - } else if (props.members) { - const vals = Array.from( - new Set( - props.members.map((id2) => { - const member = _featuresByCode[id2]; - if (member.geometry) - return member.properties.driveSide || "right"; - }).filter(Boolean) - ) - ); - if (vals.length === 1) - props.driveSide = vals[0]; + retainAll(elements) { + const retainSet = new _SplayTreeSet(this.compare, this.validKey); + const modificationCount = this.modificationCount; + for (const object of elements) { + if (modificationCount != this.modificationCount) { + throw "Concurrent modification during iteration."; + } + if (this.validKey(object) && this.splay(object) == 0) { + retainSet.add(this.root.key); + } + } + if (retainSet.size != this.size) { + this.root = retainSet.root; + this.size = retainSet.size; + this.modificationCount++; } } - function loadCallingCodes(feature22) { - const props = feature22.properties; - if (!feature22.geometry && props.members) { - props.callingCodes = Array.from( - new Set( - props.members.reduce((array2, id2) => { - const member = _featuresByCode[id2]; - if (member.geometry && member.properties.callingCodes) { - return array2.concat(member.properties.callingCodes); - } - return array2; - }, []) - ) - ); + lookup(object) { + if (!this.validKey(object)) + return null; + const comp = this.splay(object); + if (comp != 0) + return null; + return this.root.key; + } + intersection(other) { + const result = new _SplayTreeSet(this.compare, this.validKey); + for (const element of this) { + if (other.has(element)) + result.add(element); } + return result; } - function loadFlag(feature22) { - if (!feature22.properties.iso1A2) - return; - const flag = feature22.properties.iso1A2.replace(/./g, function(char) { - return String.fromCodePoint(char.charCodeAt(0) + 127397); - }); - feature22.properties.emojiFlag = flag; + difference(other) { + const result = new _SplayTreeSet(this.compare, this.validKey); + for (const element of this) { + if (!other.has(element)) + result.add(element); + } + return result; } - function loadMembersForGroupsOf(feature22) { - for (const groupID of feature22.properties.groups) { - const groupFeature = _featuresByCode[groupID]; - if (!groupFeature.properties.members) { - groupFeature.properties.members = []; - } - groupFeature.properties.members.push(feature22.properties.id); + union(other) { + const u2 = this.clone(); + u2.addAll(other); + return u2; + } + clone() { + const set4 = new _SplayTreeSet(this.compare, this.validKey); + set4.size = this.size; + set4.root = this.copyNode(this.root); + return set4; + } + copyNode(node) { + if (node == null) + return null; + function copyChildren(node2, dest) { + let left; + let right; + do { + left = node2.left; + right = node2.right; + if (left != null) { + const newLeft = new SplayTreeSetNode(left.key); + dest.left = newLeft; + copyChildren(left, newLeft); + } + if (right != null) { + const newRight = new SplayTreeSetNode(right.key); + dest.right = newRight; + node2 = right; + dest = newRight; + } + } while (right != null); + } + const result = new SplayTreeSetNode(node.key); + copyChildren(node, result); + return result; + } + toSet() { + return this.clone(); + } + entries() { + return new SplayTreeSetEntryIterableIterator(this.wrap()); + } + keys() { + return this[Symbol.iterator](); + } + values() { + return this[Symbol.iterator](); + } + [Symbol.iterator]() { + return new SplayTreeKeyIterableIterator(this.wrap()); + } + }; + _a = Symbol.toStringTag; + var SplayTreeSet = _SplayTreeSet; + var SplayTreeIterableIterator = class { + constructor(tree) { + __publicField(this, "tree"); + __publicField(this, "path", new Array()); + __publicField(this, "modificationCount", null); + __publicField(this, "splayCount"); + this.tree = tree; + this.splayCount = tree.getSplayCount(); + } + [Symbol.iterator]() { + return this; + } + next() { + if (this.moveNext()) + return { done: false, value: this.current() }; + return { done: true, value: null }; + } + current() { + if (!this.path.length) + return null; + const node = this.path[this.path.length - 1]; + return this.getValue(node); + } + rebuildPath(key) { + this.path.splice(0, this.path.length); + this.tree.splay(key); + this.path.push(this.tree.getRoot()); + this.splayCount = this.tree.getSplayCount(); + } + findLeftMostDescendent(node) { + while (node != null) { + this.path.push(node); + node = node.left; } } - function cacheFeatureByIDs(feature22) { - let ids = []; - for (const prop of identifierProps) { - const id2 = feature22.properties[prop]; - if (id2) { - ids.push(id2); + moveNext() { + if (this.modificationCount != this.tree.getModificationCount()) { + if (this.modificationCount == null) { + this.modificationCount = this.tree.getModificationCount(); + let node2 = this.tree.getRoot(); + while (node2 != null) { + this.path.push(node2); + node2 = node2.left; + } + return this.path.length > 0; } + throw "Concurrent modification during iteration."; } - for (const alias of feature22.properties.aliases || []) { - ids.push(alias); + if (!this.path.length) + return false; + if (this.splayCount != this.tree.getSplayCount()) { + this.rebuildPath(this.path[this.path.length - 1].key); } - for (const id2 of ids) { - const cid = canonicalID(id2); - _featuresByCode[cid] = feature22; + let node = this.path[this.path.length - 1]; + let next = node.right; + if (next != null) { + while (next != null) { + this.path.push(next); + next = next.left; + } + return true; + } + this.path.pop(); + while (this.path.length && this.path[this.path.length - 1].right === node) { + node = this.path.pop(); } + return this.path.length > 0; } - } - function locArray(loc) { - if (Array.isArray(loc)) { - return loc; - } else if (loc.coordinates) { - return loc.coordinates; + }; + var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator { + getValue(node) { + return node.key; } - return loc.geometry.coordinates; - } - function smallestFeature(loc) { - const query = locArray(loc); - const featureProperties = _whichPolygon(query); - if (!featureProperties) - return null; - return _featuresByCode[featureProperties.id]; - } - function countryFeature(loc) { - const feature22 = smallestFeature(loc); - if (!feature22) + }; + var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator { + getValue(node) { + return [node.key, node.key]; + } + }; + + // node_modules/polyclip-ts/dist/identity.js + var identity_default3 = (x2) => { + return x2; + }; + + // node_modules/polyclip-ts/dist/snap.js + var snap_default = (eps) => { + if (eps) { + const xTree = new SplayTreeSet(compare_default(eps)); + const yTree = new SplayTreeSet(compare_default(eps)); + const snapCoord = (coord2, tree) => { + return tree.addAndReturn(coord2); + }; + const snap = (v2) => { + return { + x: snapCoord(v2.x, xTree), + y: snapCoord(v2.y, yTree) + }; + }; + snap({ x: new bignumber_default(0), y: new bignumber_default(0) }); + return snap; + } + return identity_default3; + }; + + // node_modules/polyclip-ts/dist/precision.js + var set3 = (eps) => { + return { + set: (eps2) => { + precision = set3(eps2); + }, + reset: () => set3(eps), + compare: compare_default(eps), + snap: snap_default(eps), + orient: orient_default(eps) + }; + }; + var precision = set3(); + + // node_modules/polyclip-ts/dist/bbox.js + var isInBbox = (bbox2, point2) => { + return bbox2.ll.x.isLessThanOrEqualTo(point2.x) && point2.x.isLessThanOrEqualTo(bbox2.ur.x) && bbox2.ll.y.isLessThanOrEqualTo(point2.y) && point2.y.isLessThanOrEqualTo(bbox2.ur.y); + }; + var getBboxOverlap = (b1, b2) => { + 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)) return null; - const countryCode = feature22.properties.country || feature22.properties.iso1A2; - return _featuresByCode[countryCode] || null; - } - var defaultOpts = { - level: void 0, - maxLevel: void 0, - withProp: void 0 + const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x; + const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x; + const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y; + const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y; + return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } }; }; - function featureForLoc(loc, opts) { - const targetLevel = opts.level || "country"; - const maxLevel = opts.maxLevel || "world"; - const withProp = opts.withProp; - const targetLevelIndex = levels.indexOf(targetLevel); - if (targetLevelIndex === -1) + + // node_modules/polyclip-ts/dist/vector.js + var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x)); + var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y)); + var length = (v2) => dotProduct(v2, v2).sqrt(); + var sineOfAngle = (pShared, pBase, pAngle) => { + const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) }; + const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) }; + return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase)); + }; + var cosineOfAngle = (pShared, pBase, pAngle) => { + const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) }; + const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) }; + return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase)); + }; + var horizontalIntersection = (pt2, v2, y2) => { + if (v2.y.isZero()) return null; - const maxLevelIndex = levels.indexOf(maxLevel); - if (maxLevelIndex === -1) + return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 }; + }; + var verticalIntersection = (pt2, v2, x2) => { + if (v2.x.isZero()) return null; - if (maxLevelIndex < targetLevelIndex) + return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) }; + }; + var intersection = (pt1, v1, pt2, v2) => { + if (v1.x.isZero()) + return verticalIntersection(pt2, v2, pt1.x); + if (v2.x.isZero()) + return verticalIntersection(pt1, v1, pt2.x); + if (v1.y.isZero()) + return horizontalIntersection(pt2, v2, pt1.y); + if (v2.y.isZero()) + return horizontalIntersection(pt1, v1, pt2.y); + const kross = crossProduct(v1, v2); + if (kross.isZero()) return null; - if (targetLevel === "country") { - const fastFeature = countryFeature(loc); - if (fastFeature) { - if (!withProp || fastFeature.properties[withProp]) { - return fastFeature; + const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) }; + const d1 = crossProduct(ve2, v1).div(kross); + const d2 = crossProduct(ve2, v2).div(kross); + const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x)); + const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y)); + const x3 = x12.plus(x2).div(2); + const y3 = y12.plus(y2).div(2); + return { x: x3, y: y3 }; + }; + + // node_modules/polyclip-ts/dist/sweep-event.js + var SweepEvent = class _SweepEvent { + // Warning: 'point' input will be modified and re-used (for performance) + constructor(point2, isLeft) { + __publicField(this, "point"); + __publicField(this, "isLeft"); + __publicField(this, "segment"); + __publicField(this, "otherSE"); + __publicField(this, "consumedBy"); + if (point2.events === void 0) + point2.events = [this]; + else + point2.events.push(this); + this.point = point2; + this.isLeft = isLeft; + } + // for ordering sweep events in the sweep event queue + static compare(a2, b2) { + const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point); + if (ptCmp !== 0) + return ptCmp; + if (a2.point !== b2.point) + a2.link(b2); + if (a2.isLeft !== b2.isLeft) + return a2.isLeft ? 1 : -1; + return Segment.compare(a2.segment, b2.segment); + } + // for ordering points in sweep line order + static comparePoints(aPt, bPt) { + if (aPt.x.isLessThan(bPt.x)) + return -1; + if (aPt.x.isGreaterThan(bPt.x)) + return 1; + if (aPt.y.isLessThan(bPt.y)) + return -1; + if (aPt.y.isGreaterThan(bPt.y)) + return 1; + return 0; + } + link(other) { + if (other.point === this.point) { + throw new Error("Tried to link already linked events"); + } + const otherEvents = other.point.events; + for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) { + const evt = otherEvents[i3]; + this.point.events.push(evt); + evt.point = this.point; + } + this.checkForConsuming(); + } + /* Do a pass over our linked events and check to see if any pair + * of segments match, and should be consumed. */ + checkForConsuming() { + const numEvents = this.point.events.length; + for (let i3 = 0; i3 < numEvents; i3++) { + const evt1 = this.point.events[i3]; + if (evt1.segment.consumedBy !== void 0) + continue; + for (let j2 = i3 + 1; j2 < numEvents; j2++) { + const evt2 = this.point.events[j2]; + if (evt2.consumedBy !== void 0) + continue; + if (evt1.otherSE.point.events !== evt2.otherSE.point.events) + continue; + evt1.segment.consume(evt2.segment); } } } - const features = featuresContaining(loc); - const match = features.find((feature22) => { - let levelIndex = levels.indexOf(feature22.properties.level); - if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up - levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) { - if (!withProp || feature22.properties[withProp]) { - return feature22; + getAvailableLinkedEvents() { + const events = []; + for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) { + const evt = this.point.events[i3]; + if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) { + events.push(evt); } } - return false; - }); - return match || null; - } - function featureForID(id2) { - let stringID; - if (typeof id2 === "number") { - stringID = id2.toString(); - if (stringID.length === 1) { - stringID = "00" + stringID; - } else if (stringID.length === 2) { - stringID = "0" + stringID; + return events; + } + /** + * Returns a comparator function for sorting linked events that will + * favor the event that will give us the smallest left-side angle. + * All ring construction starts as low as possible heading to the right, + * so by always turning left as sharp as possible we'll get polygons + * without uncessary loops & holes. + * + * The comparator function has a compute cache such that it avoids + * re-computing already-computed values. + */ + getLeftmostComparator(baseEvent) { + const cache = /* @__PURE__ */ new Map(); + const fillCache = (linkedEvent) => { + const nextEvent = linkedEvent.otherSE; + cache.set(linkedEvent, { + sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point), + cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point) + }); + }; + return (a2, b2) => { + if (!cache.has(a2)) + fillCache(a2); + if (!cache.has(b2)) + fillCache(b2); + const { sine: asine, cosine: acosine } = cache.get(a2); + const { sine: bsine, cosine: bcosine } = cache.get(b2); + if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) { + if (acosine.isLessThan(bcosine)) + return 1; + if (acosine.isGreaterThan(bcosine)) + return -1; + return 0; + } + if (asine.isLessThan(0) && bsine.isLessThan(0)) { + if (acosine.isLessThan(bcosine)) + return -1; + if (acosine.isGreaterThan(bcosine)) + return 1; + return 0; + } + if (bsine.isLessThan(asine)) + return -1; + if (bsine.isGreaterThan(asine)) + return 1; + return 0; + }; + } + }; + + // node_modules/polyclip-ts/dist/segment.js + var segmentId = 0; + var Segment = class _Segment { + /* Warning: a reference to ringWindings input will be stored, + * and possibly will be later modified */ + constructor(leftSE, rightSE, rings, windings) { + __publicField(this, "id"); + __publicField(this, "leftSE"); + __publicField(this, "rightSE"); + __publicField(this, "rings"); + __publicField(this, "windings"); + __publicField(this, "ringOut"); + __publicField(this, "consumedBy"); + __publicField(this, "prev"); + __publicField(this, "_prevInResult"); + __publicField(this, "_beforeState"); + __publicField(this, "_afterState"); + __publicField(this, "_isInResult"); + this.id = ++segmentId; + this.leftSE = leftSE; + leftSE.segment = this; + leftSE.otherSE = rightSE; + this.rightSE = rightSE; + rightSE.segment = this; + rightSE.otherSE = leftSE; + this.rings = rings; + this.windings = windings; + } + /* This compare() function is for ordering segments in the sweep + * line tree, and does so according to the following criteria: + * + * Consider the vertical line that lies an infinestimal step to the + * right of the right-more of the two left endpoints of the input + * segments. Imagine slowly moving a point up from negative infinity + * in the increasing y direction. Which of the two segments will that + * point intersect first? That segment comes 'before' the other one. + * + * If neither segment would be intersected by such a line, (if one + * or more of the segments are vertical) then the line to be considered + * is directly on the right-more of the two left inputs. + */ + static compare(a2, b2) { + const alx = a2.leftSE.point.x; + const blx = b2.leftSE.point.x; + const arx = a2.rightSE.point.x; + const brx = b2.rightSE.point.x; + if (brx.isLessThan(alx)) + return 1; + if (arx.isLessThan(blx)) + return -1; + const aly = a2.leftSE.point.y; + const bly = b2.leftSE.point.y; + const ary = a2.rightSE.point.y; + const bry = b2.rightSE.point.y; + if (alx.isLessThan(blx)) { + if (bly.isLessThan(aly) && bly.isLessThan(ary)) + return 1; + if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary)) + return -1; + const aCmpBLeft = a2.comparePoint(b2.leftSE.point); + if (aCmpBLeft < 0) + return 1; + if (aCmpBLeft > 0) + return -1; + const bCmpARight = b2.comparePoint(a2.rightSE.point); + if (bCmpARight !== 0) + return bCmpARight; + return -1; } - } else { - stringID = canonicalID(id2); + if (alx.isGreaterThan(blx)) { + if (aly.isLessThan(bly) && aly.isLessThan(bry)) + return -1; + if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry)) + return 1; + const bCmpALeft = b2.comparePoint(a2.leftSE.point); + if (bCmpALeft !== 0) + return bCmpALeft; + const aCmpBRight = a2.comparePoint(b2.rightSE.point); + if (aCmpBRight < 0) + return 1; + if (aCmpBRight > 0) + return -1; + return 1; + } + if (aly.isLessThan(bly)) + return -1; + if (aly.isGreaterThan(bly)) + return 1; + if (arx.isLessThan(brx)) { + const bCmpARight = b2.comparePoint(a2.rightSE.point); + if (bCmpARight !== 0) + return bCmpARight; + } + if (arx.isGreaterThan(brx)) { + const aCmpBRight = a2.comparePoint(b2.rightSE.point); + if (aCmpBRight < 0) + return 1; + if (aCmpBRight > 0) + return -1; + } + if (!arx.eq(brx)) { + const ay = ary.minus(aly); + const ax = arx.minus(alx); + const by = bry.minus(bly); + const bx = brx.minus(blx); + if (ay.isGreaterThan(ax) && by.isLessThan(bx)) + return 1; + if (ay.isLessThan(ax) && by.isGreaterThan(bx)) + return -1; + } + if (arx.isGreaterThan(brx)) + return 1; + if (arx.isLessThan(brx)) + return -1; + if (ary.isLessThan(bry)) + return -1; + if (ary.isGreaterThan(bry)) + return 1; + if (a2.id < b2.id) + return -1; + if (a2.id > b2.id) + return 1; + return 0; } - return _featuresByCode[stringID] || null; - } - function smallestFeaturesForBbox(bbox2) { - return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]); - } - function smallestOrMatchingFeature(query) { - if (typeof query === "object") { - return smallestFeature(query); + static fromRing(pt1, pt2, ring) { + let leftPt, rightPt, winding; + const cmpPts = SweepEvent.comparePoints(pt1, pt2); + if (cmpPts < 0) { + leftPt = pt1; + rightPt = pt2; + winding = 1; + } else if (cmpPts > 0) { + leftPt = pt2; + rightPt = pt1; + winding = -1; + } else + throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]")); + const leftSE = new SweepEvent(leftPt, true); + const rightSE = new SweepEvent(rightPt, false); + return new _Segment(leftSE, rightSE, [ring], [winding]); + } + /* When a segment is split, the rightSE is replaced with a new sweep event */ + replaceRightSE(newRightSE) { + this.rightSE = newRightSE; + this.rightSE.segment = this; + this.rightSE.otherSE = this.leftSE; + this.leftSE.otherSE = this.rightSE; + } + bbox() { + const y12 = this.leftSE.point.y; + const y2 = this.rightSE.point.y; + return { + ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 }, + ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 } + }; } - return featureForID(query); - } - function feature(query, opts = defaultOpts) { - if (typeof query === "object") { - return featureForLoc(query, opts); + /* A vector from the left point to the right */ + vector() { + return { + x: this.rightSE.point.x.minus(this.leftSE.point.x), + y: this.rightSE.point.y.minus(this.leftSE.point.y) + }; } - return featureForID(query); - } - function iso1A2Code(query, opts = defaultOpts) { - opts.withProp = "iso1A2"; - const match = feature(query, opts); - if (!match) - return null; - return match.properties.iso1A2 || null; - } - function propertiesForQuery(query, property) { - const features = featuresContaining(query, false); - return features.map((feature22) => feature22.properties[property]).filter(Boolean); - } - function iso1A2Codes(query) { - return propertiesForQuery(query, "iso1A2"); - } - function featuresContaining(query, strict) { - let matchingFeatures; - if (Array.isArray(query) && query.length === 4) { - matchingFeatures = smallestFeaturesForBbox(query); - } else { - const smallestOrMatching = smallestOrMatchingFeature(query); - matchingFeatures = smallestOrMatching ? [smallestOrMatching] : []; + isAnEndpoint(pt2) { + 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); } - if (!matchingFeatures.length) - return []; - let returnFeatures; - if (!strict || typeof query === "object") { - returnFeatures = matchingFeatures.slice(); - } else { - returnFeatures = []; + /* Compare this segment with a point. + * + * A point P is considered to be colinear to a segment if there + * exists a distance D such that if we travel along the segment + * from one * endpoint towards the other a distance D, we find + * ourselves at point P. + * + * Return value indicates: + * + * 1: point lies above the segment (to the left of vertical) + * 0: point is colinear to segment + * -1: point lies below the segment (to the right of vertical) + */ + comparePoint(point2) { + return precision.orient(this.leftSE.point, point2, this.rightSE.point); } - for (const feature22 of matchingFeatures) { - const properties = feature22.properties; - for (const groupID of properties.groups) { - const groupFeature = _featuresByCode[groupID]; - if (returnFeatures.indexOf(groupFeature) === -1) { - returnFeatures.push(groupFeature); + /** + * Given another segment, returns the first non-trivial intersection + * between the two segments (in terms of sweep line ordering), if it exists. + * + * A 'non-trivial' intersection is one that will cause one or both of the + * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection: + * + * * endpoint of segA with endpoint of segB --> trivial + * * endpoint of segA with point along segB --> non-trivial + * * endpoint of segB with point along segA --> non-trivial + * * point along segA with point along segB --> non-trivial + * + * If no non-trivial intersection exists, return null + * Else, return null. + */ + getIntersection(other) { + const tBbox = this.bbox(); + const oBbox = other.bbox(); + const bboxOverlap = getBboxOverlap(tBbox, oBbox); + if (bboxOverlap === null) + return null; + const tlp = this.leftSE.point; + const trp = this.rightSE.point; + const olp = other.leftSE.point; + const orp = other.rightSE.point; + const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0; + const touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0; + const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0; + const touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0; + if (touchesThisLSE && touchesOtherLSE) { + if (touchesThisRSE && !touchesOtherRSE) + return trp; + if (!touchesThisRSE && touchesOtherRSE) + return orp; + return null; + } + if (touchesThisLSE) { + if (touchesOtherRSE) { + if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y)) + return null; + } + return tlp; + } + if (touchesOtherLSE) { + if (touchesThisRSE) { + if (trp.x.eq(olp.x) && trp.y.eq(olp.y)) + return null; } + return olp; } + if (touchesThisRSE && touchesOtherRSE) + return null; + if (touchesThisRSE) + return trp; + if (touchesOtherRSE) + return orp; + const pt2 = intersection(tlp, this.vector(), olp, other.vector()); + if (pt2 === null) + return null; + if (!isInBbox(bboxOverlap, pt2)) + return null; + return precision.snap(pt2); } - return returnFeatures; - } - function featuresIn(id2, strict) { - const feature22 = featureForID(id2); - if (!feature22) - return []; - let features = []; - if (!strict) { - features.push(feature22); + /** + * Split the given segment into multiple segments on the given points. + * * Each existing segment will retain its leftSE and a new rightSE will be + * generated for it. + * * A new segment will be generated which will adopt the original segment's + * rightSE, and a new leftSE will be generated for it. + * * If there are more than two points given to split on, new segments + * in the middle will be generated with new leftSE and rightSE's. + * * An array of the newly generated SweepEvents will be returned. + * + * Warning: input array of points is modified + */ + split(point2) { + const newEvents = []; + const alreadyLinked = point2.events !== void 0; + const newLeftSE = new SweepEvent(point2, true); + const newRightSE = new SweepEvent(point2, false); + const oldRightSE = this.rightSE; + this.replaceRightSE(newRightSE); + newEvents.push(newRightSE); + newEvents.push(newLeftSE); + const newSeg = new _Segment(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice()); + if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) { + newSeg.swapEvents(); + } + if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) { + this.swapEvents(); + } + if (alreadyLinked) { + newLeftSE.checkForConsuming(); + newRightSE.checkForConsuming(); + } + return newEvents; + } + /* Swap which event is left and right */ + swapEvents() { + const tmpEvt = this.rightSE; + this.rightSE = this.leftSE; + this.leftSE = tmpEvt; + this.leftSE.isLeft = true; + this.rightSE.isLeft = false; + for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) { + this.windings[i3] *= -1; + } + } + /* Consume another segment. We take their rings under our wing + * and mark them as consumed. Use for perfectly overlapping segments */ + consume(other) { + let consumer = this; + let consumee = other; + while (consumer.consumedBy) + consumer = consumer.consumedBy; + while (consumee.consumedBy) + consumee = consumee.consumedBy; + const cmp = _Segment.compare(consumer, consumee); + if (cmp === 0) + return; + if (cmp > 0) { + const tmp = consumer; + consumer = consumee; + consumee = tmp; + } + if (consumer.prev === consumee) { + const tmp = consumer; + consumer = consumee; + consumee = tmp; + } + for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) { + const ring = consumee.rings[i3]; + const winding = consumee.windings[i3]; + const index = consumer.rings.indexOf(ring); + if (index === -1) { + consumer.rings.push(ring); + consumer.windings.push(winding); + } else + consumer.windings[index] += winding; + } + consumee.rings = null; + consumee.windings = null; + consumee.consumedBy = consumer; + consumee.leftSE.consumedBy = consumer.leftSE; + consumee.rightSE.consumedBy = consumer.rightSE; + } + /* The first segment previous segment chain that is in the result */ + prevInResult() { + if (this._prevInResult !== void 0) + return this._prevInResult; + if (!this.prev) + this._prevInResult = null; + else if (this.prev.isInResult()) + this._prevInResult = this.prev; + else + this._prevInResult = this.prev.prevInResult(); + return this._prevInResult; + } + beforeState() { + if (this._beforeState !== void 0) + return this._beforeState; + if (!this.prev) + this._beforeState = { + rings: [], + windings: [], + multiPolys: [] + }; + else { + const seg = this.prev.consumedBy || this.prev; + this._beforeState = seg.afterState(); + } + return this._beforeState; + } + afterState() { + if (this._afterState !== void 0) + return this._afterState; + const beforeState = this.beforeState(); + this._afterState = { + rings: beforeState.rings.slice(0), + windings: beforeState.windings.slice(0), + multiPolys: [] + }; + const ringsAfter = this._afterState.rings; + const windingsAfter = this._afterState.windings; + const mpsAfter = this._afterState.multiPolys; + for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) { + const ring = this.rings[i3]; + const winding = this.windings[i3]; + const index = ringsAfter.indexOf(ring); + if (index === -1) { + ringsAfter.push(ring); + windingsAfter.push(winding); + } else + windingsAfter[index] += winding; + } + const polysAfter = []; + const polysExclude = []; + for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) { + if (windingsAfter[i3] === 0) + continue; + const ring = ringsAfter[i3]; + const poly = ring.poly; + if (polysExclude.indexOf(poly) !== -1) + continue; + if (ring.isExterior) + polysAfter.push(poly); + else { + if (polysExclude.indexOf(poly) === -1) + polysExclude.push(poly); + const index = polysAfter.indexOf(ring.poly); + if (index !== -1) + polysAfter.splice(index, 1); + } + } + for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) { + const mp = polysAfter[i3].multiPoly; + if (mpsAfter.indexOf(mp) === -1) + mpsAfter.push(mp); + } + return this._afterState; + } + /* Is this segment part of the final result? */ + isInResult() { + if (this.consumedBy) + return false; + if (this._isInResult !== void 0) + return this._isInResult; + const mpsBefore = this.beforeState().multiPolys; + const mpsAfter = this.afterState().multiPolys; + switch (operation_default.type) { + case "union": { + const noBefores = mpsBefore.length === 0; + const noAfters = mpsAfter.length === 0; + this._isInResult = noBefores !== noAfters; + break; + } + case "intersection": { + let least; + let most; + if (mpsBefore.length < mpsAfter.length) { + least = mpsBefore.length; + most = mpsAfter.length; + } else { + least = mpsAfter.length; + most = mpsBefore.length; + } + this._isInResult = most === operation_default.numMultiPolys && least < most; + break; + } + case "xor": { + const diff = Math.abs(mpsBefore.length - mpsAfter.length); + this._isInResult = diff % 2 === 1; + break; + } + case "difference": { + const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject; + this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter); + break; + } + } + return this._isInResult; } - const properties = feature22.properties; - for (const memberID of properties.members || []) { - features.push(_featuresByCode[memberID]); + }; + + // node_modules/polyclip-ts/dist/geom-in.js + var RingIn = class { + constructor(geomRing, poly, isExterior) { + __publicField(this, "poly"); + __publicField(this, "isExterior"); + __publicField(this, "segments"); + __publicField(this, "bbox"); + if (!Array.isArray(geomRing) || geomRing.length === 0) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + this.poly = poly; + this.isExterior = isExterior; + this.segments = []; + if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) }); + this.bbox = { + ll: { x: firstPoint.x, y: firstPoint.y }, + ur: { x: firstPoint.x, y: firstPoint.y } + }; + let prevPoint = firstPoint; + for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) { + if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + const point2 = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) }); + if (point2.x.eq(prevPoint.x) && point2.y.eq(prevPoint.y)) + continue; + this.segments.push(Segment.fromRing(prevPoint, point2, this)); + if (point2.x.isLessThan(this.bbox.ll.x)) + this.bbox.ll.x = point2.x; + if (point2.y.isLessThan(this.bbox.ll.y)) + this.bbox.ll.y = point2.y; + if (point2.x.isGreaterThan(this.bbox.ur.x)) + this.bbox.ur.x = point2.x; + if (point2.y.isGreaterThan(this.bbox.ur.y)) + this.bbox.ur.y = point2.y; + prevPoint = point2; + } + if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) { + this.segments.push(Segment.fromRing(prevPoint, firstPoint, this)); + } + } + getSweepEvents() { + const sweepEvents = []; + for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) { + const segment = this.segments[i3]; + sweepEvents.push(segment.leftSE); + sweepEvents.push(segment.rightSE); + } + return sweepEvents; } - return features; - } - function aggregateFeature(id2) { - var _a; - const features = featuresIn(id2, false); - if (features.length === 0) - return null; - let aggregateCoordinates = []; - for (const feature22 of features) { - if (((_a = feature22.geometry) == null ? void 0 : _a.type) === "MultiPolygon" && feature22.geometry.coordinates) { - aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates); + }; + var PolyIn = class { + constructor(geomPoly, multiPoly) { + __publicField(this, "multiPoly"); + __publicField(this, "exteriorRing"); + __publicField(this, "interiorRings"); + __publicField(this, "bbox"); + if (!Array.isArray(geomPoly)) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + this.exteriorRing = new RingIn(geomPoly[0], this, true); + this.bbox = { + ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y }, + ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y } + }; + this.interiorRings = []; + for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) { + const ring = new RingIn(geomPoly[i3], this, false); + if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x)) + this.bbox.ll.x = ring.bbox.ll.x; + if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y)) + this.bbox.ll.y = ring.bbox.ll.y; + if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) + this.bbox.ur.x = ring.bbox.ur.x; + if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) + this.bbox.ur.y = ring.bbox.ur.y; + this.interiorRings.push(ring); + } + this.multiPoly = multiPoly; + } + getSweepEvents() { + const sweepEvents = this.exteriorRing.getSweepEvents(); + for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { + const ringSweepEvents = this.interiorRings[i3].getSweepEvents(); + for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) { + sweepEvents.push(ringSweepEvents[j2]); + } + } + return sweepEvents; + } + }; + var MultiPolyIn = class { + constructor(geom, isSubject) { + __publicField(this, "isSubject"); + __publicField(this, "polys"); + __publicField(this, "bbox"); + if (!Array.isArray(geom)) { + throw new Error("Input geometry is not a valid Polygon or MultiPolygon"); + } + try { + if (typeof geom[0][0][0] === "number") + geom = [geom]; + } catch (ex) { } + this.polys = []; + this.bbox = { + ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) }, + ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) } + }; + for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) { + const poly = new PolyIn(geom[i3], this); + if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x)) + this.bbox.ll.x = poly.bbox.ll.x; + if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y)) + this.bbox.ll.y = poly.bbox.ll.y; + if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) + this.bbox.ur.x = poly.bbox.ur.x; + if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) + this.bbox.ur.y = poly.bbox.ur.y; + this.polys.push(poly); + } + this.isSubject = isSubject; + } + getSweepEvents() { + const sweepEvents = []; + for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { + const polySweepEvents = this.polys[i3].getSweepEvents(); + for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) { + sweepEvents.push(polySweepEvents[j2]); + } + } + return sweepEvents; } - return { - type: "Feature", - properties: features[0].properties, - geometry: { - type: "MultiPolygon", - coordinates: aggregateCoordinates + }; + + // node_modules/polyclip-ts/dist/geom-out.js + var RingOut = class _RingOut { + constructor(events) { + __publicField(this, "events"); + __publicField(this, "poly"); + __publicField(this, "_isExteriorRing"); + __publicField(this, "_enclosingRing"); + this.events = events; + for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) { + events[i3].segment.ringOut = this; + } + this.poly = null; + } + /* Given the segments from the sweep line pass, compute & return a series + * of closed rings from all the segments marked to be part of the result */ + static factory(allSegments) { + const ringsOut = []; + for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) { + const segment = allSegments[i3]; + if (!segment.isInResult() || segment.ringOut) + continue; + let prevEvent = null; + let event = segment.leftSE; + let nextEvent = segment.rightSE; + const events = [event]; + const startingPoint = event.point; + const intersectionLEs = []; + while (true) { + prevEvent = event; + event = nextEvent; + events.push(event); + if (event.point === startingPoint) + break; + while (true) { + const availableLEs = event.getAvailableLinkedEvents(); + if (availableLEs.length === 0) { + const firstPt = events[0].point; + const lastPt = events[events.length - 1].point; + 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, "].")); + } + if (availableLEs.length === 1) { + nextEvent = availableLEs[0].otherSE; + break; + } + let indexLE = null; + for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) { + if (intersectionLEs[j2].point === event.point) { + indexLE = j2; + break; + } + } + if (indexLE !== null) { + const intersectionLE = intersectionLEs.splice(indexLE)[0]; + const ringEvents = events.splice(intersectionLE.index); + ringEvents.unshift(ringEvents[0].otherSE); + ringsOut.push(new _RingOut(ringEvents.reverse())); + continue; + } + intersectionLEs.push({ + index: events.length, + point: event.point + }); + const comparator = event.getLeftmostComparator(prevEvent); + nextEvent = availableLEs.sort(comparator)[0].otherSE; + break; + } + } + ringsOut.push(new _RingOut(events)); } - }; - } - function roadSpeedUnit(query) { - const feature22 = smallestOrMatchingFeature(query); - return feature22 && feature22.properties.roadSpeedUnit || null; - } - function roadHeightUnit(query) { - const feature22 = smallestOrMatchingFeature(query); - return feature22 && feature22.properties.roadHeightUnit || null; - } + return ringsOut; + } + getGeom() { + let prevPt = this.events[0].point; + const points = [prevPt]; + for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) { + const pt3 = this.events[i3].point; + const nextPt2 = this.events[i3 + 1].point; + if (precision.orient(pt3, prevPt, nextPt2) === 0) + continue; + points.push(pt3); + prevPt = pt3; + } + if (points.length === 1) + return null; + const pt2 = points[0]; + const nextPt = points[1]; + if (precision.orient(pt2, prevPt, nextPt) === 0) + points.shift(); + points.push(points[0]); + const step = this.isExteriorRing() ? 1 : -1; + const iStart = this.isExteriorRing() ? 0 : points.length - 1; + const iEnd = this.isExteriorRing() ? points.length : -1; + const orderedPoints = []; + for (let i3 = iStart; i3 != iEnd; i3 += step) + orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]); + return orderedPoints; + } + isExteriorRing() { + if (this._isExteriorRing === void 0) { + const enclosing = this.enclosingRing(); + this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true; + } + return this._isExteriorRing; + } + enclosingRing() { + if (this._enclosingRing === void 0) { + this._enclosingRing = this._calcEnclosingRing(); + } + return this._enclosingRing; + } + /* Returns the ring that encloses this one, if any */ + _calcEnclosingRing() { + var _a2, _b; + let leftMostEvt = this.events[0]; + for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) { + const evt = this.events[i3]; + if (SweepEvent.compare(leftMostEvt, evt) > 0) + leftMostEvt = evt; + } + let prevSeg = leftMostEvt.segment.prevInResult(); + let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; + while (true) { + if (!prevSeg) + return null; + if (!prevPrevSeg) + return prevSeg.ringOut; + if (prevPrevSeg.ringOut !== prevSeg.ringOut) { + if (((_a2 = prevPrevSeg.ringOut) == null ? void 0 : _a2.enclosingRing()) !== prevSeg.ringOut) { + return prevSeg.ringOut; + } else + return (_b = prevSeg.ringOut) == null ? void 0 : _b.enclosingRing(); + } + prevSeg = prevPrevSeg.prevInResult(); + prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null; + } + } + }; + var PolyOut = class { + constructor(exteriorRing) { + __publicField(this, "exteriorRing"); + __publicField(this, "interiorRings"); + this.exteriorRing = exteriorRing; + exteriorRing.poly = this; + this.interiorRings = []; + } + addInterior(ring) { + this.interiorRings.push(ring); + ring.poly = this; + } + getGeom() { + const geom = [this.exteriorRing.getGeom()]; + if (geom[0] === null) + return null; + for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) { + const ringGeom = this.interiorRings[i3].getGeom(); + if (ringGeom === null) + continue; + geom.push(ringGeom); + } + return geom; + } + }; + var MultiPolyOut = class { + constructor(rings) { + __publicField(this, "rings"); + __publicField(this, "polys"); + this.rings = rings; + this.polys = this._composePolys(rings); + } + getGeom() { + const geom = []; + for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) { + const polyGeom = this.polys[i3].getGeom(); + if (polyGeom === null) + continue; + geom.push(polyGeom); + } + return geom; + } + _composePolys(rings) { + var _a2; + const polys = []; + for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) { + const ring = rings[i3]; + if (ring.poly) + continue; + if (ring.isExteriorRing()) + polys.push(new PolyOut(ring)); + else { + const enclosingRing = ring.enclosingRing(); + if (!(enclosingRing == null ? void 0 : enclosingRing.poly)) + polys.push(new PolyOut(enclosingRing)); + (_a2 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a2.addInterior(ring); + } + } + return polys; + } + }; + + // node_modules/polyclip-ts/dist/sweep-line.js + var SweepLine = class { + constructor(queue, comparator = Segment.compare) { + __publicField(this, "queue"); + __publicField(this, "tree"); + __publicField(this, "segments"); + this.queue = queue; + this.tree = new SplayTreeSet(comparator); + this.segments = []; + } + process(event) { + const segment = event.segment; + const newEvents = []; + if (event.consumedBy) { + if (event.isLeft) + this.queue.delete(event.otherSE); + else + this.tree.delete(segment); + return newEvents; + } + if (event.isLeft) + this.tree.add(segment); + let prevSeg = segment; + let nextSeg = segment; + do { + prevSeg = this.tree.lastBefore(prevSeg); + } while (prevSeg != null && prevSeg.consumedBy != void 0); + do { + nextSeg = this.tree.firstAfter(nextSeg); + } while (nextSeg != null && nextSeg.consumedBy != void 0); + if (event.isLeft) { + let prevMySplitter = null; + if (prevSeg) { + const prevInter = prevSeg.getIntersection(segment); + if (prevInter !== null) { + if (!segment.isAnEndpoint(prevInter)) + prevMySplitter = prevInter; + if (!prevSeg.isAnEndpoint(prevInter)) { + const newEventsFromSplit = this._splitSafely(prevSeg, prevInter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + } + } + let nextMySplitter = null; + if (nextSeg) { + const nextInter = nextSeg.getIntersection(segment); + if (nextInter !== null) { + if (!segment.isAnEndpoint(nextInter)) + nextMySplitter = nextInter; + if (!nextSeg.isAnEndpoint(nextInter)) { + const newEventsFromSplit = this._splitSafely(nextSeg, nextInter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + } + } + if (prevMySplitter !== null || nextMySplitter !== null) { + let mySplitter = null; + if (prevMySplitter === null) + mySplitter = nextMySplitter; + else if (nextMySplitter === null) + mySplitter = prevMySplitter; + else { + const cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter); + mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter; + } + this.queue.delete(segment.rightSE); + newEvents.push(segment.rightSE); + const newEventsFromSplit = segment.split(mySplitter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + if (newEvents.length > 0) { + this.tree.delete(segment); + newEvents.push(event); + } else { + this.segments.push(segment); + segment.prev = prevSeg; + } + } else { + if (prevSeg && nextSeg) { + const inter = prevSeg.getIntersection(nextSeg); + if (inter !== null) { + if (!prevSeg.isAnEndpoint(inter)) { + const newEventsFromSplit = this._splitSafely(prevSeg, inter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + if (!nextSeg.isAnEndpoint(inter)) { + const newEventsFromSplit = this._splitSafely(nextSeg, inter); + for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) { + newEvents.push(newEventsFromSplit[i3]); + } + } + } + } + this.tree.delete(segment); + } + return newEvents; + } + /* Safely split a segment that is currently in the datastructures + * IE - a segment other than the one that is currently being processed. */ + _splitSafely(seg, pt2) { + this.tree.delete(seg); + const rightSE = seg.rightSE; + this.queue.delete(rightSE); + const newEvents = seg.split(pt2); + newEvents.push(rightSE); + if (seg.consumedBy === void 0) + this.tree.add(seg); + return newEvents; + } + }; + + // node_modules/polyclip-ts/dist/operation.js + var Operation = class { + constructor() { + __publicField(this, "type"); + __publicField(this, "numMultiPolys"); + } + run(type2, geom, moreGeoms) { + operation.type = type2; + const multipolys = [new MultiPolyIn(geom, true)]; + for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) { + multipolys.push(new MultiPolyIn(moreGeoms[i3], false)); + } + operation.numMultiPolys = multipolys.length; + if (operation.type === "difference") { + const subject = multipolys[0]; + let i3 = 1; + while (i3 < multipolys.length) { + if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null) + i3++; + else + multipolys.splice(i3, 1); + } + } + if (operation.type === "intersection") { + for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) { + const mpA = multipolys[i3]; + for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) { + if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null) + return []; + } + } + } + const queue = new SplayTreeSet(SweepEvent.compare); + for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) { + const sweepEvents = multipolys[i3].getSweepEvents(); + for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) { + queue.add(sweepEvents[j2]); + } + } + const sweepLine = new SweepLine(queue); + let evt = null; + if (queue.size != 0) { + evt = queue.first(); + queue.delete(evt); + } + while (evt) { + const newEvents = sweepLine.process(evt); + for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) { + const evt2 = newEvents[i3]; + if (evt2.consumedBy === void 0) + queue.add(evt2); + } + if (queue.size != 0) { + evt = queue.first(); + queue.delete(evt); + } else { + evt = null; + } + } + precision.reset(); + const ringsOut = RingOut.factory(sweepLine.segments); + const result = new MultiPolyOut(ringsOut); + return result.getGeom(); + } + }; + var operation = new Operation(); + var operation_default = operation; + + // node_modules/polyclip-ts/dist/index.js + var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms); + var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms); + var setPrecision = precision.set; // node_modules/@rapideditor/location-conflation/index.mjs var import_geojson_area = __toESM(require_geojson_area(), 1); var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1); - var import_polygon_clipping = __toESM(require_polygon_clipping_umd(), 1); var import_geojson_precision = __toESM(require_geojson_precision(), 1); var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1); - var location_conflation_default = class { + var LocationConflation = class { // constructor // // `fc` Optional FeatureCollection of known features @@ -23983,7 +26570,7 @@ // } constructor(fc) { this._cache = {}; - this._strict = true; + this.strict = true; if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) { fc.features.forEach((feature3) => { feature3.properties = feature3.properties || {}; @@ -24045,7 +26632,7 @@ return { type: "countrycoder", location, id: id2 }; } } - if (this._strict) { + if (this.strict) { throw new Error('validateLocation: Invalid location: "'.concat(location, '".')); } else { return null; @@ -24106,7 +26693,7 @@ this._cache[id2] = feature3; return Object.assign(valid, { feature: feature3 }); } - if (this._strict) { + if (this.strict) { throw new Error("resolveLocation: Couldn't resolve location \"".concat(location, '".')); } else { return null; @@ -24135,7 +26722,7 @@ let include = (locationSet.include || []).map(validator).filter(Boolean); let exclude = (locationSet.exclude || []).map(validator).filter(Boolean); if (!include.length) { - if (this._strict) { + if (this.strict) { throw new Error("validateLocationSet: LocationSet includes nothing."); } else { locationSet.include = ["Q2"]; @@ -24192,21 +26779,6 @@ this._cache[id2] = resultGeoJSON; return Object.assign(valid, { feature: resultGeoJSON }); } - // strict - // - strict(val) { - if (val === void 0) { - return this._strict; - } else { - this._strict = val; - return this; - } - } - // cache - // convenience method to access the internal cache - cache() { - return this._cache; - } // stringify // convenience method to prettyStringify the given object stringify(obj, options2) { @@ -24216,7 +26788,7 @@ function _clip(features, which) { if (!Array.isArray(features) || !features.length) return null; - const fn = { UNION: import_polygon_clipping.default.union, DIFFERENCE: import_polygon_clipping.default.difference }[which]; + const fn = { UNION: union, DIFFERENCE: difference }[which]; const args = features.map((feature3) => feature3.geometry.coordinates); const coords = fn.apply(null, args); return { @@ -24248,7 +26820,7 @@ // modules/core/LocationManager.js var import_which_polygon2 = __toESM(require_which_polygon()); var import_geojson_area2 = __toESM(require_geojson_area()); - var _loco = new location_conflation_default(); + var _loco = new LocationConflation(); var LocationManager = class { /** * @constructor @@ -24321,7 +26893,7 @@ s2.add(locationSetID); }); this._knownLocationSets.set(locationSetID, area); - } catch (err) { + } catch { obj.locationSet = { include: ["Q2"] }; obj.locationSetID = "+[Q2]"; } @@ -24350,7 +26922,7 @@ geojson.id = locationSetID; geojson.properties.id = locationSetID; this._resolved.set(locationSetID, geojson); - } catch (err) { + } catch { obj.locationSet = { include: ["Q2"] }; obj.locationSetID = "+[Q2]"; } @@ -24436,7 +27008,7 @@ let locationSetID; try { locationSetID = _loco.validateLocationSet(locationSet).id; - } catch (err) { + } catch { locationSetID = "+[Q2]"; } return locationSetID; @@ -24537,7 +27109,7 @@ var nativeObjectToString = objectProto.toString; var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0; function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; + var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag]; try { value[symToStringTag] = void 0; var unmasked = true; @@ -24546,7 +27118,7 @@ var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { - value[symToStringTag] = tag; + value[symToStringTag] = tag2; } else { delete value[symToStringTag]; } @@ -24590,8 +27162,8 @@ // node_modules/lodash-es/_arrayMap.js function arrayMap(array2, iteratee) { - var index = -1, length = array2 == null ? 0 : array2.length, result = Array(length); - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2); + while (++index < length2) { result[index] = iteratee(array2[index], index, array2); } return result; @@ -24680,8 +27252,8 @@ if (!isObject_default(value)) { return false; } - var tag = baseGetTag_default(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + var tag2 = baseGetTag_default(value); + return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag; } var isFunction_default = isFunction; @@ -24754,12 +27326,12 @@ var WeakMap_default = WeakMap; // node_modules/lodash-es/_isIndex.js - var MAX_SAFE_INTEGER = 9007199254740991; + var MAX_SAFE_INTEGER2 = 9007199254740991; var reIsUint = /^(?:0|[1-9]\d*)$/; - function isIndex(value, length) { + function isIndex(value, length2) { var type2 = typeof value; - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); + length2 = length2 == null ? MAX_SAFE_INTEGER2 : length2; + return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2); } var isIndex_default = isIndex; @@ -24770,9 +27342,9 @@ var eq_default = eq; // node_modules/lodash-es/isLength.js - var MAX_SAFE_INTEGER2 = 9007199254740991; + var MAX_SAFE_INTEGER3 = 9007199254740991; function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2; + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER3; } var isLength_default = isLength; @@ -24811,7 +27383,7 @@ var objectProto5 = Object.prototype; var hasOwnProperty3 = objectProto5.hasOwnProperty; var propertyIsEnumerable = objectProto5.propertyIsEnumerable; - var isArguments = baseIsArguments_default(function() { + var isArguments = baseIsArguments_default(/* @__PURE__ */ function() { return arguments; }()) ? baseIsArguments_default : function(value) { return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); @@ -24900,13 +27472,13 @@ var objectProto6 = Object.prototype; var hasOwnProperty4 = objectProto6.hasOwnProperty; function arrayLikeKeys(value, inherited) { - 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) : [], length = result.length; + 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; for (var key in value) { if ((inherited || hasOwnProperty4.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. - isIndex_default(key, length)))) { + isIndex_default(key, length2)))) { result.push(key); } } @@ -25003,9 +27575,9 @@ // node_modules/lodash-es/_Hash.js function Hash(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -25026,10 +27598,10 @@ // node_modules/lodash-es/_assocIndexOf.js function assocIndexOf(array2, key) { - var length = array2.length; - while (length--) { - if (eq_default(array2[length][0], key)) { - return length; + var length2 = array2.length; + while (length2--) { + if (eq_default(array2[length2][0], key)) { + return length2; } } return -1; @@ -25083,9 +27655,9 @@ // node_modules/lodash-es/_ListCache.js function ListCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -25157,9 +27729,9 @@ // node_modules/lodash-es/_MapCache.js function MapCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; + var index = -1, length2 = entries == null ? 0 : entries.length; this.clear(); - while (++index < length) { + while (++index < length2) { var entry = entries[index]; this.set(entry[0], entry[1]); } @@ -25179,8 +27751,8 @@ // node_modules/lodash-es/_arrayPush.js function arrayPush(array2, values) { - var index = -1, length = values.length, offset = array2.length; - while (++index < length) { + var index = -1, length2 = values.length, offset = array2.length; + while (++index < length2) { array2[offset + index] = values[index]; } return array2; @@ -25255,8 +27827,8 @@ // node_modules/lodash-es/_arrayFilter.js function arrayFilter(array2, predicate) { - var index = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = []; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = []; + while (++index < length2) { var value = array2[index]; if (predicate(value, index, array2)) { result[resIndex++] = value; @@ -25367,9 +27939,9 @@ // node_modules/lodash-es/_SetCache.js function SetCache(values) { - var index = -1, length = values == null ? 0 : values.length; + var index = -1, length2 = values == null ? 0 : values.length; this.__data__ = new MapCache_default(); - while (++index < length) { + while (++index < length2) { this.add(values[index]); } } @@ -25379,8 +27951,8 @@ // node_modules/lodash-es/_arraySome.js function arraySome(array2, predicate) { - var index = -1, length = array2 == null ? 0 : array2.length; - while (++index < length) { + var index = -1, length2 = array2 == null ? 0 : array2.length; + while (++index < length2) { if (predicate(array2[index], index, array2)) { return true; } @@ -25454,9 +28026,9 @@ var mapToArray_default = mapToArray; // node_modules/lodash-es/_setToArray.js - function setToArray(set3) { - var index = -1, result = Array(set3.size); - set3.forEach(function(value) { + function setToArray(set4) { + var index = -1, result = Array(set4.size); + set4.forEach(function(value) { result[++index] = value; }); return result; @@ -25479,8 +28051,8 @@ var dataViewTag3 = "[object DataView]"; var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0; var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0; - function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { + function equalByTag(object, other, tag2, bitmask, customizer, equalFunc, stack) { + switch (tag2) { case dataViewTag3: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; @@ -25786,11 +28358,11 @@ // node_modules/lodash-es/unescape.js var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g; var reHasEscapedHtml = RegExp(reEscapedHtml.source); - function unescape2(string) { + function unescape(string) { string = toString_default(string); return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string; } - var unescape_default = unescape2; + var unescape_default = unescape; // modules/util/detect.js var _detected; @@ -25879,9 +28451,9 @@ // modules/util/aes.js var import_aes_js = __toESM(require_aes_js()); var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208]; - function utilAesEncrypt(text2, key) { + function utilAesEncrypt(text, key) { key = key || DEFAULT_128; - const textBytes = import_aes_js.default.utils.utf8.toBytes(text2); + const textBytes = import_aes_js.default.utils.utf8.toBytes(text); const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key); const encryptedBytes = aesCtr.encrypt(textBytes); const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes); @@ -25892,8 +28464,8 @@ const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex); const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key); const decryptedBytes = aesCtr.decrypt(encryptedBytes); - const text2 = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes); - return text2; + const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes); + return text; } // modules/util/clean_tags.js @@ -25913,7 +28485,7 @@ return /_hours|_times|:conditional$/.test(k4); } function skip(k4) { - return /^(description|note|fixme)$/.test(k4); + return /^(description|note|fixme|inscription)$/.test(k4); } if (skip(k3)) return v3; @@ -26094,16 +28666,16 @@ } _keybindings[id2] = binding; var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g); - for (var j3 = 0; j3 < matches.length; j3++) { - if (matches[j3] === "++") - matches[j3] = "+"; - if (matches[j3] in utilKeybinding.modifierCodes) { - var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j3]]]; + for (var j2 = 0; j2 < matches.length; j2++) { + if (matches[j2] === "++") + matches[j2] = "+"; + if (matches[j2] in utilKeybinding.modifierCodes) { + var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]]; binding.event.modifiers[prop] = true; } else { - binding.event.key = utilKeybinding.keys[matches[j3]] || matches[j3]; - if (matches[j3] in utilKeybinding.keyCodes) { - binding.event.keyCode = utilKeybinding.keyCodes[matches[j3]]; + binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2]; + if (matches[j2] in utilKeybinding.keyCodes) { + binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]]; } } } @@ -26235,7 +28807,7 @@ "open-bracket": "[", // Back slash, or \ "back-slash": "\\", - // Close backet, or ] + // Close bracket, or ] "close-bracket": "]", // Apostrophe, or Quote, or ' quote: "'", @@ -26392,7 +28964,7 @@ // Back slash, or \ "\\": 220, "back-slash": 220, - // Close backet, or ] + // Close bracket, or ] "]": 221, "close-bracket": 221, // Apostrophe, or Quote, or ' @@ -26527,9 +29099,9 @@ var tiles = []; for (var i3 = 0; i3 < rows.length; i3++) { var y2 = rows[i3]; - for (var j3 = 0; j3 < cols.length; j3++) { - var x2 = cols[j3]; - if (i3 >= _margin && i3 <= rows.length - _margin && j3 >= _margin && j3 <= cols.length - _margin) { + for (var j2 = 0; j2 < cols.length; j2++) { + var x2 = cols[j2]; + if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) { tiles.unshift([x2, y2, z0]); } else { tiles.push([x2, y2, z0]); @@ -26640,6 +29212,176 @@ }); } + // modules/util/units.js + var OSM_PRECISION = 7; + function displayLength(m2, isImperial) { + var d2 = m2 * (isImperial ? 3.28084 : 1); + var unit2; + if (isImperial) { + if (d2 >= 5280) { + d2 /= 5280; + unit2 = "miles"; + } else { + unit2 = "feet"; + } + } else { + if (d2 >= 1e3) { + d2 /= 1e3; + unit2 = "kilometers"; + } else { + unit2 = "meters"; + } + } + return _t("units." + unit2, { + quantity: d2.toLocaleString(_mainLocalizer.localeCode(), { + maximumSignificantDigits: 4 + }) + }); + } + function displayArea(m2, isImperial) { + var locale2 = _mainLocalizer.localeCode(); + var d2 = m2 * (isImperial ? 10.7639111056 : 1); + var d1, d22, area; + var unit1 = ""; + var unit2 = ""; + if (isImperial) { + if (d2 >= 6969600) { + d1 = d2 / 27878400; + unit1 = "square_miles"; + } else { + d1 = d2; + unit1 = "square_feet"; + } + if (d2 > 4356 && d2 < 4356e4) { + d22 = d2 / 43560; + unit2 = "acres"; + } + } else { + if (d2 >= 25e4) { + d1 = d2 / 1e6; + unit1 = "square_kilometers"; + } else { + d1 = d2; + unit1 = "square_meters"; + } + if (d2 > 1e3 && d2 < 1e7) { + d22 = d2 / 1e4; + unit2 = "hectares"; + } + } + area = _t("units." + unit1, { + quantity: d1.toLocaleString(locale2, { + maximumSignificantDigits: 4 + }) + }); + if (d22) { + return _t("units.area_pair", { + area1: area, + area2: _t("units." + unit2, { + quantity: d22.toLocaleString(locale2, { + maximumSignificantDigits: 2 + }) + }) + }); + } else { + return area; + } + } + function wrap(x2, min3, max3) { + var d2 = max3 - min3; + return ((x2 - min3) % d2 + d2) % d2 + min3; + } + function clamp(x2, min3, max3) { + return Math.max(min3, Math.min(x2, max3)); + } + function roundToDecimal(target, decimalPlace) { + target = Number(target); + decimalPlace = Number(decimalPlace); + const factor = Math.pow(10, decimalPlace); + return Math.round(target * factor) / factor; + } + function displayCoordinate(deg, pos, neg) { + var displayCoordinate2; + var locale2 = _mainLocalizer.localeCode(); + var degreesFloor = Math.floor(Math.abs(deg)); + var min3 = (Math.abs(deg) - degreesFloor) * 60; + var minFloor = Math.floor(min3); + var sec = (min3 - minFloor) * 60; + var fix = roundToDecimal(sec, 8); + var secRounded = roundToDecimal(fix, 0); + if (secRounded === 60) { + secRounded = 0; + minFloor += 1; + if (minFloor === 60) { + minFloor = 0; + degreesFloor += 1; + } + } + displayCoordinate2 = _t("units.arcdegrees", { + quantity: degreesFloor.toLocaleString(locale2) + }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", { + quantity: minFloor.toLocaleString(locale2) + }) : "") + (secRounded !== 0 ? _t("units.arcseconds", { + quantity: secRounded.toLocaleString(locale2) + }) : ""); + if (deg === 0) { + return displayCoordinate2; + } else { + return _t("units.coordinate", { + coordinate: displayCoordinate2, + direction: _t("units." + (deg > 0 ? pos : neg)) + }); + } + } + function dmsCoordinatePair(coord2) { + return _t("units.coordinate_pair", { + latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"), + longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west") + }); + } + function decimalCoordinatePair(coord2) { + return _t("units.coordinate_pair", { + latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION), + longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION) + }); + } + function dmsMatcher(q2) { + const matchers = [ + // D M SS , D M SS ex: 35 11 10.1 , 136 49 53.8 + { + condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/, + parser: function(q3) { + const match = this.condition.exec(q3); + const lat = +match[2] + +match[3] / 60 + +match[4] / 3600; + const lng = +match[6] + +match[7] / 60 + +match[8] / 3600; + const isNegLat = match[1] === "-" ? -lat : lat; + const isNegLng = match[5] === "-" ? -lng : lng; + const d2 = [isNegLat, isNegLng]; + return d2; + } + }, + // D MM , D MM ex: 35 11.1683 , 136 49.8966 + { + condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/, + parser: function(q3) { + const match = this.condition.exec(q3); + const lat = +match[2] + +match[3] / 60; + const lng = +match[5] + +match[6] / 60; + const isNegLat = match[1] === "-" ? -lat : lat; + const isNegLng = match[4] === "-" ? -lng : lng; + const d2 = [isNegLat, isNegLng]; + return d2; + } + } + ]; + for (const matcher of matchers) { + if (matcher.condition.test(q2)) { + return matcher.parser(q2); + } + } + return null; + } + // modules/core/localizer.js var _mainLocalizer = coreLocalizer(); var _t = _mainLocalizer.t; @@ -27430,9 +30172,9 @@ return []; } } - function shouldInherit(f3) { - if (f3.key && _this.tags[f3.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox - f3.type !== "multiCombo" && f3.type !== "semiCombo" && f3.type !== "manyCombo" && f3.type !== "check") + function shouldInherit(f2) { + if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox + f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check") return false; return true; } @@ -27497,12 +30239,12 @@ let newLocationSets = []; if (d2.fields) { Object.keys(d2.fields).forEach((fieldID) => { - let f3 = d2.fields[fieldID]; - if (f3) { - f3 = presetField(fieldID, f3, _fields); - if (f3.locationSet) - newLocationSets.push(f3); - _fields[fieldID] = f3; + let f2 = d2.fields[fieldID]; + if (f2) { + f2 = presetField(fieldID, f2, _fields); + if (f2.locationSet) + newLocationSets.push(f2); + _fields[fieldID] = f2; } else { delete _fields[fieldID]; } @@ -27541,10 +30283,10 @@ _this.collection = Object.values(_presets).concat(Object.values(_categories)); if (d2.defaults) { Object.keys(d2.defaults).forEach((geometry) => { - const def = d2.defaults[geometry]; - if (Array.isArray(def)) { + const def2 = d2.defaults[geometry]; + if (Array.isArray(def2)) { _defaults2[geometry] = presetCollection( - def.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean) + def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean) ); } else { delete _defaults2[geometry]; @@ -27659,7 +30401,6 @@ footway: true, railway: true, junction: true, - traffic_calming: true, type: true }; let areaKeys = {}; @@ -28211,12 +30952,12 @@ } return tags; } - function utilStringQs(str2) { + function utilStringQs(str) { var i3 = 0; - while (i3 < str2.length && (str2[i3] === "?" || str2[i3] === "#")) + while (i3 < str.length && (str[i3] === "?" || str[i3] === "#")) i3++; - str2 = str2.slice(i3); - return str2.split("&").reduce(function(obj, pair3) { + str = str.slice(i3); + return str.split("&").reduce(function(obj, pair3) { var parts = pair3.split("="); if (parts.length === 2) { obj[parts[0]] = null === parts[1] ? "" : decodeURIComponent(parts[1]); @@ -28276,25 +31017,25 @@ if (b2.length === 0) return a2.length; var matrix = []; - var i3, j3; + var i3, j2; for (i3 = 0; i3 <= b2.length; i3++) { matrix[i3] = [i3]; } - for (j3 = 0; j3 <= a2.length; j3++) { - matrix[0][j3] = j3; + for (j2 = 0; j2 <= a2.length; j2++) { + matrix[0][j2] = j2; } for (i3 = 1; i3 <= b2.length; i3++) { - for (j3 = 1; j3 <= a2.length; j3++) { - if (b2.charAt(i3 - 1) === a2.charAt(j3 - 1)) { - matrix[i3][j3] = matrix[i3 - 1][j3 - 1]; + for (j2 = 1; j2 <= a2.length; j2++) { + if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) { + matrix[i3][j2] = matrix[i3 - 1][j2 - 1]; } else { - matrix[i3][j3] = Math.min( - matrix[i3 - 1][j3 - 1] + 1, + matrix[i3][j2] = Math.min( + matrix[i3 - 1][j2 - 1] + 1, // substitution Math.min( - matrix[i3][j3 - 1] + 1, + matrix[i3][j2 - 1] + 1, // insertion - matrix[i3 - 1][j3] + 1 + matrix[i3 - 1][j2] + 1 ) ); } @@ -28329,11 +31070,11 @@ }); }); } - function utilWrap(index, length) { + function utilWrap(index, length2) { if (index < 0) { - index += Math.ceil(-index / length) * length; + index += Math.ceil(-index / length2) * length2; } - return index % length; + return index % length2; } function utilFunctor(value) { if (typeof value === "function") @@ -28346,29 +31087,29 @@ var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea"; return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("spellcheck", isText ? "true" : "false"); } - function utilHashcode(str2) { + function utilHashcode(str) { var hash = 0; - if (str2.length === 0) { + if (str.length === 0) { return hash; } - for (var i3 = 0; i3 < str2.length; i3++) { - var char = str2.charCodeAt(i3); + for (var i3 = 0; i3 < str.length; i3++) { + var char = str.charCodeAt(i3); hash = (hash << 5) - hash + char; hash = hash & hash; } return hash; } - function utilSafeClassName(str2) { - return str2.toLowerCase().replace(/[^a-z0-9]+/g, "_"); + function utilSafeClassName(str) { + return str.toLowerCase().replace(/[^a-z0-9]+/g, "_"); } function utilUniqueDomId(val) { return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString(); } - function utilUnicodeCharsCount(str2) { - return Array.from(str2).length; + function utilUnicodeCharsCount(str) { + return Array.from(str).length; } - function utilUnicodeCharsTruncated(str2, limit) { - return Array.from(str2).slice(0, limit).join(""); + function utilUnicodeCharsTruncated(str, limit) { + return Array.from(str).slice(0, limit).join(""); } function toNumericID(id2) { var match = id2.match(/^[cnwr](-?\d+)$/); @@ -28761,8 +31502,8 @@ bothways }; } - function parseTurnLanes(tag) { - if (!tag) + function parseTurnLanes(tag2) { + if (!tag2) return; var validValues = [ "left", @@ -28777,7 +31518,7 @@ "merge_to_right", "none" ]; - return tag.split("|").map(function(s2) { + return tag2.split("|").map(function(s2) { if (s2 === "") s2 = "none"; return s2.split(";").map(function(d2) { @@ -28785,10 +31526,10 @@ }); }); } - function parseMaxspeedLanes(tag, maxspeed) { - if (!tag) + function parseMaxspeedLanes(tag2, maxspeed) { + if (!tag2) return; - return tag.split("|").map(function(s2) { + return tag2.split("|").map(function(s2) { if (s2 === "none") return s2; var m2 = parseInt(s2, 10); @@ -28797,22 +31538,22 @@ return isNaN(m2) ? "unknown" : m2; }); } - function parseMiscLanes(tag) { - if (!tag) + function parseMiscLanes(tag2) { + if (!tag2) return; var validValues = [ "yes", "no", "designated" ]; - return tag.split("|").map(function(s2) { + return tag2.split("|").map(function(s2) { if (s2 === "") s2 = "no"; return validValues.indexOf(s2) === -1 ? "unknown" : s2; }); } - function parseBicycleWay(tag) { - if (!tag) + function parseBicycleWay(tag2) { + if (!tag2) return; var validValues = [ "yes", @@ -28820,7 +31561,7 @@ "designated", "lane" ]; - return tag.split("|").map(function(s2) { + return tag2.split("|").map(function(s2) { if (s2 === "") s2 = "no"; return validValues.indexOf(s2) === -1 ? "unknown" : s2; @@ -28952,6 +31693,7 @@ road: 4, living_street: 4, bus_guideway: 4, + busway: 4, pedestrian: 4, residential: 3.5, service: 3.5, @@ -29320,78 +32062,6 @@ } // modules/osm/multipolygon.js - function osmOldMultipolygonOuterMemberOfRelation(entity, graph) { - if (entity.type !== "relation" || !entity.isMultipolygon() || Object.keys(entity.tags).filter(osmIsInterestingTag).length > 1) { - return false; - } - var outerMember; - for (var memberIndex in entity.members) { - var member = entity.members[memberIndex]; - if (!member.role || member.role === "outer") { - if (outerMember) - return false; - if (member.type !== "way") - return false; - if (!graph.hasEntity(member.id)) - return false; - outerMember = graph.entity(member.id); - if (Object.keys(outerMember.tags).filter(osmIsInterestingTag).length === 0) { - return false; - } - } - } - return outerMember; - } - function osmIsOldMultipolygonOuterMember(entity, graph) { - if (entity.type !== "way" || Object.keys(entity.tags).filter(osmIsInterestingTag).length === 0) { - return false; - } - var parents = graph.parentRelations(entity); - if (parents.length !== 1) - return false; - var parent = parents[0]; - if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) { - return false; - } - var members = parent.members, member; - for (var i3 = 0; i3 < members.length; i3++) { - member = members[i3]; - if (member.id === entity.id && member.role && member.role !== "outer") { - return false; - } - if (member.id !== entity.id && (!member.role || member.role === "outer")) { - return false; - } - } - return parent; - } - function osmOldMultipolygonOuterMember(entity, graph) { - if (entity.type !== "way") - return false; - var parents = graph.parentRelations(entity); - if (parents.length !== 1) - return false; - var parent = parents[0]; - if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) { - return false; - } - var members = parent.members, member, outerMember; - for (var i3 = 0; i3 < members.length; i3++) { - member = members[i3]; - if (!member.role || member.role === "outer") { - if (outerMember) - return false; - outerMember = member; - } - } - if (!outerMember) - return false; - var outerEntity = graph.hasEntity(outerMember.id); - if (!outerEntity || !Object.keys(outerEntity.tags).filter(osmIsInterestingTag).length) { - return false; - } - return outerEntity; - } function osmJoinWays(toJoin, graph) { function resolve(member) { return graph.childNodes(graph.entity(member.id)); @@ -29468,11 +32138,11 @@ } // modules/actions/add_member.js - function actionAddMember(relationId, member, memberIndex, insertPair) { + function actionAddMember(relationId, member, memberIndex) { return function action(graph) { var relation = graph.entity(relationId); var isPTv2 = /stop|platform/.test(member.role); - if ((isNaN(memberIndex) || insertPair) && member.type === "way" && !isPTv2) { + if (member.type === "way" && !isPTv2) { graph = addWayMember(relation, graph); } else { if (isPTv2 && isNaN(memberIndex)) { @@ -29483,7 +32153,7 @@ return graph; }; function addWayMember(relation, graph) { - var groups, tempWay, insertPairIsReversed, item, i3, j3, k2; + var groups, item, i3, j2, k2; var PTv2members = []; var members = []; for (i3 = 0; i3 < relation.members.length; i3++) { @@ -29495,71 +32165,37 @@ } } relation = relation.update({ members }); - if (insertPair) { - tempWay = osmWay({ id: "wTemp", nodes: insertPair.nodes }); - graph = graph.replace(tempWay); - var tempMember = { id: tempWay.id, type: "way", role: member.role }; - var tempRelation = relation.replaceMember({ id: insertPair.originalID }, tempMember, true); - groups = utilArrayGroupBy(tempRelation.members, "type"); - groups.way = groups.way || []; - var originalWay = graph.entity(insertPair.originalID); - var insertedWay = graph.entity(insertPair.insertedID); - insertPairIsReversed = originalWay.nodes.length > 0 && insertedWay.nodes.length > 0 && insertedWay.nodes[insertedWay.nodes.length - 1] === originalWay.nodes[0] && originalWay.nodes[originalWay.nodes.length - 1] !== insertedWay.nodes[0]; - } else { - groups = utilArrayGroupBy(relation.members, "type"); - groups.way = groups.way || []; - groups.way.push(member); - } + groups = utilArrayGroupBy(relation.members, "type"); + groups.way = groups.way || []; + groups.way.push(member); members = withIndex(groups.way); var joined = osmJoinWays(members, graph); for (i3 = 0; i3 < joined.length; i3++) { var segment = joined[i3]; var nodes = segment.nodes.slice(); var startIndex = segment[0].index; - for (j3 = 0; j3 < members.length; j3++) { - if (members[j3].index === startIndex) { + for (j2 = 0; j2 < members.length; j2++) { + if (members[j2].index === startIndex) { break; } } for (k2 = 0; k2 < segment.length; k2++) { item = segment[k2]; var way = graph.entity(item.id); - if (tempWay && item.id === tempWay.id) { - var reverse = nodes[0].id !== insertPair.nodes[0] ^ insertPairIsReversed; - if (reverse) { - item.pair = [ - { id: insertPair.insertedID, type: "way", role: item.role }, - { id: insertPair.originalID, type: "way", role: item.role } - ]; - } else { - item.pair = [ - { id: insertPair.originalID, type: "way", role: item.role }, - { id: insertPair.insertedID, type: "way", role: item.role } - ]; - } - } if (k2 > 0) { - if (j3 + k2 >= members.length || item.index !== members[j3 + k2].index) { - moveMember(members, item.index, j3 + k2); + if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) { + moveMember(members, item.index, j2 + k2); } } nodes.splice(0, way.nodes.length - 1); } } - if (tempWay) { - graph = graph.remove(tempWay); - } var wayMembers = []; for (i3 = 0; i3 < members.length; i3++) { item = members[i3]; if (item.index === -1) continue; - if (item.pair) { - wayMembers.push(item.pair[0]); - wayMembers.push(item.pair[1]); - } else { - wayMembers.push(utilObjectOmit(item, ["index"])); - } + wayMembers.push(utilObjectOmit(item, ["index"])); } var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []); return graph.replace(relation.update({ members: newMembers })); @@ -29572,7 +32208,7 @@ } var item2 = Object.assign({}, arr[i4]); arr[i4].index = -1; - item2.index = toIndex; + delete item2.index; arr.splice(toIndex, 0, item2); } function withIndex(arr) { @@ -29634,7 +32270,7 @@ preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags)); } if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) { - newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f3) => f3.matchGeometry(geometry)).map((f3) => f3.key).filter(Boolean).forEach((key) => preserveKeys.push(key)); + newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key)); } } if (oldPreset) @@ -29878,7 +32514,7 @@ return geoVecLength(centroid, p2); }); var sign2 = area_default3(points) > 0 ? 1 : -1; - var ids, i3, j3, k2; + var ids, i3, j2, k2; if (!keyNodes.length) { keyNodes = [nodes[0]]; keyPoints = [points[0]]; @@ -29924,20 +32560,20 @@ numberNewPoints++; eachAngle = totalAngle / (indexRange + numberNewPoints); } while (Math.abs(eachAngle) > maxAngle); - for (j3 = 1; j3 < indexRange; j3++) { - angle2 = startAngle + j3 * eachAngle; + for (j2 = 1; j2 < indexRange; j2++) { + angle2 = startAngle + j2 * eachAngle; loc = projection2.invert([ centroid[0] + Math.cos(angle2) * radius, centroid[1] + Math.sin(angle2) * radius ]); - node = nodes[(j3 + startNodeIndex) % nodes.length]; + node = nodes[(j2 + startNodeIndex) % nodes.length]; origNode = origNodes[node.id]; nearNodes[node.id] = angle2; node = node.move(geoVecInterp(origNode.loc, loc, t2)); graph = graph.replace(node); } - for (j3 = 0; j3 < numberNewPoints; j3++) { - angle2 = startAngle + (indexRange + j3) * eachAngle; + for (j2 = 0; j2 < numberNewPoints; j2++) { + angle2 = startAngle + (indexRange + j2) * eachAngle; loc = projection2.invert([ centroid[0] + Math.cos(angle2) * radius, centroid[1] + Math.sin(angle2) * radius @@ -29953,7 +32589,7 @@ } node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) }); graph = graph.replace(node); - nodes.splice(endNodeIndex + j3, 0, node); + nodes.splice(endNodeIndex + j2, 0, node); inBetweenNodes.push(node.id); } if (indexRange === 1 && inBetweenNodes.length) { @@ -29964,8 +32600,8 @@ wayDirection1 = 1; } var parentWays = graph.parentWays(keyNodes[i3]); - for (j3 = 0; j3 < parentWays.length; j3++) { - var sharedWay = parentWays[j3]; + for (j2 = 0; j2 < parentWays.length; j2++) { + var sharedWay = parentWays[j2]; if (sharedWay === way) continue; if (sharedWay.areAdjacent(startNode.id, endNode.id)) { @@ -30004,7 +32640,7 @@ }); var sign2 = area_default3(points) > 0 ? 1 : -1; var hull = hull_default(points); - var i3, j3; + var i3, j2; if (sign2 === -1) { nodes.reverse(); points.reverse(); @@ -30016,9 +32652,9 @@ if (indexRange < 0) { indexRange += nodes.length; } - for (j3 = 1; j3 < indexRange; j3++) { - var point2 = geoVecInterp(hull[i3], hull[i3 + 1], j3 / indexRange); - var node = nodes[(j3 + startIndex) % nodes.length].move(projection2.invert(point2)); + for (j2 = 1; j2 < indexRange; j2++) { + var point2 = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange); + var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point2)); graph = graph.replace(node); } } @@ -30180,7 +32816,7 @@ var survivor; var node; var parents; - var i3, j3; + var i3, j2; nodeIDs.reverse(); var interestingIDs = []; for (i3 = 0; i3 < nodeIDs.length; i3++) { @@ -30197,12 +32833,12 @@ if (node.id === survivor.id) continue; parents = graph.parentWays(node); - for (j3 = 0; j3 < parents.length; j3++) { - graph = graph.replace(parents[j3].replaceNode(node.id, survivor.id)); + for (j2 = 0; j2 < parents.length; j2++) { + graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id)); } parents = graph.parentRelations(node); - for (j3 = 0; j3 < parents.length; j3++) { - graph = graph.replace(parents[j3].replaceMember(node, survivor)); + for (j2 = 0; j2 < parents.length; j2++) { + graph = graph.replace(parents[j2].replaceMember(node, survivor)); } survivor = survivor.mergeTags(node.tags); graph = actionDeleteNode(node.id)(graph); @@ -30222,13 +32858,13 @@ var survivor; var node, way; var relations, relation, role; - var i3, j3, k2; + var i3, j2, k2; survivor = graph.entity(utilOldestID(nodeIDs)); for (i3 = 0; i3 < nodeIDs.length; i3++) { node = graph.entity(nodeIDs[i3]); relations = graph.parentRelations(node); - for (j3 = 0; j3 < relations.length; j3++) { - relation = relations[j3]; + for (j2 = 0; j2 < relations.length; j2++) { + relation = relations[j2]; role = relation.memberById(node.id).role || ""; if (relation.hasFromViaTo()) { restrictionIDs.push(relation.id); @@ -30243,8 +32879,8 @@ for (i3 = 0; i3 < nodeIDs.length; i3++) { node = graph.entity(nodeIDs[i3]); var parents = graph.parentWays(node); - for (j3 = 0; j3 < parents.length; j3++) { - var parent = parents[j3]; + for (j2 = 0; j2 < parents.length; j2++) { + var parent = parents[j2]; relations = graph.parentRelations(parent); for (k2 = 0; k2 < relations.length; k2++) { relation = relations[k2]; @@ -30265,12 +32901,12 @@ return graph.entity(m2.id); }); memberWays = utilArrayUniq(memberWays); - var f3 = relation.memberByRole("from"); + var f2 = relation.memberByRole("from"); var t2 = relation.memberByRole("to"); - var isUturn = f3.id === t2.id; + var isUturn = f2.id === t2.id; var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] }; - for (j3 = 0; j3 < relation.members.length; j3++) { - collectNodes(relation.members[j3], nodes); + for (j2 = 0; j2 < relation.members.length; j2++) { + collectNodes(relation.members[j2], nodes); } nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates)); nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates)); @@ -30283,8 +32919,8 @@ var connectTo = false; var connectKeyFrom = false; var connectKeyTo = false; - for (j3 = 0; j3 < nodeIDs.length; j3++) { - var n3 = nodeIDs[j3]; + for (j2 = 0; j2 < nodeIDs.length; j2++) { + var n3 = nodeIDs[j2]; if (nodes.from.indexOf(n3) !== -1) { connectFrom = true; } @@ -30316,8 +32952,8 @@ } var n0 = null; var n1 = null; - for (j3 = 0; j3 < memberWays.length; j3++) { - way = memberWays[j3]; + for (j2 = 0; j2 < memberWays.length; j2++) { + way = memberWays[j2]; if (way.contains(nodeIDs[0])) { n0 = nodeIDs[0]; } @@ -30327,8 +32963,8 @@ } if (n0 && n1) { var ok = false; - for (j3 = 0; j3 < memberWays.length; j3++) { - way = memberWays[j3]; + for (j2 = 0; j2 < memberWays.length; j2++) { + way = memberWays[j2]; if (way.areAdjacent(n0, n1)) { ok = true; break; @@ -30339,8 +32975,8 @@ } } } - for (j3 = 0; j3 < memberWays.length; j3++) { - way = memberWays[j3].update({}); + for (j2 = 0; j2 < memberWays.length; j2++) { + way = memberWays[j2].update({}); for (k2 = 0; k2 < nodeIDs.length; k2++) { if (nodeIDs[k2] === survivor.id) continue; @@ -30425,11 +33061,11 @@ } // modules/actions/discard_tags.js - function actionDiscardTags(difference, discardTags) { + function actionDiscardTags(difference2, discardTags) { discardTags = discardTags || {}; return (graph) => { - difference.modified().forEach(checkTags); - difference.created().forEach(checkTags); + difference2.modified().forEach(checkTags); + difference2.created().forEach(checkTags); return graph; function checkTags(entity) { const keys2 = Object.keys(entity.tags); @@ -30489,13 +33125,13 @@ if (way.isArea() && way.nodes[0] === nodeId) { candidates.push({ wayID: way.id, index: 0 }); } else { - for (var j3 = 0; j3 < way.nodes.length; j3++) { - waynode = way.nodes[j3]; + for (var j2 = 0; j2 < way.nodes.length; j2++) { + waynode = way.nodes[j2]; if (waynode === nodeId) { - if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j3 === way.nodes.length - 1) { + if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) { continue; } - candidates.push({ wayID: way.id, index: j3 }); + candidates.push({ wayID: way.id, index: j2 }); } } } @@ -30562,7 +33198,7 @@ var fromGeometry = entity.geometry(graph); var keysToCopyAndRetain = ["source", "wheelchair"]; var keysToRetain = ["area"]; - var buildingKeysToRetain = ["architect", "building", "height", "layer"]; + var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"]; var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph)); extractedLoc = extractedLoc && projection2.invert(extractedLoc); if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) { @@ -30714,11 +33350,11 @@ } } for (i3 = 0; i3 < ids.length - 1; i3++) { - for (var j3 = i3 + 1; j3 < ids.length; j3++) { + for (var j2 = i3 + 1; j2 < ids.length; j2++) { var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) { return e3.loc; }); - var path2 = graph.childNodes(graph.entity(ids[j3])).map(function(e3) { + var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) { return e3.loc; }); var intersections = geoPathIntersections(path1, path2); @@ -30983,16 +33619,16 @@ changes2.relation = Object.values(sorted); return changes2; } - function rep2(entity) { + function rep(entity) { return entity.asJXON(changeset_id); } return { osmChange: { "@version": 0.6, "@generator": "iD", - "create": sort(nest(changes.created.map(rep2), ["node", "way", "relation"])), - "modify": nest(changes.modified.map(rep2), ["node", "way", "relation"]), - "delete": Object.assign(nest(changes.deleted.map(rep2), ["relation", "way", "node"]), { "@if-unused": true }) + "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])), + "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]), + "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true }) } }; }, @@ -31394,6 +34030,7 @@ nodeIds = [nodeIds]; var _wayIDs; var _keepHistoryOn = "longest"; + const circularJunctions = ["roundabout", "circular"]; var _createdWayIDs = []; function dist(graph, nA, nB) { var locA = graph.entity(nA).loc; @@ -31403,23 +34040,23 @@ } function splitArea(nodes, idxA, graph) { var lengths = new Array(nodes.length); - var length; + var length2; var i3; var best = 0; var idxB; function wrap2(index) { return utilWrap(index, nodes.length); } - length = 0; + length2 = 0; for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) { - length += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]); - lengths[i3] = length; + length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]); + lengths[i3] = length2; } - length = 0; + length2 = 0; for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) { - length += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]); - if (length < lengths[i3]) { - lengths[i3] = length; + length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]); + if (length2 < lengths[i3]) { + lengths[i3] = length2; } } for (i3 = 0; i3 < nodes.length; i3++) { @@ -31440,11 +34077,9 @@ } function split(graph, nodeId, wayA, newWayId) { var wayB = osmWay({ id: newWayId, tags: wayA.tags }); - var origNodes = wayA.nodes.slice(); var nodesA; var nodesB; var isArea = wayA.isArea(); - var isOuter = osmIsOldMultipolygonOuterMember(wayA, graph); if (wayA.isClosed()) { var nodes = wayA.nodes.slice(0, -1); var idxA = nodes.indexOf(nodeId); @@ -31492,13 +34127,12 @@ graph = graph.replace(wayA); graph = graph.replace(wayB); graph.parentRelations(wayA).forEach(function(relation) { - var member; if (relation.hasFromViaTo()) { - var f3 = relation.memberByRole("from"); + var f2 = relation.memberByRole("from"); var v2 = relation.membersByRole("via"); var t2 = relation.memberByRole("to"); var i3; - if (f3.id === wayA.id || t2.id === wayA.id) { + if (f2.id === wayA.id || t2.id === wayA.id) { var keepB = false; if (v2.length === 1 && v2[0].type === "node") { keepB = wayB.contains(v2[0].id); @@ -31520,36 +34154,15 @@ } else { for (i3 = 0; i3 < v2.length; i3++) { if (v2[i3].type === "way" && v2[i3].id === wayA.id) { - member = { - id: wayB.id, - type: "way", - role: "via" - }; - graph = actionAddMember(relation.id, member, v2[i3].index + 1)(graph); - break; + graph = splitWayMember(graph, relation.id, wayA, wayB); } } } } else { - if (relation === isOuter) { - graph = graph.replace(relation.mergeTags(wayA.tags)); - graph = graph.replace(wayA.update({ tags: {} })); - graph = graph.replace(wayB.update({ tags: {} })); - } - member = { - id: wayB.id, - type: "way", - role: relation.memberById(wayA.id).role - }; - var insertPair = { - originalID: wayA.id, - insertedID: wayB.id, - nodes: origNodes - }; - graph = actionAddMember(relation.id, member, void 0, insertPair)(graph); + graph = splitWayMember(graph, relation.id, wayA, wayB); } }); - if (!isOuter && isArea) { + if (isArea) { var multipolygon = osmRelation({ tags: Object.assign({}, wayA.tags, { type: "multipolygon" }), members: [ @@ -31564,14 +34177,106 @@ _createdWayIDs.push(wayB.id); return graph; } + function splitWayMember(graph, relationId, wayA, wayB) { + function connects(way1, way2) { + if (way1.nodes.length < 2 || way2.nodes.length < 2) + return false; + if (circularJunctions.includes(way1.tags.junction) && way1.isClosed()) { + return way1.nodes.some((nodeId) => nodeId === way2.nodes[0] || nodeId === way2.nodes[way2.nodes.length - 1]); + } else if (circularJunctions.includes(way2.tags.junction) && way2.isClosed()) { + return way2.nodes.some((nodeId) => nodeId === way1.nodes[0] || nodeId === way1.nodes[way1.nodes.length - 1]); + } + if (way1.nodes[0] === way2.nodes[0]) + return true; + if (way1.nodes[0] === way2.nodes[way2.nodes.length - 1]) + return true; + if (way1.nodes[way1.nodes.length - 1] === way2.nodes[way2.nodes.length - 1]) + return true; + if (way1.nodes[way1.nodes.length - 1] === way2.nodes[0]) + return true; + return false; + } + let relation = graph.entity(relationId); + const insertMembers = []; + const members = relation.members; + for (let i3 = 0; i3 < members.length; i3++) { + const member = members[i3]; + if (member.id === wayA.id) { + let wayAconnectsPrev = false; + let wayAconnectsNext = false; + let wayBconnectsPrev = false; + let wayBconnectsNext = false; + if (i3 > 0 && graph.hasEntity(members[i3 - 1].id)) { + const prevEntity = graph.entity(members[i3 - 1].id); + if (prevEntity.type === "way") { + wayAconnectsPrev = connects(prevEntity, wayA); + wayBconnectsPrev = connects(prevEntity, wayB); + } + } + if (i3 < members.length - 1 && graph.hasEntity(members[i3 + 1].id)) { + const nextEntity = graph.entity(members[i3 + 1].id); + if (nextEntity.type === "way") { + wayAconnectsNext = connects(nextEntity, wayA); + wayBconnectsNext = connects(nextEntity, wayB); + } + } + if (wayAconnectsPrev && !wayAconnectsNext || !wayBconnectsPrev && wayBconnectsNext && !(!wayAconnectsPrev && wayAconnectsNext)) { + insertMembers.push({ at: i3 + 1, role: member.role }); + continue; + } + if (!wayAconnectsPrev && wayAconnectsNext || wayBconnectsPrev && !wayBconnectsNext && !(wayAconnectsPrev && !wayAconnectsNext)) { + insertMembers.push({ at: i3, role: member.role }); + continue; + } + if (wayAconnectsPrev && wayBconnectsPrev && wayAconnectsNext && wayBconnectsNext) { + if (i3 > 2 && graph.hasEntity(members[i3 - 2].id)) { + const prev2Entity = graph.entity(members[i3 - 2].id); + if (connects(prev2Entity, wayA) && !connects(prev2Entity, wayB)) { + insertMembers.push({ at: i3, role: member.role }); + continue; + } + if (connects(prev2Entity, wayB) && !connects(prev2Entity, wayA)) { + insertMembers.push({ at: i3 + 1, role: member.role }); + continue; + } + } + if (i3 < members.length - 2 && graph.hasEntity(members[i3 + 2].id)) { + const next2Entity = graph.entity(members[i3 + 2].id); + if (connects(next2Entity, wayA) && !connects(next2Entity, wayB)) { + insertMembers.push({ at: i3 + 1, role: member.role }); + continue; + } + if (connects(next2Entity, wayB) && !connects(next2Entity, wayA)) { + insertMembers.push({ at: i3, role: member.role }); + continue; + } + } + } + if (wayA.nodes[wayA.nodes.length - 1] === wayB.nodes[0]) { + insertMembers.push({ at: i3 + 1, role: member.role }); + } else { + insertMembers.push({ at: i3, role: member.role }); + } + } + } + insertMembers.reverse().forEach((item) => { + graph = graph.replace(relation.addMember({ + id: wayB.id, + type: "way", + role: item.role + }, item.at)); + relation = graph.entity(relation.id); + }); + return graph; + } var action = function(graph) { _createdWayIDs = []; var newWayIndex = 0; for (var i3 = 0; i3 < nodeIds.length; i3++) { var nodeId = nodeIds[i3]; var candidates = action.waysForNode(nodeId, graph); - for (var j3 = 0; j3 < candidates.length; j3++) { - graph = split(graph, nodeId, candidates[j3], newWayIds && newWayIds[newWayIndex]); + for (var j2 = 0; j2 < candidates.length; j2++) { + graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex]); newWayIndex += 1; } } @@ -31612,12 +34317,36 @@ }))); }; action.disabled = function(graph) { - for (var i3 = 0; i3 < nodeIds.length; i3++) { - var nodeId = nodeIds[i3]; - var candidates = action.waysForNode(nodeId, graph); + for (const nodeId of nodeIds) { + const candidates = action.waysForNode(nodeId, graph); if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) { return "not_eligible"; } + for (const way of candidates) { + const parentRelations = graph.parentRelations(way); + for (const parentRelation of parentRelations) { + if (parentRelation.hasFromViaTo()) { + const vias = parentRelation.membersByRole("via"); + if (!vias.every((via) => graph.hasEntity(via.id))) { + return "parent_incomplete"; + } + } else { + for (let i3 = 0; i3 < parentRelation.members.length; i3++) { + if (parentRelation.members[i3].id === way.id) { + const memberBeforePresent = i3 > 0 && graph.hasEntity(parentRelation.members[i3 - 1].id); + const memberAfterPresent = i3 < parentRelation.members.length - 1 && graph.hasEntity(parentRelation.members[i3 + 1].id); + if (!memberBeforePresent && !memberAfterPresent && parentRelation.members.length > 1) { + return "parent_incomplete"; + } + } + } + } + const relTypesExceptions = ["junction", "enforcement"]; + if (circularJunctions.includes(way.tags.junction) && way.isClosed() && !relTypesExceptions.includes(parentRelation.tags.type)) { + return "simple_roundabout"; + } + } + } } }; action.limitWays = function(val) { @@ -31740,7 +34469,7 @@ // graph always contained the newly downloaded data. rebase: function(entities, stack, force) { var base = this.base(); - var i3, j3, k2, id2; + var i3, j2, k2, id2; for (i3 = 0; i3 < entities.length; i3++) { var entity = entities[i3]; if (!entity.visible || !force && base.entities[entity.id]) @@ -31748,8 +34477,8 @@ base.entities[entity.id] = entity; this._updateCalculated(void 0, entity, base.parentWays, base.parentRels); if (entity.type === "way") { - for (j3 = 0; j3 < entity.nodes.length; j3++) { - id2 = entity.nodes[j3]; + for (j2 = 0; j2 < entity.nodes.length; j2++) { + id2 = entity.nodes[j2]; for (k2 = 1; k2 < stack.length; k2++) { var ents = stack[k2].entities; if (ents.hasOwnProperty(id2) && ents[id2] === void 0) { @@ -31892,7 +34621,7 @@ function osmIntersection(graph, startVertexId, maxDistance) { maxDistance = maxDistance || 30; var vgraph = coreGraph(); - var i3, j3, k2; + var i3, j2, k2; function memberOfRestriction(entity) { return graph.parentRelations(entity).some(function(r2) { return r2.isRestriction(); @@ -31916,6 +34645,7 @@ "unclassified": true, "living_street": true, "service": true, + "busway": true, "road": true, "track": true }; @@ -31946,8 +34676,8 @@ ways.push(way); hasWays = true; nodes = utilArrayUniq(graph.childNodes(way)); - for (j3 = 0; j3 < nodes.length; j3++) { - node = nodes[j3]; + for (j2 = 0; j2 < nodes.length; j2++) { + node = nodes[j2]; if (node === vertex) continue; if (vertices.indexOf(node) !== -1) @@ -32119,19 +34849,19 @@ }).map(function(way2) { return vgraph.entity(way2.id); }); - var intersection = { + var intersection2 = { graph: vgraph, actions, vertices, ways }; - intersection.turns = function(fromWayId, maxViaWay) { + intersection2.turns = function(fromWayId, maxViaWay) { if (!fromWayId) return []; if (!maxViaWay) maxViaWay = 0; - var vgraph2 = intersection.graph; - var keyVertexIds = intersection.vertices.map(function(v2) { + var vgraph2 = intersection2.graph; + var keyVertexIds = intersection2.vertices.map(function(v2) { return v2.id; }); var start2 = vgraph2.entity(fromWayId); @@ -32154,7 +34884,7 @@ } } function stepNode(entity, currPath, currRestrictions) { - var i4, j4; + var i4, j3; var parents2 = vgraph2.parentWays(entity); var nextWays = []; for (i4 = 0; i4 < parents2.length; i4++) { @@ -32164,9 +34894,9 @@ if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3) continue; var restrict = null; - for (j4 = 0; j4 < currRestrictions.length; j4++) { - var restriction = currRestrictions[j4]; - var f3 = restriction.memberByRole("from"); + for (j3 = 0; j3 < currRestrictions.length; j3++) { + var restriction = currRestrictions[j3]; + var f2 = restriction.memberByRole("from"); var v2 = restriction.membersByRole("via"); var t2 = restriction.memberByRole("to"); var isNo = /^no_/.test(restriction.tags.restriction); @@ -32174,7 +34904,7 @@ if (!(isNo || isOnly)) { continue; } - var matchesFrom = f3.id === fromWayId; + var matchesFrom = f2.id === fromWayId; var matchesViaTo = false; var isAlongOnlyPath = false; if (t2.id === way2.id) { @@ -32204,15 +34934,15 @@ } if (matchesViaTo) { if (isOnly) { - restrict = { id: restriction.id, direct: matchesFrom, from: f3.id, only: true, end: true }; + restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true }; } else { - restrict = { id: restriction.id, direct: matchesFrom, from: f3.id, no: true, end: true }; + restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true }; } } else { if (isAlongOnlyPath) { - restrict = { id: restriction.id, direct: false, from: f3.id, only: true, end: false }; + restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false }; } else if (isOnly) { - restrict = { id: restriction.id, direct: false, from: f3.id, no: true, end: true }; + restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true }; } } if (restrict && restrict.direct) @@ -32274,8 +35004,8 @@ var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) { if (!r2.isRestriction()) return false; - var f3 = r2.memberByRole("from"); - if (!f3 || f3.id !== entity.id) + var f2 = r2.memberByRole("from"); + if (!f2 || f2.id !== entity.id) return false; var isOnly = /^only_/.test(r2.tags.restriction); if (!isOnly) @@ -32344,7 +35074,7 @@ } } }; - return intersection; + return intersection2; } function osmInferRestriction(graph, turn, projection2) { var fromWay = graph.entity(turn.from.way); @@ -32516,12 +35246,12 @@ // node_modules/node-diff3/index.mjs function LCS(buffer1, buffer2) { let equivalenceClasses = {}; - for (let j3 = 0; j3 < buffer2.length; j3++) { - const item = buffer2[j3]; + for (let j2 = 0; j2 < buffer2.length; j2++) { + const item = buffer2[j2]; if (equivalenceClasses[item]) { - equivalenceClasses[item].push(j3); + equivalenceClasses[item].push(j2); } else { - equivalenceClasses[item] = [j3]; + equivalenceClasses[item] = [j2]; } } const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null }; @@ -32532,15 +35262,15 @@ let r2 = 0; let c2 = candidates[0]; for (let jx = 0; jx < buffer2indices.length; jx++) { - const j3 = buffer2indices[jx]; + const j2 = buffer2indices[jx]; let s2; for (s2 = r2; s2 < candidates.length; s2++) { - if (candidates[s2].buffer2index < j3 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j3)) { + if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) { break; } } if (s2 < candidates.length) { - const newCandidate = { buffer1index: i3, buffer2index: j3, chain: candidates[s2] }; + const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] }; if (r2 === candidates.length) { candidates.push(c2); } else { @@ -32972,8 +35702,8 @@ for (var i3 = 0; i3 < ids.length; i3++) { var id2 = ids[i3]; var childNodes = graph.childNodes(graph.entity(id2)); - for (var j3 = 0; j3 < childNodes.length; j3++) { - var node = childNodes[j3]; + for (var j2 = 0; j2 < childNodes.length; j2++) { + var node = childNodes[j2]; var parents = graph.parentWays(node); if (parents.length !== 2) continue; @@ -33086,12 +35816,12 @@ } return graph; } - function unZorroIntersection(intersection, graph) { - var vertex = graph.entity(intersection.nodeId); - var way1 = graph.entity(intersection.movedId); - var way2 = graph.entity(intersection.unmovedId); - var isEP1 = intersection.movedIsEP; - var isEP2 = intersection.unmovedIsEP; + function unZorroIntersection(intersection2, graph) { + var vertex = graph.entity(intersection2.nodeId); + var way1 = graph.entity(intersection2.movedId); + var way2 = graph.entity(intersection2.unmovedId); + var isEP1 = intersection2.movedIsEP; + var isEP2 = intersection2.unmovedIsEP; if (isEP1 && isEP2) return graph; var nodes1 = graph.childNodes(way1).filter(function(n3) { @@ -33165,8 +35895,8 @@ return projection2(n3.loc); }); var hits = geoPathIntersections(movedPath, unmovedPath); - for (var j3 = 0; i3 < hits.length; i3++) { - if (geoVecEqual(hits[j3], end)) + for (var j2 = 0; i3 < hits.length; i3++) { + if (geoVecEqual(hits[j2], end)) continue; var edge = geoChooseEdge(unmovedNodes, end, projection2); _delta = geoVecSubtract(projection2(edge.loc), start2); @@ -33256,7 +35986,7 @@ var nodeCount = {}; var points = []; var corner = { i: 0, dotp: 1 }; - var node, point2, loc, score, motions, i3, j3; + var node, point2, loc, score, motions, i3, j2; for (i3 = 0; i3 < nodes.length; i3++) { node = nodes[i3]; nodeCount[node.id] = (nodeCount[node.id] || 0) + 1; @@ -33296,8 +36026,8 @@ score = Infinity; for (i3 = 0; i3 < 1e3; i3++) { motions = simplified.map(calcMotion); - for (j3 = 0; j3 < motions.length; j3++) { - simplified[j3].coord = geoVecAdd(simplified[j3].coord, motions[j3]); + for (j2 = 0; j2 < motions.length; j2++) { + simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]); } var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold); if (newScore < score) { @@ -33926,8 +36656,8 @@ } else if (datum2 instanceof osmEntity) { selector += ", ." + datum2.id; if (datum2.type === "relation") { - for (var j3 in datum2.members) { - selector += ", ." + datum2.members[j3].id; + for (var j2 in datum2.members) { + selector += ", ." + datum2.members[j2].id; } } } @@ -34161,15 +36891,15 @@ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal()); // node_modules/d3-scale/src/init.js - function initRange(domain2, range3) { + function initRange(domain, range3) { switch (arguments.length) { case 0: break; case 1: - this.range(domain2); + this.range(domain); break; default: - this.range(range3).domain(domain2); + this.range(range3).domain(domain); break; } return this; @@ -34205,8 +36935,8 @@ return Math.max(a2, Math.min(b2, x2)); }; } - function bimap(domain2, range3, interpolate) { - var d0 = domain2[0], d1 = domain2[1], r0 = range3[0], r1 = range3[1]; + function bimap(domain, range3, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1]; if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); else @@ -34215,18 +36945,18 @@ return r0(d0(x2)); }; } - function polymap(domain2, range3, interpolate) { - var j3 = Math.min(domain2.length, range3.length) - 1, d2 = new Array(j3), r2 = new Array(j3), i3 = -1; - if (domain2[j3] < domain2[0]) { - domain2 = domain2.slice().reverse(); + function polymap(domain, range3, interpolate) { + var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1; + if (domain[j2] < domain[0]) { + domain = domain.slice().reverse(); range3 = range3.slice().reverse(); } - while (++i3 < j3) { - d2[i3] = normalize(domain2[i3], domain2[i3 + 1]); + while (++i3 < j2) { + d2[i3] = normalize(domain[i3], domain[i3 + 1]); r2[i3] = interpolate(range3[i3], range3[i3 + 1]); } return function(x2) { - var i4 = bisect_default(domain2, x2, 1, j3) - 1; + var i4 = bisect_default(domain, x2, 1, j2) - 1; return r2[i4](d2[i4](x2)); }; } @@ -34234,23 +36964,23 @@ return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown()); } function transformer2() { - var domain2 = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input; + var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input; function rescale() { - var n3 = Math.min(domain2.length, range3.length); + var n3 = Math.min(domain.length, range3.length); if (clamp3 !== identity3) - clamp3 = clamper(domain2[0], domain2[n3 - 1]); + clamp3 = clamper(domain[0], domain[n3 - 1]); piecewise = n3 > 2 ? polymap : bimap; output = input = null; return scale; } function scale(x2) { - return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain2.map(transform2), range3, interpolate)))(transform2(clamp3(x2))); + return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2))); } scale.invert = function(y2) { - return clamp3(untransform((input || (input = piecewise(range3, domain2.map(transform2), number_default)))(y2))); + return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2))); }; scale.domain = function(_2) { - return arguments.length ? (domain2 = Array.from(_2, number2), rescale()) : domain2.slice(); + return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice(); }; scale.range = function(_2) { return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice(); @@ -34298,14 +37028,14 @@ // node_modules/d3-format/src/formatGroup.js function formatGroup_default(grouping, thousands) { return function(value, width) { - var i3 = value.length, t2 = [], j3 = 0, g3 = grouping[0], length = 0; + var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0; while (i3 > 0 && g3 > 0) { - if (length + g3 + 1 > width) - g3 = Math.max(1, width - length); + if (length2 + g3 + 1 > width) + g3 = Math.max(1, width - length2); t2.push(value.substring(i3 -= g3, i3 + g3)); - if ((length += g3 + 1) > width) + if ((length2 += g3 + 1) > width) break; - g3 = grouping[j3 = (j3 + 1) % grouping.length]; + g3 = grouping[j2 = (j2 + 1) % grouping.length]; } return t2.reverse().join(thousands); }; @@ -34417,7 +37147,7 @@ }; // node_modules/d3-format/src/identity.js - function identity_default3(x2) { + function identity_default4(x2) { return x2; } @@ -34425,19 +37155,19 @@ var map = Array.prototype.map; var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function locale_default(locale2) { - var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default3 : 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_default3 : 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 + ""; + var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default4 : formatGroup_default(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity_default4 : formatNumerals_default(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + ""; function newFormat(specifier) { specifier = formatSpecifier(specifier); - var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision2 = specifier.precision, trim = specifier.trim, type2 = specifier.type; + 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; if (type2 === "n") comma = true, type2 = "g"; else if (!formatTypes_default[type2]) - precision2 === void 0 && (precision2 = 12), trim = true, type2 = "g"; + precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g"; if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "="; var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : ""; var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2); - precision2 = precision2 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision2)) : Math.max(0, Math.min(20, precision2)); + precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3)); function format2(value) { var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2; if (type2 === "c") { @@ -34446,7 +37176,7 @@ } else { value = +value; var valueNegative = value < 0 || 1 / value < 0; - value = isNaN(value) ? nan : formatType(Math.abs(value), precision2); + value = isNaN(value) ? nan : formatType(Math.abs(value), precision3); if (trim) value = formatTrim_default(value); if (valueNegative && +value === 0 && sign2 !== "+") @@ -34466,7 +37196,7 @@ } if (comma && !zero3) value = group(value, Infinity); - var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : ""; + var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : ""; if (comma && zero3) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; switch (align) { @@ -34477,7 +37207,7 @@ value = valuePrefix + padding + value + valueSuffix; break; case "^": - value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); + value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2); break; default: value = padding + valuePrefix + value + valueSuffix; @@ -34491,9 +37221,9 @@ return format2; } function formatPrefix2(specifier, value) { - var f3 = 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]; + 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]; return function(value2) { - return f3(k2 * value2) + prefix; + return f2(k2 * value2) + prefix; }; } return { @@ -34536,13 +37266,13 @@ // node_modules/d3-scale/src/tickFormat.js function tickFormat(start2, stop, count, specifier) { - var step = tickStep(start2, stop, count), precision2; + var step = tickStep(start2, stop, count), precision3; specifier = formatSpecifier(specifier == null ? ",f" : specifier); switch (specifier.type) { case "s": { var value = Math.max(Math.abs(start2), Math.abs(stop)); - if (specifier.precision == null && !isNaN(precision2 = precisionPrefix_default(step, value))) - specifier.precision = precision2; + if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value))) + specifier.precision = precision3; return formatPrefix(specifier, value); } case "": @@ -34550,14 +37280,14 @@ case "g": case "p": case "r": { - if (specifier.precision == null && !isNaN(precision2 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop))))) - specifier.precision = precision2 - (specifier.type === "e"); + if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop))))) + specifier.precision = precision3 - (specifier.type === "e"); break; } case "f": case "%": { - if (specifier.precision == null && !isNaN(precision2 = precisionFixed_default(step))) - specifier.precision = precision2 - (specifier.type === "%") * 2; + if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step))) + specifier.precision = precision3 - (specifier.type === "%") * 2; break; } } @@ -34566,19 +37296,19 @@ // node_modules/d3-scale/src/linear.js function linearish(scale) { - var domain2 = scale.domain; + var domain = scale.domain; scale.ticks = function(count) { - var d2 = domain2(); + var d2 = domain(); return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count); }; scale.tickFormat = function(count, specifier) { - var d2 = domain2(); + var d2 = domain(); return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier); }; scale.nice = function(count) { if (count == null) count = 10; - var d2 = domain2(); + var d2 = domain(); var i0 = 0; var i1 = d2.length - 1; var start2 = d2[i0]; @@ -34595,7 +37325,7 @@ if (step === prestep) { d2[i0] = start2; d2[i1] = stop; - return domain2(d2); + return domain(d2); } else if (step > 0) { start2 = Math.floor(start2 / step) * step; stop = Math.ceil(stop / step) * step; @@ -34622,15 +37352,15 @@ // node_modules/d3-scale/src/quantize.js function quantize() { - var x05 = 0, x12 = 1, n3 = 1, domain2 = [0.5], range3 = [0, 1], unknown; + var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown; function scale(x2) { - return x2 != null && x2 <= x2 ? range3[bisect_default(domain2, x2, 0, n3)] : unknown; + return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown; } function rescale() { var i3 = -1; - domain2 = new Array(n3); + domain = new Array(n3); while (++i3 < n3) - domain2[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1); + domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1); return scale; } scale.domain = function(_2) { @@ -34641,13 +37371,13 @@ }; scale.invertExtent = function(y2) { var i3 = range3.indexOf(y2); - return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain2[0]] : i3 >= n3 ? [domain2[n3 - 1], x12] : [domain2[i3 - 1], domain2[i3]]; + return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]]; }; scale.unknown = function(_2) { return arguments.length ? (unknown = _2, scale) : scale; }; scale.thresholds = function() { - return domain2.slice(); + return domain.slice(); }; scale.copy = function() { return quantize().domain([x05, x12]).range(range3).unknown(unknown); @@ -34709,22 +37439,22 @@ function calcAnimationParams(selection2) { selection2.call(reset).each(function(d2) { var s2 = select_default2(this); - var tag = s2.node().tagName; + var tag2 = s2.node().tagName; var p2 = { "from": {}, "to": {} }; var opacity; var width; - if (tag === "circle") { + if (tag2 === "circle") { opacity = Number(s2.style("fill-opacity") || 0.5); width = Number(s2.style("r") || 15.5); } else { opacity = Number(s2.style("stroke-opacity") || 0.7); width = Number(s2.style("stroke-width") || 10); } - p2.tag = tag; + p2.tag = tag2; p2.from.opacity = opacity * 0.6; p2.to.opacity = opacity * 1.25; p2.from.width = width * 0.7; - p2.to.width = width * (tag === "circle" ? 1.5 : 1); + p2.to.width = width * (tag2 === "circle" ? 1.5 : 1); _params[d2.id] = p2; }); } @@ -34838,7 +37568,7 @@ } return actionCircularize(entityID, context.projection); } - var operation = function() { + var operation2 = function() { if (!_actions.length) return; var combinedAction = function(graph, t2) { @@ -34850,15 +37580,15 @@ return graph; }; combinedAction.transitionable = true; - context.perform(combinedAction, operation.annotation()); + context.perform(combinedAction, operation2.annotation()); window.setTimeout(function() { context.validator().validate(); }, 300); }; - operation.available = function() { + operation2.available = function() { return _actions.length && selectedIDs.length === _actions.length; }; - operation.disabled = function() { + operation2.disabled = function() { if (!_actions.length) return ""; var actionDisableds = _actions.map(function(action) { @@ -34895,18 +37625,18 @@ return false; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.circularize.annotation.feature", { n: _actions.length }); }; - operation.id = "circularize"; - operation.keys = [_t("operations.circularize.key")]; - operation.title = _t.append("operations.circularize.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "circularize"; + operation2.keys = [_t("operations.circularize.key")]; + operation2.title = _t.append("operations.circularize.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/ui/cmd.js @@ -34967,7 +37697,7 @@ return n3.loc; }); var extent = utilTotalExtent(selectedIDs, context.graph()); - var operation = function() { + var operation2 = function() { var nextSelectedID; var nextSelectedLoc; if (selectedIDs.length === 1) { @@ -34992,7 +37722,7 @@ nextSelectedLoc = context.entity(nextSelectedID).loc; } } - context.perform(action, operation.annotation()); + context.perform(action, operation2.annotation()); context.validator().validate(); if (nextSelectedID && nextSelectedLoc) { if (context.hasEntity(nextSelectedID)) { @@ -35005,10 +37735,10 @@ context.enter(modeBrowse(context)); } }; - operation.available = function() { + operation2.available = function() { return true; }; - operation.disabled = function() { + operation2.disabled = function() { if (extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } else if (someMissing()) { @@ -35064,18 +37794,18 @@ return false; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi); }; - operation.annotation = function() { + operation2.annotation = function() { return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length }); }; - operation.id = "delete"; - operation.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")]; - operation.title = _t.append("operations.delete.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "delete"; + operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")]; + operation2.title = _t.append("operations.delete.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/orthogonalize.js @@ -35115,7 +37845,7 @@ } return null; } - var operation = function() { + var operation2 = function() { if (!_actions.length) return; var combinedAction = function(graph, t2) { @@ -35127,15 +37857,15 @@ return graph; }; combinedAction.transitionable = true; - context.perform(combinedAction, operation.annotation()); + context.perform(combinedAction, operation2.annotation()); window.setTimeout(function() { context.validator().validate(); }, 300); }; - operation.available = function() { + operation2.available = function() { return _actions.length && selectedIDs.length === _actions.length; }; - operation.disabled = function() { + operation2.disabled = function() { if (!_actions.length) return ""; var actionDisableds = _actions.map(function(action) { @@ -35172,18 +37902,18 @@ return false; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length }); }; - operation.id = "orthogonalize"; - operation.keys = [_t("operations.orthogonalize.key")]; - operation.title = _t.append("operations.orthogonalize.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "orthogonalize"; + operation2.keys = [_t("operations.orthogonalize.key")]; + operation2.title = _t.append("operations.orthogonalize.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/reflect.js @@ -35201,17 +37931,17 @@ return n3.loc; }); var extent = utilTotalExtent(selectedIDs, context.graph()); - var operation = function() { + var operation2 = function() { var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long")); - context.perform(action, operation.annotation()); + context.perform(action, operation2.annotation()); window.setTimeout(function() { context.validator().validate(); }, 300); }; - operation.available = function() { + operation2.available = function() { return nodes.length >= 3; }; - operation.disabled = function() { + operation2.disabled = function() { if (extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } else if (someMissing()) { @@ -35244,18 +37974,18 @@ return entity.type === "relation" && !entity.isComplete(context.graph()); } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length }); }; - operation.id = "reflect-" + axis; - operation.keys = [_t("operations.reflect.key." + axis)]; - operation.title = _t.append("operations.reflect.title." + axis); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "reflect-" + axis; + operation2.keys = [_t("operations.reflect.key." + axis)]; + operation2.title = _t.append("operations.reflect.title." + axis); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/move.js @@ -35266,13 +37996,13 @@ return n3.loc; }); var extent = utilTotalExtent(selectedIDs, context.graph()); - var operation = function() { + var operation2 = function() { context.enter(modeMove(context, selectedIDs)); }; - operation.available = function() { + operation2.available = function() { return selectedIDs.length > 0; }; - operation.disabled = function() { + operation2.disabled = function() { if (extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } else if (someMissing()) { @@ -35305,19 +38035,19 @@ return entity.type === "relation" && !entity.isComplete(context.graph()); } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi); }; - operation.annotation = function() { + operation2.annotation = function() { return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length }); }; - operation.id = "move"; - operation.keys = [_t("operations.move.key")]; - operation.title = _t.append("operations.move.title"); - operation.behavior = behaviorOperation(context).which(operation); - operation.mouseOnly = true; - return operation; + operation2.id = "move"; + operation2.keys = [_t("operations.move.key")]; + operation2.title = _t.append("operations.move.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + operation2.mouseOnly = true; + return operation2; } // modules/modes/rotate.js @@ -35447,13 +38177,13 @@ return n3.loc; }); var extent = utilTotalExtent(selectedIDs, context.graph()); - var operation = function() { + var operation2 = function() { context.enter(modeRotate(context, selectedIDs)); }; - operation.available = function() { + operation2.available = function() { return nodes.length >= 2; }; - operation.disabled = function() { + operation2.disabled = function() { if (extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } else if (someMissing()) { @@ -35486,19 +38216,19 @@ return entity.type === "relation" && !entity.isComplete(context.graph()); } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi); }; - operation.annotation = function() { + operation2.annotation = function() { return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length }); }; - operation.id = "rotate"; - operation.keys = [_t("operations.rotate.key")]; - operation.title = _t.append("operations.rotate.title"); - operation.behavior = behaviorOperation(context).which(operation); - operation.mouseOnly = true; - return operation; + operation2.id = "rotate"; + operation2.keys = [_t("operations.rotate.key")]; + operation2.title = _t.append("operations.rotate.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + operation2.mouseOnly = true; + return operation2; } // modules/modes/move.js @@ -35988,16 +38718,16 @@ } function hasInvalidGeometry(entity, graph) { var parents = graph.parentWays(entity); - var i3, j3, k2; + var i3, j2, k2; for (i3 = 0; i3 < parents.length; i3++) { var parent = parents[i3]; var nodes = []; var activeIndex = null; var relations = graph.parentRelations(parent); - for (j3 = 0; j3 < relations.length; j3++) { - if (!relations[j3].isMultipolygon()) + for (j2 = 0; j2 < relations.length; j2++) { + if (!relations[j2].isMultipolygon()) continue; - var rings = osmJoinWays(relations[j3].members, graph); + var rings = osmJoinWays(relations[j2].members, graph); for (k2 = 0; k2 < rings.length; k2++) { nodes = rings[k2].nodes; if (nodes.find(function(n3) { @@ -36172,7 +38902,7 @@ // node_modules/d3-fetch/src/xml.js function parser(type2) { - return (input, init2) => text_default3(input, init2).then((text2) => new DOMParser().parseFromString(text2, type2)); + return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2)); } var xml_default = parser("application/xml"); var html = parser("text/html"); @@ -36309,9 +39039,9 @@ if (idType && capture) { capture = parseError(capture, idType); } else { - const compare = capture.toLowerCase(); - if (_krData.localizeStrings[compare]) { - capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare]); + const compare2 = capture.toLowerCase(); + if (_krData.localizeStrings[compare2]) { + capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]); } else { capture = unescape_default(capture); } @@ -36321,9 +39051,9 @@ return replacements; } function parseError(capture, idType) { - const compare = capture.toLowerCase(); - if (_krData.localizeStrings[compare]) { - capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare]); + const compare2 = capture.toLowerCase(); + if (_krData.localizeStrings[compare2]) { + capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]); } switch (idType) { case "this": @@ -36972,25 +39702,15 @@ function _getDefaults() { return { async: false, - baseUrl: null, breaks: false, extensions: null, gfm: true, - headerIds: false, - headerPrefix: "", - highlight: null, hooks: null, - langPrefix: "language-", - mangle: false, pedantic: false, renderer: null, - sanitize: false, - sanitizer: null, silent: false, - smartypants: false, tokenizer: null, - walkTokens: null, - xhtml: false + walkTokens: null }; } var _defaults = _getDefaults(); @@ -37009,21 +39729,21 @@ "'": "'" }; var getEscapeReplacement = (ch) => escapeReplacements[ch]; - function escape4(html2, encode) { + function escape$1(html3, encode) { if (encode) { - if (escapeTest.test(html2)) { - return html2.replace(escapeReplace, getEscapeReplacement); + if (escapeTest.test(html3)) { + return html3.replace(escapeReplace, getEscapeReplacement); } } else { - if (escapeTestNoEncode.test(html2)) { - return html2.replace(escapeReplaceNoEncode, getEscapeReplacement); + if (escapeTestNoEncode.test(html3)) { + return html3.replace(escapeReplaceNoEncode, getEscapeReplacement); } } - return html2; + return html3; } var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig; - function unescape3(html2) { - return html2.replace(unescapeTest, (_2, n3) => { + function unescape2(html3) { + return html3.replace(unescapeTest, (_2, n3) => { n3 = n3.toLowerCase(); if (n3 === "colon") return ":"; @@ -37035,38 +39755,22 @@ } var caret = /(^|[^\[])\^/g; function edit(regex, opt) { - regex = typeof regex === "string" ? regex : regex.source; + let source = typeof regex === "string" ? regex : regex.source; opt = opt || ""; const obj = { replace: (name, val) => { - val = typeof val === "object" && "source" in val ? val.source : val; - val = val.replace(caret, "$1"); - regex = regex.replace(name, val); + let valSource = typeof val === "string" ? val : val.source; + valSource = valSource.replace(caret, "$1"); + source = source.replace(name, valSource); return obj; }, getRegex: () => { - return new RegExp(regex, opt); + return new RegExp(source, opt); } }; return obj; } - var nonWordAndColonTest = /[^\w:]/g; - var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i; - function cleanUrl(sanitize, base, href) { - if (sanitize) { - let prot; - try { - prot = decodeURIComponent(unescape3(href)).replace(nonWordAndColonTest, "").toLowerCase(); - } catch (e3) { - return null; - } - if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) { - return null; - } - } - if (base && !originIndependentUrl.test(href)) { - href = resolveUrl(base, href); - } + function cleanUrl(href) { try { href = encodeURI(href).replace(/%25/g, "%"); } catch (e3) { @@ -37074,39 +39778,12 @@ } return href; } - var baseUrls = {}; - var justDomain = /^[^:]+:\/*[^/]*$/; - var protocol = /^([^:]+:)[\s\S]*$/; - var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/; - function resolveUrl(base, href) { - if (!baseUrls[" " + base]) { - if (justDomain.test(base)) { - baseUrls[" " + base] = base + "/"; - } else { - baseUrls[" " + base] = rtrim(base, "/", true); - } - } - base = baseUrls[" " + base]; - const relativeBase = base.indexOf(":") === -1; - if (href.substring(0, 2) === "//") { - if (relativeBase) { - return href; - } - return base.replace(protocol, "$1") + href; - } else if (href.charAt(0) === "/") { - if (relativeBase) { - return href; - } - return base.replace(domain, "$1") + href; - } else { - return base + href; - } - } var noopTest = { exec: () => null }; function splitCells(tableRow, count) { - const row = tableRow.replace(/\|/g, (match, offset, str2) => { - let escaped = false, curr = offset; - while (--curr >= 0 && str2[curr] === "\\") + const row = tableRow.replace(/\|/g, (match, offset, str) => { + let escaped = false; + let curr = offset; + while (--curr >= 0 && str[curr] === "\\") escaped = !escaped; if (escaped) { return "|"; @@ -37134,14 +39811,14 @@ } return cells; } - function rtrim(str2, c2, invert) { - const l2 = str2.length; + function rtrim(str, c2, invert) { + const l2 = str.length; if (l2 === 0) { return ""; } let suffLen = 0; while (suffLen < l2) { - const currChar = str2.charAt(l2 - suffLen - 1); + const currChar = str.charAt(l2 - suffLen - 1); if (currChar === c2 && !invert) { suffLen++; } else if (currChar !== c2 && invert) { @@ -37150,20 +39827,19 @@ break; } } - return str2.slice(0, l2 - suffLen); + return str.slice(0, l2 - suffLen); } - function findClosingBracket(str2, b2) { - if (str2.indexOf(b2[1]) === -1) { + function findClosingBracket(str, b2) { + if (str.indexOf(b2[1]) === -1) { return -1; } - const l2 = str2.length; - let level = 0, i3 = 0; - for (; i3 < l2; i3++) { - if (str2[i3] === "\\") { + let level = 0; + for (let i3 = 0; i3 < str.length; i3++) { + if (str[i3] === "\\") { i3++; - } else if (str2[i3] === b2[0]) { + } else if (str[i3] === b2[0]) { level++; - } else if (str2[i3] === b2[1]) { + } else if (str[i3] === b2[1]) { level--; if (level < 0) { return i3; @@ -37172,39 +39848,10 @@ } return -1; } - function checkDeprecations(opt, callback) { - if (!opt || opt.silent) { - return; - } - if (callback) { - console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async"); - } - if (opt.sanitize || opt.sanitizer) { - console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options"); - } - if (opt.highlight || opt.langPrefix !== "language-") { - console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight."); - } - if (opt.mangle) { - console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`."); - } - if (opt.baseUrl) { - console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url."); - } - if (opt.smartypants) { - console.warn("marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants."); - } - if (opt.xhtml) { - console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml."); - } - if (opt.headerIds || opt.headerPrefix) { - console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`."); - } - } - function outputLink(cap, link2, raw, lexer2) { - const href = link2.href; - const title = link2.title ? escape4(link2.title) : null; - const text2 = cap[1].replace(/\\([\[\]])/g, "$1"); + function outputLink(cap, link3, raw, lexer2) { + const href = link3.href; + const title = link3.title ? escape$1(link3.title) : null; + const text = cap[1].replace(/\\([\[\]])/g, "$1"); if (cap[0].charAt(0) !== "!") { lexer2.state.inLink = true; const token = { @@ -37212,8 +39859,8 @@ raw, href, title, - text: text2, - tokens: lexer2.inlineTokens(text2) + text, + tokens: lexer2.inlineTokens(text) }; lexer2.state.inLink = false; return token; @@ -37223,16 +39870,16 @@ raw, href, title, - text: escape4(text2) + text: escape$1(text) }; } - function indentCodeCompensation(raw, text2) { + function indentCodeCompensation(raw, text) { const matchIndentToCode = raw.match(/^(\s+)(?:```)/); if (matchIndentToCode === null) { - return text2; + return text; } const indentToCode = matchIndentToCode[1]; - return text2.split("\n").map((node) => { + return text.split("\n").map((node) => { const matchIndentInNode = node.match(/^\s+/); if (matchIndentInNode === null) { return node; @@ -37245,9 +39892,11 @@ }).join("\n"); } var _Tokenizer = class { + // set by the lexer constructor(options2) { __publicField(this, "options"); __publicField(this, "rules"); + // set by the lexer __publicField(this, "lexer"); this.options = options2 || _defaults; } @@ -37263,12 +39912,12 @@ code(src) { const cap = this.rules.block.code.exec(src); if (cap) { - const text2 = cap[0].replace(/^ {1,4}/gm, ""); + const text = cap[0].replace(/^ {1,4}/gm, ""); return { type: "code", raw: cap[0], codeBlockStyle: "indented", - text: !this.options.pedantic ? rtrim(text2, "\n") : text2 + text: !this.options.pedantic ? rtrim(text, "\n") : text }; } } @@ -37276,33 +39925,33 @@ const cap = this.rules.block.fences.exec(src); if (cap) { const raw = cap[0]; - const text2 = indentCodeCompensation(raw, cap[3] || ""); + const text = indentCodeCompensation(raw, cap[3] || ""); return { type: "code", raw, - lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, "$1") : cap[2], - text: text2 + lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2], + text }; } } heading(src) { const cap = this.rules.block.heading.exec(src); if (cap) { - let text2 = cap[2].trim(); - if (/#$/.test(text2)) { - const trimmed = rtrim(text2, "#"); + let text = cap[2].trim(); + if (/#$/.test(text)) { + const trimmed = rtrim(text, "#"); if (this.options.pedantic) { - text2 = trimmed.trim(); + text = trimmed.trim(); } else if (!trimmed || / $/.test(trimmed)) { - text2 = trimmed.trim(); + text = trimmed.trim(); } } return { type: "heading", raw: cap[0], depth: cap[1].length, - text: text2, - tokens: this.lexer.inline(text2) + text, + tokens: this.lexer.inline(text) }; } } @@ -37318,26 +39967,26 @@ blockquote(src) { const cap = this.rules.block.blockquote.exec(src); if (cap) { - const text2 = cap[0].replace(/^ *>[ \t]?/gm, ""); + let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1"); + text = rtrim(text.replace(/^ *>[ \t]?/gm, ""), "\n"); const top = this.lexer.state.top; this.lexer.state.top = true; - const tokens = this.lexer.blockTokens(text2); + const tokens = this.lexer.blockTokens(text); this.lexer.state.top = top; return { type: "blockquote", raw: cap[0], tokens, - text: text2 + text }; } } list(src) { let cap = this.rules.block.list.exec(src); if (cap) { - let raw, istask, ischecked, indent2, i3, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly; let bull = cap[1].trim(); const isordered = bull.length > 1; - const list = { + const list2 = { type: "list", raw: "", ordered: isordered, @@ -37350,8 +39999,11 @@ bull = isordered ? bull : "[*+-]"; } const itemRegex = new RegExp("^( {0,3}".concat(bull, ")((?:[ ][^\\n]*)?(?:\\n|$))")); + let raw = ""; + let itemContents = ""; + let endsWithBlankLine = false; while (src) { - endEarly = false; + let endEarly = false; if (!(cap = itemRegex.exec(src))) { break; } @@ -37360,30 +40012,31 @@ } raw = cap[0]; src = src.substring(raw.length); - line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length)); - nextLine = src.split("\n", 1)[0]; + let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length)); + let nextLine = src.split("\n", 1)[0]; + let indent = 0; if (this.options.pedantic) { - indent2 = 2; - itemContents = line.trimLeft(); + indent = 2; + itemContents = line.trimStart(); } else { - indent2 = cap[2].search(/[^ ]/); - indent2 = indent2 > 4 ? 1 : indent2; - itemContents = line.slice(indent2); - indent2 += cap[1].length; + indent = cap[2].search(/[^ ]/); + indent = indent > 4 ? 1 : indent; + itemContents = line.slice(indent); + indent += cap[1].length; } - blankLine = false; + let blankLine = false; if (!line && /^ *$/.test(nextLine)) { raw += nextLine + "\n"; src = src.substring(nextLine.length + 1); endEarly = true; } if (!endEarly) { - const nextBulletRegex = new RegExp("^ {0,".concat(Math.min(3, indent2 - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))")); - const hrRegex = new RegExp("^ {0,".concat(Math.min(3, indent2 - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)")); - const fencesBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent2 - 1), "}(?:```|~~~)")); - const headingBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent2 - 1), "}#")); + const nextBulletRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))")); + const hrRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)")); + const fencesBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)")); + const headingBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#")); while (src) { - rawLine = src.split("\n", 1)[0]; + const rawLine = src.split("\n", 1)[0]; nextLine = rawLine; if (this.options.pedantic) { nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " "); @@ -37400,8 +40053,8 @@ if (hrRegex.test(src)) { break; } - if (nextLine.search(/[^ ]/) >= indent2 || !nextLine.trim()) { - itemContents += "\n" + nextLine.slice(indent2); + if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { + itemContents += "\n" + nextLine.slice(indent); } else { if (blankLine) { break; @@ -37425,16 +40078,18 @@ } raw += rawLine + "\n"; src = src.substring(rawLine.length + 1); - line = nextLine.slice(indent2); + line = nextLine.slice(indent); } } - if (!list.loose) { + if (!list2.loose) { if (endsWithBlankLine) { - list.loose = true; + list2.loose = true; } else if (/\n *\n *$/.test(raw)) { endsWithBlankLine = true; } } + let istask = null; + let ischecked; if (this.options.gfm) { istask = /^\[[ xX]\] /.exec(itemContents); if (istask) { @@ -37442,35 +40097,35 @@ itemContents = itemContents.replace(/^\[[ xX]\] +/, ""); } } - list.items.push({ + list2.items.push({ type: "list_item", raw, task: !!istask, checked: ischecked, loose: false, - text: itemContents + text: itemContents, + tokens: [] }); - list.raw += raw; + list2.raw += raw; } - list.items[list.items.length - 1].raw = raw.trimRight(); - list.items[list.items.length - 1].text = itemContents.trimRight(); - list.raw = list.raw.trimRight(); - const l2 = list.items.length; - for (i3 = 0; i3 < l2; i3++) { + list2.items[list2.items.length - 1].raw = raw.trimEnd(); + list2.items[list2.items.length - 1].text = itemContents.trimEnd(); + list2.raw = list2.raw.trimEnd(); + for (let i3 = 0; i3 < list2.items.length; i3++) { this.lexer.state.top = false; - list.items[i3].tokens = this.lexer.blockTokens(list.items[i3].text, []); - if (!list.loose) { - const spacers = list.items[i3].tokens.filter((t2) => t2.type === "space"); + list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []); + if (!list2.loose) { + const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space"); const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => /\n.*\n/.test(t2.raw)); - list.loose = hasMultipleLineBreaks; + list2.loose = hasMultipleLineBreaks; } } - if (list.loose) { - for (i3 = 0; i3 < l2; i3++) { - list.items[i3].loose = true; + if (list2.loose) { + for (let i3 = 0; i3 < list2.items.length; i3++) { + list2.items[i3].loose = true; } } - return list; + return list2; } } html(src) { @@ -37480,28 +40135,21 @@ type: "html", block: true, raw: cap[0], - pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"), + pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style", text: cap[0] }; - if (this.options.sanitize) { - const text2 = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape4(cap[0]); - const paragraph = token; - paragraph.type = "paragraph"; - paragraph.text = text2; - paragraph.tokens = this.lexer.inline(text2); - } return token; } } def(src) { const cap = this.rules.block.def.exec(src); if (cap) { - const tag = cap[1].toLowerCase().replace(/\s+/g, " "); - const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline._escapes, "$1") : ""; - const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, "$1") : cap[3]; + const tag2 = cap[1].toLowerCase().replace(/\s+/g, " "); + const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : ""; + const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3]; return { type: "def", - tag, + tag: tag2, raw: cap[0], href, title @@ -37510,50 +40158,51 @@ } table(src) { const cap = this.rules.block.table.exec(src); - if (cap) { - const item = { - type: "table", - raw: cap[0], - header: splitCells(cap[1]).map((c2) => { - return { text: c2 }; - }), - align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */), - rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [] - }; - if (item.header.length === item.align.length) { - let l2 = item.align.length; - let i3, j3, k2, row; - for (i3 = 0; i3 < l2; i3++) { - if (/^ *-+: *$/.test(item.align[i3])) { - item.align[i3] = "right"; - } else if (/^ *:-+: *$/.test(item.align[i3])) { - item.align[i3] = "center"; - } else if (/^ *:-+ *$/.test(item.align[i3])) { - item.align[i3] = "left"; - } else { - item.align[i3] = null; - } - } - l2 = item.rows.length; - for (i3 = 0; i3 < l2; i3++) { - item.rows[i3] = splitCells(item.rows[i3], item.header.length).map((c2) => { - return { text: c2 }; - }); - } - l2 = item.header.length; - for (j3 = 0; j3 < l2; j3++) { - item.header[j3].tokens = this.lexer.inline(item.header[j3].text); - } - l2 = item.rows.length; - for (j3 = 0; j3 < l2; j3++) { - row = item.rows[j3]; - for (k2 = 0; k2 < row.length; k2++) { - row[k2].tokens = this.lexer.inline(row[k2].text); - } - } - return item; + if (!cap) { + return; + } + if (!/[:|]/.test(cap[2])) { + return; + } + const headers = splitCells(cap[1]); + const aligns = cap[2].replace(/^\||\| *$/g, "").split("|"); + const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []; + const item = { + type: "table", + raw: cap[0], + header: [], + align: [], + rows: [] + }; + if (headers.length !== aligns.length) { + return; + } + for (const align of aligns) { + if (/^ *-+: *$/.test(align)) { + item.align.push("right"); + } else if (/^ *:-+: *$/.test(align)) { + item.align.push("center"); + } else if (/^ *:-+ *$/.test(align)) { + item.align.push("left"); + } else { + item.align.push(null); } } + for (const header of headers) { + item.header.push({ + text: header, + tokens: this.lexer.inline(header) + }); + } + for (const row of rows) { + item.rows.push(splitCells(row, item.header.length).map((cell) => { + return { + text: cell, + tokens: this.lexer.inline(cell) + }; + })); + } + return item; } lheading(src) { const cap = this.rules.block.lheading.exec(src); @@ -37570,12 +40219,12 @@ paragraph(src) { const cap = this.rules.block.paragraph.exec(src); if (cap) { - const text2 = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1]; + const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1]; return { type: "paragraph", raw: cap[0], - text: text2, - tokens: this.lexer.inline(text2) + text, + tokens: this.lexer.inline(text) }; } } @@ -37596,7 +40245,7 @@ return { type: "escape", raw: cap[0], - text: escape4(cap[1]) + text: escape$1(cap[1]) }; } } @@ -37614,12 +40263,12 @@ this.lexer.state.inRawBlock = false; } return { - type: this.options.sanitize ? "text" : "html", + type: "html", raw: cap[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, - text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape4(cap[0]) : cap[0] + text: cap[0] }; } } @@ -37648,10 +40297,10 @@ let href = cap[2]; let title = ""; if (this.options.pedantic) { - const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); - if (link2) { - href = link2[1]; - title = link2[3]; + const link3 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); + if (link3) { + href = link3[1]; + title = link3[3]; } } else { title = cap[3] ? cap[3].slice(1, -1) : ""; @@ -37665,38 +40314,38 @@ } } return outputLink(cap, { - href: href ? href.replace(this.rules.inline._escapes, "$1") : href, - title: title ? title.replace(this.rules.inline._escapes, "$1") : title + href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href, + title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title }, cap[0], this.lexer); } } reflink(src, links) { let cap; if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) { - let link2 = (cap[2] || cap[1]).replace(/\s+/g, " "); - link2 = links[link2.toLowerCase()]; - if (!link2) { - const text2 = cap[0].charAt(0); + const linkString = (cap[2] || cap[1]).replace(/\s+/g, " "); + const link3 = links[linkString.toLowerCase()]; + if (!link3) { + const text = cap[0].charAt(0); return { type: "text", - raw: text2, - text: text2 + raw: text, + text }; } - return outputLink(cap, link2, cap[0], this.lexer); + return outputLink(cap, link3, cap[0], this.lexer); } } emStrong(src, maskedSrc, prevChar = "") { - let match = this.rules.inline.emStrong.lDelim.exec(src); + let match = this.rules.inline.emStrongLDelim.exec(src); if (!match) return; - if (match[3] && prevChar.match(new RegExp("[\\p{L}\\p{N}]", "u"))) + if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return; const nextChar = match[1] || match[2] || ""; if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) { const lLength = [...match[0]].length - 1; let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0; - const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd; + const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; endReg.lastIndex = 0; maskedSrc = maskedSrc.slice(-1 * src.length + lLength); while ((match = endReg.exec(maskedSrc)) != null) { @@ -37717,22 +40366,23 @@ if (delimTotal > 0) continue; rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal); - const raw = [...src].slice(0, lLength + match.index + rLength + 1).join(""); + const lastCharLength = [...match[0]][0].length; + const raw = src.slice(0, lLength + match.index + lastCharLength + rLength); if (Math.min(lLength, rLength) % 2) { - const text3 = raw.slice(1, -1); + const text2 = raw.slice(1, -1); return { type: "em", raw, - text: text3, - tokens: this.lexer.inlineTokens(text3) + text: text2, + tokens: this.lexer.inlineTokens(text2) }; } - const text2 = raw.slice(2, -2); + const text = raw.slice(2, -2); return { type: "strong", raw, - text: text2, - tokens: this.lexer.inlineTokens(text2) + text, + tokens: this.lexer.inlineTokens(text) }; } } @@ -37740,17 +40390,17 @@ codespan(src) { const cap = this.rules.inline.code.exec(src); if (cap) { - let text2 = cap[2].replace(/\n/g, " "); - const hasNonSpaceChars = /[^ ]/.test(text2); - const hasSpaceCharsOnBothEnds = /^ /.test(text2) && / $/.test(text2); + let text = cap[2].replace(/\n/g, " "); + const hasNonSpaceChars = /[^ ]/.test(text); + const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text); if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) { - text2 = text2.substring(1, text2.length - 1); + text = text.substring(1, text.length - 1); } - text2 = escape4(text2, true); + text = escape$1(text, true); return { type: "codespan", raw: cap[0], - text: text2 + text }; } } @@ -37774,46 +40424,47 @@ }; } } - autolink(src, mangle2) { + autolink(src) { const cap = this.rules.inline.autolink.exec(src); if (cap) { - let text2, href; + let text, href; if (cap[2] === "@") { - text2 = escape4(this.options.mangle ? mangle2(cap[1]) : cap[1]); - href = "mailto:" + text2; + text = escape$1(cap[1]); + href = "mailto:" + text; } else { - text2 = escape4(cap[1]); - href = text2; + text = escape$1(cap[1]); + href = text; } return { type: "link", raw: cap[0], - text: text2, + text, href, tokens: [ { type: "text", - raw: text2, - text: text2 + raw: text, + text } ] }; } } - url(src, mangle2) { + url(src) { + var _a2, _b; let cap; if (cap = this.rules.inline.url.exec(src)) { - let text2, href; + let text, href; if (cap[2] === "@") { - text2 = escape4(this.options.mangle ? mangle2(cap[0]) : cap[0]); - href = "mailto:" + text2; + text = escape$1(cap[0]); + href = "mailto:" + text; } else { let prevCapZero; do { prevCapZero = cap[0]; - cap[0] = this.rules.inline._backpedal.exec(cap[0])[0]; + cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : ""; } while (prevCapZero !== cap[0]); - text2 = escape4(cap[0]); + text = escape$1(cap[0]); if (cap[1] === "www.") { href = "http://" + cap[0]; } else { @@ -37823,170 +40474,153 @@ return { type: "link", raw: cap[0], - text: text2, + text, href, tokens: [ { type: "text", - raw: text2, - text: text2 + raw: text, + text } ] }; } } - inlineText(src, smartypants2) { + inlineText(src) { const cap = this.rules.inline.text.exec(src); if (cap) { - let text2; + let text; if (this.lexer.state.inRawBlock) { - text2 = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape4(cap[0]) : cap[0]; + text = cap[0]; } else { - text2 = escape4(this.options.smartypants ? smartypants2(cap[0]) : cap[0]); + text = escape$1(cap[0]); } return { type: "text", raw: cap[0], - text: text2 + text }; } } }; - var block = { - newline: /^(?: *(?:\n|$))+/, - code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, - fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, - hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, - heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, - blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/, - list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/, - html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", - def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/, + var newline = /^(?: *(?:\n|$))+/; + var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/; + var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; + var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; + var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; + var bullet = /(?:[*+-]|\d{1,9}[.)])/; + var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).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/).getRegex(); + var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; + var blockText = /^[^\n]+/; + var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/; + var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(); + var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex(); + 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"; + var _comment = /|$))/; + var html2 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(); + 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", ")|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex(); + var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex(); + var blockNormal = { + blockquote, + code: blockCode, + def, + fences, + heading, + hr, + html: html2, + lheading, + list, + newline, + paragraph, table: noopTest, - lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, - // regex template, placeholders will be replaced according to different paragraph - // interruption rules of commonmark and the original markdown spec: - _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, - text: /^[^\n]+/ + text: blockText }; - block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/; - block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/; - block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex(); - block.bullet = /(?:[*+-]|\d{1,9}[.)])/; - block.listItemStart = edit(/^( *)(bull) */).replace("bull", block.bullet).getRegex(); - block.list = edit(block.list).replace(/bull/g, block.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + block.def.source + ")").getRegex(); - block._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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul"; - block._comment = /|$)/; - block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(); - block.lheading = edit(block.lheading).replace(/bull/g, block.bullet).getRegex(); - block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").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", ")|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex(); - block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex(); - block.normal = __spreadValues({}, block); - block.gfm = __spreadProps(__spreadValues({}, block.normal), { - table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)" - // Cells - }); - block.gfm.table = edit(block.gfm.table).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex(); - block.gfm.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex(); - block.pedantic = __spreadProps(__spreadValues({}, block.normal), { - html: edit("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", block._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(), + var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex(); + var blockGfm = { + ...blockNormal, + table: gfmTable, + 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", ")|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex() + }; + var blockPedantic = { + ...blockNormal, + html: edit("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\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(), def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: noopTest, + // fences not supported lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, - paragraph: edit(block.normal._paragraph).replace("hr", block.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex() - }); - var inline = { - escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, - autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/, - url: noopTest, - tag: "^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^", - link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/, - reflink: /^!?\[(label)\]\[(ref)\]/, - nolink: /^!?\[(ref)\](?:\[\])?/, - reflinkSearch: "reflink|nolink(?!\\()", - emStrong: { - lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, - // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right. - // | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a - rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/, - rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/ - // ^- Not allowed for _ - }, - code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, - br: /^( {2,}|\\)\n(?!\s*$)/, + 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() + }; + var escape4 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; + var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; + var br = /^( {2,}|\\)\n(?!\s*$)/; + var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g; + var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex(); + var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex(); + var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex(); + var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex(); + 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(); + var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex(); + var tag = edit("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(); + var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/; + var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(); + var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex(); + var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex(); + var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex(); + var inlineNormal = { + _backpedal: noopTest, + // only used for GFM url + anyPunctuation, + autolink, + blockSkip, + br, + code: inlineCode, del: noopTest, - text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`^|~"; - inline.punctuation = edit(inline.punctuation, "u").replace(/punctuation/g, inline._punctuation).getRegex(); - inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; - inline.anyPunctuation = /\\[punct]/g; - inline._escapes = /\\([punct])/g; - inline._comment = edit(block._comment).replace("(?:-->|$)", "-->").getRegex(); - inline.emStrong.lDelim = edit(inline.emStrong.lDelim, "u").replace(/punct/g, inline._punctuation).getRegex(); - inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, "gu").replace(/punct/g, inline._punctuation).getRegex(); - inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, "gu").replace(/punct/g, inline._punctuation).getRegex(); - inline.anyPunctuation = edit(inline.anyPunctuation, "gu").replace(/punct/g, inline._punctuation).getRegex(); - inline._escapes = edit(inline._escapes, "gu").replace(/punct/g, inline._punctuation).getRegex(); - inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/; - inline._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])?)+(?![-_])/; - inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex(); - inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/; - inline.tag = edit(inline.tag).replace("comment", inline._comment).replace("attribute", inline._attribute).getRegex(); - inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/; - inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/; - inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/; - inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex(); - inline.reflink = edit(inline.reflink).replace("label", inline._label).replace("ref", block._label).getRegex(); - inline.nolink = edit(inline.nolink).replace("ref", block._label).getRegex(); - inline.reflinkSearch = edit(inline.reflinkSearch, "g").replace("reflink", inline.reflink).replace("nolink", inline.nolink).getRegex(); - inline.normal = __spreadValues({}, inline); - inline.pedantic = __spreadProps(__spreadValues({}, inline.normal), { - strong: { - start: /^__|\*\*/, - middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, - endAst: /\*\*(?!\*)/g, - endUnd: /__(?!_)/g - }, - em: { - start: /^_|\*/, - middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/, - endAst: /\*(?!\*)/g, - endUnd: /_(?!_)/g - }, - link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline._label).getRegex(), - reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline._label).getRegex() - }); - inline.gfm = __spreadProps(__spreadValues({}, inline.normal), { - escape: edit(inline.escape).replace("])", "~|])").getRegex(), - _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, - url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, + var inlinePedantic = { + ...inlineNormal, + link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(), + reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex() + }; + var inlineGfm = { + ...inlineNormal, + escape: edit(escape4).replace("])", "~|])").getRegex(), + 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(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\ 0.5) { - ch = "x" + ch.toString(16); - } - out += "&#" + ch + ";"; - } - return out; - } + }; + var inlineBreaks = { + ...inlineGfm, + br: edit(br).replace("{2,}", "*").getRegex(), + text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() + }; + var block = { + normal: blockNormal, + gfm: blockGfm, + pedantic: blockPedantic + }; + var inline = { + normal: inlineNormal, + gfm: inlineGfm, + breaks: inlineBreaks, + pedantic: inlinePedantic + }; var _Lexer = class __Lexer { constructor(options2) { __publicField(this, "tokens"); @@ -38053,10 +40687,11 @@ lex(src) { src = src.replace(/\r\n|\r/g, "\n"); this.blockTokens(src, this.tokens); - let next; - while (next = this.inlineQueue.shift()) { + for (let i3 = 0; i3 < this.inlineQueue.length; i3++) { + const next = this.inlineQueue[i3]; this.inlineTokens(next.src, next.tokens); } + this.inlineQueue = []; return this.tokens; } blockTokens(src, tokens = []) { @@ -38308,12 +40943,12 @@ tokens.push(token); continue; } - if (token = this.tokenizer.autolink(src, mangle)) { + if (token = this.tokenizer.autolink(src)) { src = src.substring(token.raw.length); tokens.push(token); continue; } - if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) { + if (!this.state.inLink && (token = this.tokenizer.url(src))) { src = src.substring(token.raw.length); tokens.push(token); continue; @@ -38333,7 +40968,7 @@ cutSrc = src.substring(0, startIndex + 1); } } - if (token = this.tokenizer.inlineText(cutSrc, smartypants)) { + if (token = this.tokenizer.inlineText(cutSrc)) { src = src.substring(token.raw.length); if (token.raw.slice(-1) !== "_") { prevChar = token.raw.slice(-1); @@ -38367,48 +41002,39 @@ this.options = options2 || _defaults; } code(code, infostring, escaped) { - const lang = (infostring || "").match(/\S*/)[0]; - if (this.options.highlight) { - const out = this.options.highlight(code, lang); - if (out != null && out !== code) { - escaped = true; - code = out; - } - } + var _a2; + const lang = (_a2 = (infostring || "").match(/^\S*/)) == null ? void 0 : _a2[0]; code = code.replace(/\n$/, "") + "\n"; if (!lang) { - return "
" + (escaped ? code : escape4(code, true)) + "
\n"; + return "
" + (escaped ? code : escape$1(code, true)) + "
\n"; } - return '
' + (escaped ? code : escape4(code, true)) + "
\n"; + return '
' + (escaped ? code : escape$1(code, true)) + "
\n"; } - blockquote(quote2) { - return "
\n".concat(quote2, "
\n"); + blockquote(quote) { + return "
\n".concat(quote, "
\n"); } - html(html2, block2) { - return html2; + html(html3, block2) { + return html3; } - heading(text2, level, raw, slugger) { - if (this.options.headerIds) { - const id2 = this.options.headerPrefix + slugger.slug(raw); - return "').concat(text2, "\n"); - } - return "").concat(text2, "\n"); + heading(text, level, raw) { + return "").concat(text, "\n"); } hr() { - return this.options.xhtml ? "
\n" : "
\n"; + return "
\n"; } list(body, ordered, start2) { - const type2 = ordered ? "ol" : "ul", startatt = ordered && start2 !== 1 ? ' start="' + start2 + '"' : ""; + const type2 = ordered ? "ol" : "ul"; + const startatt = ordered && start2 !== 1 ? ' start="' + start2 + '"' : ""; return "<" + type2 + startatt + ">\n" + body + "\n"; } - listitem(text2, task, checked) { - return "
  • ".concat(text2, "
  • \n"); + listitem(text, task, checked) { + return "
  • ".concat(text, "
  • \n"); } checkbox(checked) { - return " "; + return "'; } - paragraph(text2) { - return "

    ".concat(text2, "

    \n"); + paragraph(text) { + return "

    ".concat(text, "

    \n"); } table(header, body) { if (body) @@ -38420,132 +41046,97 @@ } tablecell(content, flags) { const type2 = flags.header ? "th" : "td"; - const tag = flags.align ? "<".concat(type2, ' align="').concat(flags.align, '">') : "<".concat(type2, ">"); - return tag + content + "\n"); + const tag2 = flags.align ? "<".concat(type2, ' align="').concat(flags.align, '">') : "<".concat(type2, ">"); + return tag2 + content + "\n"); } /** * span level renderer */ - strong(text2) { - return "".concat(text2, ""); + strong(text) { + return "".concat(text, ""); } - em(text2) { - return "".concat(text2, ""); + em(text) { + return "".concat(text, ""); } - codespan(text2) { - return "".concat(text2, ""); + codespan(text) { + return "".concat(text, ""); } br() { - return this.options.xhtml ? "
    " : "
    "; + return "
    "; } - del(text2) { - return "".concat(text2, ""); + del(text) { + return "".concat(text, ""); } - link(href, title, text2) { - href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); - if (href === null) { - return text2; + link(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; } + href = cleanHref; let out = '"; + out += ">" + text + ""; return out; } - image(href, title, text2) { - href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); - if (href === null) { - return text2; + image(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; } - let out = '').concat(text2, '" : ">"; + out += ">"; return out; } - text(text2) { - return text2; + text(text) { + return text; } }; var _TextRenderer = class { // no need for block level renderers - strong(text2) { - return text2; + strong(text) { + return text; } - em(text2) { - return text2; + em(text) { + return text; } - codespan(text2) { - return text2; + codespan(text) { + return text; } - del(text2) { - return text2; + del(text) { + return text; } - html(text2) { - return text2; + html(text) { + return text; } - text(text2) { - return text2; + text(text) { + return text; } - link(href, title, text2) { - return "" + text2; + link(href, title, text) { + return "" + text; } - image(href, title, text2) { - return "" + text2; + image(href, title, text) { + return "" + text; } br() { return ""; } }; - var _Slugger = class { - constructor() { - __publicField(this, "seen"); - this.seen = {}; - } - serialize(value) { - return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-"); - } - /** - * Finds the next safe (unique) slug to use - */ - getNextSafeSlug(originalSlug, isDryRun) { - let slug = originalSlug; - let occurenceAccumulator = 0; - if (this.seen.hasOwnProperty(slug)) { - occurenceAccumulator = this.seen[originalSlug]; - do { - occurenceAccumulator++; - slug = originalSlug + "-" + occurenceAccumulator; - } while (this.seen.hasOwnProperty(slug)); - } - if (!isDryRun) { - this.seen[originalSlug] = occurenceAccumulator; - this.seen[slug] = 0; - } - return slug; - } - /** - * Convert string to unique id - */ - slug(value, options2 = {}) { - const slug = this.serialize(value); - return this.getNextSafeSlug(slug, options2.dryrun); - } - }; var _Parser = class __Parser { constructor(options2) { __publicField(this, "options"); __publicField(this, "renderer"); __publicField(this, "textRenderer"); - __publicField(this, "slugger"); this.options = options2 || _defaults; this.options.renderer = this.options.renderer || new _Renderer(); this.renderer = this.options.renderer; this.renderer.options = this.options; this.textRenderer = new _TextRenderer(); - this.slugger = new _Slugger(); } /** * Static Parse Method @@ -38565,13 +41156,13 @@ * Parse Loop */ parse(tokens, top = true) { - let out = "", i3, j3, k2, l2, l3, row, cell, header, body, token, ordered, start2, loose, itemBody, item, checked, task, checkbox, ret; - const l4 = tokens.length; - for (i3 = 0; i3 < l4; i3++) { - token = tokens[i3]; + let out = ""; + for (let i3 = 0; i3 < tokens.length; i3++) { + const token = tokens[i3]; if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) { - ret = this.options.extensions.renderers[token.type].call({ parser: this }, token); - if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) { + const genericToken = token; + const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken); + if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) { out += ret || ""; continue; } @@ -38585,29 +41176,29 @@ continue; } case "heading": { - out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape3(this.parseInline(token.tokens, this.textRenderer)), this.slugger); + const headingToken = token; + out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape2(this.parseInline(headingToken.tokens, this.textRenderer))); continue; } case "code": { - out += this.renderer.code(token.text, token.lang, !!token.escaped); + const codeToken = token; + out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped); continue; } case "table": { - header = ""; - cell = ""; - l2 = token.header.length; - for (j3 = 0; j3 < l2; j3++) { - cell += this.renderer.tablecell(this.parseInline(token.header[j3].tokens), { header: true, align: token.align[j3] }); + const tableToken = token; + let header = ""; + let cell = ""; + for (let j2 = 0; j2 < tableToken.header.length; j2++) { + cell += this.renderer.tablecell(this.parseInline(tableToken.header[j2].tokens), { header: true, align: tableToken.align[j2] }); } header += this.renderer.tablerow(cell); - body = ""; - l2 = token.rows.length; - for (j3 = 0; j3 < l2; j3++) { - row = token.rows[j3]; + let body = ""; + for (let j2 = 0; j2 < tableToken.rows.length; j2++) { + const row = tableToken.rows[j2]; cell = ""; - l3 = row.length; - for (k2 = 0; k2 < l3; k2++) { - cell += this.renderer.tablecell(this.parseInline(row[k2].tokens), { header: false, align: token.align[k2] }); + for (let k2 = 0; k2 < row.length; k2++) { + cell += this.renderer.tablecell(this.parseInline(row[k2].tokens), { header: false, align: tableToken.align[k2] }); } body += this.renderer.tablerow(cell); } @@ -38615,23 +41206,24 @@ continue; } case "blockquote": { - body = this.parse(token.tokens); + const blockquoteToken = token; + const body = this.parse(blockquoteToken.tokens); out += this.renderer.blockquote(body); continue; } case "list": { - ordered = token.ordered; - start2 = token.start; - loose = token.loose; - l2 = token.items.length; - body = ""; - for (j3 = 0; j3 < l2; j3++) { - item = token.items[j3]; - checked = item.checked; - task = item.task; - itemBody = ""; + const listToken = token; + const ordered = listToken.ordered; + const start2 = listToken.start; + const loose = listToken.loose; + let body = ""; + for (let j2 = 0; j2 < listToken.items.length; j2++) { + const item = listToken.items[j2]; + const checked = item.checked; + const task = item.task; + let itemBody = ""; if (item.task) { - checkbox = this.renderer.checkbox(!!checked); + const checkbox = this.renderer.checkbox(!!checked); if (loose) { if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") { item.tokens[0].text = checkbox + " " + item.tokens[0].text; @@ -38641,11 +41233,11 @@ } else { item.tokens.unshift({ type: "text", - text: checkbox + text: checkbox + " " }); } } else { - itemBody += checkbox; + itemBody += checkbox + " "; } } itemBody += this.parse(item.tokens, loose); @@ -38655,18 +41247,21 @@ continue; } case "html": { - out += this.renderer.html(token.text, token.block); + const htmlToken = token; + out += this.renderer.html(htmlToken.text, htmlToken.block); continue; } case "paragraph": { - out += this.renderer.paragraph(this.parseInline(token.tokens)); + const paragraphToken = token; + out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens)); continue; } case "text": { - body = token.tokens ? this.parseInline(token.tokens) : token.text; - while (i3 + 1 < l4 && tokens[i3 + 1].type === "text") { - token = tokens[++i3]; - body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text); + let textToken = token; + let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text; + while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") { + textToken = tokens[++i3]; + body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text); } out += top ? this.renderer.paragraph(body) : body; continue; @@ -38689,12 +41284,11 @@ */ parseInline(tokens, renderer) { renderer = renderer || this.renderer; - let out = "", i3, token, ret; - const l2 = tokens.length; - for (i3 = 0; i3 < l2; i3++) { - token = tokens[i3]; + let out = ""; + for (let i3 = 0; i3 < tokens.length; i3++) { + const token = tokens[i3]; if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) { - ret = this.options.extensions.renderers[token.type].call({ parser: this }, token); + const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token); if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) { out += ret || ""; continue; @@ -38702,31 +41296,38 @@ } switch (token.type) { case "escape": { - out += renderer.text(token.text); + const escapeToken = token; + out += renderer.text(escapeToken.text); break; } case "html": { - out += renderer.html(token.text); + const tagToken = token; + out += renderer.html(tagToken.text); break; } case "link": { - out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer)); + const linkToken = token; + out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer)); break; } case "image": { - out += renderer.image(token.href, token.title, token.text); + const imageToken = token; + out += renderer.image(imageToken.href, imageToken.title, imageToken.text); break; } case "strong": { - out += renderer.strong(this.parseInline(token.tokens, renderer)); + const strongToken = token; + out += renderer.strong(this.parseInline(strongToken.tokens, renderer)); break; } case "em": { - out += renderer.em(this.parseInline(token.tokens, renderer)); + const emToken = token; + out += renderer.em(this.parseInline(emToken.tokens, renderer)); break; } case "codespan": { - out += renderer.codespan(token.text); + const codespanToken = token; + out += renderer.codespan(codespanToken.text); break; } case "br": { @@ -38734,11 +41335,13 @@ break; } case "del": { - out += renderer.del(this.parseInline(token.tokens, renderer)); + const delToken = token; + out += renderer.del(this.parseInline(delToken.tokens, renderer)); break; } case "text": { - out += renderer.text(token.text); + const textToken = token; + out += renderer.text(textToken.text); break; } default: { @@ -38769,13 +41372,20 @@ /** * Process HTML after marked is finished */ - postprocess(html2) { - return html2; + postprocess(html3) { + return html3; + } + /** + * Process all tokens before walk tokens + */ + processAllTokens(tokens) { + return tokens; } }; __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([ "preprocess", - "postprocess" + "postprocess", + "processAllTokens" ])); var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn; var Marked = class { @@ -38787,13 +41397,10 @@ __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse)); __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline)); __publicField(this, "Parser", _Parser); - __publicField(this, "parser", _Parser.parse); __publicField(this, "Renderer", _Renderer); __publicField(this, "TextRenderer", _TextRenderer); __publicField(this, "Lexer", _Lexer); - __publicField(this, "lexer", _Lexer.lex); __publicField(this, "Tokenizer", _Tokenizer); - __publicField(this, "Slugger", _Slugger); __publicField(this, "Hooks", _Hooks); this.use(...args); } @@ -38801,15 +41408,17 @@ * Run callback for every token */ walkTokens(tokens, callback) { + var _a2, _b; let values = []; for (const token of tokens) { values = values.concat(callback.call(this, token)); switch (token.type) { case "table": { - for (const cell of token.header) { + const tableToken = token; + for (const cell of tableToken.header) { values = values.concat(this.walkTokens(cell.tokens, callback)); } - for (const row of token.rows) { + for (const row of tableToken.rows) { for (const cell of row) { values = values.concat(this.walkTokens(cell.tokens, callback)); } @@ -38817,16 +41426,19 @@ break; } case "list": { - values = values.concat(this.walkTokens(token.items, callback)); + const listToken = token; + values = values.concat(this.walkTokens(listToken.items, callback)); break; } default: { - if (this.defaults.extensions && this.defaults.extensions.childTokens && this.defaults.extensions.childTokens[token.type]) { - this.defaults.extensions.childTokens[token.type].forEach((childTokens) => { - values = values.concat(this.walkTokens(token[childTokens], callback)); + const genericToken = token; + if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) { + this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => { + const tokens2 = genericToken[childTokens].flat(Infinity); + values = values.concat(this.walkTokens(tokens2, callback)); }); - } else if (token.tokens) { - values = values.concat(this.walkTokens(token.tokens, callback)); + } else if (genericToken.tokens) { + values = values.concat(this.walkTokens(genericToken.tokens, callback)); } } } @@ -38836,7 +41448,7 @@ use(...args) { const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} }; args.forEach((pack) => { - const opts = __spreadValues({}, pack); + const opts = { ...pack }; opts.async = this.defaults.async || opts.async || false; if (pack.extensions) { pack.extensions.forEach((ext) => { @@ -38861,8 +41473,9 @@ if (!ext.level || ext.level !== "block" && ext.level !== "inline") { throw new Error("extension level must be 'block' or 'inline'"); } - if (extensions[ext.level]) { - extensions[ext.level].unshift(ext.tokenizer); + const extLevel = extensions[ext.level]; + if (extLevel) { + extLevel.unshift(ext.tokenizer); } else { extensions[ext.level] = [ext.tokenizer]; } @@ -38891,10 +41504,16 @@ if (pack.renderer) { const renderer = this.defaults.renderer || new _Renderer(this.defaults); for (const prop in pack.renderer) { - const rendererFunc = pack.renderer[prop]; - const rendererKey = prop; - const prevRenderer = renderer[rendererKey]; - renderer[rendererKey] = (...args2) => { + if (!(prop in renderer)) { + throw new Error("renderer '".concat(prop, "' does not exist")); + } + if (prop === "options") { + continue; + } + const rendererProp = prop; + const rendererFunc = pack.renderer[rendererProp]; + const prevRenderer = renderer[rendererProp]; + renderer[rendererProp] = (...args2) => { let ret = rendererFunc.apply(renderer, args2); if (ret === false) { ret = prevRenderer.apply(renderer, args2); @@ -38907,10 +41526,16 @@ if (pack.tokenizer) { const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults); for (const prop in pack.tokenizer) { - const tokenizerFunc = pack.tokenizer[prop]; - const tokenizerKey = prop; - const prevTokenizer = tokenizer[tokenizerKey]; - tokenizer[tokenizerKey] = (...args2) => { + if (!(prop in tokenizer)) { + throw new Error("tokenizer '".concat(prop, "' does not exist")); + } + if (["options", "rules", "lexer"].includes(prop)) { + continue; + } + const tokenizerProp = prop; + const tokenizerFunc = pack.tokenizer[tokenizerProp]; + const prevTokenizer = tokenizer[tokenizerProp]; + tokenizer[tokenizerProp] = (...args2) => { let ret = tokenizerFunc.apply(tokenizer, args2); if (ret === false) { ret = prevTokenizer.apply(tokenizer, args2); @@ -38923,11 +41548,17 @@ if (pack.hooks) { const hooks = this.defaults.hooks || new _Hooks(); for (const prop in pack.hooks) { - const hooksFunc = pack.hooks[prop]; - const hooksKey = prop; - const prevHook = hooks[hooksKey]; + if (!(prop in hooks)) { + throw new Error("hook '".concat(prop, "' does not exist")); + } + if (prop === "options") { + continue; + } + const hooksProp = prop; + const hooksFunc = pack.hooks[hooksProp]; + const prevHook = hooks[hooksProp]; if (_Hooks.passThroughHooks.has(prop)) { - hooks[hooksKey] = (arg) => { + hooks[hooksProp] = (arg) => { if (this.defaults.async) { return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => { return prevHook.call(hooks, ret2); @@ -38937,7 +41568,7 @@ return prevHook.call(hooks, ret); }; } else { - hooks[hooksKey] = (...args2) => { + hooks[hooksProp] = (...args2) => { let ret = hooksFunc.apply(hooks, args2); if (ret === false) { ret = prevHook.apply(hooks, args2); @@ -38950,154 +41581,96 @@ } if (pack.walkTokens) { const walkTokens2 = this.defaults.walkTokens; + const packWalktokens = pack.walkTokens; opts.walkTokens = function(token) { let values = []; - values.push(pack.walkTokens.call(this, token)); + values.push(packWalktokens.call(this, token)); if (walkTokens2) { values = values.concat(walkTokens2.call(this, token)); } return values; }; } - this.defaults = __spreadValues(__spreadValues({}, this.defaults), opts); + this.defaults = { ...this.defaults, ...opts }; }); return this; } setOptions(opt) { - this.defaults = __spreadValues(__spreadValues({}, this.defaults), opt); + this.defaults = { ...this.defaults, ...opt }; return this; } + lexer(src, options2) { + return _Lexer.lex(src, options2 != null ? options2 : this.defaults); + } + parser(tokens, options2) { + return _Parser.parse(tokens, options2 != null ? options2 : this.defaults); + } }; _parseMarkdown = new WeakSet(); parseMarkdown_fn = function(lexer2, parser3) { - return (src, optOrCallback, callback) => { - if (typeof optOrCallback === "function") { - callback = optOrCallback; - optOrCallback = null; - } - const origOpt = __spreadValues({}, optOrCallback); - const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt); - const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback); + return (src, options2) => { + const origOpt = { ...options2 }; + const opt = { ...this.defaults, ...origOpt }; + if (this.defaults.async === true && origOpt.async === false) { + if (!opt.silent) { + console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."); + } + opt.async = true; + } + const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async); if (typeof src === "undefined" || src === null) { return throwError(new Error("marked(): input parameter is undefined or null")); } if (typeof src !== "string") { return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected")); } - checkDeprecations(opt, callback); if (opt.hooks) { opt.hooks.options = opt; } - if (callback) { - const highlight = opt.highlight; - let tokens; - try { - if (opt.hooks) { - src = opt.hooks.preprocess(src); - } - tokens = lexer2(src, opt); - } catch (e3) { - return throwError(e3); - } - const done = (err) => { - let out; - if (!err) { - try { - if (opt.walkTokens) { - this.walkTokens(tokens, opt.walkTokens); - } - out = parser3(tokens, opt); - if (opt.hooks) { - out = opt.hooks.postprocess(out); - } - } catch (e3) { - err = e3; - } - } - opt.highlight = highlight; - return err ? throwError(err) : callback(null, out); - }; - if (!highlight || highlight.length < 3) { - return done(); - } - delete opt.highlight; - if (!tokens.length) - return done(); - let pending = 0; - this.walkTokens(tokens, (token) => { - if (token.type === "code") { - pending++; - setTimeout(() => { - highlight(token.text, token.lang, (err, code) => { - if (err) { - return done(err); - } - if (code != null && code !== token.text) { - token.text = code; - token.escaped = true; - } - pending--; - if (pending === 0) { - done(); - } - }); - }, 0); - } - }); - if (pending === 0) { - done(); - } - return; - } if (opt.async) { - return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser3(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError); + 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); } try { if (opt.hooks) { src = opt.hooks.preprocess(src); } - const tokens = lexer2(src, opt); + let tokens = lexer2(src, opt); + if (opt.hooks) { + tokens = opt.hooks.processAllTokens(tokens); + } if (opt.walkTokens) { this.walkTokens(tokens, opt.walkTokens); } - let html2 = parser3(tokens, opt); + let html3 = parser3(tokens, opt); if (opt.hooks) { - html2 = opt.hooks.postprocess(html2); + html3 = opt.hooks.postprocess(html3); } - return html2; + return html3; } catch (e3) { return throwError(e3); } }; }; _onError = new WeakSet(); - onError_fn = function(silent, async, callback) { + onError_fn = function(silent, async) { return (e3) => { e3.message += "\nPlease report this to https://github.com/markedjs/marked."; if (silent) { - const msg = "

    An error occurred:

    " + escape4(e3.message + "", true) + "
    "; + const msg = "

    An error occurred:

    " + escape$1(e3.message + "", true) + "
    "; if (async) { return Promise.resolve(msg); } - if (callback) { - callback(null, msg); - return; - } return msg; } if (async) { return Promise.reject(e3); } - if (callback) { - callback(e3); - return; - } throw e3; }; }; var markedInstance = new Marked(); - function marked(src, opt, callback) { - return markedInstance.parse(src, opt, callback); + function marked(src, opt) { + return markedInstance.parse(src, opt); } marked.options = marked.setOptions = function(options2) { markedInstance.setOptions(options2); @@ -39124,7 +41697,6 @@ marked.Lexer = _Lexer; marked.lexer = _Lexer.lex; marked.Tokenizer = _Tokenizer; - marked.Slugger = _Slugger; marked.Hooks = _Hooks; marked.parse = marked; var options = marked.options; @@ -39905,9 +42477,9 @@ function showDetections(detections) { const tagComponent = _mlyViewer.getComponent("tag"); detections.forEach(function(data) { - const tag = makeTag(data); - if (tag) { - tagComponent.add([tag]); + const tag2 = makeTag(data); + if (tag2) { + tagComponent.add([tag2]); } }); } @@ -39915,17 +42487,17 @@ const valueParts = data.value.split("--"); if (!valueParts.length) return; - let tag; - let text2; + let tag2; + let text; let color2 = 16777215; if (_mlyHighlightedDetection === data.id) { color2 = 16776960; - text2 = valueParts[1]; - if (text2 === "flat" || text2 === "discrete" || text2 === "sign") { - text2 = valueParts[2]; + text = valueParts[1]; + if (text === "flat" || text === "discrete" || text === "sign") { + text = valueParts[2]; } - text2 = text2.replace(/-/g, " "); - text2 = text2.charAt(0).toUpperCase() + text2.slice(1); + text = text.replace(/-/g, " "); + text = text.charAt(0).toUpperCase() + text.slice(1); _mlyHighlightedDetection = null; } var decodedGeometry = window.atob(data.geometry); @@ -39937,11 +42509,11 @@ const layer = tile.layers["mpy-or"]; const geometries = layer.feature(0).loadGeometry(); const polygon2 = geometries.map((ring) => ring.map((point2) => [point2.x / layer.extent, point2.y / layer.extent])); - tag = new mapillary.OutlineTag( + tag2 = new mapillary.OutlineTag( data.id, new mapillary.PolygonGeometry(polygon2[0]), { - text: text2, + text, textColor: color2, lineColor: color2, lineWidth: 2, @@ -39949,7 +42521,7 @@ fillOpacity: 0.3 } ); - return tag; + return tag2; } }, // Return the current cache @@ -40302,7 +42874,7 @@ } } load(); - _diff.length = function length() { + _diff.length = function length2() { return Object.keys(_changes).length; }; _diff.changes = function changes() { @@ -40395,8 +42967,8 @@ } function addParents(entity) { var parents = head.parentWays(entity); - for (var j3 = parents.length - 1; j3 >= 0; j3--) { - var parent = parents[j3]; + for (var j2 = parents.length - 1; j2 >= 0; j2--) { + var parent = parents[j2]; if (!(parent.id in relevant)) { addEntity(parent, head, "modified"); } @@ -40742,11 +43314,11 @@ return change(previous); } function change(previous) { - var difference = coreDifference(previous, history.graph()); + var difference2 = coreDifference(previous, history.graph()); if (!_pausedGraph) { - dispatch14.call("change", this, difference); + dispatch14.call("change", this, difference2); } - return difference; + return difference2; } function getKey(n3) { return "iD_" + window.location.origin + "_" + n3; @@ -40886,11 +43458,11 @@ if (action) { head = action(head); } - var difference = coreDifference(base, head); + var difference2 = coreDifference(base, head); return { - modified: difference.modified(), - created: difference.created(), - deleted: difference.deleted() + modified: difference2.modified(), + created: difference2.created(), + deleted: difference2.deleted() }; }, hasChanges: function() { @@ -41251,6 +43823,7 @@ validationMismatchedGeometry: () => validationMismatchedGeometry, validationMissingRole: () => validationMissingRole, validationMissingTag: () => validationMissingTag, + validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags, validationOutdatedTags: () => validationOutdatedTags, validationPrivateData: () => validationPrivateData, validationSuspiciousName: () => validationSuspiciousName, @@ -41578,15 +44151,15 @@ if (!shouldCheckWay(parentWay)) continue; var lastIndex = parentWay.nodes.length - 1; - for (var j3 = 0; j3 < parentWay.nodes.length; j3++) { - if (j3 !== 0) { - if (parentWay.nodes[j3 - 1] === node.id) { - checkForCloseness(node, graph.entity(parentWay.nodes[j3]), parentWay); + for (var j2 = 0; j2 < parentWay.nodes.length; j2++) { + if (j2 !== 0) { + if (parentWay.nodes[j2 - 1] === node.id) { + checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay); } } - if (j3 !== lastIndex) { - if (parentWay.nodes[j3 + 1] === node.id) { - checkForCloseness(graph.entity(parentWay.nodes[j3]), node, parentWay); + if (j2 !== lastIndex) { + if (parentWay.nodes[j2 + 1] === node.id) { + checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay); } } } @@ -41618,8 +44191,8 @@ [lon + lon_range, lat + lat_range] ]); var intersected = context.history().tree().intersects(queryExtent, graph); - for (var j3 = 0; j3 < intersected.length; j3++) { - var nearby = intersected[j3]; + for (var j2 = 0; j2 < intersected.length; j2++) { + var nearby = intersected[j2]; if (nearby.id === node.id) continue; if (nearby.type !== "node" || nearby.geometry(graph) !== "point") @@ -41903,7 +44476,7 @@ if (way1FeatureType === null) return edgeCrossInfos; var checkedSingleCrossingWays = {}; - var i3, j3; + var i3, j2; var extent; var n1, n22, nA, nB, nAId, nBId; var segment1, segment2; @@ -41925,8 +44498,8 @@ ] ]); segmentInfos = tree.waySegments(extent, graph); - for (j3 = 0; j3 < segmentInfos.length; j3++) { - segment2Info = segmentInfos[j3]; + for (j2 = 0; j2 < segmentInfos.length; j2++) { + segment2Info = segmentInfos[j2]; if (segment2Info.wayId === way1.id) continue; if (checkedSingleCrossingWays[segment2Info.wayId]) @@ -42627,7 +45200,7 @@ id: nextNode.id, properties: { target: true, entity: nextNode } }); - } catch (ex) { + } catch { context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))(); } } @@ -42757,9 +45330,9 @@ entityIds: [singleEntity.id], onClick: function(context2) { var id2 = this.issue.entityIds[0]; - var operation = operationDelete(context2, [id2]); - if (!operation.disabled()) { - operation(); + var operation2 = operationDelete(context2, [id2]); + if (!operation2.disabled()) { + operation2(); } } })); @@ -43668,7 +46241,7 @@ // modules/validations/missing_tag.js function validationMissingTag(context) { var type2 = "missing_tag"; - function hasDescriptiveTags(entity, graph) { + function hasDescriptiveTags(entity) { var onlyAttributeKeys = ["description", "name", "note", "start_date"]; var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) { if (k2 === "area" || !osmIsInterestingTag(k2)) @@ -43678,7 +46251,7 @@ }); }); if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") { - return osmOldMultipolygonOuterMemberOfRelation(entity, graph); + return false; } return entityDescriptiveKeys.length > 0; } @@ -43697,7 +46270,7 @@ !entity.hasParentRelations(graph)) { if (Object.keys(entity.tags).length === 0) { subtype = "any"; - } else if (!hasDescriptiveTags(entity, graph)) { + } else if (!hasDescriptiveTags(entity)) { subtype = "descriptive"; } else if (isUntypedRelation(entity)) { subtype = "relation_type"; @@ -43736,14 +46309,14 @@ })); var deleteOnClick; var id2 = this.entityIds[0]; - var operation = operationDelete(context2, [id2]); - var disabledReasonID = operation.disabled(); + var operation2 = operationDelete(context2, [id2]); + var disabledReasonID = operation2.disabled(); if (!disabledReasonID) { deleteOnClick = function(context3) { var id3 = this.issue.entityIds[0]; - var operation2 = operationDelete(context3, [id3]); - if (!operation2.disabled()) { - operation2(); + var operation3 = operationDelete(context3, [id3]); + if (!operation3.disabled()) { + operation3(); } }; } @@ -43766,6 +46339,72 @@ return validation; } + // modules/validations/mutually_exclusive_tags.js + function validationMutuallyExclusiveTags() { + const type2 = "mutually_exclusive_tags"; + const tagKeyPairs = osmMutuallyExclusiveTagPairs; + const validation = function checkMutuallyExclusiveTags(entity) { + let pairsFounds = tagKeyPairs.filter((pair3) => { + return pair3[0] in entity.tags && pair3[1] in entity.tags; + }).filter((pair3) => { + 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"); + }); + Object.keys(entity.tags).forEach((key) => { + let negative_key = "not:" + key; + if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) { + pairsFounds.push([negative_key, key, "same_value"]); + } + if (key.match(/^name:[a-z]+/)) { + negative_key = "not:name"; + if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) { + pairsFounds.push([negative_key, key, "same_value"]); + } + } + }); + let issues = pairsFounds.map((pair3) => { + const subtype = pair3[2] || "default"; + return new validationIssue({ + type: type2, + subtype, + severity: "warning", + message: function(context) { + let entity2 = context.hasEntity(this.entityIds[0]); + return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), { + feature: utilDisplayLabel(entity2, context.graph()), + tag1: pair3[0], + tag2: pair3[1] + }) : ""; + }, + reference: (selection2) => showReference(selection2, pair3, subtype), + entityIds: [entity.id], + dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove)) + }); + }); + function createIssueFix(tagToRemove) { + return new validationIssueFix({ + icon: "iD-operation-delete", + title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }), + onClick: function(context) { + const entityId = this.issue.entityIds[0]; + const entity2 = context.entity(entityId); + let tags = Object.assign({}, entity2.tags); + delete tags[tagToRemove]; + context.perform( + actionChangeTags(entityId, tags), + _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove }) + ); + } + }); + } + function showReference(selection2, pair3, subtype) { + 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] })); + } + return issues; + }; + validation.type = type2; + return validation; + } + // modules/validations/outdated_tags.js function validationOutdatedTags() { const type2 = "outdated_tags"; @@ -43793,11 +46432,22 @@ entity = graph.entity(entity.id); preset = newPreset; } + const upgradeReasons = []; if (_dataDeprecated) { const deprecatedTags = entity.deprecatedTags(_dataDeprecated); + if (entity.type === "way" && entity.isClosed() && entity.tags.traffic_calming === "island" && !entity.tags.highway) { + deprecatedTags.push({ + old: { traffic_calming: "island" }, + replace: { "area:highway": "traffic_island" } + }); + } if (deprecatedTags.length) { - deprecatedTags.forEach((tag) => { - graph = actionUpgradeTags(entity.id, tag.old, tag.replace)(graph); + deprecatedTags.forEach((tag2) => { + graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph); + upgradeReasons.push({ + source: "id-tagging-schema--deprecated", + data: tag2 + }); }); entity = graph.entity(entity.id); } @@ -43808,9 +46458,13 @@ if (!newTags[k2]) { if (preset.addTags[k2] === "*") { newTags[k2] = "yes"; - } else { + } else if (preset.addTags[k2]) { newTags[k2] = preset.addTags[k2]; } + upgradeReasons.push({ + source: "id-tagging-schema--preset-addTags", + data: preset + }); } }); } @@ -43825,6 +46479,10 @@ if (nsiResult) { newTags = nsiResult.newTags; subtype = "noncanonical_brand"; + upgradeReasons.push({ + source: "name-suggestion-index", + data: nsiResult + }); } } } @@ -43935,71 +46593,7 @@ }).html((d2) => d2.display); } } - function oldMultipolygonIssues(entity, graph) { - let multipolygon, outerWay; - if (entity.type === "relation") { - outerWay = osmOldMultipolygonOuterMemberOfRelation(entity, graph); - multipolygon = entity; - } else if (entity.type === "way") { - multipolygon = osmIsOldMultipolygonOuterMember(entity, graph); - outerWay = entity; - } else { - return []; - } - if (!multipolygon || !outerWay) - return []; - return [new validationIssue({ - type: type2, - subtype: "old_multipolygon", - severity: "warning", - message: showMessage, - reference: showReference, - entityIds: [outerWay.id, multipolygon.id], - dynamicFixes: () => { - return [ - new validationIssueFix({ - autoArgs: [doUpgrade, _t("issues.fix.move_tags.annotation")], - title: _t.append("issues.fix.move_tags.title"), - onClick: (context) => { - context.perform(doUpgrade, _t("issues.fix.move_tags.annotation")); - } - }) - ]; - } - })]; - function doUpgrade(graph2) { - let currMultipolygon = graph2.hasEntity(multipolygon.id); - let currOuterWay = graph2.hasEntity(outerWay.id); - if (!currMultipolygon || !currOuterWay) - return graph2; - currMultipolygon = currMultipolygon.mergeTags(currOuterWay.tags); - graph2 = graph2.replace(currMultipolygon); - return actionChangeTags(currOuterWay.id, {})(graph2); - } - function showMessage(context) { - let currMultipolygon = context.hasEntity(multipolygon.id); - if (!currMultipolygon) - return ""; - return _t.append( - "issues.old_multipolygon.message", - { multipolygon: utilDisplayLabel( - currMultipolygon, - context.graph(), - true - /* verbose */ - ) } - ); - } - function showReference(selection2) { - selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.old_multipolygon.reference")); - } - } - let validation = function checkOutdatedTags(entity, graph) { - let issues = oldMultipolygonIssues(entity, graph); - if (!issues.length) - issues = oldTagIssues(entity, graph); - return issues; - }; + let validation = oldTagIssues; validation.type = type2; return validation; } @@ -44194,70 +46788,18 @@ selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference")); } } - function makeIncorrectNameIssue(entityId, nameKey, incorrectName, langCode) { - return new validationIssue({ - type: type2, - subtype: "not_name", - severity: "warning", - message: function(context) { - const entity = context.hasEntity(this.entityIds[0]); - if (!entity) - return ""; - const preset = _mainPresetIndex.match(entity, context.graph()); - const langName = langCode && _mainLocalizer.languageName(langCode); - return _t.append( - "issues.incorrect_name.message" + (langName ? "_language" : ""), - { feature: preset.name(), name: incorrectName, language: langName } - ); - }, - reference: showReference, - entityIds: [entityId], - hash: "".concat(nameKey, "=").concat(incorrectName), - dynamicFixes: function() { - return [ - new validationIssueFix({ - icon: "iD-operation-delete", - title: _t.append("issues.fix.remove_the_name.title"), - onClick: function(context) { - const entityId2 = this.issue.entityIds[0]; - const entity = context.entity(entityId2); - let tags = Object.assign({}, entity.tags); - delete tags[nameKey]; - context.perform( - actionChangeTags(entityId2, tags), - _t("issues.fix.remove_mistaken_name.annotation") - ); - } - }) - ]; - } - }); - function showReference(selection2) { - selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference")); - } - } let validation = function checkGenericName(entity) { const tags = entity.tags; const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"]; if (hasWikidata) return []; let issues = []; - const notNames2 = (tags["not:name"] || "").split(";"); for (let key in tags) { const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/); if (!m2) continue; const langCode = m2.length >= 2 ? m2[1] : null; const value = tags[key]; - if (notNames2.length) { - for (let i3 in notNames2) { - const notName = notNames2[i3]; - if (notName && value === notName) { - issues.push(makeIncorrectNameIssue(entity.id, key, value, langCode)); - continue; - } - } - } if (isGenericName(value, tags)) { issues.provisional = _waitingForNsi; issues.push(makeGenericNameIssue(entity.id, key, value, langCode)); @@ -44410,8 +46952,8 @@ result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) }); }); return result; - function makeRegExp(str2) { - const escaped = str2.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*"); + function makeRegExp(str) { + const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*"); return new RegExp("^" + escaped + "$"); } } @@ -45028,10 +47570,10 @@ } } function detectConflicts() { - function choice(id2, text2, action) { + function choice(id2, text, action) { return { id: id2, - text: text2, + text, action: function() { history.replace(action); } @@ -45158,8 +47700,8 @@ var entity = context.hasEntity(_conflicts[i3].id); if (entity && entity.type === "way") { var children2 = utilArrayUniq(entity.nodes); - for (var j3 = 0; j3 < children2.length; j3++) { - history.replace(actionRevert(children2[j3])); + for (var j2 = 0; j2 < children2.length; j2++) { + history.replace(actionRevert(children2[j2])); } } history.replace(actionRevert(_conflicts[i3].id)); @@ -45288,7 +47830,7 @@ return source; }; source.url = function(coord2) { - var result = _template.replace(new RegExp("#[\\s\\S]*", "u"), ""); + var result = _template.replace(/#[\s\S]*/u, ""); if (result === "") return result; if (!source.type || source.id === "custom") { @@ -45542,7 +48084,7 @@ inflight[tileID] = true; json_default(url).then(function(result) { delete inflight[tileID]; - result = result.features.map((f3) => f3.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0]; + result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0]; if (!result) { throw new Error("Unknown Error"); } else if (result.features && result.features.length < 1) { @@ -45612,7 +48154,7 @@ if (cleaned.indexOf("?") !== -1) { var parts = cleaned.split("?", 2); var qs = utilStringQs(parts[1]); - ["access_token", "connectId", "token"].forEach(function(param) { + ["access_token", "connectId", "token", "Signature"].forEach(function(param) { if (qs[param]) { qs[param] = "{apikey}"; } @@ -45688,8 +48230,8 @@ if (ring.length < 4) { throw new Error("Each LinearRing of a Polygon must have 4 or more Positions."); } - for (var j3 = 0; j3 < ring[ring.length - 1].length; j3++) { - if (ring[ring.length - 1][j3] !== ring[0][j3]) { + for (var j2 = 0; j2 < ring[ring.length - 1].length; j2++) { + if (ring[ring.length - 1][j2] !== ring[0][j2]) { throw new Error("First and last Position are not equivalent."); } } @@ -45872,7 +48414,7 @@ function coordEach(geojson, callback, excludeWrapCoord) { if (geojson === null) return; - var j3, 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; + 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; for (var featureIndex = 0; featureIndex < stop; featureIndex++) { geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson; isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false; @@ -45903,9 +48445,9 @@ break; case "LineString": case "MultiPoint": - for (j3 = 0; j3 < coords.length; j3++) { + for (j2 = 0; j2 < coords.length; j2++) { if (callback( - coords[j3], + coords[j2], coordIndex, featureIndex, multiFeatureIndex, @@ -45921,10 +48463,10 @@ break; case "Polygon": case "MultiLineString": - for (j3 = 0; j3 < coords.length; j3++) { - for (k2 = 0; k2 < coords[j3].length - wrapShrink; k2++) { + for (j2 = 0; j2 < coords.length; j2++) { + for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) { if (callback( - coords[j3][k2], + coords[j2][k2], coordIndex, featureIndex, multiFeatureIndex, @@ -45942,12 +48484,12 @@ multiFeatureIndex++; break; case "MultiPolygon": - for (j3 = 0; j3 < coords.length; j3++) { + for (j2 = 0; j2 < coords.length; j2++) { geometryIndex = 0; - for (k2 = 0; k2 < coords[j3].length; k2++) { - for (l2 = 0; l2 < coords[j3][k2].length - wrapShrink; l2++) { + for (k2 = 0; k2 < coords[j2].length; k2++) { + for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) { if (callback( - coords[j3][k2][l2], + coords[j2][k2][l2], coordIndex, featureIndex, multiFeatureIndex, @@ -45962,8 +48504,8 @@ } break; case "GeometryCollection": - for (j3 = 0; j3 < geometry.geometries.length; j3++) - if (coordEach(geometry.geometries[j3], callback, excludeWrapCoord) === false) + for (j2 = 0; j2 < geometry.geometries.length; j2++) + if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false) return false; break; default: @@ -46787,8 +49329,8 @@ }; features.toggle = function(k2) { if (_rules[k2]) { - (function(f3) { - return f3.enabled ? f3.disable() : f3.enable(); + (function(f2) { + return f2.enabled ? f2.disable() : f2.enable(); })(_rules[k2]); update(); } @@ -46803,7 +49345,7 @@ var needsRedraw = false; var types = utilArrayGroupBy(d2, "type"); var entities = [].concat(types.relation || [], types.way || [], types.node || []); - var currHidden, geometry, matches, i3, j3; + var currHidden, geometry, matches, i3, j2; for (i3 = 0; i3 < _keys.length; i3++) { _rules[_keys[i3]].count = 0; } @@ -46811,8 +49353,8 @@ for (i3 = 0; i3 < entities.length; i3++) { geometry = entities[i3].geometry(resolver); matches = Object.keys(features.getMatches(entities[i3], resolver, geometry)); - for (j3 = 0; j3 < matches.length; j3++) { - _rules[matches[j3]].count++; + for (j2 = 0; j2 < matches.length; j2++) { + _rules[matches[j2]].count++; } } currHidden = features.hidden(); @@ -46992,8 +49534,8 @@ _forceVisible[entityIDs[i3]] = true; var entity = context.hasEntity(entityIDs[i3]); if (entity && entity.type === "relation") { - for (var j3 in entity.members) { - _forceVisible[entity.members[j3].id] = true; + for (var j2 in entity.members) { + _forceVisible[entity.members[j2].id] = true; } } } @@ -47038,16 +49580,16 @@ if (activeID === node.id) return 0; var parents = graph.parentWays(node); - var i3, j3, nodes, isClosed, ix1, ix2, ix3, ix4, max3; + var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3; for (i3 = 0; i3 < parents.length; i3++) { nodes = parents[i3].nodes; isClosed = parents[i3].isClosed(); - for (j3 = 0; j3 < nodes.length; j3++) { - if (nodes[j3] === node.id) { - ix1 = j3 - 2; - ix2 = j3 - 1; - ix3 = j3 + 1; - ix4 = j3 + 2; + for (j2 = 0; j2 < nodes.length; j2++) { + if (nodes[j2] === node.id) { + ix1 = j2 - 2; + ix2 = j2 - 1; + ix3 = j2 + 1; + ix4 = j2 + 2; if (isClosed) { max3 = nodes.length - 1; if (ix1 < 0) @@ -47101,12 +49643,12 @@ if (a2) { var span = geoVecLength(a2, b2) - offset; if (span >= 0) { - var heading = geoVecAngle(a2, b2); - var dx = dt2 * Math.cos(heading); - var dy = dt2 * Math.sin(heading); + var heading2 = geoVecAngle(a2, b2); + var dx = dt2 * Math.cos(heading2); + var dy = dt2 * Math.sin(heading2); var p2 = [ - a2[0] + offset * Math.cos(heading), - a2[1] + offset * Math.sin(heading) + a2[0] + offset * Math.cos(heading2), + a2[1] + offset * Math.sin(heading2) ]; var coord2 = [a2, p2]; for (span -= dt2; span >= 0; span -= dt2) { @@ -47115,15 +49657,15 @@ } coord2.push(b2); var segment = ""; - var j3; - for (j3 = 0; j3 < coord2.length; j3++) { - segment += (j3 === 0 ? "M" : "L") + coord2[j3][0] + "," + coord2[j3][1]; + var j2; + for (j2 = 0; j2 < coord2.length; j2++) { + segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1]; } segments.push({ id: entity.id, index: i3++, d: segment }); if (bothDirections(entity)) { segment = ""; - for (j3 = coord2.length - 1; j3 >= 0; j3--) { - segment += (j3 === coord2.length - 1 ? "M" : "L") + coord2[j3][0] + "," + coord2[j3][1]; + for (j2 = coord2.length - 1; j2 >= 0; j2--) { + segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1]; } segments.push({ id: entity.id, index: i3++, d: segment }); } @@ -47278,6 +49820,7 @@ "man_made", "route", "attraction", + "roller_coaster", "building:part", "indoor" ]; @@ -47324,7 +49867,7 @@ }; tagClasses.getClassesString = function(t2, value) { var primary, status; - var i3, j3, k2, v2; + var i3, j2, k2, v2; var overrideGeometry; if (/\bstroke\b/.test(value)) { if (!!t2.barrier && t2.barrier !== "no") { @@ -47358,8 +49901,8 @@ } if (!primary) { for (i3 = 0; i3 < statuses.length; i3++) { - for (j3 = 0; j3 < primaries.length; j3++) { - k2 = statuses[i3] + ":" + primaries[j3]; + for (j2 = 0; j2 < primaries.length; j2++) { + k2 = statuses[i3] + ":" + primaries[j2]; v2 = t2[k2]; if (!v2 || v2 === "no") continue; @@ -47509,14 +50052,14 @@ if (tags.building && tags.building !== "no") { return null; } - for (var tag in patterns) { - var entityValue = tags[tag]; + for (var tag2 in patterns) { + var entityValue = tags[tag2]; if (!entityValue) continue; - if (typeof patterns[tag] === "string") { - return "pattern-" + patterns[tag]; + if (typeof patterns[tag2] === "string") { + return "pattern-" + patterns[tag2]; } else { - var values = patterns[tag]; + var values = patterns[tag2]; for (var value in values) { if (entityValue !== value) continue; @@ -47600,19 +50143,12 @@ function drawAreas(selection2, graph, entities, filter2) { var path = svgPath(projection2, graph, true); var areas = {}; - var multipolygon; var base = context.history().base(); for (var i3 = 0; i3 < entities.length; i3++) { var entity = entities[i3]; if (entity.geometry(graph) !== "area") continue; - multipolygon = osmIsOldMultipolygonOuterMember(entity, graph); - if (multipolygon) { - areas[multipolygon.id] = { - entity: multipolygon.mergeTags(entity.tags), - area: Math.abs(entity.area(graph)) - }; - } else if (!areas[entity.id]) { + if (!areas[entity.id]) { areas[entity.id] = { entity, area: Math.abs(entity.area(graph)) @@ -47806,7 +50342,7 @@ }; } function extractProperties(node) { - var _a; + var _a2; const properties = getMulti(node, [ "name", "cmt", @@ -47817,13 +50353,13 @@ ]); const extensions = Array.from(node.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*")); for (const child of extensions) { - if (((_a = child.parentNode) == null ? void 0 : _a.parentNode) === node) { + if (((_a2 = child.parentNode) == null ? void 0 : _a2.parentNode) === node) { properties[child.tagName.replace(":", "_")] = nodeVal(child); } } const links = $(node, "link"); if (links.length) { - properties.links = links.map((link2) => Object.assign({ href: link2.getAttribute("href") }, getMulti(link2, ["text", "type"]))); + properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"]))); } return properties; } @@ -48223,7 +50759,7 @@ }; } function getPlacemark(node, styleMap, schema, options2) { - var _a; + var _a2; const { coordTimes, geometries } = getGeometry(node); const geometry = geometryListToGeometry(geometries); if (!geometry && options2.skipNullGeometry) { @@ -48245,7 +50781,7 @@ } } : {}) }; - if (((_a = feature3.properties) == null ? void 0 : _a.visibility) !== void 0) { + if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) { feature3.properties.visibility = feature3.properties.visibility !== "0"; } const id2 = node.getAttribute("id"); @@ -48317,7 +50853,7 @@ return null; } function getGroundOverlay(node, styleMap, schema, options2) { - var _a; + var _a2; const box = getGroundOverlayBox(node); const geometry = (box == null ? void 0 : box.geometry) || null; if (!geometry && options2.skipNullGeometry) { @@ -48352,7 +50888,7 @@ if (box == null ? void 0 : box.bbox) { feature3.bbox = box.bbox; } - if (((_a = feature3.properties) == null ? void 0 : _a.visibility) !== void 0) { + if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) { feature3.properties.visibility = feature3.properties.visibility !== "0"; } const id2 = node.getAttribute("id"); @@ -48452,8 +50988,8 @@ d3_event.preventDefault(); if (!detected.filedrop) return; - var f3 = d3_event.dataTransfer.files[0]; - var extension = getExtension(f3.name); + var f2 = d3_event.dataTransfer.files[0]; + var extension = getExtension(f2.name); if (!supportedFormats.includes(extension)) return; drawData.fileList(d3_event.dataTransfer.files); @@ -48729,15 +51265,15 @@ _fileList = fileList; if (!fileList || !fileList.length) return this; - var f3 = fileList[0]; - var extension = getExtension(f3.name); + var f2 = fileList[0]; + var extension = getExtension(f2.name); var reader = new FileReader(); - reader.onload = function() { + reader.onload = /* @__PURE__ */ function() { return function(e3) { drawData.setFile(extension, e3.target.result); }; - }(f3); - reader.readAsText(f3); + }(f2); + reader.readAsText(f2); return this; }; drawData.url = function(url, defaultExtension) { @@ -49209,21 +51745,21 @@ return array2[i3][prop]; }; } - function textWidth(text2, size, elem) { + function textWidth(text, size, elem) { var c2 = _textWidthCache[size]; if (!c2) c2 = _textWidthCache[size] = {}; - if (c2[text2]) { - return c2[text2]; + if (c2[text]) { + return c2[text]; } else if (elem) { - c2[text2] = elem.getComputedTextLength(); - return c2[text2]; + c2[text] = elem.getComputedTextLength(); + return c2[text]; } else { - var str2 = encodeURIComponent(text2).match(/%[CDEFcdef]/g); - if (str2 === null) { - return size / 3 * 2 * text2.length; + var str = encodeURIComponent(text).match(/%[CDEFcdef]/g); + if (str === null) { + return size / 3 * 2 * text.length; } else { - return size / 3 * (2 * text2.length + str2.length); + return size / 3 * (2 * text.length + str.length); } } } @@ -49293,7 +51829,7 @@ var zoom = geoScaleToZoom(projection2.scale()); var labelable = []; var renderNodeAs = {}; - var i3, j3, k2, entity, geometry; + var i3, j2, k2, entity, geometry; for (i3 = 0; i3 < labelStack.length; i3++) { labelable.push([]); } @@ -49305,9 +51841,9 @@ for (i3 = 0; i3 < entities.length; i3++) { entity = entities[i3]; var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []); - for (j3 = 0; j3 < toRemove.length; j3++) { - _rdrawn.remove(toRemove[j3]); - _rskipped.remove(toRemove[j3]); + for (j2 = 0; j2 < toRemove.length; j2++) { + _rdrawn.remove(toRemove[j2]); + _rskipped.remove(toRemove[j2]); } } } @@ -49441,8 +51977,8 @@ var points = graph.childNodes(entity2).map(function(node) { return projection2(node.loc); }); - var length = geoPathLength(points); - if (length < width2 + 20) + var length2 = geoPathLength(points); + if (length2 < width2 + 20) return; var lineOffsets = [ 50, @@ -49468,9 +52004,9 @@ var padding = 3; for (var i4 = 0; i4 < lineOffsets.length; i4++) { var offset = lineOffsets[i4]; - var middle = offset / 100 * length; + var middle = offset / 100 * length2; var start2 = middle - width2 / 2; - if (start2 < 0 || start2 + width2 > length) + if (start2 < 0 || start2 + width2 > length2) continue; var sub = subpath(points, start2, start2 + width2); if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) { @@ -49482,9 +52018,9 @@ } var bboxes = []; var boxsize = (height + 2) / 2; - for (var j4 = 0; j4 < sub.length - 1; j4++) { - var a2 = sub[j4]; - var b2 = sub[j4 + 1]; + for (var j3 = 0; j3 < sub.length - 1; j3++) { + var a2 = sub[j3]; + var b2 = sub[j3 + 1]; var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2)); for (var box = 0; box < num; box++) { var p3 = geoVecInterp(a2, b2, box / num); @@ -49727,10 +52263,10 @@ function l(e3, t2 = o) { if (n2) try { - return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : Promise.resolve().then(() => ( + return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import( /* webpackIgnore: true */ - __toESM(__require(e3)) - )).then(t2); + e3 + ).then(t2); } catch (t3) { console.warn("Couldn't load ".concat(e3)); } @@ -49740,9 +52276,9 @@ if (!e.fetch) { const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => { let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3); - const f3 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 }; - "" !== o2 && (f3.port = Number(o2)); - const d2 = ("https:" === u2 ? await t2 : await e3).request(f3, (e4) => { + const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 }; + "" !== o2 && (f2.port = Number(o2)); + const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => { if (301 === e4.statusCode || 302 === e4.statusCode) { let t3 = new URL(e4.headers.location, n3).toString(); return i3(t3, { headers: s2 }).then(r2).catch(a2); @@ -49759,7 +52295,7 @@ function c(e3, t2, i3) { return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3; } - var f2 = (e3) => p(e3) ? void 0 : e3; + var f = (e3) => p(e3) ? void 0 : e3; var d = (e3) => void 0 !== e3; function p(e3) { return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length); @@ -49977,7 +52513,7 @@ var V = ["jfif", "xmp", "icc", "iptc", "ihdr"]; var z = ["tiff", ...V]; var H = ["ifd0", "ifd1", "exif", "gps", "interop"]; - var j2 = [...z, ...H]; + var j = [...z, ...H]; var W = ["makerNote", "userComment"]; var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"]; var X = [...K, "sanitize", "mergeOutput", "silentErrors"]; @@ -50039,7 +52575,7 @@ this[e3] = $2[e3]; for (e3 of W) this[e3] = $2[e3]; - for (e3 of j2) + for (e3 of j) this[e3] = new Y(e3, $2[e3], void 0, this); } setupFromTrue() { @@ -50050,7 +52586,7 @@ this[e3] = $2[e3]; for (e3 of W) this[e3] = true; - for (e3 of j2) + for (e3 of j) this[e3] = new Y(e3, true, void 0, this); } setupFromArray(e3) { @@ -50061,7 +52597,7 @@ this[t2] = $2[t2]; for (t2 of W) this[t2] = $2[t2]; - for (t2 of j2) + for (t2 of j) this[t2] = new Y(t2, false, void 0, this); this.setupGlobalFilters(e3, void 0, H); } @@ -50077,7 +52613,7 @@ this[t2] = new Y(t2, $2[t2], e3[t2], this); for (t2 of H) this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff); - this.setupGlobalFilters(e3.pick, e3.skip, H, j2), 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); + 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); } batchEnableWithBool(e3, t2) { for (let i3 of e3) @@ -50155,7 +52691,7 @@ } async parse() { let { output: e3, errors: t2 } = this; - 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), f2(e3); + 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); } async executeParsers() { let { output: e3 } = this; @@ -50180,7 +52716,7 @@ let i3 = new te(t2); return await i3.read(e3), i3.parse(); } - 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: j2, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q }); + 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 }); var se = class { constructor(e3, t2, i3) { c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => { @@ -50304,17 +52840,17 @@ } findAppSegmentsInRange(e3, t2) { t2 -= 2; - let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f3 } = this; + let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this; for (; e3 < t2; e3++) if (255 === l2.getUint8(e3)) { if (i3 = l2.getUint8(e3 + 1), oe(i3)) { - 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 = f3[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))) + 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; - f3.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1; + f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1; } else if (ae(i3)) { - if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f3.stopAfterSos) + if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos) return; - f3.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1; + f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1; } } return e3; @@ -50540,7 +53076,7 @@ return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2; } c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe); - 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: j2, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie }); + 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 }); var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false }; var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] }); async function Se(e3) { @@ -50715,7 +53251,7 @@ return this.set(s2, e3, true); } }); - 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: j2, 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() { + 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() { return we; }, get rotateCss() { return Te; @@ -50922,8 +53458,8 @@ return function(e4) { let t3; for (let i4 in e4) - t3 = e4[i4] = f2(e4[i4]), void 0 === t3 && delete e4[i4]; - return f2(e4); + t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4]; + return f(e4); }(n3); } assignToOutput(e3, t2) { @@ -51004,7 +53540,7 @@ let e3 = {}; for (let t2 of this.properties) _e(t2, e3); - return void 0 !== this.value && (e3.value = this.value), f2(e3); + return void 0 !== this.value && (e3.value = this.value), f(e3); } }; function _e(e3, t2) { @@ -51035,7 +53571,7 @@ } var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"]; var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g"); - 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: j2, 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() { + 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() { return we; }, get rotateCss() { return Te; @@ -51425,7 +53961,7 @@ } const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]); const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true); - viewerEnter.append("div").attr("class", "photo-attribution fillD"); + viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD"); return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => { _photoFrame = planePhotoFrame; }); @@ -51435,6 +53971,9 @@ const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false); const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false); const attribution = viewerWrap.selectAll(".photo-attribution").text(""); + if (image.date) { + attribution.append("span").text(image.date.toLocaleString()); + } if (image.name) { attribution.append("span").classed("filename", true).text(image.name); } @@ -51471,9 +54010,9 @@ const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); viewfields.exit().remove(); viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() { - var _a; + var _a2; const d2 = this.parentNode.__data__; - return "rotate(".concat(Math.round((_a = d2.direction) != null ? _a : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)"); + return "rotate(".concat(Math.round((_a2 = d2.direction) != null ? _a2 : 0), ",0,0),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").style("visibility", function() { const d2 = this.parentNode.__data__; return isNumber_default(d2.direction) ? "visible" : "hidden"; @@ -51485,7 +54024,7 @@ const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos"); layerEnter.append("g").attr("class", "markers"); layer = layerEnter.merge(layer); - if (_photos && _photos.length !== 0) { + if (_photos) { display_markers(_photos); } } @@ -51508,7 +54047,8 @@ getSrc: () => readFileAsDataURL(file), file, loc: [exifData.longitude, exifData.latitude], - direction: exifData.GPSImgDirection + direction: exifData.GPSImgDirection, + date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate }; loaded.push(photo); const sameName = _photos.filter((i3) => i3.name === photo.name); @@ -51521,7 +54061,7 @@ _photos.push(photo); } } - } catch (err) { + } catch { } } if (typeof callback === "function") @@ -53479,7 +56019,8 @@ unclassified: 8, residential: 9, service: 10, - footway: 11 + busway: 11, + footway: 12 }; function drawTargets(selection2, graph, entities, filter2) { var targetClass = context.getDebug("target") ? "pink " : "nocolor "; @@ -53607,11 +56148,7 @@ var oldMultiPolygonOuters = {}; for (var i3 = 0; i3 < entities.length; i3++) { var entity = entities[i3]; - var outer = osmOldMultipolygonOuterMember(entity, graph); - if (outer) { - ways.push(entity.mergeTags(outer.tags)); - oldMultiPolygonOuters[outer.id] = true; - } else if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") { + if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") { ways.push(entity); } } @@ -53737,9 +56274,9 @@ if (context.selectedIDs().indexOf(entity.id) < 0) continue; var nodes = graph.childNodes(entity); - for (var j3 = 0; j3 < nodes.length - 1; j3++) { - var a2 = nodes[j3]; - var b2 = nodes[j3 + 1]; + for (var j2 = 0; j2 < nodes.length - 1; j2++) { + var a2 = nodes[j2]; + var b2 = nodes[j2 + 1]; var id2 = [a2.id, b2.id].sort().join("-"); if (midpoints[id2]) { midpoints[id2].parents.push(entity); @@ -54620,7 +57157,7 @@ var maxZoom = 24; var kMin = geoZoomToScale(minZoom2, TILESIZE); var kMax = geoZoomToScale(maxZoom, TILESIZE); - function clamp(num, min3, max3) { + function clamp2(num, min3, max3) { return Math.max(min3, Math.min(num, max3)); } function rendererMap(context) { @@ -54812,14 +57349,14 @@ function pxCenter() { return [_dimensions[0] / 2, _dimensions[1] / 2]; } - function drawEditable(difference, extent) { + function drawEditable(difference2, extent) { var mode = context.mode(); var graph = context.graph(); var features = context.features(); var all = context.history().intersects(map2.extent()); var fullRedraw = false; var data; - var set3; + var set4; var filter2; var applyFeatureLayerFilters = true; if (map2.isInWideSelection()) { @@ -54832,12 +57369,12 @@ fullRedraw = true; filter2 = utilFunctor(true); applyFeatureLayerFilters = false; - } else if (difference) { - var complete = difference.complete(map2.extent()); + } else if (difference2) { + var complete = difference2.complete(map2.extent()); data = Object.values(complete).filter(Boolean); - set3 = new Set(Object.keys(complete)); + set4 = new Set(Object.keys(complete)); filter2 = function(d2) { - return set3.has(d2.id); + return set4.has(d2.id); }; features.clear(data); } else { @@ -54846,11 +57383,11 @@ } if (extent) { data = context.history().intersects(map2.extent().intersection(extent)); - set3 = new Set(data.map(function(entity) { + set4 = new Set(data.map(function(entity) { return entity.id; })); filter2 = function(d2) { - return set3.has(d2.id); + return set4.has(d2.id); }; } else { data = all; @@ -54934,7 +57471,7 @@ if (source.deltaMode === 1) { var lines = Math.abs(source.deltaY); var sign2 = source.deltaY > 0 ? 1 : -1; - dY = sign2 * clamp( + dY = sign2 * clamp2( Math.exp((lines - 1) * 0.75) * 4.000244140625, 4.000244140625, // min @@ -54948,7 +57485,7 @@ p02 = _getMouseCoords(source); p1 = t0.invert(p02); k22 = t0.k * Math.pow(2, -dY / 500); - k22 = clamp(k22, kMin, kMax); + k22 = clamp2(k22, kMin, kMax); x22 = p02[0] - p1[0] * k22; y22 = p02[1] - p1[1] * k22; } else if (source._scale) { @@ -54956,7 +57493,7 @@ p02 = _getMouseCoords(source); p1 = t0.invert(p02); k22 = t0.k * source._scale; - k22 = clamp(k22, kMin, kMax); + k22 = clamp2(k22, kMin, kMax); x22 = p02[0] - p1[0] * k22; y22 = p02[1] - p1[1] * k22; } else if (source.ctrlKey && !isInteger(dY)) { @@ -54965,7 +57502,7 @@ p02 = _getMouseCoords(source); p1 = t0.invert(p02); k22 = t0.k * Math.pow(2, -dY / 500); - k22 = clamp(k22, kMin, kMax); + k22 = clamp2(k22, kMin, kMax); x22 = p02[0] - p1[0] * k22; y22 = p02[1] - p1[1] * k22; } else if ((source.altKey || source.shiftKey) && isInteger(dY)) { @@ -54973,7 +57510,7 @@ p02 = _getMouseCoords(source); p1 = t0.invert(p02); k22 = t0.k * Math.pow(2, -dY / 500); - k22 = clamp(k22, kMin, kMax); + k22 = clamp2(k22, kMin, kMax); x22 = p02[0] - p1[0] * k22; y22 = p02[1] - p1[1] * k22; } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) { @@ -54981,7 +57518,7 @@ x22 = p1[0] - dX; y22 = p1[1] - dY; k22 = projection2.scale(); - k22 = clamp(k22, kMin, kMax); + k22 = clamp2(k22, kMin, kMax); } if (x22 !== x2 || y22 !== y2 || k22 !== k2) { x2 = x22; @@ -55046,11 +57583,11 @@ } return true; } - function redraw(difference, extent) { + function redraw(difference2, extent) { if (surface.empty() || !_redrawEnabled) return; if (resetTransform()) { - difference = extent = void 0; + difference2 = extent = void 0; } var zoom = map2.zoom(); var z2 = String(~~zoom); @@ -55060,23 +57597,23 @@ var lat = map2.center()[1]; var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true); surface.classed("low-zoom", zoom <= lowzoom(lat)); - if (!difference) { + if (!difference2) { supersurface.call(context.background()); wrapper.call(drawLayers); } if (map2.editableDataEnabled() || map2.isInWideSelection()) { context.loadTiles(projection2); - drawEditable(difference, extent); + drawEditable(difference2, extent); } else { editOff(); } _transformStart = projection2.transform(); return map2; } - var immediateRedraw = function(difference, extent) { - if (!difference && !extent) + var immediateRedraw = function(difference2, extent) { + if (!difference2 && !extent) cancelPendingRedraw(); - redraw(difference, extent); + redraw(difference2, extent); }; map2.lastPointerEvent = function() { return _lastPointerEvent; @@ -55132,7 +57669,7 @@ if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force) return false; var proj = geoRawMercator().transform(projection2.transform()); - var k2 = clamp(geoZoomToScale(z2, TILESIZE), kMin, kMax); + var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax); proj.scale(k2); var t2 = proj.translate(); var point2 = proj(loc2); @@ -55246,7 +57783,7 @@ var extent = entity.extent(context.graph()); if (!isFinite(extent.area())) return map2; - var z2 = clamp(map2.trimmedExtentZoom(extent), 0, 20); + var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); return map2.centerZoom(extent.center(), z2); }; map2.centerEase = function(loc2, duration) { @@ -55290,7 +57827,7 @@ } if (!isFinite(extent.area())) return map2; - var z2 = clamp(map2.trimmedExtentZoom(extent), 0, 20); + var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); return map2.centerZoomEase(extent.center(), z2, duration); }; map2.startEase = function() { @@ -55330,9 +57867,9 @@ }; function calcExtentZoom(extent, dim) { var tl = projection2([extent[0][0], extent[1][1]]); - var br = projection2([extent[1][0], extent[0][1]]); - var hFactor = (br[0] - tl[0]) / dim[0]; - var vFactor = (br[1] - tl[1]) / dim[1]; + var br2 = projection2([extent[1][0], extent[0][1]]); + var hFactor = (br2[0] - tl[0]) / dim[0]; + var vFactor = (br2[1] - tl[1]) / dim[1]; var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2; var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2; var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff); @@ -56063,16 +58600,16 @@ return tooltip; }; tooltip.content(function() { - var heading = _heading.apply(this, arguments); - var text2 = _title.apply(this, arguments); + var heading2 = _heading.apply(this, arguments); + var text = _title.apply(this, arguments); var keys2 = _keys.apply(this, arguments); - var headingCallback = typeof heading === "function" ? heading : (s2) => s2.text(heading); - var textCallback = typeof text2 === "function" ? text2 : (s2) => s2.text(text2); + var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2); + var textCallback = typeof text === "function" ? text : (s2) => s2.text(text); return function(selection2) { - var headingSelect = selection2.selectAll(".tooltip-heading").data(heading ? [heading] : []); + var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []); headingSelect.exit().remove(); headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback); - var textSelect = selection2.selectAll(".tooltip-text").data(text2 ? [text2] : []); + var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []); textSelect.exit().remove(); textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback); var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []); @@ -56167,20 +58704,20 @@ function pointerup(d3_event) { lastPointerUpType = d3_event.pointerType; } - function click(d3_event, operation) { + function click(d3_event, operation2) { d3_event.stopPropagation(); - if (operation.relatedEntityIds) { - utilHighlightEntities(operation.relatedEntityIds(), false, context); + if (operation2.relatedEntityIds) { + utilHighlightEntities(operation2.relatedEntityIds(), false, context); } - if (operation.disabled()) { + if (operation2.disabled()) { if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { - context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation.id).iconClass("operation disabled").label(operation.tooltip())(); + context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())(); } } else { if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { - context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation.id).iconClass("operation").label(operation.annotation() || operation.title)(); + context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)(); } - operation(); + operation2(); editMenu.close(); } lastPointerUpType = null; @@ -56529,12 +59066,12 @@ _metadata = {}; } selection2.text(""); - var list = selection2.append("ul").attr("class", "background-info"); - list.append("li").call(_currSourceName); + var list2 = selection2.append("ul").attr("class", "background-info"); + list2.append("li").call(_currSourceName); _metadataKeys.forEach(function(k2) { if (isDG && k2 === "vintage") return; - list.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]); + 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]); }); debouncedGetMetadata(selection2); var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles"; @@ -56688,11 +59225,11 @@ selection2.append("div").call(_t.append("info_panels.history.note_no_history")); return; } - var list = selection2.append("ul"); - list.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length); + var list2 = selection2.append("ul"); + list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length); if (note.comments.length) { - list.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date)); - list.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user); + list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date)); + list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user); } if (osm) { 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")); @@ -56708,11 +59245,11 @@ 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")); } 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"); - var list = selection2.append("ul"); - list.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version); - list.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp)); - list.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user); - list.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset); + var list2 = selection2.append("ul"); + list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version); + list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp)); + list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user); + list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset); } var panel = function(selection2) { selection2.call(redraw); @@ -56733,144 +59270,17 @@ return panel; } - // modules/util/units.js - var OSM_PRECISION = 7; - function displayLength(m2, isImperial) { - var d2 = m2 * (isImperial ? 3.28084 : 1); - var unit2; - if (isImperial) { - if (d2 >= 5280) { - d2 /= 5280; - unit2 = "miles"; - } else { - unit2 = "feet"; - } - } else { - if (d2 >= 1e3) { - d2 /= 1e3; - unit2 = "kilometers"; - } else { - unit2 = "meters"; - } - } - return _t("units." + unit2, { - quantity: d2.toLocaleString(_mainLocalizer.localeCode(), { - maximumSignificantDigits: 4 - }) - }); - } - function displayArea(m2, isImperial) { - var locale2 = _mainLocalizer.localeCode(); - var d2 = m2 * (isImperial ? 10.7639111056 : 1); - var d1, d22, area; - var unit1 = ""; - var unit2 = ""; - if (isImperial) { - if (d2 >= 6969600) { - d1 = d2 / 27878400; - unit1 = "square_miles"; - } else { - d1 = d2; - unit1 = "square_feet"; - } - if (d2 > 4356 && d2 < 4356e4) { - d22 = d2 / 43560; - unit2 = "acres"; - } - } else { - if (d2 >= 25e4) { - d1 = d2 / 1e6; - unit1 = "square_kilometers"; - } else { - d1 = d2; - unit1 = "square_meters"; - } - if (d2 > 1e3 && d2 < 1e7) { - d22 = d2 / 1e4; - unit2 = "hectares"; - } - } - area = _t("units." + unit1, { - quantity: d1.toLocaleString(locale2, { - maximumSignificantDigits: 4 - }) - }); - if (d22) { - return _t("units.area_pair", { - area1: area, - area2: _t("units." + unit2, { - quantity: d22.toLocaleString(locale2, { - maximumSignificantDigits: 2 - }) - }) - }); - } else { - return area; - } - } - function wrap(x2, min3, max3) { - var d2 = max3 - min3; - return ((x2 - min3) % d2 + d2) % d2 + min3; - } - function clamp2(x2, min3, max3) { - return Math.max(min3, Math.min(x2, max3)); - } - function displayCoordinate(deg, pos, neg) { - var locale2 = _mainLocalizer.localeCode(); - var min3 = (Math.abs(deg) - Math.floor(Math.abs(deg))) * 60; - var sec = (min3 - Math.floor(min3)) * 60; - var displayDegrees = _t("units.arcdegrees", { - quantity: Math.floor(Math.abs(deg)).toLocaleString(locale2) - }); - var displayCoordinate2; - if (Math.floor(sec) > 0) { - displayCoordinate2 = displayDegrees + _t("units.arcminutes", { - quantity: Math.floor(min3).toLocaleString(locale2) - }) + _t("units.arcseconds", { - quantity: Math.round(sec).toLocaleString(locale2) - }); - } else if (Math.floor(min3) > 0) { - displayCoordinate2 = displayDegrees + _t("units.arcminutes", { - quantity: Math.round(min3).toLocaleString(locale2) - }); - } else { - displayCoordinate2 = _t("units.arcdegrees", { - quantity: Math.round(Math.abs(deg)).toLocaleString(locale2) - }); - } - if (deg === 0) { - return displayCoordinate2; - } else { - return _t("units.coordinate", { - coordinate: displayCoordinate2, - direction: _t("units." + (deg > 0 ? pos : neg)) - }); - } - } - function dmsCoordinatePair(coord2) { - return _t("units.coordinate_pair", { - latitude: displayCoordinate(clamp2(coord2[1], -90, 90), "north", "south"), - longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west") - }); - } - function decimalCoordinatePair(coord2) { - return _t("units.coordinate_pair", { - latitude: clamp2(coord2[1], -90, 90).toFixed(OSM_PRECISION), - longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION) - }); - } - // modules/ui/panels/location.js function uiPanelLocation(context) { var currLocation = ""; function redraw(selection2) { selection2.html(""); - var list = selection2.append("ul"); + var list2 = selection2.append("ul"); var coord2 = context.map().mouseCoordinates(); if (coord2.some(isNaN)) { coord2 = context.map().center(); } - list.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2)); + list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2)); selection2.append("div").attr("class", "location-info").text(currLocation || " "); debouncedGetLocation(selection2, coord2); } @@ -56926,13 +59336,13 @@ var selectedNoteID = context.selectedNoteID(); var osm = services.osm; var localeCode = _mainLocalizer.localeCode(); - var heading; + var heading2; var center, location, centroid; var closed, geometry; - var totalNodeCount, length = 0, area = 0, distance; + var totalNodeCount, length2 = 0, area = 0, distance; if (selectedNoteID && osm) { var note = osm.getNote(selectedNoteID); - heading = _t.html("note.note") + " " + selectedNoteID; + heading2 = _t.html("note.note") + " " + selectedNoteID; location = note.loc; geometry = "note"; } else { @@ -56942,7 +59352,7 @@ var selected = selectedIDs.map(function(id2) { return context.entity(id2); }); - heading = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length }); + heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length }); if (selected.length) { var extent = geoExtent(); for (var i3 in selected) { @@ -56952,7 +59362,7 @@ if (geometry === "line" || geometry === "area") { closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate(); var feature3 = entity.asGeoJSON(graph); - length += radiansToMeters(length_default(toLineString(feature3))); + length2 += radiansToMeters(length_default(toLineString(feature3))); centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph)); centroid = centroid && context.projection.invert(centroid); if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) { @@ -56982,44 +59392,44 @@ } } selection2.html(""); - if (heading) { - selection2.append("h4").attr("class", "measurement-heading").html(heading); + if (heading2) { + selection2.append("h4").attr("class", "measurement-heading").html(heading2); } - var list = selection2.append("ul"); + var list2 = selection2.append("ul"); var coordItem; if (geometry) { - list.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html( + list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html( closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry) ); } if (totalNodeCount) { - list.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode)); + list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode)); } if (area) { - list.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial)); + list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial)); } - if (length) { - list.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length, _isImperial)); + if (length2) { + list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial)); } if (typeof distance === "number") { - list.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial)); + list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial)); } if (location) { - coordItem = list.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" })); + coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" })); coordItem.append("span").text(dmsCoordinatePair(location)); coordItem.append("span").text(decimalCoordinatePair(location)); } if (centroid) { - coordItem = list.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" })); + coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" })); coordItem.append("span").text(dmsCoordinatePair(centroid)); coordItem.append("span").text(decimalCoordinatePair(centroid)); } if (center) { - coordItem = list.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" })); + coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" })); coordItem.append("span").text(dmsCoordinatePair(center)); coordItem.append("span").text(decimalCoordinatePair(center)); } - if (length || area || typeof distance === "number") { + if (length2 || area || typeof distance === "number") { var toggle = _isImperial ? "imperial" : "metric"; selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) { d3_event.preventDefault(); @@ -57282,16 +59692,16 @@ } return _t.html(id2, reps).replace(/\`(.*?)\`/g, "$1"); } - function slugify(text2) { - return text2.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, ""); + function slugify(text) { + return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, ""); } var missingStrings = {}; - function checkKey(key, text2) { + function checkKey(key, text) { if (_t(key, { default: void 0 }) === void 0) { if (missingStrings.hasOwnProperty(key)) return; - missingStrings[key] = text2; - var missing = key + ": " + text2; + missingStrings[key] = text; + var missing = key + ": " + text; if (typeof console !== "undefined") console.log(missing); } @@ -57325,14 +59735,14 @@ ]; addrTags.forEach(function(k2) { var key2 = "intro.graph." + k2; - var tag = "addr:" + k2; - var val = obj.tags && obj.tags[tag]; - var str2 = _t(key2, { default: val }); - if (str2) { - if (str2.match(/^<.*>$/) !== null) { - delete obj.tags[tag]; + var tag2 = "addr:" + k2; + var val = obj.tags && obj.tags[tag2]; + var str = _t(key2, { default: val }); + if (str) { + if (str.match(/^<.*>$/) !== null) { + delete obj.tags[tag2]; } else { - obj.tags[tag] = str2; + obj.tags[tag2] = str; } } }); @@ -57355,8 +59765,8 @@ } return true; } - function selectMenuItem(context, operation) { - return context.container().select(".edit-menu .edit-menu-item-" + operation); + function selectMenuItem(context, operation2) { + return context.container().select(".edit-menu .edit-menu-item-" + operation2); } function transitionTime(point1, point2) { var distance = geoSphericalDistance(point1, point2); @@ -57396,7 +59806,7 @@ curtain.cut(darkness.datum()); } } - curtain.reveal = function(box, html2, options2) { + curtain.reveal = function(box, html3, options2) { options2 = options2 || {}; if (typeof box === "string") { box = select_default2(box).node(); @@ -57427,22 +59837,22 @@ } else { tooltipBox = box; } - if (tooltipBox && html2) { - if (html2.indexOf("**") !== -1) { - if (html2.indexOf(")(.+?)(\*\*)/, "$1$2$3"); + if (tooltipBox && html3) { + if (html3.indexOf("**") !== -1) { + if (html3.indexOf(")(.+?)(\*\*)/, "$1$2$3"); } else { - html2 = html2.replace(/^(.+?)(\*\*)/, "$1$2"); + html3 = html3.replace(/^(.+?)(\*\*)/, "$1$2"); } - html2 = html2.replace(/\*\*(.*?)\*\*/g, '$1'); + html3 = html3.replace(/\*\*(.*?)\*\*/g, '$1'); } - html2 = html2.replace(/\*(.*?)\*/g, "$1"); - html2 = html2.replace(/\{br\}/g, "

    "); + html3 = html3.replace(/\*(.*?)\*/g, "$1"); + html3 = html3.replace(/\{br\}/g, "

    "); if (options2.buttonText && options2.buttonCallback) { - html2 += '
    "; + html3 += '
    "; } var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || ""); - tooltip.classed(classes, true).selectAll(".popover-inner").html(html2); + tooltip.classed(classes, true).selectAll(".popover-inner").html(html3); if (options2.buttonText && options2.buttonCallback) { var button = tooltip.selectAll(".button-section .button.action"); button.on("click", function(d3_event) { @@ -57608,8 +60018,8 @@ var chapter = { title: "intro.navigation.title" }; - function timeout2(f3, t2) { - timeouts.push(window.setTimeout(f3, t2)); + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } function eventCancel(d3_event) { d3_event.stopPropagation(); @@ -58077,15 +60487,15 @@ function uiIntroPoint(context, reveal) { var dispatch14 = dispatch_default("done"); var timeouts = []; - var intersection = [-85.63279, 41.94394]; + var intersection2 = [-85.63279, 41.94394]; var building = [-85.632422, 41.944045]; var cafePreset = _mainPresetIndex.item("amenity/cafe"); var _pointID = null; var chapter = { title: "intro.points.title" }; - function timeout2(f3, t2) { - timeouts.push(window.setTimeout(f3, t2)); + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } function eventCancel(d3_event) { d3_event.stopPropagation(); @@ -58094,11 +60504,11 @@ function addPoint() { context.enter(modeBrowse(context)); context.history().reset("initial"); - var msec = transitionTime(intersection, context.map().center()); + var msec = transitionTime(intersection2, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerZoomEase(intersection, 19, msec); + context.map().centerZoomEase(intersection2, 19, msec); timeout2(function() { var tooltip = reveal( "button.add-point", @@ -58132,7 +60542,18 @@ if (mode.id !== "select") return chapter.restart(); _pointID = context.mode().selectedIDs()[0]; - continueTo(searchPreset); + if (context.graph().geometry(_pointID) === "vertex") { + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); + reveal(pointBox2, helpHtml("intro.points.place_point_error"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + return chapter.restart(); + } + }); + } else { + continueTo(searchPreset); + } }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); @@ -58481,17 +60902,17 @@ var chapter = { title: "intro.areas.title" }; - function timeout2(f3, t2) { - timeouts.push(window.setTimeout(f3, t2)); + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } function eventCancel(d3_event) { d3_event.stopPropagation(); d3_event.preventDefault(); } - function revealPlayground(center, text2, options2) { + function revealPlayground(center, text, options2) { var padding = 180 * Math.pow(2, context.map().zoom() - 19.5); var box = pad(center, padding, context); - reveal(box, text2, options2); + reveal(box, text, options2); } function addArea() { context.enter(modeBrowse(context)); @@ -58902,8 +61323,8 @@ var chapter = { title: "intro.lines.title" }; - function timeout2(f3, t2) { - timeouts.push(window.setTimeout(f3, t2)); + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } function eventCancel(d3_event) { d3_event.stopPropagation(); @@ -59792,22 +62213,22 @@ var chapter = { title: "intro.buildings.title" }; - function timeout2(f3, t2) { - timeouts.push(window.setTimeout(f3, t2)); + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } function eventCancel(d3_event) { d3_event.stopPropagation(); d3_event.preventDefault(); } - function revealHouse(center, text2, options2) { + function revealHouse(center, text, options2) { var padding = 160 * Math.pow(2, context.map().zoom() - 20); var box = pad(center, padding, context); - reveal(box, text2, options2); + reveal(box, text, options2); } - function revealTank(center, text2, options2) { + function revealTank(center, text, options2) { var padding = 190 * Math.pow(2, context.map().zoom() - 19.5); var box = pad(center, padding, context); - reveal(box, text2, options2); + reveal(box, text, options2); } function addHouse() { context.enter(modeBrowse(context)); @@ -61484,11 +63905,11 @@ var bestIndex = -1; for (var i3 = 0; i3 < suggestionValues.length; i3++) { var suggestion = suggestionValues[i3]; - var compare = _caseSensitive ? suggestion : suggestion.toLowerCase(); - if (compare === val) { + var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase(); + if (compare2 === val) { bestIndex = i3; break; - } else if (bestIndex === -1 && compare.indexOf(val) === 0) { + } else if (bestIndex === -1 && compare2.indexOf(val) === 0) { bestIndex = i3; } } @@ -61941,7 +64362,7 @@ }; var docs = fieldHelpKeys[fieldName].map(function(key) { var helpkey = "help.field." + fieldName + "." + key[0]; - var text2 = key[1].reduce(function(all, part) { + var text = key[1].reduce(function(all, part) { var subkey = helpkey + "." + part; var depth = fieldHelpHeadings[subkey]; var hhh = depth ? Array(depth + 1).join("#") + " " : ""; @@ -61950,7 +64371,7 @@ return { key: helpkey, title: _t.html(helpkey + ".title"), - html: marked(text2.trim()) + html: marked(text.trim()) }; }); function show() { @@ -62041,7 +64462,7 @@ var texts = []; var _tags; var input = select_default2(null); - var text2 = select_default2(null); + var text = select_default2(null); var label = select_default2(null); var reverser = select_default2(null); var _impliedYes; @@ -62105,7 +64526,7 @@ } label = label.merge(enter); input = label.selectAll("input"); - text2 = label.selectAll("span.value"); + text = label.selectAll("span.value"); input.on("click", function(d3_event) { d3_event.stopPropagation(); var t2 = {}; @@ -62166,7 +64587,7 @@ _value = "yes"; } input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value)); - text2.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed); + text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed); label.classed("set", !!_value); if (field.type === "onewayCheck") { reverser.classed("hide", reverserHidden()).call(reverserSetText); @@ -62678,7 +65099,8 @@ chips.exit().remove(); var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip"); enter.append("span"); - enter.append("a"); + const field_buttons = enter.append("div").attr("class", "field_buttons"); + field_buttons.append("a").attr("class", "remove"); chips = chips.merge(enter).order().classed("raw-value", function(d2) { var k3 = d2.key; if (_isMulti) @@ -62702,16 +65124,30 @@ if (allowDragAndDrop) { registerDragAndDrop(chips); } - chips.select("span").each(function(d2) { + chips.each(function(d2) { const selection2 = select_default2(this); + const text_span = selection2.select("span"); + const field_buttons2 = selection2.select(".field_buttons"); + const clean_value = d2.value.trim(); + text_span.text(""); + if (!field_buttons2.select("button").empty()) { + field_buttons2.select("button").remove(); + } + if (clean_value.startsWith("https://")) { + text_span.text(clean_value); + 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) { + d3_event.preventDefault(); + window.open(clean_value, "_blank"); + }); + return; + } if (d2.display) { - selection2.text(""); - d2.display(selection2); - } else { - selection2.text(d2.value); + d2.display(text_span); + return; } + text_span.text(d2.value); }); - chips.select("a").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7"); + chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7"); updateIcon(""); } else { var mixedValues = isMixed && tags[field.key].map(function(val) { @@ -62932,14 +65368,15 @@ } else if (field.type === "identifier" && field.urlFormat && field.pattern) { input.attr("type", "text"); outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]); - outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() { + outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() { var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat); if (domainResults.length >= 2 && domainResults[1]) { - var domain2 = domainResults[1]; - return _t("icons.view_on", { domain: domain2 }); + var domain = domainResults[1]; + return _t("icons.view_on", { domain }); } return ""; - }).on("click", function(d3_event) { + }).merge(outlinkButton); + outlinkButton.on("click", function(d3_event) { d3_event.preventDefault(); var value = validIdentifierValueForLink(); if (value) { @@ -62965,14 +65402,6 @@ } } function updateColourPreview() { - function isColourValid(colour2) { - if (!colour2.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) { - return false; - } else if (!CSS.supports("color", colour2) || ["unset", "inherit", "initial", "revert"].includes(colour2)) { - return false; - } - return true; - } wrap2.selectAll(".colour-preview").remove(); const colour = utilGetSetValue(input); if (!isColourValid(colour) && colour !== "") { @@ -63046,17 +65475,17 @@ input.attr("placeholder", format2); } function validIdentifierValueForLink() { - var _a; + var _a2; const value = utilGetSetValue(input).trim(); if (field.type === "url" && value) { try { return new URL(value).href; - } catch (e3) { + } catch { return null; } } if (field.type === "identifier" && field.pattern) { - return value && ((_a = value.match(new RegExp(field.pattern))) == null ? void 0 : _a[0]); + return value && ((_a2 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a2[0]); } return null; } @@ -63125,11 +65554,11 @@ return i3; }; i3.tags = function(tags) { - var _a; + var _a2; _tags = tags; const vals = getVals(tags); const isMixed = vals.size > 1; - var val = vals.size === 1 ? (_a = [...vals][0]) != null ? _a : "" : ""; + var val = vals.size === 1 ? (_a2 = [...vals][0]) != null ? _a2 : "" : ""; var shouldUpdate; if (field.type === "number" && val) { var numbers2 = val.split(";"); @@ -63197,13 +65626,13 @@ function access(selection2) { var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]); wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2); - var list = wrap2.selectAll("ul").data([0]); - list = list.enter().append("ul").attr("class", "rows").merge(list); - items = list.selectAll("li").data(field.keys); + var list2 = wrap2.selectAll("ul").data([0]); + list2 = list2.enter().append("ul").attr("class", "rows").merge(list2); + items = list2.selectAll("li").data(field.keys); var enter = items.enter().append("li").attr("class", function(d2) { return "labeled-input preset-access-" + d2; }); - enter.append("span").attr("class", "label preset-label-access").attr("for", function(d2) { + enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) { return "preset-input-access-" + d2; }).html(function(d2) { return field.t.html("types." + d2); @@ -63219,12 +65648,12 @@ wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change); } function change(d3_event, d2) { - var tag = {}; + var tag2 = {}; var value = context.cleanTagValue(utilGetSetValue(select_default2(this))); if (!value && typeof _tags[d2] !== "string") return; - tag[d2] = value || void 0; - dispatch14.call("change", this, tag); + tag2[d2] = value || void 0; + dispatch14.call("change", this, tag2); } access.options = function(type2) { var options2 = [ @@ -63356,6 +65785,11 @@ }, construction: { access: "no" + }, + busway: { + access: "no", + bus: "designated", + emergency: "yes" } }, barrier: { @@ -63770,10 +66204,11 @@ var _tags; var _combos = {}; if (field.type === "cycleway") { - field = __spreadProps(__spreadValues({}, field), { + field = { + ...field, key: field.keys[0], keys: field.keys.slice(1) - }); + }; } function directionalCombo(selection2) { function stripcolon(s2) { @@ -63782,21 +66217,22 @@ wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]); wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2); var div = wrap2.selectAll("ul").data([0]); - div = div.enter().append("ul").attr("class", "rows").merge(div); + div = div.enter().append("ul").attr("class", "rows rows-table").merge(div); items = div.selectAll("li").data(field.keys); var enter = items.enter().append("li").attr("class", function(d2) { return "labeled-input preset-directionalcombo-" + stripcolon(d2); }); - enter.append("span").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) { + enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) { return "preset-input-directionalcombo-" + stripcolon(d2); }).html(function(d2) { return field.t.html("types." + d2); }); enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) { - const subField = __spreadProps(__spreadValues({}, field), { + const subField = { + ...field, type: "combo", key - }); + }; const combo = uiFieldCombo(subField, context); combo.on("change", (t2) => change(key, t2[key])); _combos[key] = combo; @@ -64115,9 +66551,9 @@ var wrap2 = select_default2(this); var domId = utilUniqueDomId(index); var label = wrap2.append("label").attr("class", "field-label").attr("for", domId); - var text2 = label.append("span").attr("class", "label-text"); - text2.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label")); - text2.append("span").attr("class", "label-textannotation"); + var text = label.append("span").attr("class", "label-text"); + text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label")); + text.append("span").attr("class", "label-textannotation"); label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) { if (field.locked()) return; @@ -64258,13 +66694,13 @@ utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m"); } function change() { - var tag = {}; + var tag2 = {}; var primaryValue = utilGetSetValue(primaryInput).trim(); var secondaryValue = utilGetSetValue(secondaryInput).trim(); if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key])) return; if (!primaryValue && !secondaryValue) { - tag[field.key] = void 0; + tag2[field.key] = void 0; } else { var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue); if (isNaN(rawPrimaryValue)) @@ -64273,7 +66709,7 @@ if (isNaN(rawSecondaryValue)) rawSecondaryValue = secondaryValue; if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) { - tag[field.key] = context.cleanTagValue(rawPrimaryValue); + tag2[field.key] = context.cleanTagValue(rawPrimaryValue); } else { if (rawPrimaryValue !== "") { rawPrimaryValue = rawPrimaryValue + "'"; @@ -64281,10 +66717,10 @@ if (rawSecondaryValue !== "") { rawSecondaryValue = rawSecondaryValue + '"'; } - tag[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue); + tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue); } } - dispatch14.call("change", this, tag); + dispatch14.call("change", this, tag2); } roadheight.tags = function(tags) { _tags = tags; @@ -64379,23 +66815,23 @@ }; } function change() { - var tag = {}; + var tag2 = {}; var value = utilGetSetValue(input).trim(); if (!value && Array.isArray(_tags[field.key])) return; if (!value) { - tag[field.key] = void 0; + tag2[field.key] = void 0; } else { var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value); if (isNaN(rawValue)) rawValue = value; if (isNaN(rawValue) || !_isImperial) { - tag[field.key] = context.cleanTagValue(rawValue); + tag2[field.key] = context.cleanTagValue(rawValue); } else { - tag[field.key] = context.cleanTagValue(rawValue + " mph"); + tag2[field.key] = context.cleanTagValue(rawValue + " mph"); } } - dispatch14.call("change", this, tag); + dispatch14.call("change", this, tag2); } roadspeed.tags = function(tags) { _tags = tags; @@ -64473,8 +66909,8 @@ var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []); extrasWrap.exit().remove(); extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap); - var list = extrasWrap.selectAll("ul").data([0]); - list = list.enter().append("ul").attr("class", "rows").merge(list); + var list2 = extrasWrap.selectAll("ul").data([0]); + list2 = list2.enter().append("ul").attr("class", "rows").merge(list2); if (type2) { if (!typeField || typeField.id !== selected) { typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType); @@ -64483,12 +66919,12 @@ } else { typeField = null; } - var typeItem = list.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) { + var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) { return d2.id; }); typeItem.exit().remove(); var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item"); - typeEnter.append("span").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type")); + typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type")); typeEnter.append("div").attr("class", "structure-input-type-wrap"); typeItem = typeItem.merge(typeEnter); if (typeField) { @@ -64506,10 +66942,10 @@ return k2 !== "layer"; }); } - var layerItem = list.selectAll(".structure-layer-item").data(layerField ? [layerField] : []); + var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []); layerItem.exit().remove(); var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item"); - layerEnter.append("span").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer")); + layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer")); layerEnter.append("div").attr("class", "structure-input-layer-wrap"); layerItem = layerItem.merge(layerEnter); if (layerField) { @@ -64658,10 +67094,7 @@ var isOK = _intersection && _intersection.vertices.length && // has vertices _intersection.vertices.filter(function(vertex) { return vertex.id === _vertexID; - }).length && _intersection.ways.length > 2 && // has more than 2 ways - _intersection.ways.filter(function(way) { - return way.__to; - }).length > 1; + }).length && _intersection.ways.length > 2; select_default2(selection2.node().parentNode).classed("hide", !isOK); if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) { selection2.call(restrictions.off); @@ -64727,9 +67160,9 @@ var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4)); var vPadding = 160; var tl = projection2([extent[0][0], extent[1][1]]); - var br = projection2([extent[1][0], extent[0][1]]); - var hFactor = (br[0] - tl[0]) / (d2[0] - hPadding); - var vFactor = (br[1] - tl[1]) / (d2[1] - vPadding - padTop); + var br2 = projection2([extent[1][0], extent[0][1]]); + var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding); + var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop); var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2; var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2; z2 = z2 - Math.max(hZoomDiff, vZoomDiff); @@ -65068,9 +67501,9 @@ _selection = selection2; var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]); wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2); - var list = wrap2.selectAll("ul").data([0]); - list = list.enter().append("ul").attr("class", "rows").merge(list); - var searchRow = list.selectAll("li.wikidata-search").data([0]); + var list2 = wrap2.selectAll("ul").data([0]); + list2 = list2.enter().append("ul").attr("class", "rows").merge(list2); + var searchRow = list2.selectAll("li.wikidata-search").data([0]); var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search"); searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() { var node = select_default2(this).node(); @@ -65094,11 +67527,11 @@ searchRow = searchRow.merge(searchRowEnter); _searchInput = searchRow.select("input"); var wikidataProperties = ["description", "identifier"]; - var items = list.selectAll("li.labeled-input").data(wikidataProperties); + var items = list2.selectAll("li.labeled-input").data(wikidataProperties); var enter = items.enter().append("li").attr("class", function(d2) { return "labeled-input preset-wikidata-" + d2; }); - enter.append("span").attr("class", "label").html(function(d2) { + enter.append("div").attr("class", "label").html(function(d2) { return _t.html("wikidata." + d2); }); enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true"); @@ -65297,6 +67730,8 @@ // modules/ui/fields/wikipedia.js function uiFieldWikipedia(field, context) { + const scheme = "https://"; + const domain = "wikipedia.org"; const dispatch14 = dispatch_default("change"); const wikipedia = services.wikipedia; const wikidata = services.wikidata; @@ -65353,9 +67788,9 @@ }).on("change", function() { change(false); }); - let link2 = titleContainer.selectAll(".wiki-link").data([0]); - link2 = link2.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikipedia.org" })).call(svgIcon("#iD-icon-out-link")).merge(link2); - link2.on("click", (d3_event) => { + let link3 = titleContainer.selectAll(".wiki-link").data([0]); + 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); + link3.on("click", (d3_event) => { d3_event.preventDefault(); if (_wikiURL) window.open(_wikiURL, "_blank"); @@ -65454,20 +67889,13 @@ const nativeLangName = tagLangInfo[1]; utilGetSetValue(_langInput, nativeLangName); utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : "")); - if (anchor) { - try { - anchor = encodeURIComponent(anchor.replace(/ /g, "_")).replace(/%/g, "."); - } catch (e3) { - anchor = anchor.replace(/ /g, "_"); - } - } - _wikiURL = "https://" + tagLang + ".wikipedia.org/wiki/" + tagArticleTitle.replace(/ /g, "_") + (anchor ? "#" + anchor : ""); + _wikiURL = "".concat(scheme).concat(tagLang, ".").concat(domain, "/wiki/").concat(wiki.encodePath(tagArticleTitle, anchor)); } else { utilGetSetValue(_titleInput, value); if (value && value !== "") { utilGetSetValue(_langInput, ""); const defaultLangInfo = defaultLanguageInfo(); - _wikiURL = "https://".concat(defaultLangInfo[2], ".wikipedia.org/w/index.php?fulltext=1&search=").concat(value); + _wikiURL = "".concat(scheme).concat(defaultLangInfo[2], ".").concat(domain, "/w/index.php?fulltext=1&search=").concat(value); } else { const shownOrDefaultLangInfo = language( true @@ -65478,6 +67906,18 @@ } } } + wiki.encodePath = (tagArticleTitle, anchor) => { + const underscoredTitle = tagArticleTitle.replace(/ /g, "_"); + const uriEncodedUnderscoredTitle = encodeURIComponent(underscoredTitle); + const uriEncodedAnchorFragment = wiki.encodeURIAnchorFragment(anchor); + return "".concat(uriEncodedUnderscoredTitle).concat(uriEncodedAnchorFragment); + }; + wiki.encodeURIAnchorFragment = (anchor) => { + if (!anchor) + return ""; + const underscoredAnchor = anchor.replace(/ /g, "_"); + return "#" + encodeURIComponent(underscoredAnchor); + }; wiki.entityIDs = (val) => { if (!arguments.length) return _entityIDs; @@ -67093,6 +69533,7 @@ subway: ["railway/subway", "railway/subway", "railway/subway"], train: ["railway/rail", "railway/rail", "railway/rail"], tram: ["railway/tram", "railway/tram", "railway/tram"], + railway: ["railway/rail", "railway/rail", "railway/rail"], waterway: ["waterway/stream", "waterway/stream", "waterway/stream"] }; function render() { @@ -67360,7 +69801,7 @@ var _maxMembers = 1e3; function downloadMember(d3_event, d2) { d3_event.preventDefault(); - select_default2(this.parentNode).classed("tag-reference-loading", true); + select_default2(this).classed("loading", true); context.loadEntity(d2.id, function() { section.reRender(); }); @@ -67388,504 +69829,137 @@ var member = { id: d2.id, type: d2.type, role: newRole }; context.perform( actionChangeMember(d2.relation.id, member, d2.index), - _t("operations.change_role.annotation", { - n: 1 - }) - ); - context.validator().validate(); - } - } - function deleteMember(d3_event, d2) { - utilHighlightEntities([d2.id], false, context); - context.perform( - actionDeleteMember(d2.relation.id, d2.index), - _t("operations.delete_member.annotation", { - n: 1 - }) - ); - if (!context.hasEntity(d2.relation.id)) { - context.enter(modeBrowse(context)); - } else { - context.validator().validate(); - } - } - function renderDisclosureContent(selection2) { - var entityID = _entityIDs[0]; - var memberships = []; - var entity = context.entity(entityID); - entity.members.slice(0, _maxMembers).forEach(function(member, index) { - memberships.push({ - index, - id: member.id, - type: member.type, - role: member.role, - relation: entity, - member: context.hasEntity(member.id), - domId: utilUniqueDomId(entityID + "-member-" + index) - }); - }); - var list = selection2.selectAll(".member-list").data([0]); - list = list.enter().append("ul").attr("class", "member-list").merge(list); - var items = list.selectAll("li").data(memberships, function(d2) { - return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete"); - }); - items.exit().each(unbind).remove(); - var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) { - return !d2.member; - }); - itemsEnter.each(function(d2) { - var item = select_default2(this); - var label = item.append("label").attr("class", "field-label").attr("for", d2.domId); - if (d2.member) { - item.on("mouseover", function() { - utilHighlightEntities([d2.id], true, context); - }).on("mouseout", function() { - utilHighlightEntities([d2.id], false, context); - }); - var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember); - labelLink.append("span").attr("class", "member-entity-type").text(function(d4) { - var matched = _mainPresetIndex.match(d4.member, context.graph()); - return matched && matched.name() || utilDisplayType(d4.member.id); - }); - labelLink.append("span").attr("class", "member-entity-name").text(function(d4) { - return utilDisplayName(d4.member); - }); - label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete")); - label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember); - } else { - var labelText = label.append("span").attr("class", "label-text"); - labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id })); - labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id })); - label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember); - } - }); - var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member"); - wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) { - return d2.domId; - }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto); - if (taginfo) { - wrapEnter.each(bindTypeahead); - } - items = items.merge(itemsEnter).order(); - items.select("input.member-role").property("value", function(d2) { - return d2.role; - }).on("blur", changeRole).on("change", changeRole); - items.select("button.member-delete").on("click", deleteMember); - var dragOrigin, targetIndex; - items.call( - drag_default().on("start", function(d3_event) { - dragOrigin = { - x: d3_event.x, - y: d3_event.y - }; - targetIndex = null; - }).on("drag", function(d3_event) { - var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y; - if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold - Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) - return; - var index = items.nodes().indexOf(this); - select_default2(this).classed("dragging", true); - targetIndex = null; - selection2.selectAll("li.member-row").style("transform", function(d2, index2) { - var node = select_default2(this).node(); - if (index === index2) { - return "translate(" + x2 + "px, " + y2 + "px)"; - } else if (index2 > index && d3_event.y > node.offsetTop) { - if (targetIndex === null || index2 > targetIndex) { - targetIndex = index2; - } - return "translateY(-100%)"; - } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) { - if (targetIndex === null || index2 < targetIndex) { - targetIndex = index2; - } - return "translateY(100%)"; - } - return null; - }); - }).on("end", function(d3_event, d2) { - if (!select_default2(this).classed("dragging")) - return; - var index = items.nodes().indexOf(this); - select_default2(this).classed("dragging", false); - selection2.selectAll("li.member-row").style("transform", null); - if (targetIndex !== null) { - context.perform( - actionMoveMember(d2.relation.id, index, targetIndex), - _t("operations.reorder_members.annotation") - ); - context.validator().validate(); - } - }) - ); - function bindTypeahead(d2) { - var row = select_default2(this); - var role = row.selectAll("input.member-role"); - var origValue = role.property("value"); - function sort(value, data) { - var sameletter = []; - var other = []; - for (var i3 = 0; i3 < data.length; i3++) { - if (data[i3].value.substring(0, value.length) === value) { - sameletter.push(data[i3]); - } else { - other.push(data[i3]); - } - } - return sameletter.concat(other); - } - role.call( - uiCombobox(context, "member-role").fetcher(function(role2, callback) { - var geometry; - if (d2.member) { - geometry = context.graph().geometry(d2.member.id); - } else if (d2.type === "relation") { - geometry = "relation"; - } else if (d2.type === "way") { - geometry = "line"; - } else { - geometry = "point"; - } - var rtype = entity.tags.type; - taginfo.roles({ - debounce: true, - rtype: rtype || "", - geometry, - query: role2 - }, function(err, data) { - if (!err) - callback(sort(role2, data)); - }); - }).on("cancel", function() { - role.property("value", origValue); - }) - ); - } - function unbind() { - var row = select_default2(this); - row.selectAll("input.member-role").call(uiCombobox.off, context); - } - } - section.entityIDs = function(val) { - if (!arguments.length) - return _entityIDs; - _entityIDs = val; - return section; - }; - return section; - } - - // modules/actions/delete_members.js - function actionDeleteMembers(relationId, memberIndexes) { - return function(graph) { - memberIndexes.sort((a2, b2) => b2 - a2); - for (var i3 in memberIndexes) { - graph = actionDeleteMember(relationId, memberIndexes[i3])(graph); - } - return graph; - }; - } - - // modules/ui/sections/raw_membership_editor.js - function uiSectionRawMembershipEditor(context) { - var section = uiSection("raw-membership-editor", context).shouldDisplay(function() { - return _entityIDs && _entityIDs.length; - }).label(function() { - var parents = getSharedParentRelations(); - var gt2 = parents.length > _maxMemberships ? ">" : ""; - var count = gt2 + parents.slice(0, _maxMemberships).length; - return _t.append("inspector.title_count", { title: _t("inspector.relations"), count }); - }).disclosureContent(renderDisclosureContent); - var taginfo = services.taginfo; - var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) { - if (d2.relation) - utilHighlightEntities([d2.relation.id], true, context); - }).itemsMouseLeave(function(d3_event, d2) { - if (d2.relation) - utilHighlightEntities([d2.relation.id], false, context); - }); - var _inChange = false; - var _entityIDs = []; - var _showBlank; - var _maxMemberships = 1e3; - function getSharedParentRelations() { - var parents = []; - for (var i3 = 0; i3 < _entityIDs.length; i3++) { - var entity = context.graph().hasEntity(_entityIDs[i3]); - if (!entity) - continue; - if (i3 === 0) { - parents = context.graph().parentRelations(entity); - } else { - parents = utilArrayIntersection(parents, context.graph().parentRelations(entity)); - } - if (!parents.length) - break; - } - return parents; - } - function getMemberships() { - var memberships = []; - var relations = getSharedParentRelations().slice(0, _maxMemberships); - var isMultiselect = _entityIDs.length > 1; - var i3, relation, membership, index, member, indexedMember; - for (i3 = 0; i3 < relations.length; i3++) { - relation = relations[i3]; - membership = { - relation, - members: [], - hash: osmEntity.key(relation) - }; - for (index = 0; index < relation.members.length; index++) { - member = relation.members[index]; - if (_entityIDs.indexOf(member.id) !== -1) { - indexedMember = Object.assign({}, member, { index }); - membership.members.push(indexedMember); - membership.hash += "," + index.toString(); - if (!isMultiselect) { - memberships.push(membership); - membership = { - relation, - members: [], - hash: osmEntity.key(relation) - }; - } - } - } - if (membership.members.length) - memberships.push(membership); - } - memberships.forEach(function(membership2) { - membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id); - var roles = []; - membership2.members.forEach(function(member2) { - if (roles.indexOf(member2.role) === -1) - roles.push(member2.role); - }); - membership2.role = roles.length === 1 ? roles[0] : roles; - }); - return memberships; - } - function selectRelation(d3_event, d2) { - d3_event.preventDefault(); - utilHighlightEntities([d2.relation.id], false, context); - context.enter(modeSelect(context, [d2.relation.id])); - } - function zoomToRelation(d3_event, d2) { - d3_event.preventDefault(); - var entity = context.entity(d2.relation.id); - context.map().zoomToEase(entity); - utilHighlightEntities([d2.relation.id], true, context); - } - function changeRole(d3_event, d2) { - if (d2 === 0) - return; - if (_inChange) - return; - var newRole = context.cleanRelationRole(select_default2(this).property("value")); - if (!newRole.trim() && typeof d2.role !== "string") - return; - var membersToUpdate = d2.members.filter(function(member) { - return member.role !== newRole; - }); - if (membersToUpdate.length) { - _inChange = true; - context.perform( - function actionChangeMemberRoles(graph) { - membersToUpdate.forEach(function(member) { - var newMember = Object.assign({}, member, { role: newRole }); - delete newMember.index; - graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph); - }); - return graph; - }, - _t("operations.change_role.annotation", { - n: membersToUpdate.length - }) - ); - context.validator().validate(); - } - _inChange = false; - } - function addMembership(d2, role) { - this.blur(); - _showBlank = false; - function actionAddMembers(relationId, ids, role2) { - return function(graph) { - for (var i3 in ids) { - var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 }; - graph = actionAddMember(relationId, member)(graph); - } - return graph; - }; - } - if (d2.relation) { - context.perform( - actionAddMembers(d2.relation.id, _entityIDs, role), - _t("operations.add_member.annotation", { - n: _entityIDs.length - }) - ); - context.validator().validate(); - } else { - var relation = osmRelation(); - context.perform( - actionAddEntity(relation), - actionAddMembers(relation.id, _entityIDs, role), - _t("operations.add.annotation.relation") - ); - context.enter(modeSelect(context, [relation.id]).newFeature(true)); - } - } - function deleteMembership(d3_event, d2) { - this.blur(); - if (d2 === 0) - return; - utilHighlightEntities([d2.relation.id], false, context); - var indexes = d2.members.map(function(member) { - return member.index; - }); + _t("operations.change_role.annotation", { + n: 1 + }) + ); + context.validator().validate(); + } + } + function deleteMember(d3_event, d2) { + utilHighlightEntities([d2.id], false, context); context.perform( - actionDeleteMembers(d2.relation.id, indexes), + actionDeleteMember(d2.relation.id, d2.index), _t("operations.delete_member.annotation", { - n: _entityIDs.length + n: 1 }) ); - context.validator().validate(); - } - function fetchNearbyRelations(q2, callback) { - var newRelation = { - relation: null, - value: _t("inspector.new_relation"), - display: _t.append("inspector.new_relation") - }; - var entityID = _entityIDs[0]; - var result = []; - var graph = context.graph(); - function baseDisplayLabel(entity) { - var matched = _mainPresetIndex.match(entity, graph); - var presetName = matched && matched.name() || _t("inspector.relation"); - var entityName = utilDisplayName(entity) || ""; - return presetName + " " + entityName; - } - var explicitRelation = q2 && context.hasEntity(q2.toLowerCase()); - if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) { - result.push({ - relation: explicitRelation, - value: baseDisplayLabel(explicitRelation) + " " + explicitRelation.id - }); + if (!context.hasEntity(d2.relation.id)) { + context.enter(modeBrowse(context)); } else { - context.history().intersects(context.map().extent()).forEach(function(entity) { - if (entity.type !== "relation" || entity.id === entityID) - return; - var value = baseDisplayLabel(entity); - if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1) - return; - result.push({ relation: entity, value }); - }); - result.sort(function(a2, b2) { - return osmRelation.creationOrder(a2.relation, b2.relation); - }); - var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) { - return v2.length > 1; - }); - dupeGroups.forEach(function(group) { - group.forEach(function(obj) { - obj.value += " " + obj.relation.id; - }); - }); + context.validator().validate(); } - result.forEach(function(obj) { - obj.title = obj.value; - }); - result.unshift(newRelation); - callback(result); } function renderDisclosureContent(selection2) { - var memberships = getMemberships(); - var list = selection2.selectAll(".member-list").data([0]); - list = list.enter().append("ul").attr("class", "member-list").merge(list); - var items = list.selectAll("li.member-row-normal").data(memberships, function(d2) { - return d2.hash; - }); - items.exit().each(unbind).remove(); - var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field"); - itemsEnter.on("mouseover", function(d3_event, d2) { - utilHighlightEntities([d2.relation.id], true, context); - }).on("mouseout", function(d3_event, d2) { - utilHighlightEntities([d2.relation.id], false, context); + var entityID = _entityIDs[0]; + var memberships = []; + var entity = context.entity(entityID); + entity.members.slice(0, _maxMembers).forEach(function(member, index) { + memberships.push({ + index, + id: member.id, + type: member.type, + role: member.role, + relation: entity, + member: context.hasEntity(member.id), + domId: utilUniqueDomId(entityID + "-member-" + index) + }); }); - var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) { - return d2.domId; + var list2 = selection2.selectAll(".member-list").data([0]); + list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2); + var items = list2.selectAll("li").data(memberships, function(d2) { + return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete"); }); - var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation); - labelLink.append("span").attr("class", "member-entity-type").text(function(d2) { - var matched = _mainPresetIndex.match(d2.relation, context.graph()); - return matched && matched.name() || _t.html("inspector.relation"); + items.exit().each(unbind).remove(); + var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) { + return !d2.member; }); - labelLink.append("span").attr("class", "member-entity-name").text(function(d2) { - return utilDisplayName(d2.relation); + itemsEnter.each(function(d2) { + var item = select_default2(this); + var label = item.append("label").attr("class", "field-label").attr("for", d2.domId); + if (d2.member) { + item.on("mouseover", function() { + utilHighlightEntities([d2.id], true, context); + }).on("mouseout", function() { + utilHighlightEntities([d2.id], false, context); + }); + var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember); + labelLink.append("span").attr("class", "member-entity-type").text(function(d4) { + var matched = _mainPresetIndex.match(d4.member, context.graph()); + return matched && matched.name() || utilDisplayType(d4.member.id); + }); + 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) { + return utilDisplayName(d4.member); + }); + label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete")); + label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember); + } else { + var labelText = label.append("span").attr("class", "label-text"); + labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id })); + labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id })); + label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember); + } }); - labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership); - labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation); var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member"); wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) { return d2.domId; - }).property("type", "text").property("value", function(d2) { - return typeof d2.role === "string" ? d2.role : ""; - }).attr("title", function(d2) { - return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role; - }).attr("placeholder", function(d2) { - return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role"); - }).classed("mixed", function(d2) { - return Array.isArray(d2.role); - }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole); + }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto); if (taginfo) { wrapEnter.each(bindTypeahead); } - var newMembership = list.selectAll(".member-row-new").data(_showBlank ? [0] : []); - newMembership.exit().remove(); - var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field"); - var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label"); - newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto); - newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() { - list.selectAll(".member-row-new").remove(); - }); - var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member"); - newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto); - newMembership = newMembership.merge(newMembershipEnter); - newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call( - nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity) + items = items.merge(itemsEnter).order(); + items.select("input.member-role").property("value", function(d2) { + return d2.role; + }).on("blur", changeRole).on("change", changeRole); + items.select("button.member-delete").on("click", deleteMember); + var dragOrigin, targetIndex; + items.call( + drag_default().on("start", function(d3_event) { + dragOrigin = { + x: d3_event.x, + y: d3_event.y + }; + targetIndex = null; + }).on("drag", function(d3_event) { + var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y; + if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold + Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) + return; + var index = items.nodes().indexOf(this); + select_default2(this).classed("dragging", true); + targetIndex = null; + selection2.selectAll("li.member-row").style("transform", function(d2, index2) { + var node = select_default2(this).node(); + if (index === index2) { + return "translate(" + x2 + "px, " + y2 + "px)"; + } else if (index2 > index && d3_event.y > node.offsetTop) { + if (targetIndex === null || index2 > targetIndex) { + targetIndex = index2; + } + return "translateY(-100%)"; + } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) { + if (targetIndex === null || index2 < targetIndex) { + targetIndex = index2; + } + return "translateY(100%)"; + } + return null; + }); + }).on("end", function(d3_event, d2) { + if (!select_default2(this).classed("dragging")) + return; + var index = items.nodes().indexOf(this); + select_default2(this).classed("dragging", false); + selection2.selectAll("li.member-row").style("transform", null); + if (targetIndex !== null) { + context.perform( + actionMoveMember(d2.relation.id, index, targetIndex), + _t("operations.reorder_members.annotation") + ); + context.validator().validate(); + } + }) ); - var addRow = selection2.selectAll(".add-row").data([0]); - var addRowEnter = addRow.enter().append("div").attr("class", "add-row"); - var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation")); - addRelationButton.call(svgIcon("#iD-icon-plus", "light")); - addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left")); - addRowEnter.append("div").attr("class", "space-value"); - addRowEnter.append("div").attr("class", "space-buttons"); - addRow = addRow.merge(addRowEnter); - addRow.select(".add-relation").on("click", function() { - _showBlank = true; - section.reRender(); - list.selectAll(".member-entity-input").node().focus(); - }); - function acceptEntity(d2) { - if (!d2) { - cancelEntity(); - return; - } - if (d2.relation) - utilHighlightEntities([d2.relation.id], false, context); - var role = context.cleanRelationRole(list.selectAll(".member-row-new .member-role").property("value")); - addMembership(d2, role); - } - function cancelEntity() { - var input = newMembership.selectAll(".member-entity-input"); - input.property("value", ""); - context.surface().selectAll(".highlighted").classed("highlighted", false); - } function bindTypeahead(d2) { var row = select_default2(this); var role = row.selectAll("input.member-role"); @@ -67904,11 +69978,21 @@ } role.call( uiCombobox(context, "member-role").fetcher(function(role2, callback) { - var rtype = d2.relation.tags.type; + var geometry; + if (d2.member) { + geometry = context.graph().geometry(d2.member.id); + } else if (d2.type === "relation") { + geometry = "relation"; + } else if (d2.type === "way") { + geometry = "line"; + } else { + geometry = "point"; + } + var rtype = entity.tags.type; taginfo.roles({ debounce: true, rtype: rtype || "", - geometry: context.graph().geometry(_entityIDs[0]), + geometry, query: role2 }, function(err, data) { if (!err) @@ -67919,1500 +70003,898 @@ }) ); } - function unbind() { - var row = select_default2(this); - row.selectAll("input.member-role").call(uiCombobox.off, context); - } - } - section.entityIDs = function(val) { - if (!arguments.length) - return _entityIDs; - _entityIDs = val; - _showBlank = false; - return section; - }; - return section; - } - - // modules/ui/sections/selection_list.js - function uiSectionSelectionList(context) { - var _selectedIDs = []; - var section = uiSection("selected-features", context).shouldDisplay(function() { - return _selectedIDs.length > 1; - }).label(function() { - return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length }); - }).disclosureContent(renderDisclosureContent); - context.history().on("change.selectionList", function(difference) { - if (difference) { - section.reRender(); - } - }); - section.entityIDs = function(val) { - if (!arguments.length) - return _selectedIDs; - _selectedIDs = val; - return section; - }; - function selectEntity(d3_event, entity) { - context.enter(modeSelect(context, [entity.id])); - } - function deselectEntity(d3_event, entity) { - var selectedIDs = _selectedIDs.slice(); - var index = selectedIDs.indexOf(entity.id); - if (index > -1) { - selectedIDs.splice(index, 1); - context.enter(modeSelect(context, selectedIDs)); - } - } - function renderDisclosureContent(selection2) { - var list = selection2.selectAll(".feature-list").data([0]); - list = list.enter().append("ul").attr("class", "feature-list").merge(list); - var entities = _selectedIDs.map(function(id2) { - return context.hasEntity(id2); - }).filter(Boolean); - var items = list.selectAll(".feature-list-item").data(entities, osmEntity.key); - items.exit().remove(); - var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) { - select_default2(this).on("mouseover", function() { - utilHighlightEntities([d2.id], true, context); - }).on("mouseout", function() { - utilHighlightEntities([d2.id], false, context); - }); - }); - var label = enter.append("button").attr("class", "label").on("click", selectEntity); - label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text")); - label.append("span").attr("class", "entity-type"); - label.append("span").attr("class", "entity-name"); - enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close")); - items = items.merge(enter); - items.selectAll(".entity-geom-icon use").attr("href", function() { - var entity = this.parentNode.parentNode.__data__; - return "#iD-icon-" + entity.geometry(context.graph()); - }); - items.selectAll(".entity-type").text(function(entity) { - return _mainPresetIndex.match(entity, context.graph()).name(); - }); - items.selectAll(".entity-name").text(function(d2) { - var entity = context.entity(d2.id); - return utilDisplayName(entity); - }); - } - return section; - } - - // modules/ui/entity_editor.js - function uiEntityEditor(context) { - var dispatch14 = dispatch_default("choose"); - var _state = "select"; - var _coalesceChanges = false; - var _modified = false; - var _base; - var _entityIDs; - var _activePresets = []; - var _newFeature; - var _sections; - function entityEditor(selection2) { - var combinedTags = utilCombinedTags(_entityIDs, context.graph()); - var header = selection2.selectAll(".header").data([0]); - var headerEnter = header.enter().append("div").attr("class", "header fillL"); - var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward"; - headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction))); - headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() { - context.enter(modeBrowse(context)); - }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close")); - headerEnter.append("h2"); - header = header.merge(headerEnter); - header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features")); - header.selectAll(".preset-reset").on("click", function() { - dispatch14.call("choose", this, _activePresets); - }); - var body = selection2.selectAll(".inspector-body").data([0]); - var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top"); - body = body.merge(bodyEnter); - if (!_sections) { - _sections = [ - uiSectionSelectionList(context), - uiSectionFeatureType(context).on("choose", function(presets) { - dispatch14.call("choose", this, presets); - }), - uiSectionEntityIssues(context), - uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags), - uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags), - uiSectionRawMemberEditor(context), - uiSectionRawMembershipEditor(context) - ]; - } - _sections.forEach(function(section) { - if (section.entityIDs) { - section.entityIDs(_entityIDs); - } - if (section.presets) { - section.presets(_activePresets); - } - if (section.tags) { - section.tags(combinedTags); - } - if (section.state) { - section.state(_state); - } - body.call(section.render); - }); - context.history().on("change.entity-editor", historyChanged); - function historyChanged(difference) { - if (selection2.selectAll(".entity-editor").empty()) - return; - if (_state === "hide") - return; - var significant = !difference || difference.didChange.properties || difference.didChange.addition || difference.didChange.deletion; - if (!significant) - return; - _entityIDs = _entityIDs.filter(context.hasEntity); - if (!_entityIDs.length) - return; - var priorActivePreset = _activePresets.length === 1 && _activePresets[0]; - loadActivePresets(); - var graph = context.graph(); - entityEditor.modified(_base !== graph); - entityEditor(selection2); - if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) { - context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null); - } - } - } - function changeTags(entityIDs, changed, onInput) { - var actions = []; - for (var i3 in entityIDs) { - var entityID = entityIDs[i3]; - var entity = context.entity(entityID); - var tags = Object.assign({}, entity.tags); - if (typeof changed === "function") { - tags = changed(tags); - } else { - for (var k2 in changed) { - if (!k2) - continue; - var v2 = changed[k2]; - if (typeof v2 === "object") { - tags[k2] = tags[v2.oldKey]; - } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) { - tags[k2] = v2; - } - } - } - if (!onInput) { - tags = utilCleanTags(tags); - } - if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) { - actions.push(actionChangeTags(entityID, tags)); - } - } - if (actions.length) { - var combinedAction = function(graph) { - actions.forEach(function(action) { - graph = action(graph); - }); - return graph; - }; - var annotation = _t("operations.change_tags.annotation"); - if (_coalesceChanges) { - context.overwrite(combinedAction, annotation); - } else { - context.perform(combinedAction, annotation); - _coalesceChanges = !!onInput; - } - } - if (!onInput) { - context.validator().validate(); - } - } - function revertTags(keys2) { - var actions = []; - for (var i3 in _entityIDs) { - var entityID = _entityIDs[i3]; - var original = context.graph().base().entities[entityID]; - var changed = {}; - for (var j3 in keys2) { - var key = keys2[j3]; - changed[key] = original ? original.tags[key] : void 0; - } - var entity = context.entity(entityID); - var tags = Object.assign({}, entity.tags); - for (var k2 in changed) { - if (!k2) - continue; - var v2 = changed[k2]; - if (v2 !== void 0 || tags.hasOwnProperty(k2)) { - tags[k2] = v2; - } - } - tags = utilCleanTags(tags); - if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) { - actions.push(actionChangeTags(entityID, tags)); - } - } - if (actions.length) { - var combinedAction = function(graph) { - actions.forEach(function(action) { - graph = action(graph); - }); - return graph; - }; - var annotation = _t("operations.change_tags.annotation"); - if (_coalesceChanges) { - context.overwrite(combinedAction, annotation); - } else { - context.perform(combinedAction, annotation); - _coalesceChanges = false; - } - } - context.validator().validate(); - } - entityEditor.modified = function(val) { - if (!arguments.length) - return _modified; - _modified = val; - return entityEditor; - }; - entityEditor.state = function(val) { - if (!arguments.length) - return _state; - _state = val; - return entityEditor; - }; - entityEditor.entityIDs = function(val) { - if (!arguments.length) - return _entityIDs; - _base = context.graph(); - _coalesceChanges = false; - if (val && _entityIDs && utilArrayIdentical(_entityIDs, val)) - return entityEditor; - _entityIDs = val; - loadActivePresets(true); - return entityEditor.modified(false); - }; - entityEditor.newFeature = function(val) { - if (!arguments.length) - return _newFeature; - _newFeature = val; - return entityEditor; - }; - function loadActivePresets(isForNewSelection) { - var graph = context.graph(); - var counts = {}; - for (var i3 in _entityIDs) { - var entity = graph.hasEntity(_entityIDs[i3]); - if (!entity) - return; - var match = _mainPresetIndex.match(entity, graph); - if (!counts[match.id]) - counts[match.id] = 0; - counts[match.id] += 1; - } - var matches = Object.keys(counts).sort(function(p1, p2) { - return counts[p2] - counts[p1]; - }).map(function(pID) { - return _mainPresetIndex.item(pID); - }); - if (!isForNewSelection) { - var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0; - if (weakPreset && matches.length === 1 && matches[0].isFallback()) - return; + function unbind() { + var row = select_default2(this); + row.selectAll("input.member-role").call(uiCombobox.off, context); } - entityEditor.presets(matches); } - entityEditor.presets = function(val) { + section.entityIDs = function(val) { if (!arguments.length) - return _activePresets; - if (!utilArrayIdentical(val, _activePresets)) { - _activePresets = val; - } - return entityEditor; + return _entityIDs; + _entityIDs = val; + return section; }; - return utilRebind(entityEditor, dispatch14, "on"); + return section; } - // modules/ui/feature_list.js - var sexagesimal = __toESM(require_sexagesimal()); - function uiFeatureList(context) { - var _geocodeResults; - function featureList(selection2) { - var header = selection2.append("div").attr("class", "header fillL"); - header.append("h2").call(_t.append("inspector.feature_list")); - var searchWrap = selection2.append("div").attr("class", "search-header"); - searchWrap.call(svgIcon("#iD-icon-search", "pre-text")); - var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent); - var listWrap = selection2.append("div").attr("class", "inspector-body"); - var list = listWrap.append("div").attr("class", "feature-list"); - context.on("exit.feature-list", clearSearch); - context.map().on("drawn.feature-list", mapDrawn); - context.keybinding().on(uiCmd("\u2318F"), focusSearch); - function focusSearch(d3_event) { - var mode = context.mode() && context.mode().id; - if (mode !== "browse") - return; - d3_event.preventDefault(); - search.node().focus(); - } - function keydown(d3_event) { - if (d3_event.keyCode === 27) { - search.node().blur(); - } + // modules/actions/delete_members.js + function actionDeleteMembers(relationId, memberIndexes) { + return function(graph) { + memberIndexes.sort((a2, b2) => b2 - a2); + for (var i3 in memberIndexes) { + graph = actionDeleteMember(relationId, memberIndexes[i3])(graph); } - function keypress(d3_event) { - var q2 = search.property("value"), items = list.selectAll(".feature-list-item"); - if (d3_event.keyCode === 13 && // ↩ Return - q2.length && items.size()) { - click(d3_event, items.datum()); + return graph; + }; + } + + // modules/ui/sections/raw_membership_editor.js + function uiSectionRawMembershipEditor(context) { + var section = uiSection("raw-membership-editor", context).shouldDisplay(function() { + return _entityIDs && _entityIDs.length; + }).label(function() { + var parents = getSharedParentRelations(); + var gt2 = parents.length > _maxMemberships ? ">" : ""; + var count = gt2 + parents.slice(0, _maxMemberships).length; + return _t.append("inspector.title_count", { title: _t("inspector.relations"), count }); + }).disclosureContent(renderDisclosureContent); + var taginfo = services.taginfo; + var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) { + if (d2.relation) + utilHighlightEntities([d2.relation.id], true, context); + }).itemsMouseLeave(function(d3_event, d2) { + if (d2.relation) + utilHighlightEntities([d2.relation.id], false, context); + }); + var _inChange = false; + var _entityIDs = []; + var _showBlank; + var _maxMemberships = 1e3; + function getSharedParentRelations() { + var parents = []; + for (var i3 = 0; i3 < _entityIDs.length; i3++) { + var entity = context.graph().hasEntity(_entityIDs[i3]); + if (!entity) + continue; + if (i3 === 0) { + parents = context.graph().parentRelations(entity); + } else { + parents = utilArrayIntersection(parents, context.graph().parentRelations(entity)); } + if (!parents.length) + break; } - function inputevent() { - _geocodeResults = void 0; - drawList(); - } - function clearSearch() { - search.property("value", ""); - drawList(); - } - function mapDrawn(e3) { - if (e3.full) { - drawList(); + return parents; + } + function getMemberships() { + var memberships = []; + var relations = getSharedParentRelations().slice(0, _maxMemberships); + var isMultiselect = _entityIDs.length > 1; + var i3, relation, membership, index, member, indexedMember; + for (i3 = 0; i3 < relations.length; i3++) { + relation = relations[i3]; + membership = { + relation, + members: [], + hash: osmEntity.key(relation) + }; + for (index = 0; index < relation.members.length; index++) { + member = relation.members[index]; + if (_entityIDs.indexOf(member.id) !== -1) { + indexedMember = Object.assign({}, member, { index }); + membership.members.push(indexedMember); + membership.hash += "," + index.toString(); + if (!isMultiselect) { + memberships.push(membership); + membership = { + relation, + members: [], + hash: osmEntity.key(relation) + }; + } + } } + if (membership.members.length) + memberships.push(membership); } - function features() { - var result = []; - var graph = context.graph(); - var visibleCenter = context.map().extent().center(); - var q2 = search.property("value").toLowerCase(); - if (!q2) - return result; - var locationMatch = sexagesimal.pair(q2.toUpperCase()) || q2.match(/^(-?\d+\.?\d*)\s+(-?\d+\.?\d*)$/); - if (locationMatch) { - var loc = [Number(locationMatch[0]), Number(locationMatch[1])]; - result.push({ - id: -1, - geometry: "point", - type: _t("inspector.location"), - name: dmsCoordinatePair([loc[1], loc[0]]), - location: loc - }); - } - var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i); - if (idMatch) { - var elemType = idMatch[1].charAt(0); - var elemId = idMatch[2]; - result.push({ - id: elemType + elemId, - geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : "relation", - type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : _t("inspector.relation"), - name: elemId - }); - } - var allEntities = graph.entities; - var localResults = []; - for (var id2 in allEntities) { - var entity = allEntities[id2]; - if (!entity) - continue; - var name = utilDisplayName(entity) || ""; - if (name.toLowerCase().indexOf(q2) < 0) - continue; - var matched = _mainPresetIndex.match(entity, graph); - var type2 = matched && matched.name() || utilDisplayType(entity.id); - var extent = entity.extent(graph); - var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0; - localResults.push({ - id: entity.id, - entity, - geometry: entity.geometry(graph), - type: type2, - name, - distance - }); - if (localResults.length > 100) - break; - } - localResults = localResults.sort(function byDistance(a2, b2) { - return a2.distance - b2.distance; + memberships.forEach(function(membership2) { + membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id); + var roles = []; + membership2.members.forEach(function(member2) { + if (roles.indexOf(member2.role) === -1) + roles.push(member2.role); }); - result = result.concat(localResults); - (_geocodeResults || []).forEach(function(d2) { - if (d2.osm_type && d2.osm_id) { - var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id); - var tags = {}; - tags[d2.class] = d2.type; - var attrs = { id: id3, type: d2.osm_type, tags }; - if (d2.osm_type === "way") { - attrs.nodes = ["a", "a"]; - } - var tempEntity = osmEntity(attrs); - var tempGraph = coreGraph([tempEntity]); - var matched2 = _mainPresetIndex.match(tempEntity, tempGraph); - var type3 = matched2 && matched2.name() || utilDisplayType(id3); - result.push({ - id: tempEntity.id, - geometry: tempEntity.geometry(tempGraph), - type: type3, - name: d2.display_name, - extent: new geoExtent( - [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])], - [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])] - ) + membership2.role = roles.length === 1 ? roles[0] : roles; + }); + return memberships; + } + function selectRelation(d3_event, d2) { + d3_event.preventDefault(); + utilHighlightEntities([d2.relation.id], false, context); + context.enter(modeSelect(context, [d2.relation.id])); + } + function zoomToRelation(d3_event, d2) { + d3_event.preventDefault(); + var entity = context.entity(d2.relation.id); + context.map().zoomToEase(entity); + utilHighlightEntities([d2.relation.id], true, context); + } + function changeRole(d3_event, d2) { + if (d2 === 0) + return; + if (_inChange) + return; + var newRole = context.cleanRelationRole(select_default2(this).property("value")); + if (!newRole.trim() && typeof d2.role !== "string") + return; + var membersToUpdate = d2.members.filter(function(member) { + return member.role !== newRole; + }); + if (membersToUpdate.length) { + _inChange = true; + context.perform( + function actionChangeMemberRoles(graph) { + membersToUpdate.forEach(function(member) { + var newMember = Object.assign({}, member, { role: newRole }); + delete newMember.index; + graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph); }); + return graph; + }, + _t("operations.change_role.annotation", { + n: membersToUpdate.length + }) + ); + context.validator().validate(); + } + _inChange = false; + } + function addMembership(d2, role) { + this.blur(); + _showBlank = false; + function actionAddMembers(relationId, ids, role2) { + return function(graph) { + for (var i3 in ids) { + var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 }; + graph = actionAddMember(relationId, member)(graph); } + return graph; + }; + } + if (d2.relation) { + context.perform( + actionAddMembers(d2.relation.id, _entityIDs, role), + _t("operations.add_member.annotation", { + n: _entityIDs.length + }) + ); + context.validator().validate(); + } else { + var relation = osmRelation(); + context.perform( + actionAddEntity(relation), + actionAddMembers(relation.id, _entityIDs, role), + _t("operations.add.annotation.relation") + ); + context.enter(modeSelect(context, [relation.id]).newFeature(true)); + } + } + function downloadMembers(d3_event, d2) { + d3_event.preventDefault(); + const button = select_default2(this); + button.classed("loading", true); + context.loadEntity(d2.relation.id, function() { + section.reRender(); + }); + } + function deleteMembership(d3_event, d2) { + this.blur(); + if (d2 === 0) + return; + utilHighlightEntities([d2.relation.id], false, context); + var indexes = d2.members.map(function(member) { + return member.index; + }); + context.perform( + actionDeleteMembers(d2.relation.id, indexes), + _t("operations.delete_member.annotation", { + n: _entityIDs.length + }) + ); + context.validator().validate(); + } + function fetchNearbyRelations(q2, callback) { + var newRelation = { + relation: null, + value: _t("inspector.new_relation"), + display: _t.append("inspector.new_relation") + }; + var entityID = _entityIDs[0]; + var result = []; + var graph = context.graph(); + function baseDisplayValue(entity) { + var matched = _mainPresetIndex.match(entity, graph); + var presetName = matched && matched.name() || _t("inspector.relation"); + var entityName = utilDisplayName(entity) || ""; + return presetName + " " + entityName; + } + function baseDisplayLabel(entity) { + var matched = _mainPresetIndex.match(entity, graph); + var presetName = matched && matched.name() || _t("inspector.relation"); + var entityName = utilDisplayName(entity) || ""; + return (selection2) => { + selection2.append("b").text(presetName + " "); + selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName); + }; + } + var explicitRelation = q2 && context.hasEntity(q2.toLowerCase()); + if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) { + result.push({ + relation: explicitRelation, + value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id, + display: baseDisplayLabel(explicitRelation) }); - if (q2.match(/^[0-9]+$/)) { - result.push({ - id: "n" + q2, - geometry: "point", - type: _t("inspector.node"), - name: q2 - }); - result.push({ - id: "w" + q2, - geometry: "line", - type: _t("inspector.way"), - name: q2 - }); + } else { + context.history().intersects(context.map().extent()).forEach(function(entity) { + if (entity.type !== "relation" || entity.id === entityID) + return; + var value = baseDisplayValue(entity); + if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1) + return; result.push({ - id: "r" + q2, - geometry: "relation", - type: _t("inspector.relation"), - name: q2 + relation: entity, + value, + display: baseDisplayLabel(entity) }); - } - return result; - } - function drawList() { - var value = search.property("value"); - var results = features(); - list.classed("filtered", value.length); - var resultsIndicator = list.selectAll(".no-results-item").data([0]).enter().append("button").property("disabled", true).attr("class", "no-results-item").call(svgIcon("#iD-icon-alert", "pre-text")); - resultsIndicator.append("span").attr("class", "entity-name"); - list.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide")); - if (services.geocoder) { - list.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")); - } - list.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none"); - list.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none"); - list.selectAll(".feature-list-item").data([-1]).remove(); - var items = list.selectAll(".feature-list-item").data(results, function(d2) { - return d2.id; - }); - var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click); - var label = enter.append("div").attr("class", "label"); - label.each(function(d2) { - select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text")); }); - label.append("span").attr("class", "entity-type").text(function(d2) { - return d2.type; + result.sort(function(a2, b2) { + return osmRelation.creationOrder(a2.relation, b2.relation); }); - label.append("span").attr("class", "entity-name").text(function(d2) { - return d2.name; + var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) { + return v2.length > 1; }); - enter.style("opacity", 0).transition().style("opacity", 1); - items.order(); - items.exit().remove(); - } - function mouseover(d3_event, d2) { - if (d2.id === -1) - return; - utilHighlightEntities([d2.id], true, context); - } - function mouseout(d3_event, d2) { - if (d2.id === -1) - return; - utilHighlightEntities([d2.id], false, context); - } - function click(d3_event, d2) { - d3_event.preventDefault(); - if (d2.location) { - context.map().centerZoomEase([d2.location[1], d2.location[0]], 19); - } else if (d2.entity) { - utilHighlightEntities([d2.id], false, context); - context.enter(modeSelect(context, [d2.entity.id])); - context.map().zoomToEase(d2.entity); - } else { - context.zoomToEntity(d2.id); - } - } - function geocoderSearch() { - services.geocoder.search(search.property("value"), function(err, resp) { - _geocodeResults = resp || []; - drawList(); + dupeGroups.forEach(function(group) { + group.forEach(function(obj) { + obj.value += " " + obj.relation.id; + }); }); } - } - return featureList; - } - - // modules/ui/improveOSM_comments.js - function uiImproveOsmComments() { - let _qaItem; - function issueComments(selection2) { - let comments = selection2.selectAll(".comments-container").data([0]); - comments = comments.enter().append("div").attr("class", "comments-container").merge(comments); - services.improveOSM.getComments(_qaItem).then((d2) => { - if (!d2.comments) - return; - const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment"); - commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon")); - const mainEnter = commentEnter.append("div").attr("class", "comment-main"); - const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata"); - metadataEnter.append("div").attr("class", "comment-author").each(function(d4) { - const osm = services.osm; - let selection3 = select_default2(this); - if (osm && d4.username) { - selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank"); - } - selection3.text((d5) => d5.username); - }); - metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) })); - mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text); - }).catch((err) => { - console.log(err); + result.forEach(function(obj) { + obj.title = obj.value; }); + result.unshift(newRelation); + callback(result); } - function localeDateString2(s2) { - if (!s2) - return null; - const options2 = { day: "numeric", month: "short", year: "numeric" }; - const d2 = new Date(s2 * 1e3); - if (isNaN(d2.getTime())) - return null; - return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2); - } - issueComments.issue = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return issueComments; - }; - return issueComments; - } - - // modules/ui/improveOSM_details.js - function uiImproveOsmDetails(context) { - let _qaItem; - function issueDetail(d2) { - if (d2.desc) - return d2.desc; - const issueKey = d2.issueKey; - d2.replacements = d2.replacements || {}; - d2.replacements.default = { html: _t.html("inspector.unknown") }; - return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements); - } - function improveOsmDetails(selection2) { - const details = selection2.selectAll(".error-details").data( - _qaItem ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + function renderDisclosureContent(selection2) { + var memberships = getMemberships(); + var list2 = selection2.selectAll(".member-list").data([0]); + list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2); + var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) { + return d2.hash; + }); + items.exit().each(unbind).remove(); + var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field"); + itemsEnter.on("mouseover", function(d3_event, d2) { + utilHighlightEntities([d2.relation.id], true, context); + }).on("mouseout", function(d3_event, d2) { + utilHighlightEntities([d2.relation.id], false, context); + }); + var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) { + return d2.domId; + }); + var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation); + labelLink.append("span").attr("class", "member-entity-type").text(function(d2) { + var matched = _mainPresetIndex.match(d2.relation, context.graph()); + return matched && matched.name() || _t.html("inspector.relation"); + }); + labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).text(function(d2) { + return utilDisplayName(d2.relation); + }); + labelEnter.append("button").attr("class", "members-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMembers); + labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership); + labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation); + items = items.merge(itemsEnter); + items.selectAll("button.members-download").classed("hide", (d2) => { + const graph = context.graph(); + return d2.relation.members.every((m2) => graph.hasEntity(m2.id)); + }); + var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member"); + wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) { + return d2.domId; + }).property("type", "text").property("value", function(d2) { + return typeof d2.role === "string" ? d2.role : ""; + }).attr("title", function(d2) { + return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role; + }).attr("placeholder", function(d2) { + return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role"); + }).classed("mixed", function(d2) { + return Array.isArray(d2.role); + }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole); + if (taginfo) { + wrapEnter.each(bindTypeahead); + } + var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []); + newMembership.exit().remove(); + var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field"); + var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label"); + newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto); + newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() { + list2.selectAll(".member-row-new").remove(); + }); + var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member"); + newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto); + newMembership = newMembership.merge(newMembershipEnter); + newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call( + nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity) ); - details.exit().remove(); - const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container"); - const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection"); - descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description")); - descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail); - let relatedEntities = []; - descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() { - const link2 = select_default2(this); - const isObjectLink = link2.classed("error_object_link"); - const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent; - const entity = context.hasEntity(entityID); - relatedEntities.push(entityID); - link2.on("mouseenter", () => { - utilHighlightEntities([entityID], true, context); - }).on("mouseleave", () => { - utilHighlightEntities([entityID], false, context); - }).on("click", (d3_event) => { - d3_event.preventDefault(); - utilHighlightEntities([entityID], false, context); - const osmlayer = context.layers().layer("osm"); - if (!osmlayer.enabled()) { - osmlayer.enabled(true); - } - context.map().centerZoom(_qaItem.loc, 20); - if (entity) { - context.enter(modeSelect(context, [entityID])); - } else { - context.loadEntity(entityID, (err, result) => { - if (err) - return; - const entity2 = result.data.find((e3) => e3.id === entityID); - if (entity2) - context.enter(modeSelect(context, [entityID])); - }); - } - }); - if (entity) { - let name = utilDisplayName(entity); - if (!name && !isObjectLink) { - const preset = _mainPresetIndex.match(entity, context.graph()); - name = preset && !preset.isFallback() && preset.name(); - } - if (name) { - this.innerText = name; + var addRow = selection2.selectAll(".add-row").data([0]); + var addRowEnter = addRow.enter().append("div").attr("class", "add-row"); + var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation")); + addRelationButton.call(svgIcon("#iD-icon-plus", "light")); + addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left")); + addRowEnter.append("div").attr("class", "space-value"); + addRowEnter.append("div").attr("class", "space-buttons"); + addRow = addRow.merge(addRowEnter); + addRow.select(".add-relation").on("click", function() { + _showBlank = true; + section.reRender(); + list2.selectAll(".member-entity-input").node().focus(); + }); + function acceptEntity(d2) { + if (!d2) { + cancelEntity(); + return; + } + if (d2.relation) + utilHighlightEntities([d2.relation.id], false, context); + var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value")); + addMembership(d2, role); + } + function cancelEntity() { + var input = newMembership.selectAll(".member-entity-input"); + input.property("value", ""); + context.surface().selectAll(".highlighted").classed("highlighted", false); + } + function bindTypeahead(d2) { + var row = select_default2(this); + var role = row.selectAll("input.member-role"); + var origValue = role.property("value"); + function sort(value, data) { + var sameletter = []; + var other = []; + for (var i3 = 0; i3 < data.length; i3++) { + if (data[i3].value.substring(0, value.length) === value) { + sameletter.push(data[i3]); + } else { + other.push(data[i3]); + } } + return sameletter.concat(other); } - }); - context.features().forceVisible(relatedEntities); - context.map().pan([0, 0]); + role.call( + uiCombobox(context, "member-role").fetcher(function(role2, callback) { + var rtype = d2.relation.tags.type; + taginfo.roles({ + debounce: true, + rtype: rtype || "", + geometry: context.graph().geometry(_entityIDs[0]), + query: role2 + }, function(err, data) { + if (!err) + callback(sort(role2, data)); + }); + }).on("cancel", function() { + role.property("value", origValue); + }) + ); + } + function unbind() { + var row = select_default2(this); + row.selectAll("input.member-role").call(uiCombobox.off, context); + } } - improveOsmDetails.issue = function(val) { + section.entityIDs = function(val) { if (!arguments.length) - return _qaItem; - _qaItem = val; - return improveOsmDetails; + return _entityIDs; + _entityIDs = val; + _showBlank = false; + return section; }; - return improveOsmDetails; + return section; } - // modules/ui/improveOSM_header.js - function uiImproveOsmHeader() { - let _qaItem; - function issueTitle(d2) { - const issueKey = d2.issueKey; - d2.replacements = d2.replacements || {}; - d2.replacements.default = { html: _t.html("inspector.unknown") }; - return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements); - } - function improveOsmHeader(selection2) { - const header = selection2.selectAll(".qa-header").data( - _qaItem ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) - ); - header.exit().remove(); - const headerEnter = header.enter().append("div").attr("class", "qa-header"); - 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)); - svgEnter.append("polygon").attr("fill", "currentColor").attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); - 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 : ""); - headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle); - } - improveOsmHeader.issue = function(val) { + // modules/ui/sections/selection_list.js + function uiSectionSelectionList(context) { + var _selectedIDs = []; + var section = uiSection("selected-features", context).shouldDisplay(function() { + return _selectedIDs.length > 1; + }).label(function() { + return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length }); + }).disclosureContent(renderDisclosureContent); + context.history().on("change.selectionList", function(difference2) { + if (difference2) { + section.reRender(); + } + }); + section.entityIDs = function(val) { if (!arguments.length) - return _qaItem; - _qaItem = val; - return improveOsmHeader; + return _selectedIDs; + _selectedIDs = val; + return section; }; - return improveOsmHeader; - } - - // modules/ui/improveOSM_editor.js - function uiImproveOsmEditor(context) { - const dispatch14 = dispatch_default("change"); - const qaDetails = uiImproveOsmDetails(context); - const qaComments = uiImproveOsmComments(context); - const qaHeader = uiImproveOsmHeader(context); - let _qaItem; - function improveOsmEditor(selection2) { - const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL"); - headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close")); - headerEnter.append("h2").call(_t.append("QA.improveOSM.title")); - let body = selection2.selectAll(".body").data([0]); - body = body.enter().append("div").attr("class", "body").merge(body); - const editor = body.selectAll(".qa-editor").data([0]); - editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(qaComments.issue(_qaItem)).call(improveOsmSaveSection); + function selectEntity(d3_event, entity) { + context.enter(modeSelect(context, [entity.id])); } - function improveOsmSaveSection(selection2) { - const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); - const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment); - let saveSection = selection2.selectAll(".qa-save").data( - isShown ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) - ); - saveSection.exit().remove(); - const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf"); - saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment")); - saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput); - saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); - function changeInput() { - const input = select_default2(this); - let val = input.property("value").trim(); - if (val === "") { - val = void 0; - } - _qaItem = _qaItem.update({ newComment: val }); - const qaService = services.improveOSM; - if (qaService) { - qaService.replaceItem(_qaItem); - } - saveSection.call(qaSaveButtons); + function deselectEntity(d3_event, entity) { + var selectedIDs = _selectedIDs.slice(); + var index = selectedIDs.indexOf(entity.id); + if (index > -1) { + selectedIDs.splice(index, 1); + context.enter(modeSelect(context, selectedIDs)); } } - function qaSaveButtons(selection2) { - const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); - let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id); - buttonSection.exit().remove(); - const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons"); - buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment")); - buttonEnter.append("button").attr("class", "button close-button action"); - buttonEnter.append("button").attr("class", "button ignore-button action"); - buttonSection = buttonSection.merge(buttonEnter); - buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) { - this.blur(); - const qaService = services.improveOSM; - if (qaService) { - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } + function renderDisclosureContent(selection2) { + var list2 = selection2.selectAll(".feature-list").data([0]); + list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2); + var entities = _selectedIDs.map(function(id2) { + return context.hasEntity(id2); + }).filter(Boolean); + var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key); + items.exit().remove(); + var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) { + select_default2(this).on("mouseover", function() { + utilHighlightEntities([d2.id], true, context); + }).on("mouseout", function() { + utilHighlightEntities([d2.id], false, context); + }); }); - buttonSection.select(".close-button").html((d2) => { - const andComment = d2.newComment ? "_comment" : ""; - return _t.html("QA.keepRight.close".concat(andComment)); - }).on("click.close", function(d3_event, d2) { - this.blur(); - const qaService = services.improveOSM; - if (qaService) { - d2.newStatus = "SOLVED"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } + var label = enter.append("button").attr("class", "label").on("click", selectEntity); + label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text")); + label.append("span").attr("class", "entity-type"); + label.append("span").attr("class", "entity-name"); + enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close")); + items = items.merge(enter); + items.selectAll(".entity-geom-icon use").attr("href", function() { + var entity = this.parentNode.parentNode.__data__; + return "#iD-icon-" + entity.geometry(context.graph()); }); - buttonSection.select(".ignore-button").html((d2) => { - const andComment = d2.newComment ? "_comment" : ""; - return _t.html("QA.keepRight.ignore".concat(andComment)); - }).on("click.ignore", function(d3_event, d2) { - this.blur(); - const qaService = services.improveOSM; - if (qaService) { - d2.newStatus = "INVALID"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } + items.selectAll(".entity-type").text(function(entity) { + return _mainPresetIndex.match(entity, context.graph()).name(); + }); + items.selectAll(".entity-name").text(function(d2) { + var entity = context.entity(d2.id); + return utilDisplayName(entity); }); } - improveOsmEditor.error = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return improveOsmEditor; - }; - return utilRebind(improveOsmEditor, dispatch14, "on"); + return section; } - // modules/ui/preset_list.js - function uiPresetList(context) { - var dispatch14 = dispatch_default("cancel", "choose"); + // modules/ui/entity_editor.js + function uiEntityEditor(context) { + var dispatch14 = dispatch_default("choose"); + var _state = "select"; + var _coalesceChanges = false; + var _modified = false; + var _base; var _entityIDs; - var _currLoc; - var _currentPresets; - var _autofocus = false; - function presetList(selection2) { - if (!_entityIDs) - return; - var presets = _mainPresetIndex.matchAllGeometry(entityGeometries()); - selection2.html(""); - var messagewrap = selection2.append("div").attr("class", "header fillL"); - var message = messagewrap.append("h2").call(_t.append("inspector.choose")); - var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward"; - messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() { - dispatch14.call("cancel", this); - }).call(svgIcon("#iD-icon-".concat(direction))); - function initialKeydown(d3_event) { - if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - operationDelete(context, _entityIDs)(); - } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - context.undo(); - } else if (!d3_event.ctrlKey && !d3_event.metaKey) { - select_default2(this).on("keydown", keydown); - keydown.call(this, d3_event); - } + var _activePresets = []; + var _newFeature; + var _sections; + function entityEditor(selection2) { + var combinedTags = utilCombinedTags(_entityIDs, context.graph()); + var header = selection2.selectAll(".header").data([0]); + var headerEnter = header.enter().append("div").attr("class", "header fillL"); + var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward"; + headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction))); + headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() { + context.enter(modeBrowse(context)); + }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close")); + headerEnter.append("h2"); + header = header.merge(headerEnter); + header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features")); + header.selectAll(".preset-reset").on("click", function() { + dispatch14.call("choose", this, _activePresets); + }); + var body = selection2.selectAll(".inspector-body").data([0]); + var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top"); + body = body.merge(bodyEnter); + if (!_sections) { + _sections = [ + uiSectionSelectionList(context), + uiSectionFeatureType(context).on("choose", function(presets) { + dispatch14.call("choose", this, presets); + }), + uiSectionEntityIssues(context), + uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags), + uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags), + uiSectionRawMemberEditor(context), + uiSectionRawMembershipEditor(context) + ]; } - function keydown(d3_event) { - if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string - search.node().selectionStart === search.property("value").length) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var buttons = list.selectAll(".preset-list-button"); - if (!buttons.empty()) - buttons.nodes()[0].focus(); + _sections.forEach(function(section) { + if (section.entityIDs) { + section.entityIDs(_entityIDs); } - } - function keypress(d3_event) { - var value = search.property("value"); - if (d3_event.keyCode === 13 && // ↩ Return - value.length) { - list.selectAll(".preset-list-item:first-child").each(function(d2) { - d2.choose.call(this); - }); + if (section.presets) { + section.presets(_activePresets); } - } - function inputevent() { - var value = search.property("value"); - list.classed("filtered", value.length); - var results, messageText; - if (value.length) { - results = presets.search(value, entityGeometries()[0], _currLoc); - messageText = _t.html("inspector.results", { - n: results.collection.length, - search: value - }); - } else { - var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph())); - results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2); - messageText = _t.html("inspector.choose"); + if (section.tags) { + section.tags(combinedTags); } - list.call(drawList, results); - message.html(messageText); - } - var searchWrap = selection2.append("div").attr("class", "search-header"); - searchWrap.call(svgIcon("#iD-icon-search", "pre-text")); - var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent)); - if (_autofocus) { - search.node().focus(); - setTimeout(function() { - search.node().focus(); - }, 0); - } - var listWrap = selection2.append("div").attr("class", "inspector-body"); - var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph())); - var list = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets)); - context.features().on("change.preset-list", updateForFeatureHiddenState); - } - function drawList(list, presets) { - presets = presets.matchAllGeometry(entityGeometries()); - var collection = presets.collection.reduce(function(collection2, preset) { - if (!preset) - return collection2; - if (preset.members) { - if (preset.members.collection.filter(function(preset2) { - return preset2.addable(); - }).length > 1) { - collection2.push(CategoryItem(preset)); - } - } else if (preset.addable()) { - collection2.push(PresetItem(preset)); + if (section.state) { + section.state(_state); } - return collection2; - }, []); - var items = list.selectAll(".preset-list-item").data(collection, function(d2) { - return d2.preset.id; + body.call(section.render); }); - items.order(); - items.exit().remove(); - items.enter().append("div").attr("class", function(item) { - return "preset-list-item preset-" + item.preset.id.replace("/", "-"); - }).classed("current", function(item) { - return _currentPresets.indexOf(item.preset) !== -1; - }).each(function(item) { - select_default2(this).call(item); - }).style("opacity", 0).transition().style("opacity", 1); - updateForFeatureHiddenState(); - } - function itemKeydown(d3_event) { - var item = select_default2(this.closest(".preset-list-item")); - var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item")); - if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var nextItem = select_default2(item.node().nextElementSibling); - if (nextItem.empty()) { - if (!parentItem.empty()) { - nextItem = select_default2(parentItem.node().nextElementSibling); - } - } else if (select_default2(this).classed("expanded")) { - nextItem = item.select(".subgrid .preset-list-item:first-child"); - } - if (!nextItem.empty()) { - nextItem.select(".preset-list-button").node().focus(); - } - } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var previousItem = select_default2(item.node().previousElementSibling); - if (previousItem.empty()) { - if (!parentItem.empty()) { - previousItem = parentItem; - } - } else if (previousItem.select(".preset-list-button").classed("expanded")) { - previousItem = previousItem.select(".subgrid .preset-list-item:last-child"); - } - if (!previousItem.empty()) { - previousItem.select(".preset-list-button").node().focus(); - } else { - var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input"); - search.node().focus(); - } - } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - if (!parentItem.empty()) { - parentItem.select(".preset-list-button").node().focus(); - } - } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - item.datum().choose.call(select_default2(this).node()); - } - } - function CategoryItem(preset) { - var box, sublist, shown = false; - function item(selection2) { - var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category"); - function click() { - var isExpanded = select_default2(this).classed("expanded"); - var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down"; - select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand")); - select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName); - item.choose(); + context.history().on("change.entity-editor", historyChanged); + function historyChanged(difference2) { + if (selection2.selectAll(".entity-editor").empty()) + return; + if (_state === "hide") + return; + var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion; + if (!significant) + return; + _entityIDs = _entityIDs.filter(context.hasEntity); + if (!_entityIDs.length) + return; + var priorActivePreset = _activePresets.length === 1 && _activePresets[0]; + loadActivePresets(); + var graph = context.graph(); + entityEditor.modified(_base !== graph); + entityEditor(selection2); + if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) { + context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null); } - var geometries = entityGeometries(); - 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) { - if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - if (!select_default2(this).classed("expanded")) { - click.call(this, d3_event); - } - } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - if (select_default2(this).classed("expanded")) { - click.call(this, d3_event); + } + } + function changeTags(entityIDs, changed, onInput) { + var actions = []; + for (var i3 in entityIDs) { + var entityID = entityIDs[i3]; + var entity = context.entity(entityID); + var tags = Object.assign({}, entity.tags); + if (typeof changed === "function") { + tags = changed(tags); + } else { + for (var k2 in changed) { + if (!k2) + continue; + var v2 = changed[k2]; + if (typeof v2 === "object") { + tags[k2] = tags[v2.oldKey]; + } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) { + tags[k2] = v2; } - } else { - itemKeydown.call(this, d3_event); } - }); - var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner"); - 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"); - box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0); - box.append("div").attr("class", "arrow"); - sublist = box.append("div").attr("class", "preset-list fillL3"); + } + if (!onInput) { + tags = utilCleanTags(tags); + } + if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) { + actions.push(actionChangeTags(entityID, tags)); + } } - item.choose = function() { - if (!box || !sublist) - return; - if (shown) { - shown = false; - box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px"); + if (actions.length) { + var combinedAction = function(graph) { + actions.forEach(function(action) { + graph = action(graph); + }); + return graph; + }; + var annotation = _t("operations.change_tags.annotation"); + if (_coalesceChanges) { + context.overwrite(combinedAction, annotation); } else { - shown = true; - var members = preset.members.matchAllGeometry(entityGeometries()); - sublist.call(drawList, members); - box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px"); + context.perform(combinedAction, annotation); + _coalesceChanges = !!onInput; } - }; - item.preset = preset; - return item; - } - function PresetItem(preset) { - function item(selection2) { - var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap"); - var geometries = entityGeometries(); - 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); - var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner"); - var nameparts = [ - preset.nameLabel(), - preset.subtitleLabel() - ].filter(Boolean); - label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) { - d2(select_default2(this)); - }); - wrap2.call(item.reference.button); - selection2.call(item.reference.body); } - item.choose = function() { - if (select_default2(this).classed("disabled")) - return; - if (!context.inIntro()) { - _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]); - } - context.perform( - function(graph) { - for (var i3 in _entityIDs) { - var entityID = _entityIDs[i3]; - var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph); - graph = actionChangePreset(entityID, oldPreset, preset)(graph); - } - return graph; - }, - _t("operations.change_tags.annotation") - ); + if (!onInput) { context.validator().validate(); - dispatch14.call("choose", this, preset); - }; - item.help = function(d3_event) { - d3_event.stopPropagation(); - item.reference.toggle(); - }; - item.preset = preset; - item.reference = uiTagReference(preset.reference(), context); - return item; + } } - function updateForFeatureHiddenState() { - if (!_entityIDs.every(context.hasEntity)) - return; - var geometries = entityGeometries(); - var button = context.container().selectAll(".preset-list .preset-list-button"); - button.call(uiTooltip().destroyAny); - button.each(function(item, index) { - var hiddenPresetFeaturesId; - for (var i3 in geometries) { - hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]); - if (hiddenPresetFeaturesId) - break; + function revertTags(keys2) { + var actions = []; + for (var i3 in _entityIDs) { + var entityID = _entityIDs[i3]; + var original = context.graph().base().entities[entityID]; + var changed = {}; + for (var j2 in keys2) { + var key = keys2[j2]; + changed[key] = original ? original.tags[key] : void 0; } - var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]); - select_default2(this).classed("disabled", isHiddenPreset); - if (isHiddenPreset) { - var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId); - select_default2(this).call( - uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), { - features: _t("feature." + hiddenPresetFeaturesId + ".description") - })).placement(index < 2 ? "bottom" : "top") - ); + var entity = context.entity(entityID); + var tags = Object.assign({}, entity.tags); + for (var k2 in changed) { + if (!k2) + continue; + var v2 = changed[k2]; + if (v2 !== void 0 || tags.hasOwnProperty(k2)) { + tags[k2] = v2; + } } - }); + tags = utilCleanTags(tags); + if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) { + actions.push(actionChangeTags(entityID, tags)); + } + } + if (actions.length) { + var combinedAction = function(graph) { + actions.forEach(function(action) { + graph = action(graph); + }); + return graph; + }; + var annotation = _t("operations.change_tags.annotation"); + if (_coalesceChanges) { + context.overwrite(combinedAction, annotation); + } else { + context.perform(combinedAction, annotation); + _coalesceChanges = false; + } + } + context.validator().validate(); } - presetList.autofocus = function(val) { + entityEditor.modified = function(val) { if (!arguments.length) - return _autofocus; - _autofocus = val; - return presetList; + return _modified; + _modified = val; + return entityEditor; }; - presetList.entityIDs = function(val) { + entityEditor.state = function(val) { + if (!arguments.length) + return _state; + _state = val; + return entityEditor; + }; + entityEditor.entityIDs = function(val) { if (!arguments.length) return _entityIDs; + _base = context.graph(); + _coalesceChanges = false; + if (val && _entityIDs && utilArrayIdentical(_entityIDs, val)) + return entityEditor; _entityIDs = val; - _currLoc = null; - if (_entityIDs && _entityIDs.length) { - const extent = _entityIDs.reduce(function(extent2, entityID) { - var entity = context.graph().entity(entityID); - return extent2.extend(entity.extent(context.graph())); - }, geoExtent()); - _currLoc = extent.center(); - var presets = _entityIDs.map(function(entityID) { - return _mainPresetIndex.match(context.entity(entityID), context.graph()); - }); - presetList.presets(presets); - } - return presetList; + loadActivePresets(true); + return entityEditor.modified(false); }; - presetList.presets = function(val) { + entityEditor.newFeature = function(val) { if (!arguments.length) - return _currentPresets; - _currentPresets = val; - return presetList; + return _newFeature; + _newFeature = val; + return entityEditor; }; - function entityGeometries() { + function loadActivePresets(isForNewSelection) { + var graph = context.graph(); var counts = {}; for (var i3 in _entityIDs) { - var entityID = _entityIDs[i3]; - var entity = context.entity(entityID); - var geometry = entity.geometry(context.graph()); - if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) { - geometry = "point"; - } - if (!counts[geometry]) - counts[geometry] = 0; - counts[geometry] += 1; + var entity = graph.hasEntity(_entityIDs[i3]); + if (!entity) + return; + var match = _mainPresetIndex.match(entity, graph); + if (!counts[match.id]) + counts[match.id] = 0; + counts[match.id] += 1; } - return Object.keys(counts).sort(function(geom1, geom2) { - return counts[geom2] - counts[geom1]; + var matches = Object.keys(counts).sort(function(p1, p2) { + return counts[p2] - counts[p1]; + }).map(function(pID) { + return _mainPresetIndex.item(pID); }); - } - return utilRebind(presetList, dispatch14, "on"); - } - - // modules/ui/view_on_osm.js - function uiViewOnOSM(context) { - var _what; - function viewOnOSM(selection2) { - var url; - if (_what instanceof osmEntity) { - url = context.connection().entityURL(_what); - } else if (_what instanceof osmNote) { - url = context.connection().noteURL(_what); + if (!isForNewSelection) { + var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0; + if (weakPreset && matches.length === 1 && matches[0].isFallback()) + return; } - var data = !_what || _what.isNew() ? [] : [_what]; - var link2 = selection2.selectAll(".view-on-osm").data(data, function(d2) { - return d2.id; - }); - link2.exit().remove(); - var linkEnter = link2.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline")); - linkEnter.append("span").call(_t.append("inspector.view_on_osm")); + entityEditor.presets(matches); } - viewOnOSM.what = function(_2) { + entityEditor.presets = function(val) { if (!arguments.length) - return _what; - _what = _2; - return viewOnOSM; + return _activePresets; + if (!utilArrayIdentical(val, _activePresets)) { + _activePresets = val; + } + return entityEditor; }; - return viewOnOSM; + return utilRebind(entityEditor, dispatch14, "on"); } - // modules/ui/inspector.js - function uiInspector(context) { - var presetList = uiPresetList(context); - var entityEditor = uiEntityEditor(context); - var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null); - var _state = "select"; - var _entityIDs; - var _newFeature = false; - function inspector(selection2) { - presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() { - inspector.setPreset(); - }); - entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList); - wrap2 = selection2.selectAll(".panewrap").data([0]); - var enter = wrap2.enter().append("div").attr("class", "panewrap"); - enter.append("div").attr("class", "preset-list-pane pane"); - enter.append("div").attr("class", "entity-editor-pane pane"); - wrap2 = wrap2.merge(enter); - presetPane = wrap2.selectAll(".preset-list-pane"); - editorPane = wrap2.selectAll(".entity-editor-pane"); - function shouldDefaultToPresetList() { - if (_state !== "select") - return false; - if (_entityIDs.length !== 1) - return false; - var entityID = _entityIDs[0]; - var entity = context.hasEntity(entityID); - if (!entity) - return false; - if (entity.hasNonGeometryTags()) - return false; - if (_newFeature) - return true; - if (entity.geometry(context.graph()) !== "vertex") - return false; - if (context.graph().parentRelations(entity).length) - return false; - if (context.validator().getEntityIssues(entityID).length) - return false; - if (entity.isHighwayIntersection(context.graph())) - return false; - return true; - } - if (shouldDefaultToPresetList()) { - wrap2.style("right", "-100%"); - editorPane.classed("hide", true); - presetPane.classed("hide", false).call(presetList); - } else { - wrap2.style("right", "0%"); - presetPane.classed("hide", true); - editorPane.classed("hide", false).call(entityEditor); - } - var footer = selection2.selectAll(".footer").data([0]); - footer = footer.enter().append("div").attr("class", "footer").merge(footer); - footer.call( - uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0])) - ); - } - inspector.showList = function(presets) { - presetPane.classed("hide", false); - wrap2.transition().styleTween("right", function() { - return value_default("0%", "-100%"); - }).on("end", function() { - editorPane.classed("hide", true); - }); - if (presets) { - presetList.presets(presets); - } - presetPane.call(presetList.autofocus(true)); + // modules/ui/feature_list.js + var sexagesimal = __toESM(require_sexagesimal()); + + // modules/modes/draw_area.js + function modeDrawArea(context, wayID, startGraph, button) { + var mode = { + button, + id: "draw-area" }; - inspector.setPreset = function(preset) { - if (preset && preset.id === "type/multipolygon") { - presetPane.call(presetList.autofocus(true)); - } else { - editorPane.classed("hide", false); - wrap2.transition().styleTween("right", function() { - return value_default("-100%", "0%"); - }).on("end", function() { - presetPane.classed("hide", true); - }); - if (preset) { - entityEditor.presets([preset]); - } - editorPane.call(entityEditor); - } + var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() { + context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))(); + }); + mode.wayID = wayID; + mode.enter = function() { + context.install(behavior); }; - inspector.state = function(val) { - if (!arguments.length) - return _state; - _state = val; - entityEditor.state(_state); - context.container().selectAll(".field-help-body").remove(); - return inspector; + mode.exit = function() { + context.uninstall(behavior); }; - inspector.entityIDs = function(val) { - if (!arguments.length) - return _entityIDs; - _entityIDs = val; - return inspector; + mode.selectedIDs = function() { + return [wayID]; }; - inspector.newFeature = function(val) { - if (!arguments.length) - return _newFeature; - _newFeature = val; - return inspector; + mode.activeID = function() { + return behavior && behavior.activeID() || []; }; - return inspector; + return mode; } - // modules/ui/keepRight_details.js - function uiKeepRightDetails(context) { - let _qaItem; - function issueDetail(d2) { - const { itemType, parentIssueType } = d2; - const unknown = { html: _t.html("inspector.unknown") }; - let replacements = d2.replacements || {}; - replacements.default = unknown; - if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) { - return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements); - } else { - return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements); - } + // modules/modes/add_area.js + function modeAddArea(context, mode) { + mode.id = "add-area"; + var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); + function defaultTags(loc) { + var defaultTags2 = { area: "yes" }; + if (mode.preset) + defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc); + return defaultTags2; } - function keepRightDetails(selection2) { - const details = selection2.selectAll(".error-details").data( - _qaItem ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + function actionClose(wayId) { + return function(graph) { + return graph.replace(graph.entity(wayId).close()); + }; + } + function start2(loc) { + var startGraph = context.graph(); + var node = osmNode({ loc }); + var way = osmWay({ tags: defaultTags(loc) }); + context.perform( + actionAddEntity(node), + actionAddEntity(way), + actionAddVertex(way.id, node.id), + actionClose(way.id) ); - details.exit().remove(); - const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container"); - const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection"); - descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description")); - descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail); - let relatedEntities = []; - descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() { - const link2 = select_default2(this); - const isObjectLink = link2.classed("error_object_link"); - const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent; - const entity = context.hasEntity(entityID); - relatedEntities.push(entityID); - link2.on("mouseenter", () => { - utilHighlightEntities([entityID], true, context); - }).on("mouseleave", () => { - utilHighlightEntities([entityID], false, context); - }).on("click", (d3_event) => { - d3_event.preventDefault(); - utilHighlightEntities([entityID], false, context); - const osmlayer = context.layers().layer("osm"); - if (!osmlayer.enabled()) { - osmlayer.enabled(true); - } - context.map().centerZoomEase(_qaItem.loc, 20); - if (entity) { - context.enter(modeSelect(context, [entityID])); - } else { - context.loadEntity(entityID, (err, result) => { - if (err) - return; - const entity2 = result.data.find((e3) => e3.id === entityID); - if (entity2) - context.enter(modeSelect(context, [entityID])); - }); - } - }); - if (entity) { - let name = utilDisplayName(entity); - if (!name && !isObjectLink) { - const preset = _mainPresetIndex.match(entity, context.graph()); - name = preset && !preset.isFallback() && preset.name(); - } - if (name) { - this.innerText = name; - } - } - }); - context.features().forceVisible(relatedEntities); - context.map().pan([0, 0]); + context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); + } + function startFromWay(loc, edge) { + var startGraph = context.graph(); + var node = osmNode({ loc }); + var way = osmWay({ tags: defaultTags(loc) }); + context.perform( + actionAddEntity(node), + actionAddEntity(way), + actionAddVertex(way.id, node.id), + actionClose(way.id), + actionAddMidpoint({ loc, edge }, node) + ); + context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); + } + function startFromNode(node) { + var startGraph = context.graph(); + var way = osmWay({ tags: defaultTags(node.loc) }); + context.perform( + actionAddEntity(way), + actionAddVertex(way.id, node.id), + actionClose(way.id) + ); + context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); } - keepRightDetails.issue = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return keepRightDetails; + mode.enter = function() { + context.install(behavior); }; - return keepRightDetails; + mode.exit = function() { + context.uninstall(behavior); + }; + return mode; } - // modules/ui/keepRight_header.js - function uiKeepRightHeader() { - let _qaItem; - function issueTitle(d2) { - const { itemType, parentIssueType } = d2; - const unknown = _t.html("inspector.unknown"); - let replacements = d2.replacements || {}; - replacements.default = { html: unknown }; - if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) { - return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements); - } else { - return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements); - } + // modules/modes/add_line.js + function modeAddLine(context, mode) { + mode.id = "add-line"; + var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); + function defaultTags(loc) { + var defaultTags2 = {}; + if (mode.preset) + defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc); + return defaultTags2; } - function keepRightHeader(selection2) { - const header = selection2.selectAll(".qa-header").data( - _qaItem ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + function start2(loc) { + var startGraph = context.graph(); + var node = osmNode({ loc }); + var way = osmWay({ tags: defaultTags(loc) }); + context.perform( + actionAddEntity(node), + actionAddEntity(way), + actionAddVertex(way.id, node.id) ); - header.exit().remove(); - const headerEnter = header.enter().append("div").attr("class", "qa-header"); - const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0); - 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")); - headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle); + context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); } - keepRightHeader.issue = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return keepRightHeader; - }; - return keepRightHeader; - } - - // modules/ui/view_on_keepRight.js - function uiViewOnKeepRight() { - let _qaItem; - function viewOnKeepRight(selection2) { - let url; - if (services.keepRight && _qaItem instanceof QAItem) { - url = services.keepRight.issueURL(_qaItem); - } - const link2 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []); - link2.exit().remove(); - const linkEnter = link2.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")); - linkEnter.append("span").call(_t.append("inspector.view_on_keepRight")); + function startFromWay(loc, edge) { + var startGraph = context.graph(); + var node = osmNode({ loc }); + var way = osmWay({ tags: defaultTags(loc) }); + context.perform( + actionAddEntity(node), + actionAddEntity(way), + actionAddVertex(way.id, node.id), + actionAddMidpoint({ loc, edge }, node) + ); + context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); } - viewOnKeepRight.what = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return viewOnKeepRight; + function startFromNode(node) { + var startGraph = context.graph(); + var way = osmWay({ tags: defaultTags(node.loc) }); + context.perform( + actionAddEntity(way), + actionAddVertex(way.id, node.id) + ); + context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); + } + mode.enter = function() { + context.install(behavior); }; - return viewOnKeepRight; + mode.exit = function() { + context.uninstall(behavior); + }; + return mode; } - // modules/ui/keepRight_editor.js - function uiKeepRightEditor(context) { - const dispatch14 = dispatch_default("change"); - const qaDetails = uiKeepRightDetails(context); - const qaHeader = uiKeepRightHeader(context); - let _qaItem; - function keepRightEditor(selection2) { - const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL"); - headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close")); - headerEnter.append("h2").call(_t.append("QA.keepRight.title")); - let body = selection2.selectAll(".body").data([0]); - body = body.enter().append("div").attr("class", "body").merge(body); - const editor = body.selectAll(".qa-editor").data([0]); - editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection); - const footer = selection2.selectAll(".footer").data([0]); - footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem)); + // modules/modes/add_point.js + function modeAddPoint(context, mode) { + mode.id = "add-point"; + var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel); + function defaultTags(loc) { + var defaultTags2 = {}; + if (mode.preset) + defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc); + return defaultTags2; } - function keepRightSaveSection(selection2) { - const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); - const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment); - let saveSection = selection2.selectAll(".qa-save").data( - isShown ? [_qaItem] : [], - (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + function add(loc) { + var node = osmNode({ loc, tags: defaultTags(loc) }); + context.perform( + actionAddEntity(node), + _t("operations.add.annotation.point") ); - saveSection.exit().remove(); - const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf"); - saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment")); - 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); - saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); - function changeInput() { - const input = select_default2(this); - let val = input.property("value").trim(); - if (val === _qaItem.comment) { - val = void 0; - } - _qaItem = _qaItem.update({ newComment: val }); - const qaService = services.keepRight; - if (qaService) { - qaService.replaceItem(_qaItem); - } - saveSection.call(qaSaveButtons); - } + enterSelectMode(node); } - function qaSaveButtons(selection2) { - const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); - let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id); - buttonSection.exit().remove(); - const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons"); - buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment")); - buttonEnter.append("button").attr("class", "button close-button action"); - buttonEnter.append("button").attr("class", "button ignore-button action"); - buttonSection = buttonSection.merge(buttonEnter); - buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) { - this.blur(); - const qaService = services.keepRight; - if (qaService) { - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } - }); - buttonSection.select(".close-button").html((d2) => { - const andComment = d2.newComment ? "_comment" : ""; - return _t.html("QA.keepRight.close".concat(andComment)); - }).on("click.close", function(d3_event, d2) { - this.blur(); - const qaService = services.keepRight; - if (qaService) { - d2.newStatus = "ignore_t"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } - }); - buttonSection.select(".ignore-button").html((d2) => { - const andComment = d2.newComment ? "_comment" : ""; - return _t.html("QA.keepRight.ignore".concat(andComment)); - }).on("click.ignore", function(d3_event, d2) { - this.blur(); - const qaService = services.keepRight; - if (qaService) { - d2.newStatus = "ignore"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); - } - }); + function addWay(loc, edge) { + var node = osmNode({ tags: defaultTags(loc) }); + context.perform( + actionAddMidpoint({ loc, edge }, node), + _t("operations.add.annotation.vertex") + ); + enterSelectMode(node); } - keepRightEditor.error = function(val) { - if (!arguments.length) - return _qaItem; - _qaItem = val; - return keepRightEditor; - }; - return utilRebind(keepRightEditor, dispatch14, "on"); - } - - // modules/ui/lasso.js - function uiLasso(context) { - var group, polygon2; - lasso.coordinates = []; - function lasso(selection2) { - context.container().classed("lasso", true); - group = selection2.append("g").attr("class", "lasso hide"); - polygon2 = group.append("path").attr("class", "lasso-path"); - group.call(uiToggle(true)); + function enterSelectMode(node) { + context.enter( + modeSelect(context, [node.id]).newFeature(true) + ); } - function draw() { - if (polygon2) { - polygon2.data([lasso.coordinates]).attr("d", function(d2) { - return "M" + d2.join(" L") + " Z"; - }); + function addNode(node) { + const _defaultTags = defaultTags(node.loc); + if (Object.keys(_defaultTags).length === 0) { + enterSelectMode(node); + return; + } + var tags = Object.assign({}, node.tags); + for (var key in _defaultTags) { + tags[key] = _defaultTags[key]; } + context.perform( + actionChangeTags(node.id, tags), + _t("operations.add.annotation.point") + ); + enterSelectMode(node); } - lasso.extent = function() { - return lasso.coordinates.reduce(function(extent, point2) { - return extent.extend(geoExtent(point2)); - }, geoExtent()); - }; - lasso.p = function(_2) { - if (!arguments.length) - return lasso; - lasso.coordinates.push(_2); - draw(); - return lasso; + function cancel() { + context.enter(modeBrowse(context)); + } + mode.enter = function() { + context.install(behavior); }; - lasso.close = function() { - if (group) { - group.call(uiToggle(false, function() { - select_default2(this).remove(); - })); - } - context.container().classed("lasso", false); + mode.exit = function() { + context.uninstall(behavior); }; - return lasso; + return mode; } // modules/ui/note_comments.js @@ -69539,9 +71021,9 @@ if (services.osm && _note instanceof osmNote && !_note.isNew()) { url = services.osm.noteReportURL(_note); } - var link2 = selection2.selectAll(".note-report").data(url ? [url] : []); - link2.exit().remove(); - var linkEnter = link2.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) { + var link3 = selection2.selectAll(".note-report").data(url ? [url] : []); + link3.exit().remove(); + var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) { return d2; }).call(svgIcon("#iD-icon-out-link", "inline")); linkEnter.append("span").call(_t.append("note.report")); @@ -69555,6 +71037,33 @@ return noteReport; } + // modules/ui/view_on_osm.js + function uiViewOnOSM(context) { + var _what; + function viewOnOSM(selection2) { + var url; + if (_what instanceof osmEntity) { + url = context.connection().entityURL(_what); + } else if (_what instanceof osmNote) { + url = context.connection().noteURL(_what); + } + var data = !_what || _what.isNew() ? [] : [_what]; + var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) { + return d2.id; + }); + link3.exit().remove(); + var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline")); + linkEnter.append("span").call(_t.append("inspector.view_on_osm")); + } + viewOnOSM.what = function(_2) { + if (!arguments.length) + return _what; + _what = _2; + return viewOnOSM; + }; + return viewOnOSM; + } + // modules/ui/note_editor.js function uiNoteEditor(context) { var dispatch14 = dispatch_default("change"); @@ -69589,8 +71098,12 @@ }); noteSave.exit().remove(); var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf"); - noteSaveEnter.append("h4").attr("class", ".note-save-header").html(function() { - return _note.isNew() ? _t.html("note.newDescription") : _t.html("note.newComment"); + noteSaveEnter.append("h4").attr("class", ".note-save-header").text("").each(function() { + if (_note.isNew()) { + _t.append("note.newDescription")(select_default2(this)); + } else { + _t.append("note.newComment")(select_default2(this)); + } }); var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) { return d2.newComment; @@ -69684,11 +71197,12 @@ buttonSection = buttonSection.merge(buttonEnter); buttonSection.select(".cancel-button").on("click.cancel", clickCancel); buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave); - buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).html(function(d2) { + buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).text("").each(function(d2) { var action = d2.status === "open" ? "close" : "open"; var andComment = d2.newComment ? "_comment" : ""; - return _t.html("note." + action + andComment); - }).on("click.status", clickStatus); + _t.append("note." + action + andComment)(select_default2(this)); + }); + buttonSection.select(".status-button").on("click.status", clickStatus); buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment); function isSaveDisabled(d2) { return hasAuth && d2.status === "open" && d2.newComment ? null : true; @@ -69746,172 +71260,132 @@ return utilRebind(noteEditor, dispatch14, "on"); } - // modules/ui/source_switch.js - function uiSourceSwitch(context) { - var keys2; - function click(d3_event) { - d3_event.preventDefault(); - var osm = context.connection(); - if (!osm) - return; - if (context.inIntro()) + // modules/modes/select_note.js + function modeSelectNote(context, selectedNoteID) { + var mode = { + id: "select-note", + button: "browse" + }; + var _keybinding = utilKeybinding("select-note"); + var _noteEditor = uiNoteEditor(context).on("change", function() { + context.map().pan([0, 0]); + var note = checkSelectedID(); + if (!note) return; - if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes"))) + context.ui().sidebar.show(_noteEditor.note(note)); + }); + var _behaviors = [ + behaviorBreathe(context), + behaviorHover(context), + behaviorSelect(context), + behaviorLasso(context), + modeDragNode(context).behavior, + modeDragNote(context).behavior + ]; + var _newFeature = false; + function checkSelectedID() { + if (!services.osm) return; - var isLive = select_default2(this).classed("live"); - isLive = !isLive; - context.enter(modeBrowse(context)); - context.history().clearSaved(); - context.flush(); - select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive); - osm.switch(isLive ? keys2[0] : keys2[1]); - } - var sourceSwitch = function(selection2) { - selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click); - }; - sourceSwitch.keys = function(_2) { - if (!arguments.length) - return keys2; - keys2 = _2; - return sourceSwitch; - }; - return sourceSwitch; - } - - // modules/ui/spinner.js - function uiSpinner(context) { - var osm = context.connection(); - return function(selection2) { - var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0); - if (osm) { - osm.on("loading.spinner", function() { - img.transition().style("opacity", 1); - }).on("loaded.spinner", function() { - img.transition().style("opacity", 0); - }); + var note = services.osm.getNote(selectedNoteID); + if (!note) { + context.enter(modeBrowse(context)); } - }; - } - - // modules/ui/sections/privacy.js - function uiSectionPrivacy(context) { - let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent); - function renderDisclosureContent(selection2) { - selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list"); - 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( - uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom") - ); - thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => { - d3_event.preventDefault(); - corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true"); - }); - thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description")); - selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true"); - 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")); + return note; } - corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender); - return section; - } - - // modules/ui/splash.js - function uiSplash(context) { - return (selection2) => { - if (context.history().hasRestorableChanges()) + function selectNote(d3_event, drawn) { + if (!checkSelectedID()) return; - let updateMessage = ""; - const sawPrivacyVersion = corePreferences("sawPrivacyVersion"); - let showSplash = !corePreferences("sawSplash"); - if (sawPrivacyVersion !== context.privacyVersion) { - updateMessage = _t("splash.privacy_update"); - showSplash = true; + var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID); + if (selection2.empty()) { + var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent; + if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) { + context.enter(modeBrowse(context)); + } + } else { + selection2.classed("selected", true); + context.selectedNoteID(selectedNoteID); } - if (!showSplash) + } + function esc() { + if (context.container().select(".combobox").size()) return; - corePreferences("sawSplash", true); - corePreferences("sawPrivacyVersion", context.privacyVersion); - _mainFileFetcher.get("intro_graph"); - let modalSelection = uiModal(selection2); - modalSelection.select(".modal").attr("class", "modal-splash modal"); - let introModal = modalSelection.select(".content").append("div").attr("class", "fillL"); - introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome")); - let modalSection = introModal.append("div").attr("class", "modal-section"); - modalSection.append("p").html(_t.html("splash.text", { - version: context.version, - website: { html: '' + _t.html("splash.changelog") + "" }, - github: { html: 'github.com' } - })); - modalSection.append("p").html(_t.html("splash.privacy", { - updateMessage, - privacyLink: { html: '' + _t("splash.privacy_policy") + "" } - })); - uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection); - let buttonWrap = introModal.append("div").attr("class", "modal-actions"); - let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => { - context.container().call(uiIntro(context)); - modalSelection.close(); - }); - walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough"); - walkthrough.append("div").call(_t.append("splash.walkthrough")); - let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close); - startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features"); - startEditing.append("div").call(_t.append("splash.start")); - modalSelection.select("button.close").attr("class", "hide"); - }; - } - - // modules/ui/status.js - function uiStatus(context) { - var osm = context.connection(); - return function(selection2) { - if (!osm) + context.enter(modeBrowse(context)); + } + mode.zoomToSelected = function() { + if (!services.osm) return; - function update(err, apiStatus) { - selection2.html(""); - if (err) { - if (apiStatus === "connectionSwitched") { - return; - } else if (apiStatus === "rateLimited") { - 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) { - d3_event.preventDefault(); - osm.authenticate(); - }); - } else { - var throttledRetry = throttle_default(function() { - context.loadTiles(context.projection); - osm.reloadApiStatus(); - }, 2e3); - 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) { - d3_event.preventDefault(); - throttledRetry(); - }); - } - } else if (apiStatus === "readonly") { - selection2.call(_t.append("osm_api_status.message.readonly")); - } else if (apiStatus === "offline") { - selection2.call(_t.append("osm_api_status.message.offline")); - } - selection2.attr("class", "api-status " + (err ? "error" : apiStatus)); + var note = services.osm.getNote(selectedNoteID); + if (note) { + context.map().centerZoomEase(note.loc, 20); } - osm.on("apiStatusChange.uiStatus", update); - context.history().on("storage_error", () => { - selection2.selectAll("span.local-storage-full").remove(); - selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full")); - selection2.classed("error", true); - }); - window.setInterval(function() { - osm.reloadApiStatus(); - }, 9e4); - osm.reloadApiStatus(); }; + mode.newFeature = function(val) { + if (!arguments.length) + return _newFeature; + _newFeature = val; + return mode; + }; + mode.enter = function() { + var note = checkSelectedID(); + if (!note) + return; + _behaviors.forEach(context.install); + _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true); + select_default2(document).call(_keybinding); + selectNote(); + var sidebar = context.ui().sidebar; + sidebar.show(_noteEditor.note(note).newNote(_newFeature)); + sidebar.expand(sidebar.intersects(note.extent())); + context.map().on("drawn.select", selectNote); + }; + mode.exit = function() { + _behaviors.forEach(context.uninstall); + select_default2(document).call(_keybinding.unbind); + context.surface().selectAll(".layer-notes .selected").classed("selected hover", false); + context.map().on("drawn.select", null); + context.ui().sidebar.hide(); + context.selectedNoteID(null); + }; + return mode; + } + + // modules/modes/add_note.js + function modeAddNote(context) { + var mode = { + id: "add-note", + button: "note", + description: _t.append("modes.add_note.description"), + key: _t("modes.add_note.key") + }; + var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel); + function add(loc) { + var osm = services.osm; + if (!osm) + return; + var note = osmNote({ loc, status: "open", comments: [] }); + osm.replaceNote(note); + context.map().pan([0, 0]); + context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true)); + } + function cancel() { + context.enter(modeBrowse(context)); + } + mode.enter = function() { + context.install(behavior); + }; + mode.exit = function() { + context.uninstall(behavior); + }; + return mode; } // node_modules/osm-community-index/lib/simplify.js var import_diacritics2 = __toESM(require_diacritics(), 1); - function simplify(str2) { - if (typeof str2 !== "string") + function simplify(str) { + if (typeof str !== "string") return ""; return import_diacritics2.default.remove( - str2.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() + 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() ); } @@ -69985,11 +71459,11 @@ } return result; } - function linkify(url, text2) { + function linkify(url, text) { if (!url) return void 0; - text2 = text2 || url; - return '').concat(text2, ""); + text = text || url; + return '').concat(text, ""); } } @@ -70064,6 +71538,18 @@ summaryDetail.append("div").html(_t.html("success.changeset_id", { changeset_id: { html: '').concat(_changeset2.id, "") } })); + if (showDonationMessage !== false) { + const donationUrl = "https://supporting.openstreetmap.org/"; + let supporting = body.append("div").attr("class", "save-supporting"); + supporting.append("h3").call(_t.append("success.supporting.title")); + supporting.append("p").call(_t.append("success.supporting.details")); + table = supporting.append("table").attr("class", "supporting-table"); + row = table.append("tr").attr("class", "supporting-row"); + 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"); + let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail"); + supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title")); + supportingDetail.append("div").call(_t.append("success.supporting.donation.details")); + } ensureOSMCommunityIndex().then((oci) => { const loc = context.map().center(); const validHere = _sharedLocationManager.locationSetsAt(loc); @@ -70181,572 +71667,600 @@ return utilRebind(success, dispatch14, "on"); } - // modules/ui/version.js - var sawVersion = null; - var isNewVersion = false; - var isNewUser = false; - function uiVersion(context) { - var currVersion = context.version; - var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/); - if (sawVersion === null && matchedVersion !== null) { - if (corePreferences("sawVersion")) { - isNewUser = false; - isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1; - } else { - isNewUser = true; - isNewVersion = true; - } - corePreferences("sawVersion", currVersion); - sawVersion = currVersion; - } - return function(selection2) { - selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion); - if (isNewVersion && !isNewUser) { - 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( - uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap")) - ); - } - }; - } - - // modules/ui/zoom.js - function uiZoom(context) { - var zooms = [{ - id: "zoom-in", - icon: "iD-icon-plus", - title: _t.append("zoom.in"), - action: zoomIn, - disabled: function() { - return !context.map().canZoomIn(); - }, - disabledTitle: _t.append("zoom.disabled.in"), - key: "+" - }, { - id: "zoom-out", - icon: "iD-icon-minus", - title: _t.append("zoom.out"), - action: zoomOut, - disabled: function() { - return !context.map().canZoomOut(); - }, - disabledTitle: _t.append("zoom.disabled.out"), - key: "-" - }]; - function zoomIn(d3_event) { - if (d3_event.shiftKey) - return; - d3_event.preventDefault(); - context.map().zoomIn(); + // modules/modes/save.js + function modeSave(context) { + var mode = { id: "save" }; + var keybinding = utilKeybinding("modeSave"); + var commit = uiCommit(context).on("cancel", cancel); + var _conflictsUi; + var _location; + var _success; + var uploader = context.uploader().on("saveStarted.modeSave", function() { + keybindingOff(); + }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() { + cancel(); + }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess); + function cancel() { + context.enter(modeBrowse(context)); } - function zoomOut(d3_event) { - if (d3_event.shiftKey) - return; - d3_event.preventDefault(); - context.map().zoomOut(); + function showProgress(num, total) { + var modal = context.container().select(".loading-modal .modal-section"); + var progress = modal.selectAll(".progress").data([0]); + progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total })); } - function zoomInFurther(d3_event) { - if (d3_event.shiftKey) - return; - d3_event.preventDefault(); - context.map().zoomInFurther(); + function showConflicts(changeset, conflicts, origChanges) { + var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component"); + context.container().selectAll(".main-content").classed("active", true).classed("inactive", false); + _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() { + context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); + selection2.remove(); + keybindingOn(); + uploader.cancelConflictResolution(); + }).on("save", function() { + context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); + selection2.remove(); + uploader.processResolvedConflicts(changeset); + }); + selection2.call(_conflictsUi); } - function zoomOutFurther(d3_event) { - if (d3_event.shiftKey) - return; - d3_event.preventDefault(); - context.map().zoomOutFurther(); + function showErrors(errors) { + keybindingOn(); + var selection2 = uiConfirm(context.container()); + selection2.select(".modal-section.header").append("h3").text(_t("save.error")); + addErrors(selection2, errors); + selection2.okButton(); } - return function(selection2) { - var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) { - if (d2.disabled()) { - return d2.disabledTitle; - } - return d2.title; - }).keys(function(d2) { - return [d2.key]; + function addErrors(selection2, data) { + var message = selection2.select(".modal-section.message-text"); + var items = message.selectAll(".error-container").data(data); + var enter = items.enter().append("div").attr("class", "error-container"); + enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) { + return d2.msg || _t("save.unknown_error_details"); + }).on("click", function(d3_event) { + d3_event.preventDefault(); + var error = select_default2(this); + var detail = select_default2(this.nextElementSibling); + var exp2 = error.classed("expanded"); + detail.style("display", exp2 ? "none" : "block"); + error.classed("expanded", !exp2); }); - var lastPointerUpType; - var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) { - return d2.id; - }).on("pointerup.editor", function(d3_event) { - lastPointerUpType = d3_event.pointerType; - }).on("click.editor", function(d3_event, d2) { - if (!d2.disabled()) { - d2.action(d3_event); - } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { - context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)(); - } - lastPointerUpType = null; - }).call(tooltipBehavior); - buttons.each(function(d2) { - select_default2(this).call(svgIcon("#" + d2.icon, "light")); + var details = enter.append("div").attr("class", "error-detail-container").style("display", "none"); + details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) { + return d2.details || []; + }).enter().append("li").attr("class", "error-detail-item").text(function(d2) { + return d2; }); - utilKeybinding.plusKeys.forEach(function(key) { - context.keybinding().on([key], zoomIn); - context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther); + items.exit().remove(); + } + function showSuccess(changeset) { + commit.reset(); + var ui = _success.changeset(changeset).location(_location).on("cancel", function() { + context.ui().sidebar.hide(); }); - utilKeybinding.minusKeys.forEach(function(key) { - context.keybinding().on([key], zoomOut); - context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther); + context.enter(modeBrowse(context).sidebar(ui)); + } + function keybindingOn() { + select_default2(document).call(keybinding.on("\u238B", cancel, true)); + } + function keybindingOff() { + select_default2(document).call(keybinding.unbind); + } + function prepareForSuccess() { + _success = uiSuccess(context); + _location = null; + if (!services.geocoder) + return; + services.geocoder.reverse(context.map().center(), function(err, result) { + if (err || !result || !result.address) + return; + var addr = result.address; + var place = addr && (addr.town || addr.city || addr.county) || ""; + var region = addr && (addr.state || addr.country) || ""; + var separator = place && region ? _t("success.thank_you_where.separator") : ""; + _location = _t( + "success.thank_you_where.format", + { place, separator, region } + ); }); - function updateButtonStates() { - buttons.classed("disabled", function(d2) { - return d2.disabled(); - }).each(function() { - var selection3 = select_default2(this); - if (!selection3.select(".tooltip.in").empty()) { - selection3.call(tooltipBehavior.updateContent); + } + mode.selectedIDs = function() { + return _conflictsUi ? _conflictsUi.shownEntityIds() : []; + }; + mode.enter = function() { + context.ui().sidebar.expand(); + function done() { + context.ui().sidebar.show(commit); + } + keybindingOn(); + context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); + var osm = context.connection(); + if (!osm) { + cancel(); + return; + } + if (osm.authenticated()) { + done(); + } else { + osm.authenticate(function(err) { + if (err) { + cancel(); + } else { + done(); } }); } - updateButtonStates(); - context.map().on("move.uiZoom", updateButtonStates); }; + mode.exit = function() { + keybindingOff(); + context.container().selectAll(".main-content").classed("active", true).classed("inactive", false); + context.ui().sidebar.hide(); + }; + return mode; } - // modules/ui/sections/raw_tag_editor.js - function uiSectionRawTagEditor(id2, context) { - var section = uiSection(id2, context).classes("raw-tag-editor").label(function() { - var count = Object.keys(_tags).filter(function(d2) { - return d2; - }).length; - return _t.append("inspector.title_count", { title: _t("inspector.tags"), count }); - }).expandedByDefault(false).disclosureContent(renderDisclosureContent); - var taginfo = services.taginfo; - var dispatch14 = dispatch_default("change"); - var availableViews = [ - { id: "list", icon: "#fas-th-list" }, - { id: "text", icon: "#fas-i-cursor" } - ]; - let _discardTags = {}; - _mainFileFetcher.get("discarded").then((d2) => { - _discardTags = d2; - }).catch(() => { - }); - var _tagView = corePreferences("raw-tag-editor-view") || "list"; - var _readOnlyTags = []; - var _orderedKeys = []; - var _showBlank = false; - var _pendingChange = null; - var _state; - var _presets; - var _tags; - var _entityIDs; - var _didInteract = false; - function interacted() { - _didInteract = true; - } - function renderDisclosureContent(wrap2) { - _orderedKeys = _orderedKeys.filter(function(key) { - return _tags[key] !== void 0; - }); - var all = Object.keys(_tags).sort(); - var missingKeys = utilArrayDifference(all, _orderedKeys); - for (var i3 in missingKeys) { - _orderedKeys.push(missingKeys[i3]); - } - var rowData = _orderedKeys.map(function(key, i4) { - return { index: i4, key, value: _tags[key] }; - }); - if (!rowData.length || _showBlank) { - _showBlank = false; - rowData.push({ index: rowData.length, key: "", value: "" }); - } - var options2 = wrap2.selectAll(".raw-tag-options").data([0]); - options2.exit().remove(); - var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist"); - var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) { - return d2.id; - }).enter(); - optionEnter.append("button").attr("class", function(d2) { - return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : ""); - }).attr("aria-selected", function(d2) { - return _tagView === d2.id; - }).attr("role", "tab").attr("title", function(d2) { - return _t("icons." + d2.id); - }).on("click", function(d3_event, d2) { - _tagView = d2.id; - corePreferences("raw-tag-editor-view", d2.id); - wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) { - return datum2 === d2; - }).attr("aria-selected", function(datum2) { - return datum2 === d2; + // modules/ui/improveOSM_comments.js + function uiImproveOsmComments() { + let _qaItem; + function issueComments(selection2) { + let comments = selection2.selectAll(".comments-container").data([0]); + comments = comments.enter().append("div").attr("class", "comments-container").merge(comments); + services.improveOSM.getComments(_qaItem).then((d2) => { + if (!d2.comments) + return; + const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment"); + commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon")); + const mainEnter = commentEnter.append("div").attr("class", "comment-main"); + const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata"); + metadataEnter.append("div").attr("class", "comment-author").each(function(d4) { + const osm = services.osm; + let selection3 = select_default2(this); + if (osm && d4.username) { + selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank"); + } + selection3.text((d5) => d5.username); }); - wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight); - wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list"); - }).each(function(d2) { - select_default2(this).call(svgIcon(d2.icon)); - }); - var textData = rowsToText(rowData); - var textarea = wrap2.selectAll(".tag-text").data([0]); - 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); - textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged); - var list = wrap2.selectAll(".tag-list").data([0]); - list = list.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list); - var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : "")); - 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); - addRowEnter.append("div").attr("class", "space-value"); - addRowEnter.append("div").attr("class", "space-buttons"); - var items = list.selectAll(".tag-row").data(rowData, function(d2) { - return d2.key; - }); - items.exit().each(unbind).remove(); - var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly); - var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap"); - 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); - 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); - innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")); - items = items.merge(itemsEnter).sort(function(a2, b2) { - return a2.index - b2.index; - }); - items.each(function(d2) { - var row = select_default2(this); - var key = row.select("input.key"); - var value = row.select("input.value"); - if (_entityIDs && taginfo && _state !== "hover") { - bindTypeahead(key, value); - } - var referenceOptions = { key: d2.key }; - if (typeof d2.value === "string") { - referenceOptions.value = d2.value; - } - var reference = uiTagReference(referenceOptions, context); - if (_state === "hover") { - reference.showing(false); - } - row.select(".inner-wrap").call(reference.button); - row.call(reference.body); - row.select("button.remove"); - }); - items.selectAll("input.key").attr("title", function(d2) { - return d2.key; - }).call(utilGetSetValue, function(d2) { - return d2.key; - }).attr("readonly", function(d2) { - return isReadOnly(d2) || null; - }); - items.selectAll("input.value").attr("title", function(d2) { - return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value; - }).classed("mixed", function(d2) { - return Array.isArray(d2.value); - }).attr("placeholder", function(d2) { - return typeof d2.value === "string" ? null : _t("inspector.multiple_values"); - }).call(utilGetSetValue, function(d2) { - return typeof d2.value === "string" ? d2.value : ""; - }).attr("readonly", function(d2) { - return isReadOnly(d2) || null; + metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) })); + mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text); + }).catch((err) => { + console.log(err); }); - items.selectAll("button.remove").on( - ("PointerEvent" in window ? "pointer" : "mouse") + "down", - // 'click' fires too late - #5878 - (d3_event, d2) => { - if (d3_event.button !== 0) - return; - removeTag(d3_event, d2); - } - ); } - function isReadOnly(d2) { - for (var i3 = 0; i3 < _readOnlyTags.length; i3++) { - if (d2.key.match(_readOnlyTags[i3]) !== null) { - return true; + function localeDateString2(s2) { + if (!s2) + return null; + const options2 = { day: "numeric", month: "short", year: "numeric" }; + const d2 = new Date(s2 * 1e3); + if (isNaN(d2.getTime())) + return null; + return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2); + } + issueComments.issue = function(val) { + if (!arguments.length) + return _qaItem; + _qaItem = val; + return issueComments; + }; + return issueComments; + } + + // modules/ui/improveOSM_details.js + function uiImproveOsmDetails(context) { + let _qaItem; + function issueDetail(d2) { + if (d2.desc) + return d2.desc; + const issueKey = d2.issueKey; + d2.replacements = d2.replacements || {}; + d2.replacements.default = { html: _t.html("inspector.unknown") }; + return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements); + } + function improveOsmDetails(selection2) { + const details = selection2.selectAll(".error-details").data( + _qaItem ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + details.exit().remove(); + const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container"); + const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection"); + descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description")); + descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail); + let relatedEntities = []; + descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() { + const link3 = select_default2(this); + const isObjectLink = link3.classed("error_object_link"); + const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent; + const entity = context.hasEntity(entityID); + relatedEntities.push(entityID); + link3.on("mouseenter", () => { + utilHighlightEntities([entityID], true, context); + }).on("mouseleave", () => { + utilHighlightEntities([entityID], false, context); + }).on("click", (d3_event) => { + d3_event.preventDefault(); + utilHighlightEntities([entityID], false, context); + const osmlayer = context.layers().layer("osm"); + if (!osmlayer.enabled()) { + osmlayer.enabled(true); + } + context.map().centerZoom(_qaItem.loc, 20); + if (entity) { + context.enter(modeSelect(context, [entityID])); + } else { + context.loadEntity(entityID, (err, result) => { + if (err) + return; + const entity2 = result.data.find((e3) => e3.id === entityID); + if (entity2) + context.enter(modeSelect(context, [entityID])); + }); + } + }); + if (entity) { + let name = utilDisplayName(entity); + if (!name && !isObjectLink) { + const preset = _mainPresetIndex.match(entity, context.graph()); + name = preset && !preset.isFallback() && preset.name(); + } + if (name) { + this.innerText = name; + } } - } - return false; + }); + context.features().forceVisible(relatedEntities); + context.map().pan([0, 0]); } - function setTextareaHeight() { - if (_tagView !== "text") - return; - var selection2 = select_default2(this); - var matches = selection2.node().value.match(/\n/g); - var lineCount = 2 + Number(matches && matches.length); - var lineHeight = 20; - selection2.style("height", lineCount * lineHeight + "px"); + improveOsmDetails.issue = function(val) { + if (!arguments.length) + return _qaItem; + _qaItem = val; + return improveOsmDetails; + }; + return improveOsmDetails; + } + + // modules/ui/improveOSM_header.js + function uiImproveOsmHeader() { + let _qaItem; + function issueTitle(d2) { + const issueKey = d2.issueKey; + d2.replacements = d2.replacements || {}; + d2.replacements.default = { html: _t.html("inspector.unknown") }; + return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements); } - function stringify3(s2) { - return JSON.stringify(s2).slice(1, -1); + function improveOsmHeader(selection2) { + const header = selection2.selectAll(".qa-header").data( + _qaItem ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + header.exit().remove(); + const headerEnter = header.enter().append("div").attr("class", "qa-header"); + 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)); + svgEnter.append("polygon").attr("fill", "currentColor").attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); + 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 : ""); + headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle); } - function unstringify(s2) { - var leading = ""; - var trailing = ""; - if (s2.length < 1 || s2.charAt(0) !== '"') { - leading = '"'; - } - if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") { - trailing = '"'; - } - return JSON.parse(leading + s2 + trailing); + improveOsmHeader.issue = function(val) { + if (!arguments.length) + return _qaItem; + _qaItem = val; + return improveOsmHeader; + }; + return improveOsmHeader; + } + + // modules/ui/improveOSM_editor.js + function uiImproveOsmEditor(context) { + const dispatch14 = dispatch_default("change"); + const qaDetails = uiImproveOsmDetails(context); + const qaComments = uiImproveOsmComments(context); + const qaHeader = uiImproveOsmHeader(context); + let _qaItem; + function improveOsmEditor(selection2) { + const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL"); + headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close")); + headerEnter.append("h2").call(_t.append("QA.improveOSM.title")); + let body = selection2.selectAll(".body").data([0]); + body = body.enter().append("div").attr("class", "body").merge(body); + const editor = body.selectAll(".qa-editor").data([0]); + editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(qaComments.issue(_qaItem)).call(improveOsmSaveSection); } - function rowsToText(rows) { - var str2 = rows.filter(function(row) { - return row.key && row.key.trim() !== ""; - }).map(function(row) { - var rawVal = row.value; - if (typeof rawVal !== "string") - rawVal = "*"; - var val = rawVal ? stringify3(rawVal) : ""; - return stringify3(row.key) + "=" + val; - }).join("\n"); - if (_state !== "hover" && str2.length) { - return str2 + "\n"; + function improveOsmSaveSection(selection2) { + const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); + const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment); + let saveSection = selection2.selectAll(".qa-save").data( + isShown ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + saveSection.exit().remove(); + const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf"); + saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment")); + saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput); + saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); + function changeInput() { + const input = select_default2(this); + let val = input.property("value").trim(); + if (val === "") { + val = void 0; + } + _qaItem = _qaItem.update({ newComment: val }); + const qaService = services.improveOSM; + if (qaService) { + qaService.replaceItem(_qaItem); + } + saveSection.call(qaSaveButtons); } - return str2; } - function textChanged() { - var newText = this.value.trim(); - var newTags = {}; - newText.split("\n").forEach(function(row) { - var m2 = row.match(/^\s*([^=]+)=(.*)$/); - if (m2 !== null) { - var k2 = context.cleanTagKey(unstringify(m2[1].trim())); - var v2 = context.cleanTagValue(unstringify(m2[2].trim())); - newTags[k2] = v2; + function qaSaveButtons(selection2) { + const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); + let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id); + buttonSection.exit().remove(); + const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons"); + buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment")); + buttonEnter.append("button").attr("class", "button close-button action"); + buttonEnter.append("button").attr("class", "button ignore-button action"); + buttonSection = buttonSection.merge(buttonEnter); + buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) { + this.blur(); + const qaService = services.improveOSM; + if (qaService) { + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); } }); - var tagDiff = utilTagDiff(_tags, newTags); - if (!tagDiff.length) - return; - _pendingChange = _pendingChange || {}; - tagDiff.forEach(function(change) { - if (isReadOnly({ key: change.key })) - return; - if (change.newVal === "*" && typeof change.oldVal !== "string") - return; - if (change.type === "-") { - _pendingChange[change.key] = void 0; - } else if (change.type === "+") { - _pendingChange[change.key] = change.newVal || ""; + buttonSection.select(".close-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html("QA.keepRight.close".concat(andComment)); + }).on("click.close", function(d3_event, d2) { + this.blur(); + const qaService = services.improveOSM; + if (qaService) { + d2.newStatus = "SOLVED"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } + }); + buttonSection.select(".ignore-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html("QA.keepRight.ignore".concat(andComment)); + }).on("click.ignore", function(d3_event, d2) { + this.blur(); + const qaService = services.improveOSM; + if (qaService) { + d2.newStatus = "INVALID"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); } }); - if (Object.keys(_pendingChange).length === 0) { - _pendingChange = null; - return; - } - scheduleChange(); } - function pushMore(d3_event) { - if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) { - addTag(); + improveOsmEditor.error = function(val) { + if (!arguments.length) + return _qaItem; + _qaItem = val; + return improveOsmEditor; + }; + return utilRebind(improveOsmEditor, dispatch14, "on"); + } + + // modules/ui/keepRight_details.js + function uiKeepRightDetails(context) { + let _qaItem; + function issueDetail(d2) { + const { itemType, parentIssueType } = d2; + const unknown = { html: _t.html("inspector.unknown") }; + let replacements = d2.replacements || {}; + replacements.default = unknown; + if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) { + return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements); + } else { + return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements); } } - function bindTypeahead(key, value) { - if (isReadOnly(key.datum())) - return; - if (Array.isArray(value.datum().value)) { - value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) { - var keyString = utilGetSetValue(key); - if (!_tags[keyString]) - return; - var data = _tags[keyString].filter(Boolean).map(function(tagValue) { - return { - value: tagValue, - title: tagValue - }; - }); - callback(data); - })); - return; - } - var geometry = context.graph().geometry(_entityIDs[0]); - key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) { - taginfo.keys({ - debounce: true, - geometry, - query: value2 - }, function(err, data) { - if (!err) { - const filtered = data.filter((d2) => _tags[d2.value] === void 0).filter((d2) => !(d2.value in _discardTags)).filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase())); - callback(sort(value2, filtered)); + function keepRightDetails(selection2) { + const details = selection2.selectAll(".error-details").data( + _qaItem ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + details.exit().remove(); + const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container"); + const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection"); + descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description")); + descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail); + let relatedEntities = []; + descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() { + const link3 = select_default2(this); + const isObjectLink = link3.classed("error_object_link"); + const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent; + const entity = context.hasEntity(entityID); + relatedEntities.push(entityID); + link3.on("mouseenter", () => { + utilHighlightEntities([entityID], true, context); + }).on("mouseleave", () => { + utilHighlightEntities([entityID], false, context); + }).on("click", (d3_event) => { + d3_event.preventDefault(); + utilHighlightEntities([entityID], false, context); + const osmlayer = context.layers().layer("osm"); + if (!osmlayer.enabled()) { + osmlayer.enabled(true); } - }); - })); - value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) { - taginfo.values({ - debounce: true, - key: utilGetSetValue(key), - geometry, - query: value2 - }, function(err, data) { - if (!err) { - const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase())); - callback(sort(value2, filtered)); + context.map().centerZoomEase(_qaItem.loc, 20); + if (entity) { + context.enter(modeSelect(context, [entityID])); + } else { + context.loadEntity(entityID, (err, result) => { + if (err) + return; + const entity2 = result.data.find((e3) => e3.id === entityID); + if (entity2) + context.enter(modeSelect(context, [entityID])); + }); } }); - }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key)))); - function sort(value2, data) { - var sameletter = []; - var other = []; - for (var i3 = 0; i3 < data.length; i3++) { - if (data[i3].value.substring(0, value2.length) === value2) { - sameletter.push(data[i3]); - } else { - other.push(data[i3]); + if (entity) { + let name = utilDisplayName(entity); + if (!name && !isObjectLink) { + const preset = _mainPresetIndex.match(entity, context.graph()); + name = preset && !preset.isFallback() && preset.name(); } - } - return sameletter.concat(other); - } - } - function unbind() { - var row = select_default2(this); - row.selectAll("input.key").call(uiCombobox.off, context); - row.selectAll("input.value").call(uiCombobox.off, context); - } - function keyChange(d3_event, d2) { - if (select_default2(this).attr("readonly")) - return; - var kOld = d2.key; - if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0) - return; - var kNew = context.cleanTagKey(this.value.trim()); - if (isReadOnly({ key: kNew })) { - this.value = kOld; - return; - } - if (kNew && kNew !== kOld && _tags[kNew] !== void 0) { - this.value = kOld; - section.selection().selectAll(".tag-list input.value").each(function(d4) { - if (d4.key === kNew) { - var input = select_default2(this).node(); - input.focus(); - input.select(); + if (name) { + this.innerText = name; } - }); - return; - } - _pendingChange = _pendingChange || {}; - if (kOld) { - if (kOld === kNew) - return; - _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld }; - _pendingChange[kOld] = void 0; - } else { - let row = this.parentNode.parentNode; - let inputVal = select_default2(row).selectAll("input.value"); - let vNew = context.cleanTagValue(utilGetSetValue(inputVal)); - _pendingChange[kNew] = vNew; - utilGetSetValue(inputVal, vNew); - } - var existingKeyIndex = _orderedKeys.indexOf(kOld); - if (existingKeyIndex !== -1) - _orderedKeys[existingKeyIndex] = kNew; - d2.key = kNew; - this.value = kNew; - scheduleChange(); - } - function valueChange(d3_event, d2) { - if (isReadOnly(d2)) - return; - if (typeof d2.value !== "string" && !this.value) - return; - if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0) - return; - _pendingChange = _pendingChange || {}; - _pendingChange[d2.key] = context.cleanTagValue(this.value); - scheduleChange(); + } + }); + context.features().forceVisible(relatedEntities); + context.map().pan([0, 0]); } - function removeTag(d3_event, d2) { - if (isReadOnly(d2)) - return; - if (d2.key === "") { - _showBlank = false; - section.reRender(); + keepRightDetails.issue = function(val) { + if (!arguments.length) + return _qaItem; + _qaItem = val; + return keepRightDetails; + }; + return keepRightDetails; + } + + // modules/ui/keepRight_header.js + function uiKeepRightHeader() { + let _qaItem; + function issueTitle(d2) { + const { itemType, parentIssueType } = d2; + const unknown = _t.html("inspector.unknown"); + let replacements = d2.replacements || {}; + replacements.default = { html: unknown }; + if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) { + return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements); } else { - _orderedKeys = _orderedKeys.filter(function(key) { - return key !== d2.key; - }); - _pendingChange = _pendingChange || {}; - _pendingChange[d2.key] = void 0; - scheduleChange(); + return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements); } } - function addTag() { - window.setTimeout(function() { - _showBlank = true; - section.reRender(); - section.selection().selectAll(".tag-list li:last-child input.key").node().focus(); - }, 20); - } - function scheduleChange() { - var entityIDs = _entityIDs; - window.setTimeout(function() { - if (!_pendingChange) - return; - dispatch14.call("change", this, entityIDs, _pendingChange); - _pendingChange = null; - }, 10); + function keepRightHeader(selection2) { + const header = selection2.selectAll(".qa-header").data( + _qaItem ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + header.exit().remove(); + const headerEnter = header.enter().append("div").attr("class", "qa-header"); + const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0); + 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")); + headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle); } - section.state = function(val) { - if (!arguments.length) - return _state; - if (_state !== val) { - _orderedKeys = []; - _state = val; - } - return section; - }; - section.presets = function(val) { - if (!arguments.length) - return _presets; - _presets = val; - if (_presets && _presets.length && _presets[0].isFallback()) { - section.disclosureExpanded(true); - } else if (!_didInteract) { - section.disclosureExpanded(null); - } - return section; - }; - section.tags = function(val) { + keepRightHeader.issue = function(val) { if (!arguments.length) - return _tags; - _tags = val; - return section; + return _qaItem; + _qaItem = val; + return keepRightHeader; }; - section.entityIDs = function(val) { - if (!arguments.length) - return _entityIDs; - if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { - _entityIDs = val; - _orderedKeys = []; + return keepRightHeader; + } + + // modules/ui/view_on_keepRight.js + function uiViewOnKeepRight() { + let _qaItem; + function viewOnKeepRight(selection2) { + let url; + if (services.keepRight && _qaItem instanceof QAItem) { + url = services.keepRight.issueURL(_qaItem); } - return section; - }; - section.readOnlyTags = function(val) { + const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []); + link3.exit().remove(); + 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")); + linkEnter.append("span").call(_t.append("inspector.view_on_keepRight")); + } + viewOnKeepRight.what = function(val) { if (!arguments.length) - return _readOnlyTags; - _readOnlyTags = val; - return section; + return _qaItem; + _qaItem = val; + return viewOnKeepRight; }; - return utilRebind(section, dispatch14, "on"); + return viewOnKeepRight; } - // modules/ui/data_editor.js - function uiDataEditor(context) { - var dataHeader = uiDataHeader(); - var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]); - var _datum; - function dataEditor(selection2) { - var header = selection2.selectAll(".header").data([0]); - var headerEnter = header.enter().append("div").attr("class", "header fillL"); - headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() { - context.enter(modeBrowse(context)); - }).call(svgIcon("#iD-icon-close")); - headerEnter.append("h2").call(_t.append("map_data.title")); - var body = selection2.selectAll(".body").data([0]); + // modules/ui/keepRight_editor.js + function uiKeepRightEditor(context) { + const dispatch14 = dispatch_default("change"); + const qaDetails = uiKeepRightDetails(context); + const qaHeader = uiKeepRightHeader(context); + let _qaItem; + function keepRightEditor(selection2) { + const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL"); + headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close")); + headerEnter.append("h2").call(_t.append("QA.keepRight.title")); + let body = selection2.selectAll(".body").data([0]); body = body.enter().append("div").attr("class", "body").merge(body); - var editor = body.selectAll(".data-editor").data([0]); - editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum)); - var rte = body.selectAll(".raw-tag-editor").data([0]); - rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call( - rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render - ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true); + const editor = body.selectAll(".qa-editor").data([0]); + editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection); + const footer = selection2.selectAll(".footer").data([0]); + footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem)); + } + function keepRightSaveSection(selection2) { + const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); + const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment); + let saveSection = selection2.selectAll(".qa-save").data( + isShown ? [_qaItem] : [], + (d2) => "".concat(d2.id, "-").concat(d2.status || 0) + ); + saveSection.exit().remove(); + const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf"); + saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment")); + 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); + saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); + function changeInput() { + const input = select_default2(this); + let val = input.property("value").trim(); + if (val === _qaItem.comment) { + val = void 0; + } + _qaItem = _qaItem.update({ newComment: val }); + const qaService = services.keepRight; + if (qaService) { + qaService.replaceItem(_qaItem); + } + saveSection.call(qaSaveButtons); + } } - dataEditor.datum = function(val) { + function qaSaveButtons(selection2) { + const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); + let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id); + buttonSection.exit().remove(); + const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons"); + buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment")); + buttonEnter.append("button").attr("class", "button close-button action"); + buttonEnter.append("button").attr("class", "button ignore-button action"); + buttonSection = buttonSection.merge(buttonEnter); + buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) { + this.blur(); + const qaService = services.keepRight; + if (qaService) { + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } + }); + buttonSection.select(".close-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html("QA.keepRight.close".concat(andComment)); + }).on("click.close", function(d3_event, d2) { + this.blur(); + const qaService = services.keepRight; + if (qaService) { + d2.newStatus = "ignore_t"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } + }); + buttonSection.select(".ignore-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html("QA.keepRight.ignore".concat(andComment)); + }).on("click.ignore", function(d3_event, d2) { + this.blur(); + const qaService = services.keepRight; + if (qaService) { + d2.newStatus = "ignore"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } + }); + } + keepRightEditor.error = function(val) { if (!arguments.length) - return _datum; - _datum = val; - return this; + return _qaItem; + _qaItem = val; + return keepRightEditor; }; - return dataEditor; + return utilRebind(keepRightEditor, dispatch14, "on"); } // modules/ui/osmose_details.js @@ -70794,10 +72308,10 @@ } elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title")); 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() { - const link2 = select_default2(this); + const link3 = select_default2(this); const entityID = this.textContent; const entity = context.hasEntity(entityID); - link2.on("mouseenter", () => { + link3.on("mouseenter", () => { utilHighlightEntities([entityID], true, context); }).on("mouseleave", () => { utilHighlightEntities([entityID], false, context); @@ -70886,9 +72400,9 @@ if (services.osmose && _qaItem instanceof QAItem) { url = services.osmose.itemURL(_qaItem); } - const link2 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []); - link2.exit().remove(); - const linkEnter = link2.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")); + const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []); + link3.exit().remove(); + 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")); linkEnter.append("span").call(_t.append("inspector.view_on_osmose")); } viewOnOsmose.what = function(val) { @@ -70963,825 +72477,1826 @@ return utilRebind(osmoseEditor, dispatch14, "on"); } - // modules/ui/sidebar.js - function uiSidebar(context) { - var inspector = uiInspector(context); - var dataEditor = uiDataEditor(context); - var noteEditor = uiNoteEditor(context); - var improveOsmEditor = uiImproveOsmEditor(context); - var keepRightEditor = uiKeepRightEditor(context); - var osmoseEditor = uiOsmoseEditor(context); - var _current; - var _wasData = false; - var _wasNote = false; - var _wasQaItem = false; - var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; - function sidebar(selection2) { - var container = context.container(); - var minWidth = 240; - var sidebarWidth; - var containerWidth; - var dragOffset; - selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%"); - var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown); - var downPointerId, lastClientX, containerLocGetter; - function pointerdown(d3_event) { - if (downPointerId) + // modules/modes/select_error.js + function modeSelectError(context, selectedErrorID, selectedErrorService) { + var mode = { + id: "select-error", + button: "browse" + }; + var keybinding = utilKeybinding("select-error"); + var errorService = services[selectedErrorService]; + var errorEditor; + switch (selectedErrorService) { + case "improveOSM": + errorEditor = uiImproveOsmEditor(context).on("change", function() { + context.map().pan([0, 0]); + var error = checkSelectedID(); + if (!error) + return; + context.ui().sidebar.show(errorEditor.error(error)); + }); + break; + case "keepRight": + errorEditor = uiKeepRightEditor(context).on("change", function() { + context.map().pan([0, 0]); + var error = checkSelectedID(); + if (!error) + return; + context.ui().sidebar.show(errorEditor.error(error)); + }); + break; + case "osmose": + errorEditor = uiOsmoseEditor(context).on("change", function() { + context.map().pan([0, 0]); + var error = checkSelectedID(); + if (!error) + return; + context.ui().sidebar.show(errorEditor.error(error)); + }); + break; + } + var behaviors = [ + behaviorBreathe(context), + behaviorHover(context), + behaviorSelect(context), + behaviorLasso(context), + modeDragNode(context).behavior, + modeDragNote(context).behavior + ]; + function checkSelectedID() { + if (!errorService) + return; + var error = errorService.getError(selectedErrorID); + if (!error) { + context.enter(modeBrowse(context)); + } + return error; + } + mode.zoomToSelected = function() { + if (!errorService) + return; + var error = errorService.getError(selectedErrorID); + if (error) { + context.map().centerZoomEase(error.loc, 20); + } + }; + mode.enter = function() { + var error = checkSelectedID(); + if (!error) + return; + behaviors.forEach(context.install); + keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true); + select_default2(document).call(keybinding); + selectError(); + var sidebar = context.ui().sidebar; + sidebar.show(errorEditor.error(error)); + context.map().on("drawn.select-error", selectError); + function selectError(d3_event, drawn) { + if (!checkSelectedID()) return; - if ("button" in d3_event && d3_event.button !== 0) + var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService); + if (selection2.empty()) { + var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent; + if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) { + context.enter(modeBrowse(context)); + } + } else { + selection2.classed("selected", true); + context.selectedErrorID(selectedErrorID); + } + } + function esc() { + if (context.container().select(".combobox").size()) return; - downPointerId = d3_event.pointerId || "mouse"; - lastClientX = d3_event.clientX; - containerLocGetter = utilFastMouse(container.node()); - dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1; - sidebarWidth = selection2.node().getBoundingClientRect().width; - containerWidth = container.node().getBoundingClientRect().width; - var widthPct = sidebarWidth / containerWidth * 100; - selection2.style("width", widthPct + "%").style("max-width", "85%"); - resizer.classed("dragging", true); - select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) { - d3_event2.preventDefault(); - }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup); + context.enter(modeBrowse(context)); } - function pointermove(d3_event) { - if (downPointerId !== (d3_event.pointerId || "mouse")) + }; + mode.exit = function() { + behaviors.forEach(context.uninstall); + select_default2(document).call(keybinding.unbind); + context.surface().selectAll(".qaItem.selected").classed("selected hover", false); + context.map().on("drawn.select-error", null); + context.ui().sidebar.hide(); + context.selectedErrorID(null); + context.features().forceVisible([]); + }; + return mode; + } + + // modules/ui/feature_list.js + function uiFeatureList(context) { + var _geocodeResults; + function featureList(selection2) { + var header = selection2.append("div").attr("class", "header fillL"); + header.append("h2").call(_t.append("inspector.feature_list")); + var searchWrap = selection2.append("div").attr("class", "search-header"); + searchWrap.call(svgIcon("#iD-icon-search", "pre-text")); + var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent); + var listWrap = selection2.append("div").attr("class", "inspector-body"); + var list2 = listWrap.append("div").attr("class", "feature-list"); + context.on("exit.feature-list", clearSearch); + context.map().on("drawn.feature-list", mapDrawn); + context.keybinding().on(uiCmd("\u2318F"), focusSearch); + function focusSearch(d3_event) { + var mode = context.mode() && context.mode().id; + if (mode !== "browse") + return; + d3_event.preventDefault(); + search.node().focus(); + } + function keydown(d3_event) { + if (d3_event.keyCode === 27) { + search.node().blur(); + } + } + function keypress(d3_event) { + var q2 = search.property("value"), items = list2.selectAll(".feature-list-item"); + if (d3_event.keyCode === 13 && // ↩ Return + q2.length && items.size()) { + click(d3_event, items.datum()); + } + } + function inputevent() { + _geocodeResults = void 0; + drawList(); + } + function clearSearch() { + search.property("value", ""); + drawList(); + } + function mapDrawn(e3) { + if (e3.full) { + drawList(); + } + } + function features() { + var result = []; + var graph = context.graph(); + var visibleCenter = context.map().extent().center(); + var q2 = search.property("value").toLowerCase(); + if (!q2) + return result; + var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2); + if (locationMatch) { + var loc = [Number(locationMatch[0]), Number(locationMatch[1])]; + result.push({ + id: -1, + geometry: "point", + type: _t("inspector.location"), + name: dmsCoordinatePair([loc[1], loc[0]]), + location: loc + }); + } + var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i); + if (idMatch) { + var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0); + var elemId = idMatch[2]; + result.push({ + id: elemType + elemId, + geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation", + type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"), + name: elemId + }); + } + var allEntities = graph.entities; + var localResults = []; + for (var id2 in allEntities) { + var entity = allEntities[id2]; + if (!entity) + continue; + var name = utilDisplayName(entity) || ""; + if (name.toLowerCase().indexOf(q2) < 0) + continue; + var matched = _mainPresetIndex.match(entity, graph); + var type2 = matched && matched.name() || utilDisplayType(entity.id); + var extent = entity.extent(graph); + var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0; + localResults.push({ + id: entity.id, + entity, + geometry: entity.geometry(graph), + type: type2, + name, + distance + }); + if (localResults.length > 100) + break; + } + localResults = localResults.sort(function byDistance(a2, b2) { + return a2.distance - b2.distance; + }); + result = result.concat(localResults); + (_geocodeResults || []).forEach(function(d2) { + if (d2.osm_type && d2.osm_id) { + var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id); + var tags = {}; + tags[d2.class] = d2.type; + var attrs = { id: id3, type: d2.osm_type, tags }; + if (d2.osm_type === "way") { + attrs.nodes = ["a", "a"]; + } + var tempEntity = osmEntity(attrs); + var tempGraph = coreGraph([tempEntity]); + var matched2 = _mainPresetIndex.match(tempEntity, tempGraph); + var type3 = matched2 && matched2.name() || utilDisplayType(id3); + result.push({ + id: tempEntity.id, + geometry: tempEntity.geometry(tempGraph), + type: type3, + name: d2.display_name, + extent: new geoExtent( + [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])], + [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])] + ) + }); + } + }); + if (q2.match(/^[0-9]+$/)) { + result.push({ + id: "n" + q2, + geometry: "point", + type: _t("inspector.node"), + name: q2 + }); + result.push({ + id: "w" + q2, + geometry: "line", + type: _t("inspector.way"), + name: q2 + }); + result.push({ + id: "r" + q2, + geometry: "relation", + type: _t("inspector.relation"), + name: q2 + }); + result.push({ + id: "note" + q2, + geometry: "note", + type: _t("note.note"), + name: q2 + }); + } + return result; + } + function drawList() { + var value = search.property("value"); + var results = features(); + list2.classed("filtered", value.length); + 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")); + resultsIndicator.append("span").attr("class", "entity-name"); + list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide")); + if (services.geocoder) { + 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")); + } + list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none"); + list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none"); + list2.selectAll(".feature-list-item").data([-1]).remove(); + var items = list2.selectAll(".feature-list-item").data(results, function(d2) { + return d2.id; + }); + var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click); + var label = enter.append("div").attr("class", "label"); + label.each(function(d2) { + select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text")); + }); + label.append("span").attr("class", "entity-type").text(function(d2) { + return d2.type; + }); + 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) { + return d2.name; + }); + enter.style("opacity", 0).transition().style("opacity", 1); + items.order(); + items.exit().remove(); + } + function mouseover(d3_event, d2) { + if (d2.id === -1) + return; + utilHighlightEntities([d2.id], true, context); + } + function mouseout(d3_event, d2) { + if (d2.id === -1) return; + utilHighlightEntities([d2.id], false, context); + } + function click(d3_event, d2) { + d3_event.preventDefault(); + if (d2.location) { + context.map().centerZoomEase([d2.location[1], d2.location[0]], 19); + } else if (d2.entity) { + utilHighlightEntities([d2.id], false, context); + context.enter(modeSelect(context, [d2.entity.id])); + context.map().zoomToEase(d2.entity); + } else if (d2.geometry === "note") { + const noteId = d2.id.replace(/\D/g, ""); + context.loadNote(noteId, (err, result) => { + if (err) + return; + const entity = result.data.find((e3) => e3.id === noteId); + if (entity) { + const note = services.osm.getNote(noteId); + context.map().centerZoom(note.loc, 15); + const noteLayer = context.layers().layer("notes"); + noteLayer.enabled(true); + context.enter(modeSelectNote(context, noteId)); + } + }); + } else { + context.zoomToEntity(d2.id); + } + } + function geocoderSearch() { + services.geocoder.search(search.property("value"), function(err, resp) { + _geocodeResults = resp || []; + drawList(); + }); + } + } + return featureList; + } + + // modules/ui/preset_list.js + function uiPresetList(context) { + var dispatch14 = dispatch_default("cancel", "choose"); + var _entityIDs; + var _currLoc; + var _currentPresets; + var _autofocus = false; + function presetList(selection2) { + if (!_entityIDs) + return; + var presets = _mainPresetIndex.matchAllGeometry(entityGeometries()); + selection2.html(""); + var messagewrap = selection2.append("div").attr("class", "header fillL"); + var message = messagewrap.append("h2").call(_t.append("inspector.choose")); + var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward"; + messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() { + dispatch14.call("cancel", this); + }).call(svgIcon("#iD-icon-".concat(direction))); + function initialKeydown(d3_event) { + if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + operationDelete(context, _entityIDs)(); + } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + context.undo(); + } else if (!d3_event.ctrlKey && !d3_event.metaKey) { + select_default2(this).on("keydown", keydown); + keydown.call(this, d3_event); + } + } + function keydown(d3_event) { + if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string + search.node().selectionStart === search.property("value").length) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + var buttons = list2.selectAll(".preset-list-button"); + if (!buttons.empty()) + buttons.nodes()[0].focus(); + } + } + function keypress(d3_event) { + var value = search.property("value"); + if (d3_event.keyCode === 13 && // ↩ Return + value.length) { + list2.selectAll(".preset-list-item:first-child").each(function(d2) { + d2.choose.call(this); + }); + } + } + function inputevent() { + var value = search.property("value"); + list2.classed("filtered", value.length); + var results, messageText; + if (value.length) { + results = presets.search(value, entityGeometries()[0], _currLoc); + messageText = _t.html("inspector.results", { + n: results.collection.length, + search: value + }); + } else { + var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph())); + results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2); + messageText = _t.html("inspector.choose"); + } + list2.call(drawList, results); + message.html(messageText); + } + var searchWrap = selection2.append("div").attr("class", "search-header"); + searchWrap.call(svgIcon("#iD-icon-search", "pre-text")); + var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent)); + if (_autofocus) { + search.node().focus(); + setTimeout(function() { + search.node().focus(); + }, 0); + } + var listWrap = selection2.append("div").attr("class", "inspector-body"); + var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph())); + var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets)); + context.features().on("change.preset-list", updateForFeatureHiddenState); + } + function drawList(list2, presets) { + presets = presets.matchAllGeometry(entityGeometries()); + var collection = presets.collection.reduce(function(collection2, preset) { + if (!preset) + return collection2; + if (preset.members) { + if (preset.members.collection.filter(function(preset2) { + return preset2.addable(); + }).length > 1) { + collection2.push(CategoryItem(preset)); + } + } else if (preset.addable()) { + collection2.push(PresetItem(preset)); + } + return collection2; + }, []); + var items = list2.selectAll(".preset-list-item").data(collection, function(d2) { + return d2.preset.id; + }); + items.order(); + items.exit().remove(); + items.enter().append("div").attr("class", function(item) { + return "preset-list-item preset-" + item.preset.id.replace("/", "-"); + }).classed("current", function(item) { + return _currentPresets.indexOf(item.preset) !== -1; + }).each(function(item) { + select_default2(this).call(item); + }).style("opacity", 0).transition().style("opacity", 1); + updateForFeatureHiddenState(); + } + function itemKeydown(d3_event) { + var item = select_default2(this.closest(".preset-list-item")); + var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item")); + if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) { d3_event.preventDefault(); - var dx = d3_event.clientX - lastClientX; - lastClientX = d3_event.clientX; - var isRTL = _mainLocalizer.textDirection() === "rtl"; - var scaleX = isRTL ? 0 : 1; - var xMarginProperty = isRTL ? "margin-right" : "margin-left"; - var x2 = containerLocGetter(d3_event)[0] - dragOffset; - sidebarWidth = isRTL ? containerWidth - x2 : x2; - var isCollapsed = selection2.classed("collapsed"); - var shouldCollapse = sidebarWidth < minWidth; - selection2.classed("collapsed", shouldCollapse); - if (shouldCollapse) { - if (!isCollapsed) { - selection2.style(xMarginProperty, "-400px").style("width", "400px"); - context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]); + d3_event.stopPropagation(); + var nextItem = select_default2(item.node().nextElementSibling); + if (nextItem.empty()) { + if (!parentItem.empty()) { + nextItem = select_default2(parentItem.node().nextElementSibling); } - } else { - var widthPct = sidebarWidth / containerWidth * 100; - selection2.style(xMarginProperty, null).style("width", widthPct + "%"); - if (isCollapsed) { - context.ui().onResize([-sidebarWidth * scaleX, 0]); - } else { - context.ui().onResize([-dx * scaleX, 0]); + } else if (select_default2(this).classed("expanded")) { + nextItem = item.select(".subgrid .preset-list-item:first-child"); + } + if (!nextItem.empty()) { + nextItem.select(".preset-list-button").node().focus(); + } + } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + var previousItem = select_default2(item.node().previousElementSibling); + if (previousItem.empty()) { + if (!parentItem.empty()) { + previousItem = parentItem; } + } else if (previousItem.select(".preset-list-button").classed("expanded")) { + previousItem = previousItem.select(".subgrid .preset-list-item:last-child"); } + if (!previousItem.empty()) { + previousItem.select(".preset-list-button").node().focus(); + } else { + var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input"); + search.node().focus(); + } + } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + if (!parentItem.empty()) { + parentItem.select(".preset-list-button").node().focus(); + } + } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + item.datum().choose.call(select_default2(this).node()); } - function pointerup(d3_event) { - if (downPointerId !== (d3_event.pointerId || "mouse")) - return; - downPointerId = null; - resizer.classed("dragging", false); - select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null); - } - var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context)); - var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap"); - var hoverModeSelect = function(targets) { - context.container().selectAll(".feature-list-item button").classed("hover", false); - if (context.selectedIDs().length > 1 && targets && targets.length) { - var elements = context.container().selectAll(".feature-list-item button").filter(function(node) { - return targets.indexOf(node) !== -1; - }); - if (!elements.empty()) { - elements.classed("hover", true); - } + } + function CategoryItem(preset) { + var box, sublist, shown = false; + function item(selection2) { + var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category"); + function click() { + var isExpanded = select_default2(this).classed("expanded"); + var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down"; + select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand")); + select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName); + item.choose(); } - }; - sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200); - function hover(targets) { - var datum2 = targets && targets.length && targets[0]; - if (datum2 && datum2.__featurehash__) { - _wasData = true; - sidebar.show(dataEditor.datum(datum2)); - selection2.selectAll(".sidebar-component").classed("inspector-hover", true); - } else if (datum2 instanceof osmNote) { - if (context.mode().id === "drag-note") - return; - _wasNote = true; - var osm = services.osm; - if (osm) { - datum2 = osm.getNote(datum2.id); - } - sidebar.show(noteEditor.note(datum2)); - selection2.selectAll(".sidebar-component").classed("inspector-hover", true); - } else if (datum2 instanceof QAItem) { - _wasQaItem = true; - var errService = services[datum2.service]; - if (errService) { - datum2 = errService.getError(datum2.id); - } - var errEditor; - if (datum2.service === "keepRight") { - errEditor = keepRightEditor; - } else if (datum2.service === "osmose") { - errEditor = osmoseEditor; + var geometries = entityGeometries(); + 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) { + if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + if (!select_default2(this).classed("expanded")) { + click.call(this, d3_event); + } + } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + if (select_default2(this).classed("expanded")) { + click.call(this, d3_event); + } } else { - errEditor = improveOsmEditor; - } - context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) { - return d2.id === datum2.id; - }); - sidebar.show(errEditor.error(datum2)); - selection2.selectAll(".sidebar-component").classed("inspector-hover", true); - } else if (!_current && datum2 instanceof osmEntity) { - featureListWrap.classed("inspector-hidden", true); - inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true); - if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") { - inspector.state("hover").entityIDs([datum2.id]).newFeature(false); - inspectorWrap.call(inspector); + itemKeydown.call(this, d3_event); } - } else if (!_current) { - featureListWrap.classed("inspector-hidden", false); - inspectorWrap.classed("inspector-hidden", true); - inspector.state("hide"); - } else if (_wasData || _wasNote || _wasQaItem) { - _wasNote = false; - _wasData = false; - _wasQaItem = false; - context.container().selectAll(".note").classed("hover", false); - context.container().selectAll(".qaItem").classed("hover", false); - sidebar.hide(); - } + }); + var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner"); + 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"); + box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0); + box.append("div").attr("class", "arrow"); + sublist = box.append("div").attr("class", "preset-list fillL3"); } - sidebar.hover = throttle_default(hover, 200); - sidebar.intersects = function(extent) { - var rect = selection2.node().getBoundingClientRect(); - return extent.intersects([ - context.projection.invert([0, rect.height]), - context.projection.invert([rect.width, 0]) - ]); - }; - sidebar.select = function(ids, newFeature) { - sidebar.hide(); - if (ids && ids.length) { - var entity = ids.length === 1 && context.entity(ids[0]); - if (entity && newFeature && selection2.classed("collapsed")) { - var extent = entity.extent(context.graph()); - sidebar.expand(sidebar.intersects(extent)); - } - featureListWrap.classed("inspector-hidden", true); - inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false); - inspector.state("select").entityIDs(ids).newFeature(newFeature); - inspectorWrap.call(inspector); + item.choose = function() { + if (!box || !sublist) + return; + if (shown) { + shown = false; + box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px"); } else { - inspector.state("hide"); + shown = true; + var members = preset.members.matchAllGeometry(entityGeometries()); + sublist.call(drawList, members); + box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px"); } }; - sidebar.showPresetList = function() { - inspector.showList(); - }; - sidebar.show = function(component, element) { - featureListWrap.classed("inspector-hidden", true); - inspectorWrap.classed("inspector-hidden", true); - if (_current) - _current.remove(); - _current = selection2.append("div").attr("class", "sidebar-component").call(component, element); - }; - sidebar.hide = function() { - featureListWrap.classed("inspector-hidden", false); - inspectorWrap.classed("inspector-hidden", true); - if (_current) - _current.remove(); - _current = null; - }; - sidebar.expand = function(moveMap) { - if (selection2.classed("collapsed")) { - sidebar.toggle(moveMap); + item.preset = preset; + return item; + } + function PresetItem(preset) { + function item(selection2) { + var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap"); + var geometries = entityGeometries(); + 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); + var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner"); + var nameparts = [ + preset.nameLabel(), + preset.subtitleLabel() + ].filter(Boolean); + label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) { + d2(select_default2(this)); + }); + wrap2.call(item.reference.button); + selection2.call(item.reference.body); + } + item.choose = function() { + if (select_default2(this).classed("disabled")) + return; + if (!context.inIntro()) { + _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]); } + context.perform( + function(graph) { + for (var i3 in _entityIDs) { + var entityID = _entityIDs[i3]; + var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph); + graph = actionChangePreset(entityID, oldPreset, preset)(graph); + } + return graph; + }, + _t("operations.change_tags.annotation") + ); + context.validator().validate(); + dispatch14.call("choose", this, preset); }; - sidebar.collapse = function(moveMap) { - if (!selection2.classed("collapsed")) { - sidebar.toggle(moveMap); - } + item.help = function(d3_event) { + d3_event.stopPropagation(); + item.reference.toggle(); }; - sidebar.toggle = function(moveMap) { - if (context.inIntro()) - return; - var isCollapsed = selection2.classed("collapsed"); - var isCollapsing = !isCollapsed; - var isRTL = _mainLocalizer.textDirection() === "rtl"; - var scaleX = isRTL ? 0 : 1; - var xMarginProperty = isRTL ? "margin-right" : "margin-left"; - sidebarWidth = selection2.node().getBoundingClientRect().width; - selection2.style("width", sidebarWidth + "px"); - var startMargin, endMargin, lastMargin; - if (isCollapsing) { - startMargin = lastMargin = 0; - endMargin = -sidebarWidth; - } else { - startMargin = lastMargin = -sidebarWidth; - endMargin = 0; + item.preset = preset; + item.reference = uiTagReference(preset.reference(), context); + return item; + } + function updateForFeatureHiddenState() { + if (!_entityIDs.every(context.hasEntity)) + return; + var geometries = entityGeometries(); + var button = context.container().selectAll(".preset-list .preset-list-button"); + button.call(uiTooltip().destroyAny); + button.each(function(item, index) { + var hiddenPresetFeaturesId; + for (var i3 in geometries) { + hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]); + if (hiddenPresetFeaturesId) + break; } - if (!isCollapsing) { - selection2.classed("collapsed", isCollapsing); + var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]); + select_default2(this).classed("disabled", isHiddenPreset); + if (isHiddenPreset) { + var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId); + select_default2(this).call( + uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), { + features: _t("feature." + hiddenPresetFeaturesId + ".description") + })).placement(index < 2 ? "bottom" : "top") + ); } - selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() { - var i3 = number_default(startMargin, endMargin); - return function(t2) { - var dx = lastMargin - Math.round(i3(t2)); - lastMargin = lastMargin - dx; - context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]); - }; - }).on("end", function() { - if (isCollapsing) { - selection2.classed("collapsed", isCollapsing); - } - if (!isCollapsing) { - var containerWidth2 = container.node().getBoundingClientRect().width; - var widthPct = sidebarWidth / containerWidth2 * 100; - selection2.style(xMarginProperty, null).style("width", widthPct + "%"); - } + }); + } + presetList.autofocus = function(val) { + if (!arguments.length) + return _autofocus; + _autofocus = val; + return presetList; + }; + presetList.entityIDs = function(val) { + if (!arguments.length) + return _entityIDs; + _entityIDs = val; + _currLoc = null; + if (_entityIDs && _entityIDs.length) { + const extent = _entityIDs.reduce(function(extent2, entityID) { + var entity = context.graph().entity(entityID); + return extent2.extend(entity.extent(context.graph())); + }, geoExtent()); + _currLoc = extent.center(); + var presets = _entityIDs.map(function(entityID) { + return _mainPresetIndex.match(context.entity(entityID), context.graph()); }); - }; - resizer.on("dblclick", function(d3_event) { - d3_event.preventDefault(); - if (d3_event.sourceEvent) { - d3_event.sourceEvent.preventDefault(); + presetList.presets(presets); + } + return presetList; + }; + presetList.presets = function(val) { + if (!arguments.length) + return _currentPresets; + _currentPresets = val; + return presetList; + }; + function entityGeometries() { + var counts = {}; + for (var i3 in _entityIDs) { + var entityID = _entityIDs[i3]; + var entity = context.entity(entityID); + var geometry = entity.geometry(context.graph()); + if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) { + geometry = "point"; } - sidebar.toggle(); + if (!counts[geometry]) + counts[geometry] = 0; + counts[geometry] += 1; + } + return Object.keys(counts).sort(function(geom1, geom2) { + return counts[geom2] - counts[geom1]; }); - context.map().on("crossEditableZoom.sidebar", function(within) { - if (!within && !selection2.select(".inspector-hover").empty()) { - hover([]); - } + } + return utilRebind(presetList, dispatch14, "on"); + } + + // modules/ui/inspector.js + function uiInspector(context) { + var presetList = uiPresetList(context); + var entityEditor = uiEntityEditor(context); + var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null); + var _state = "select"; + var _entityIDs; + var _newFeature = false; + function inspector(selection2) { + presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() { + inspector.setPreset(); }); + entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList); + wrap2 = selection2.selectAll(".panewrap").data([0]); + var enter = wrap2.enter().append("div").attr("class", "panewrap"); + enter.append("div").attr("class", "preset-list-pane pane"); + enter.append("div").attr("class", "entity-editor-pane pane"); + wrap2 = wrap2.merge(enter); + presetPane = wrap2.selectAll(".preset-list-pane"); + editorPane = wrap2.selectAll(".entity-editor-pane"); + function shouldDefaultToPresetList() { + if (_state !== "select") + return false; + if (_entityIDs.length !== 1) + return false; + var entityID = _entityIDs[0]; + var entity = context.hasEntity(entityID); + if (!entity) + return false; + if (entity.hasNonGeometryTags()) + return false; + if (_newFeature) + return true; + if (entity.geometry(context.graph()) !== "vertex") + return false; + if (context.graph().parentRelations(entity).length) + return false; + if (context.validator().getEntityIssues(entityID).length) + return false; + if (entity.isHighwayIntersection(context.graph())) + return false; + return true; + } + if (shouldDefaultToPresetList()) { + wrap2.style("right", "-100%"); + editorPane.classed("hide", true); + presetPane.classed("hide", false).call(presetList); + } else { + wrap2.style("right", "0%"); + presetPane.classed("hide", true); + editorPane.classed("hide", false).call(entityEditor); + } + var footer = selection2.selectAll(".footer").data([0]); + footer = footer.enter().append("div").attr("class", "footer").merge(footer); + footer.call( + uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0])) + ); } - sidebar.showPresetList = function() { - }; - sidebar.hover = function() { - }; - sidebar.hover.cancel = function() { + inspector.showList = function(presets) { + presetPane.classed("hide", false); + wrap2.transition().styleTween("right", function() { + return value_default("0%", "-100%"); + }).on("end", function() { + editorPane.classed("hide", true); + }); + if (presets) { + presetList.presets(presets); + } + presetPane.call(presetList.autofocus(true)); }; - sidebar.intersects = function() { + inspector.setPreset = function(preset) { + if (preset && preset.id === "type/multipolygon") { + presetPane.call(presetList.autofocus(true)); + } else { + editorPane.classed("hide", false); + wrap2.transition().styleTween("right", function() { + return value_default("-100%", "0%"); + }).on("end", function() { + presetPane.classed("hide", true); + }); + if (preset) { + entityEditor.presets([preset]); + } + editorPane.call(entityEditor); + } }; - sidebar.select = function() { + inspector.state = function(val) { + if (!arguments.length) + return _state; + _state = val; + entityEditor.state(_state); + context.container().selectAll(".field-help-body").remove(); + return inspector; }; - sidebar.show = function() { + inspector.entityIDs = function(val) { + if (!arguments.length) + return _entityIDs; + _entityIDs = val; + return inspector; }; - sidebar.hide = function() { + inspector.newFeature = function(val) { + if (!arguments.length) + return _newFeature; + _newFeature = val; + return inspector; }; - sidebar.expand = function() { + return inspector; + } + + // modules/ui/lasso.js + function uiLasso(context) { + var group, polygon2; + lasso.coordinates = []; + function lasso(selection2) { + context.container().classed("lasso", true); + group = selection2.append("g").attr("class", "lasso hide"); + polygon2 = group.append("path").attr("class", "lasso-path"); + group.call(uiToggle(true)); + } + function draw() { + if (polygon2) { + polygon2.data([lasso.coordinates]).attr("d", function(d2) { + return "M" + d2.join(" L") + " Z"; + }); + } + } + lasso.extent = function() { + return lasso.coordinates.reduce(function(extent, point2) { + return extent.extend(geoExtent(point2)); + }, geoExtent()); }; - sidebar.collapse = function() { + lasso.p = function(_2) { + if (!arguments.length) + return lasso; + lasso.coordinates.push(_2); + draw(); + return lasso; }; - sidebar.toggle = function() { + lasso.close = function() { + if (group) { + group.call(uiToggle(false, function() { + select_default2(this).remove(); + })); + } + context.container().classed("lasso", false); }; - return sidebar; + return lasso; } - // modules/modes/draw_area.js - function modeDrawArea(context, wayID, startGraph, button) { - var mode = { - button, - id: "draw-area" + // modules/ui/source_switch.js + function uiSourceSwitch(context) { + var keys2; + function click(d3_event) { + d3_event.preventDefault(); + var osm = context.connection(); + if (!osm) + return; + if (context.inIntro()) + return; + if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes"))) + return; + var isLive = select_default2(this).classed("live"); + isLive = !isLive; + context.enter(modeBrowse(context)); + context.history().clearSaved(); + context.flush(); + select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive); + osm.switch(isLive ? keys2[0] : keys2[1]); + } + var sourceSwitch = function(selection2) { + selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click); }; - var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() { - context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))(); - }); - mode.wayID = wayID; - mode.enter = function() { - context.install(behavior); + sourceSwitch.keys = function(_2) { + if (!arguments.length) + return keys2; + keys2 = _2; + return sourceSwitch; }; - mode.exit = function() { - context.uninstall(behavior); + return sourceSwitch; + } + + // modules/ui/spinner.js + function uiSpinner(context) { + var osm = context.connection(); + return function(selection2) { + var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0); + if (osm) { + osm.on("loading.spinner", function() { + img.transition().style("opacity", 1); + }).on("loaded.spinner", function() { + img.transition().style("opacity", 0); + }); + } }; - mode.selectedIDs = function() { - return [wayID]; + } + + // modules/ui/sections/privacy.js + function uiSectionPrivacy(context) { + let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent); + function renderDisclosureContent(selection2) { + selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list"); + 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( + uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom") + ); + thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => { + d3_event.preventDefault(); + corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true"); + }); + thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description")); + selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true"); + 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")); + } + corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender); + return section; + } + + // modules/ui/splash.js + function uiSplash(context) { + return (selection2) => { + if (context.history().hasRestorableChanges()) + return; + let updateMessage = ""; + const sawPrivacyVersion = corePreferences("sawPrivacyVersion"); + let showSplash = !corePreferences("sawSplash"); + if (sawPrivacyVersion !== context.privacyVersion) { + updateMessage = _t("splash.privacy_update"); + showSplash = true; + } + if (!showSplash) + return; + corePreferences("sawSplash", true); + corePreferences("sawPrivacyVersion", context.privacyVersion); + _mainFileFetcher.get("intro_graph"); + let modalSelection = uiModal(selection2); + modalSelection.select(".modal").attr("class", "modal-splash modal"); + let introModal = modalSelection.select(".content").append("div").attr("class", "fillL"); + introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome")); + let modalSection = introModal.append("div").attr("class", "modal-section"); + modalSection.append("p").html(_t.html("splash.text", { + version: context.version, + website: { html: '' + _t.html("splash.changelog") + "" }, + github: { html: 'github.com' } + })); + modalSection.append("p").html(_t.html("splash.privacy", { + updateMessage, + privacyLink: { html: '' + _t("splash.privacy_policy") + "" } + })); + uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection); + let buttonWrap = introModal.append("div").attr("class", "modal-actions"); + let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => { + context.container().call(uiIntro(context)); + modalSelection.close(); + }); + walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough"); + walkthrough.append("div").call(_t.append("splash.walkthrough")); + let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close); + startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features"); + startEditing.append("div").call(_t.append("splash.start")); + modalSelection.select("button.close").attr("class", "hide"); }; - mode.activeID = function() { - return behavior && behavior.activeID() || []; + } + + // modules/ui/status.js + function uiStatus(context) { + var osm = context.connection(); + return function(selection2) { + if (!osm) + return; + function update(err, apiStatus) { + selection2.html(""); + if (err) { + if (apiStatus === "connectionSwitched") { + return; + } else if (apiStatus === "rateLimited") { + 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) { + d3_event.preventDefault(); + osm.authenticate(); + }); + } else { + var throttledRetry = throttle_default(function() { + context.loadTiles(context.projection); + osm.reloadApiStatus(); + }, 2e3); + 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) { + d3_event.preventDefault(); + throttledRetry(); + }); + } + } else if (apiStatus === "readonly") { + selection2.call(_t.append("osm_api_status.message.readonly")); + } else if (apiStatus === "offline") { + selection2.call(_t.append("osm_api_status.message.offline")); + } + selection2.attr("class", "api-status " + (err ? "error" : apiStatus)); + } + osm.on("apiStatusChange.uiStatus", update); + context.history().on("storage_error", () => { + selection2.selectAll("span.local-storage-full").remove(); + selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full")); + selection2.classed("error", true); + }); + window.setInterval(function() { + osm.reloadApiStatus(); + }, 9e4); + osm.reloadApiStatus(); }; - return mode; } - // modules/modes/add_area.js - function modeAddArea(context, mode) { - mode.id = "add-area"; - var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); - function defaultTags(loc) { - var defaultTags2 = { area: "yes" }; - if (mode.preset) - defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc); - return defaultTags2; + // modules/ui/version.js + var sawVersion = null; + var isNewVersion = false; + var isNewUser = false; + function uiVersion(context) { + var currVersion = context.version; + var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/); + if (sawVersion === null && matchedVersion !== null) { + if (corePreferences("sawVersion")) { + isNewUser = false; + isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1; + } else { + isNewUser = true; + isNewVersion = true; + } + corePreferences("sawVersion", currVersion); + sawVersion = currVersion; } - function actionClose(wayId) { - return function(graph) { - return graph.replace(graph.entity(wayId).close()); - }; + return function(selection2) { + selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion); + if (isNewVersion && !isNewUser) { + 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( + uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap")) + ); + } + }; + } + + // modules/ui/zoom.js + function uiZoom(context) { + var zooms = [{ + id: "zoom-in", + icon: "iD-icon-plus", + title: _t.append("zoom.in"), + action: zoomIn, + disabled: function() { + return !context.map().canZoomIn(); + }, + disabledTitle: _t.append("zoom.disabled.in"), + key: "+" + }, { + id: "zoom-out", + icon: "iD-icon-minus", + title: _t.append("zoom.out"), + action: zoomOut, + disabled: function() { + return !context.map().canZoomOut(); + }, + disabledTitle: _t.append("zoom.disabled.out"), + key: "-" + }]; + function zoomIn(d3_event) { + if (d3_event.shiftKey) + return; + d3_event.preventDefault(); + context.map().zoomIn(); } - function start2(loc) { - var startGraph = context.graph(); - var node = osmNode({ loc }); - var way = osmWay({ tags: defaultTags(loc) }); - context.perform( - actionAddEntity(node), - actionAddEntity(way), - actionAddVertex(way.id, node.id), - actionClose(way.id) - ); - context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); + function zoomOut(d3_event) { + if (d3_event.shiftKey) + return; + d3_event.preventDefault(); + context.map().zoomOut(); } - function startFromWay(loc, edge) { - var startGraph = context.graph(); - var node = osmNode({ loc }); - var way = osmWay({ tags: defaultTags(loc) }); - context.perform( - actionAddEntity(node), - actionAddEntity(way), - actionAddVertex(way.id, node.id), - actionClose(way.id), - actionAddMidpoint({ loc, edge }, node) - ); - context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); + function zoomInFurther(d3_event) { + if (d3_event.shiftKey) + return; + d3_event.preventDefault(); + context.map().zoomInFurther(); } - function startFromNode(node) { - var startGraph = context.graph(); - var way = osmWay({ tags: defaultTags(node.loc) }); - context.perform( - actionAddEntity(way), - actionAddVertex(way.id, node.id), - actionClose(way.id) - ); - context.enter(modeDrawArea(context, way.id, startGraph, mode.button)); + function zoomOutFurther(d3_event) { + if (d3_event.shiftKey) + return; + d3_event.preventDefault(); + context.map().zoomOutFurther(); } - mode.enter = function() { - context.install(behavior); - }; - mode.exit = function() { - context.uninstall(behavior); + return function(selection2) { + var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) { + if (d2.disabled()) { + return d2.disabledTitle; + } + return d2.title; + }).keys(function(d2) { + return [d2.key]; + }); + var lastPointerUpType; + var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) { + return d2.id; + }).on("pointerup.editor", function(d3_event) { + lastPointerUpType = d3_event.pointerType; + }).on("click.editor", function(d3_event, d2) { + if (!d2.disabled()) { + d2.action(d3_event); + } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { + context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)(); + } + lastPointerUpType = null; + }).call(tooltipBehavior); + buttons.each(function(d2) { + select_default2(this).call(svgIcon("#" + d2.icon, "light")); + }); + utilKeybinding.plusKeys.forEach(function(key) { + context.keybinding().on([key], zoomIn); + context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther); + }); + utilKeybinding.minusKeys.forEach(function(key) { + context.keybinding().on([key], zoomOut); + context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther); + }); + function updateButtonStates() { + buttons.classed("disabled", function(d2) { + return d2.disabled(); + }).each(function() { + var selection3 = select_default2(this); + if (!selection3.select(".tooltip.in").empty()) { + selection3.call(tooltipBehavior.updateContent); + } + }); + } + updateButtonStates(); + context.map().on("move.uiZoom", updateButtonStates); }; - return mode; } - // modules/modes/add_line.js - function modeAddLine(context, mode) { - mode.id = "add-line"; - var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); - function defaultTags(loc) { - var defaultTags2 = {}; - if (mode.preset) - defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc); - return defaultTags2; - } - function start2(loc) { - var startGraph = context.graph(); - var node = osmNode({ loc }); - var way = osmWay({ tags: defaultTags(loc) }); - context.perform( - actionAddEntity(node), - actionAddEntity(way), - actionAddVertex(way.id, node.id) - ); - context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); - } - function startFromWay(loc, edge) { - var startGraph = context.graph(); - var node = osmNode({ loc }); - var way = osmWay({ tags: defaultTags(loc) }); - context.perform( - actionAddEntity(node), - actionAddEntity(way), - actionAddVertex(way.id, node.id), - actionAddMidpoint({ loc, edge }, node) - ); - context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); + // modules/ui/sections/raw_tag_editor.js + function uiSectionRawTagEditor(id2, context) { + var section = uiSection(id2, context).classes("raw-tag-editor").label(function() { + var count = Object.keys(_tags).filter(function(d2) { + return d2; + }).length; + return _t.append("inspector.title_count", { title: _t("inspector.tags"), count }); + }).expandedByDefault(false).disclosureContent(renderDisclosureContent); + var taginfo = services.taginfo; + var dispatch14 = dispatch_default("change"); + var availableViews = [ + { id: "list", icon: "#fas-th-list" }, + { id: "text", icon: "#fas-i-cursor" } + ]; + let _discardTags = {}; + _mainFileFetcher.get("discarded").then((d2) => { + _discardTags = d2; + }).catch(() => { + }); + var _tagView = corePreferences("raw-tag-editor-view") || "list"; + var _readOnlyTags = []; + var _orderedKeys = []; + var _showBlank = false; + var _pendingChange = null; + var _state; + var _presets; + var _tags; + var _entityIDs; + var _didInteract = false; + function interacted() { + _didInteract = true; } - function startFromNode(node) { - var startGraph = context.graph(); - var way = osmWay({ tags: defaultTags(node.loc) }); - context.perform( - actionAddEntity(way), - actionAddVertex(way.id, node.id) + function renderDisclosureContent(wrap2) { + _orderedKeys = _orderedKeys.filter(function(key) { + return _tags[key] !== void 0; + }); + var all = Object.keys(_tags).sort(); + var missingKeys = utilArrayDifference(all, _orderedKeys); + for (var i3 in missingKeys) { + _orderedKeys.push(missingKeys[i3]); + } + var rowData = _orderedKeys.map(function(key, i4) { + return { index: i4, key, value: _tags[key] }; + }); + if (!rowData.length || _showBlank) { + _showBlank = false; + rowData.push({ index: rowData.length, key: "", value: "" }); + } + var options2 = wrap2.selectAll(".raw-tag-options").data([0]); + options2.exit().remove(); + var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist"); + var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) { + return d2.id; + }).enter(); + optionEnter.append("button").attr("class", function(d2) { + return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : ""); + }).attr("aria-selected", function(d2) { + return _tagView === d2.id; + }).attr("role", "tab").attr("title", function(d2) { + return _t("icons." + d2.id); + }).on("click", function(d3_event, d2) { + _tagView = d2.id; + corePreferences("raw-tag-editor-view", d2.id); + wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) { + return datum2 === d2; + }).attr("aria-selected", function(datum2) { + return datum2 === d2; + }); + wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight); + wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list"); + }).each(function(d2) { + select_default2(this).call(svgIcon(d2.icon)); + }); + var textData = rowsToText(rowData); + var textarea = wrap2.selectAll(".tag-text").data([0]); + 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); + textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged); + var list2 = wrap2.selectAll(".tag-list").data([0]); + list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2); + var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : "")); + 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); + addRowEnter.append("div").attr("class", "space-value"); + addRowEnter.append("div").attr("class", "space-buttons"); + var items = list2.selectAll(".tag-row").data(rowData, function(d2) { + return d2.key; + }); + items.exit().each(unbind).remove(); + var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly); + var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap"); + 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); + 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); + innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")); + items = items.merge(itemsEnter).sort(function(a2, b2) { + return a2.index - b2.index; + }); + items.each(function(d2) { + var row = select_default2(this); + var key = row.select("input.key"); + var value = row.select("input.value"); + if (_entityIDs && taginfo && _state !== "hover") { + bindTypeahead(key, value); + } + var referenceOptions = { key: d2.key }; + if (typeof d2.value === "string") { + referenceOptions.value = d2.value; + } + var reference = uiTagReference(referenceOptions, context); + if (_state === "hover") { + reference.showing(false); + } + row.select(".inner-wrap").call(reference.button); + row.call(reference.body); + row.select("button.remove"); + }); + items.selectAll("input.key").attr("title", function(d2) { + return d2.key; + }).call(utilGetSetValue, function(d2) { + return d2.key; + }).attr("readonly", function(d2) { + return isReadOnly(d2) || null; + }); + items.selectAll("input.value").attr("title", function(d2) { + return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value; + }).classed("mixed", function(d2) { + return Array.isArray(d2.value); + }).attr("placeholder", function(d2) { + return typeof d2.value === "string" ? null : _t("inspector.multiple_values"); + }).call(utilGetSetValue, function(d2) { + return typeof d2.value === "string" ? d2.value : ""; + }).attr("readonly", function(d2) { + return isReadOnly(d2) || null; + }); + items.selectAll("button.remove").on( + ("PointerEvent" in window ? "pointer" : "mouse") + "down", + // 'click' fires too late - #5878 + (d3_event, d2) => { + if (d3_event.button !== 0) + return; + removeTag(d3_event, d2); + } ); - context.enter(modeDrawLine(context, way.id, startGraph, mode.button)); - } - mode.enter = function() { - context.install(behavior); - }; - mode.exit = function() { - context.uninstall(behavior); - }; - return mode; - } - - // modules/modes/add_point.js - function modeAddPoint(context, mode) { - mode.id = "add-point"; - var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel); - function defaultTags(loc) { - var defaultTags2 = {}; - if (mode.preset) - defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc); - return defaultTags2; } - function add(loc) { - var node = osmNode({ loc, tags: defaultTags(loc) }); - context.perform( - actionAddEntity(node), - _t("operations.add.annotation.point") - ); - enterSelectMode(node); + function isReadOnly(d2) { + for (var i3 = 0; i3 < _readOnlyTags.length; i3++) { + if (d2.key.match(_readOnlyTags[i3]) !== null) { + return true; + } + } + return false; } - function addWay(loc, edge) { - var node = osmNode({ tags: defaultTags(loc) }); - context.perform( - actionAddMidpoint({ loc, edge }, node), - _t("operations.add.annotation.vertex") - ); - enterSelectMode(node); + function setTextareaHeight() { + if (_tagView !== "text") + return; + var selection2 = select_default2(this); + var matches = selection2.node().value.match(/\n/g); + var lineCount = 2 + Number(matches && matches.length); + var lineHeight = 20; + selection2.style("height", lineCount * lineHeight + "px"); } - function enterSelectMode(node) { - context.enter( - modeSelect(context, [node.id]).newFeature(true) - ); + function stringify3(s2) { + return JSON.stringify(s2).slice(1, -1); } - function addNode(node) { - const _defaultTags = defaultTags(node.loc); - if (Object.keys(_defaultTags).length === 0) { - enterSelectMode(node); - return; + function unstringify(s2) { + var leading = ""; + var trailing = ""; + if (s2.length < 1 || s2.charAt(0) !== '"') { + leading = '"'; } - var tags = Object.assign({}, node.tags); - for (var key in _defaultTags) { - tags[key] = _defaultTags[key]; + if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") { + trailing = '"'; } - context.perform( - actionChangeTags(node.id, tags), - _t("operations.add.annotation.point") - ); - enterSelectMode(node); + return JSON.parse(leading + s2 + trailing); } - function cancel() { - context.enter(modeBrowse(context)); + function rowsToText(rows) { + var str = rows.filter(function(row) { + return row.key && row.key.trim() !== ""; + }).map(function(row) { + var rawVal = row.value; + if (typeof rawVal !== "string") + rawVal = "*"; + var val = rawVal ? stringify3(rawVal) : ""; + return stringify3(row.key) + "=" + val; + }).join("\n"); + if (_state !== "hover" && str.length) { + return str + "\n"; + } + return str; } - mode.enter = function() { - context.install(behavior); - }; - mode.exit = function() { - context.uninstall(behavior); - }; - return mode; - } - - // modules/modes/select_note.js - function modeSelectNote(context, selectedNoteID) { - var mode = { - id: "select-note", - button: "browse" - }; - var _keybinding = utilKeybinding("select-note"); - var _noteEditor = uiNoteEditor(context).on("change", function() { - context.map().pan([0, 0]); - var note = checkSelectedID(); - if (!note) + function textChanged() { + var newText = this.value.trim(); + var newTags = {}; + newText.split("\n").forEach(function(row) { + var m2 = row.match(/^\s*([^=]+)=(.*)$/); + if (m2 !== null) { + var k2 = context.cleanTagKey(unstringify(m2[1].trim())); + var v2 = context.cleanTagValue(unstringify(m2[2].trim())); + newTags[k2] = v2; + } + }); + var tagDiff = utilTagDiff(_tags, newTags); + if (!tagDiff.length) return; - context.ui().sidebar.show(_noteEditor.note(note)); - }); - var _behaviors = [ - behaviorBreathe(context), - behaviorHover(context), - behaviorSelect(context), - behaviorLasso(context), - modeDragNode(context).behavior, - modeDragNote(context).behavior - ]; - var _newFeature = false; - function checkSelectedID() { - if (!services.osm) + _pendingChange = _pendingChange || {}; + tagDiff.forEach(function(change) { + if (isReadOnly({ key: change.key })) + return; + if (change.newVal === "*" && typeof change.oldVal !== "string") + return; + if (change.type === "-") { + _pendingChange[change.key] = void 0; + } else if (change.type === "+") { + _pendingChange[change.key] = change.newVal || ""; + } + }); + if (Object.keys(_pendingChange).length === 0) { + _pendingChange = null; return; - var note = services.osm.getNote(selectedNoteID); - if (!note) { - context.enter(modeBrowse(context)); } - return note; + scheduleChange(); } - function selectNote(d3_event, drawn) { - if (!checkSelectedID()) + function pushMore(d3_event) { + if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) { + addTag(); + } + } + function bindTypeahead(key, value) { + if (isReadOnly(key.datum())) return; - var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID); - if (selection2.empty()) { - var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent; - if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) { - context.enter(modeBrowse(context)); + if (Array.isArray(value.datum().value)) { + value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) { + var keyString = utilGetSetValue(key); + if (!_tags[keyString]) + return; + var data = _tags[keyString].map(function(tagValue) { + if (!tagValue) { + return { + value: " ", + title: _t("inspector.empty"), + display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty")) + }; + } + return { + value: tagValue, + title: tagValue + }; + }); + callback(data); + })); + return; + } + var geometry = context.graph().geometry(_entityIDs[0]); + key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) { + taginfo.keys({ + debounce: true, + geometry, + query: value2 + }, function(err, data) { + if (!err) { + 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())); + callback(sort(value2, filtered)); + } + }); + })); + value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) { + taginfo.values({ + debounce: true, + key: utilGetSetValue(key), + geometry, + query: value2 + }, function(err, data) { + if (!err) { + const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase())); + callback(sort(value2, filtered)); + } + }); + }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key)))); + function sort(value2, data) { + var sameletter = []; + var other = []; + for (var i3 = 0; i3 < data.length; i3++) { + if (data[i3].value.substring(0, value2.length) === value2) { + sameletter.push(data[i3]); + } else { + other.push(data[i3]); + } } - } else { - selection2.classed("selected", true); - context.selectedNoteID(selectedNoteID); + return sameletter.concat(other); } } - function esc() { - if (context.container().select(".combobox").size()) - return; - context.enter(modeBrowse(context)); + function unbind() { + var row = select_default2(this); + row.selectAll("input.key").call(uiCombobox.off, context); + row.selectAll("input.value").call(uiCombobox.off, context); } - mode.zoomToSelected = function() { - if (!services.osm) + function keyChange(d3_event, d2) { + if (select_default2(this).attr("readonly")) return; - var note = services.osm.getNote(selectedNoteID); - if (note) { - context.map().centerZoomEase(note.loc, 20); - } - }; - mode.newFeature = function(val) { - if (!arguments.length) - return _newFeature; - _newFeature = val; - return mode; - }; - mode.enter = function() { - var note = checkSelectedID(); - if (!note) + var kOld = d2.key; + if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0) return; - _behaviors.forEach(context.install); - _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true); - select_default2(document).call(_keybinding); - selectNote(); - var sidebar = context.ui().sidebar; - sidebar.show(_noteEditor.note(note).newNote(_newFeature)); - sidebar.expand(sidebar.intersects(note.extent())); - context.map().on("drawn.select", selectNote); - }; - mode.exit = function() { - _behaviors.forEach(context.uninstall); - select_default2(document).call(_keybinding.unbind); - context.surface().selectAll(".layer-notes .selected").classed("selected hover", false); - context.map().on("drawn.select", null); - context.ui().sidebar.hide(); - context.selectedNoteID(null); - }; - return mode; - } - - // modules/modes/add_note.js - function modeAddNote(context) { - var mode = { - id: "add-note", - button: "note", - description: _t.append("modes.add_note.description"), - key: _t("modes.add_note.key") - }; - var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel); - function add(loc) { - var osm = services.osm; - if (!osm) + var kNew = context.cleanTagKey(this.value.trim()); + if (isReadOnly({ key: kNew })) { + this.value = kOld; return; - var note = osmNote({ loc, status: "open", comments: [] }); - osm.replaceNote(note); - context.map().pan([0, 0]); - context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true)); - } - function cancel() { - context.enter(modeBrowse(context)); - } - mode.enter = function() { - context.install(behavior); - }; - mode.exit = function() { - context.uninstall(behavior); - }; - return mode; - } - - // modules/modes/save.js - function modeSave(context) { - var mode = { id: "save" }; - var keybinding = utilKeybinding("modeSave"); - var commit = uiCommit(context).on("cancel", cancel); - var _conflictsUi; - var _location; - var _success; - var uploader = context.uploader().on("saveStarted.modeSave", function() { - keybindingOff(); - }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() { - cancel(); - }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess); - function cancel() { - context.enter(modeBrowse(context)); - } - function showProgress(num, total) { - var modal = context.container().select(".loading-modal .modal-section"); - var progress = modal.selectAll(".progress").data([0]); - progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total })); - } - function showConflicts(changeset, conflicts, origChanges) { - var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component"); - context.container().selectAll(".main-content").classed("active", true).classed("inactive", false); - _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() { - context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); - selection2.remove(); - keybindingOn(); - uploader.cancelConflictResolution(); - }).on("save", function() { - context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); - selection2.remove(); - uploader.processResolvedConflicts(changeset); - }); - selection2.call(_conflictsUi); - } - function showErrors(errors) { - keybindingOn(); - var selection2 = uiConfirm(context.container()); - selection2.select(".modal-section.header").append("h3").text(_t("save.error")); - addErrors(selection2, errors); - selection2.okButton(); - } - function addErrors(selection2, data) { - var message = selection2.select(".modal-section.message-text"); - var items = message.selectAll(".error-container").data(data); - var enter = items.enter().append("div").attr("class", "error-container"); - enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) { - return d2.msg || _t("save.unknown_error_details"); - }).on("click", function(d3_event) { - d3_event.preventDefault(); - var error = select_default2(this); - var detail = select_default2(this.nextElementSibling); - var exp2 = error.classed("expanded"); - detail.style("display", exp2 ? "none" : "block"); - error.classed("expanded", !exp2); - }); - var details = enter.append("div").attr("class", "error-detail-container").style("display", "none"); - details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) { - return d2.details || []; - }).enter().append("li").attr("class", "error-detail-item").text(function(d2) { - return d2; - }); - items.exit().remove(); + } + if (kNew && kNew !== kOld && _tags[kNew] !== void 0) { + this.value = kOld; + section.selection().selectAll(".tag-list input.value").each(function(d4) { + if (d4.key === kNew) { + var input = select_default2(this).node(); + input.focus(); + input.select(); + } + }); + return; + } + _pendingChange = _pendingChange || {}; + if (kOld) { + if (kOld === kNew) + return; + _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld }; + _pendingChange[kOld] = void 0; + } else { + let row = this.parentNode.parentNode; + let inputVal = select_default2(row).selectAll("input.value"); + let vNew = context.cleanTagValue(utilGetSetValue(inputVal)); + _pendingChange[kNew] = vNew; + utilGetSetValue(inputVal, vNew); + } + var existingKeyIndex = _orderedKeys.indexOf(kOld); + if (existingKeyIndex !== -1) + _orderedKeys[existingKeyIndex] = kNew; + d2.key = kNew; + this.value = kNew; + scheduleChange(); } - function showSuccess(changeset) { - commit.reset(); - var ui = _success.changeset(changeset).location(_location).on("cancel", function() { - context.ui().sidebar.hide(); - }); - context.enter(modeBrowse(context).sidebar(ui)); + function valueChange(d3_event, d2) { + if (isReadOnly(d2)) + return; + if (typeof d2.value !== "string" && !this.value) + return; + if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0) + return; + _pendingChange = _pendingChange || {}; + _pendingChange[d2.key] = context.cleanTagValue(this.value); + scheduleChange(); } - function keybindingOn() { - select_default2(document).call(keybinding.on("\u238B", cancel, true)); + function removeTag(d3_event, d2) { + if (isReadOnly(d2)) + return; + if (d2.key === "") { + _showBlank = false; + section.reRender(); + } else { + _orderedKeys = _orderedKeys.filter(function(key) { + return key !== d2.key; + }); + _pendingChange = _pendingChange || {}; + _pendingChange[d2.key] = void 0; + scheduleChange(); + } } - function keybindingOff() { - select_default2(document).call(keybinding.unbind); + function addTag() { + window.setTimeout(function() { + _showBlank = true; + section.reRender(); + section.selection().selectAll(".tag-list li:last-child input.key").node().focus(); + }, 20); } - function prepareForSuccess() { - _success = uiSuccess(context); - _location = null; - if (!services.geocoder) - return; - services.geocoder.reverse(context.map().center(), function(err, result) { - if (err || !result || !result.address) + function scheduleChange() { + var entityIDs = _entityIDs; + window.setTimeout(function() { + if (!_pendingChange) return; - var addr = result.address; - var place = addr && (addr.town || addr.city || addr.county) || ""; - var region = addr && (addr.state || addr.country) || ""; - var separator = place && region ? _t("success.thank_you_where.separator") : ""; - _location = _t( - "success.thank_you_where.format", - { place, separator, region } - ); - }); + dispatch14.call("change", this, entityIDs, _pendingChange); + _pendingChange = null; + }, 10); } - mode.selectedIDs = function() { - return _conflictsUi ? _conflictsUi.shownEntityIds() : []; - }; - mode.enter = function() { - context.ui().sidebar.expand(); - function done() { - context.ui().sidebar.show(commit); - } - keybindingOn(); - context.container().selectAll(".main-content").classed("active", false).classed("inactive", true); - var osm = context.connection(); - if (!osm) { - cancel(); - return; + section.state = function(val) { + if (!arguments.length) + return _state; + if (_state !== val) { + _orderedKeys = []; + _state = val; } - if (osm.authenticated()) { - done(); - } else { - osm.authenticate(function(err) { - if (err) { - cancel(); - } else { - done(); - } - }); + return section; + }; + section.presets = function(val) { + if (!arguments.length) + return _presets; + _presets = val; + if (_presets && _presets.length && _presets[0].isFallback()) { + section.disclosureExpanded(true); + } else if (!_didInteract) { + section.disclosureExpanded(null); } + return section; }; - mode.exit = function() { - keybindingOff(); - context.container().selectAll(".main-content").classed("active", true).classed("inactive", false); - context.ui().sidebar.hide(); + section.tags = function(val) { + if (!arguments.length) + return _tags; + _tags = val; + return section; }; - return mode; + section.entityIDs = function(val) { + if (!arguments.length) + return _entityIDs; + if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { + _entityIDs = val; + _orderedKeys = []; + } + return section; + }; + section.readOnlyTags = function(val) { + if (!arguments.length) + return _readOnlyTags; + _readOnlyTags = val; + return section; + }; + return utilRebind(section, dispatch14, "on"); } - // modules/modes/select_error.js - function modeSelectError(context, selectedErrorID, selectedErrorService) { - var mode = { - id: "select-error", - button: "browse" - }; - var keybinding = utilKeybinding("select-error"); - var errorService = services[selectedErrorService]; - var errorEditor; - switch (selectedErrorService) { - case "improveOSM": - errorEditor = uiImproveOsmEditor(context).on("change", function() { - context.map().pan([0, 0]); - var error = checkSelectedID(); - if (!error) - return; - context.ui().sidebar.show(errorEditor.error(error)); - }); - break; - case "keepRight": - errorEditor = uiKeepRightEditor(context).on("change", function() { - context.map().pan([0, 0]); - var error = checkSelectedID(); - if (!error) - return; - context.ui().sidebar.show(errorEditor.error(error)); - }); - break; - case "osmose": - errorEditor = uiOsmoseEditor(context).on("change", function() { - context.map().pan([0, 0]); - var error = checkSelectedID(); - if (!error) - return; - context.ui().sidebar.show(errorEditor.error(error)); - }); - break; - } - var behaviors = [ - behaviorBreathe(context), - behaviorHover(context), - behaviorSelect(context), - behaviorLasso(context), - modeDragNode(context).behavior, - modeDragNote(context).behavior - ]; - function checkSelectedID() { - if (!errorService) - return; - var error = errorService.getError(selectedErrorID); - if (!error) { + // modules/ui/data_editor.js + function uiDataEditor(context) { + var dataHeader = uiDataHeader(); + var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]); + var _datum; + function dataEditor(selection2) { + var header = selection2.selectAll(".header").data([0]); + var headerEnter = header.enter().append("div").attr("class", "header fillL"); + headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() { context.enter(modeBrowse(context)); - } - return error; + }).call(svgIcon("#iD-icon-close")); + headerEnter.append("h2").call(_t.append("map_data.title")); + var body = selection2.selectAll(".body").data([0]); + body = body.enter().append("div").attr("class", "body").merge(body); + var editor = body.selectAll(".data-editor").data([0]); + editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum)); + var rte = body.selectAll(".raw-tag-editor").data([0]); + rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call( + rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render + ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true); } - mode.zoomToSelected = function() { - if (!errorService) - return; - var error = errorService.getError(selectedErrorID); - if (error) { - context.map().centerZoomEase(error.loc, 20); - } + dataEditor.datum = function(val) { + if (!arguments.length) + return _datum; + _datum = val; + return this; }; - mode.enter = function() { - var error = checkSelectedID(); - if (!error) - return; - behaviors.forEach(context.install); - keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true); - select_default2(document).call(keybinding); - selectError(); - var sidebar = context.ui().sidebar; - sidebar.show(errorEditor.error(error)); - context.map().on("drawn.select-error", selectError); - function selectError(d3_event, drawn) { - if (!checkSelectedID()) + return dataEditor; + } + + // modules/ui/sidebar.js + function uiSidebar(context) { + var inspector = uiInspector(context); + var dataEditor = uiDataEditor(context); + var noteEditor = uiNoteEditor(context); + var improveOsmEditor = uiImproveOsmEditor(context); + var keepRightEditor = uiKeepRightEditor(context); + var osmoseEditor = uiOsmoseEditor(context); + var _current; + var _wasData = false; + var _wasNote = false; + var _wasQaItem = false; + var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; + function sidebar(selection2) { + var container = context.container(); + var minWidth = 240; + var sidebarWidth; + var containerWidth; + var dragOffset; + selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%"); + var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown); + var downPointerId, lastClientX, containerLocGetter; + function pointerdown(d3_event) { + if (downPointerId) return; - var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService); - if (selection2.empty()) { - var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent; - if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) { - context.enter(modeBrowse(context)); + if ("button" in d3_event && d3_event.button !== 0) + return; + downPointerId = d3_event.pointerId || "mouse"; + lastClientX = d3_event.clientX; + containerLocGetter = utilFastMouse(container.node()); + dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1; + sidebarWidth = selection2.node().getBoundingClientRect().width; + containerWidth = container.node().getBoundingClientRect().width; + var widthPct = sidebarWidth / containerWidth * 100; + selection2.style("width", widthPct + "%").style("max-width", "85%"); + resizer.classed("dragging", true); + select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) { + d3_event2.preventDefault(); + }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup); + } + function pointermove(d3_event) { + if (downPointerId !== (d3_event.pointerId || "mouse")) + return; + d3_event.preventDefault(); + var dx = d3_event.clientX - lastClientX; + lastClientX = d3_event.clientX; + var isRTL = _mainLocalizer.textDirection() === "rtl"; + var scaleX = isRTL ? 0 : 1; + var xMarginProperty = isRTL ? "margin-right" : "margin-left"; + var x2 = containerLocGetter(d3_event)[0] - dragOffset; + sidebarWidth = isRTL ? containerWidth - x2 : x2; + var isCollapsed = selection2.classed("collapsed"); + var shouldCollapse = sidebarWidth < minWidth; + selection2.classed("collapsed", shouldCollapse); + if (shouldCollapse) { + if (!isCollapsed) { + selection2.style(xMarginProperty, "-400px").style("width", "400px"); + context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]); } } else { - selection2.classed("selected", true); - context.selectedErrorID(selectedErrorID); + var widthPct = sidebarWidth / containerWidth * 100; + selection2.style(xMarginProperty, null).style("width", widthPct + "%"); + if (isCollapsed) { + context.ui().onResize([-sidebarWidth * scaleX, 0]); + } else { + context.ui().onResize([-dx * scaleX, 0]); + } } } - function esc() { - if (context.container().select(".combobox").size()) + function pointerup(d3_event) { + if (downPointerId !== (d3_event.pointerId || "mouse")) return; - context.enter(modeBrowse(context)); + downPointerId = null; + resizer.classed("dragging", false); + select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null); + } + var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context)); + var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap"); + var hoverModeSelect = function(targets) { + context.container().selectAll(".feature-list-item button").classed("hover", false); + if (context.selectedIDs().length > 1 && targets && targets.length) { + var elements = context.container().selectAll(".feature-list-item button").filter(function(node) { + return targets.indexOf(node) !== -1; + }); + if (!elements.empty()) { + elements.classed("hover", true); + } + } + }; + sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200); + function hover(targets) { + var datum2 = targets && targets.length && targets[0]; + if (datum2 && datum2.__featurehash__) { + _wasData = true; + sidebar.show(dataEditor.datum(datum2)); + selection2.selectAll(".sidebar-component").classed("inspector-hover", true); + } else if (datum2 instanceof osmNote) { + if (context.mode().id === "drag-note") + return; + _wasNote = true; + var osm = services.osm; + if (osm) { + datum2 = osm.getNote(datum2.id); + } + sidebar.show(noteEditor.note(datum2)); + selection2.selectAll(".sidebar-component").classed("inspector-hover", true); + } else if (datum2 instanceof QAItem) { + _wasQaItem = true; + var errService = services[datum2.service]; + if (errService) { + datum2 = errService.getError(datum2.id); + } + var errEditor; + if (datum2.service === "keepRight") { + errEditor = keepRightEditor; + } else if (datum2.service === "osmose") { + errEditor = osmoseEditor; + } else { + errEditor = improveOsmEditor; + } + context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) { + return d2.id === datum2.id; + }); + sidebar.show(errEditor.error(datum2)); + selection2.selectAll(".sidebar-component").classed("inspector-hover", true); + } else if (!_current && datum2 instanceof osmEntity) { + featureListWrap.classed("inspector-hidden", true); + inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true); + if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") { + inspector.state("hover").entityIDs([datum2.id]).newFeature(false); + inspectorWrap.call(inspector); + } + } else if (!_current) { + featureListWrap.classed("inspector-hidden", false); + inspectorWrap.classed("inspector-hidden", true); + inspector.state("hide"); + } else if (_wasData || _wasNote || _wasQaItem) { + _wasNote = false; + _wasData = false; + _wasQaItem = false; + context.container().selectAll(".note").classed("hover", false); + context.container().selectAll(".qaItem").classed("hover", false); + sidebar.hide(); + } } + sidebar.hover = throttle_default(hover, 200); + sidebar.intersects = function(extent) { + var rect = selection2.node().getBoundingClientRect(); + return extent.intersects([ + context.projection.invert([0, rect.height]), + context.projection.invert([rect.width, 0]) + ]); + }; + sidebar.select = function(ids, newFeature) { + sidebar.hide(); + if (ids && ids.length) { + var entity = ids.length === 1 && context.entity(ids[0]); + if (entity && newFeature && selection2.classed("collapsed")) { + var extent = entity.extent(context.graph()); + sidebar.expand(sidebar.intersects(extent)); + } + featureListWrap.classed("inspector-hidden", true); + inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false); + inspector.state("select").entityIDs(ids).newFeature(newFeature); + inspectorWrap.call(inspector); + } else { + inspector.state("hide"); + } + }; + sidebar.showPresetList = function() { + inspector.showList(); + }; + sidebar.show = function(component, element) { + featureListWrap.classed("inspector-hidden", true); + inspectorWrap.classed("inspector-hidden", true); + if (_current) + _current.remove(); + _current = selection2.append("div").attr("class", "sidebar-component").call(component, element); + }; + sidebar.hide = function() { + featureListWrap.classed("inspector-hidden", false); + inspectorWrap.classed("inspector-hidden", true); + if (_current) + _current.remove(); + _current = null; + }; + sidebar.expand = function(moveMap) { + if (selection2.classed("collapsed")) { + sidebar.toggle(moveMap); + } + }; + sidebar.collapse = function(moveMap) { + if (!selection2.classed("collapsed")) { + sidebar.toggle(moveMap); + } + }; + sidebar.toggle = function(moveMap) { + if (context.inIntro()) + return; + var isCollapsed = selection2.classed("collapsed"); + var isCollapsing = !isCollapsed; + var isRTL = _mainLocalizer.textDirection() === "rtl"; + var scaleX = isRTL ? 0 : 1; + var xMarginProperty = isRTL ? "margin-right" : "margin-left"; + sidebarWidth = selection2.node().getBoundingClientRect().width; + selection2.style("width", sidebarWidth + "px"); + var startMargin, endMargin, lastMargin; + if (isCollapsing) { + startMargin = lastMargin = 0; + endMargin = -sidebarWidth; + } else { + startMargin = lastMargin = -sidebarWidth; + endMargin = 0; + } + if (!isCollapsing) { + selection2.classed("collapsed", isCollapsing); + } + selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() { + var i3 = number_default(startMargin, endMargin); + return function(t2) { + var dx = lastMargin - Math.round(i3(t2)); + lastMargin = lastMargin - dx; + context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]); + }; + }).on("end", function() { + if (isCollapsing) { + selection2.classed("collapsed", isCollapsing); + } + if (!isCollapsing) { + var containerWidth2 = container.node().getBoundingClientRect().width; + var widthPct = sidebarWidth / containerWidth2 * 100; + selection2.style(xMarginProperty, null).style("width", widthPct + "%"); + } + }); + }; + resizer.on("dblclick", function(d3_event) { + d3_event.preventDefault(); + if (d3_event.sourceEvent) { + d3_event.sourceEvent.preventDefault(); + } + sidebar.toggle(); + }); + context.map().on("crossEditableZoom.sidebar", function(within) { + if (!within && !selection2.select(".inspector-hover").empty()) { + hover([]); + } + }); + } + sidebar.showPresetList = function() { }; - mode.exit = function() { - behaviors.forEach(context.uninstall); - select_default2(document).call(keybinding.unbind); - context.surface().selectAll(".qaItem.selected").classed("selected hover", false); - context.map().on("drawn.select-error", null); - context.ui().sidebar.hide(); - context.selectedErrorID(null); - context.features().forceVisible([]); + sidebar.hover = function() { }; - return mode; + sidebar.hover.cancel = function() { + }; + sidebar.intersects = function() { + }; + sidebar.select = function() { + }; + sidebar.show = function() { + }; + sidebar.hide = function() { + }; + sidebar.expand = function() { + }; + sidebar.collapse = function() { + }; + sidebar.toggle = function() { + }; + return sidebar; } // modules/ui/tools/modes.js @@ -72138,8 +74653,8 @@ }); var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate); - context.history().on("change.undo_redo", function(difference) { - if (difference) + context.history().on("change.undo_redo", function(difference2) { + if (difference2) update(); }); context.on("enter.undo_redo", update); @@ -72330,9 +74845,9 @@ }; pane.renderPane = function(selection2) { _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2); - var heading = _paneSelection.append("div").attr("class", "pane-heading"); - heading.append("h2").text("").call(_label); - heading.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close")); + var heading2 = _paneSelection.append("div").attr("class", "pane-heading"); + heading2.append("h2").text("").call(_label); + heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close")); _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent); if (_key) { context.keybinding().on(_key, pane.togglePane); @@ -72429,7 +74944,7 @@ var _currSettings = { template: corePreferences("background-custom-template") }; - var example = "https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png"; + var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png"; var modal = uiConfirm(selection2).okButton(); modal.classed("settings-modal settings-custom-background", true); modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header")); @@ -73018,7 +75533,7 @@ var docs = docKeys.map(function(key) { var helpkey = "help." + key[0]; var helpPaneReplacements = { version: context.version }; - var text2 = key[1].reduce(function(all, part) { + var text = key[1].reduce(function(all, part) { var subkey = helpkey + "." + part; var depth = headings[subkey]; var hhh = depth ? Array(depth + 1).join("#") + " " : ""; @@ -73026,7 +75541,7 @@ }, ""); return { title: _t.html(helpkey + ".title"), - content: marked(text2.trim()).replace(//g, "").replace(/<\/code>/g, "") + content: marked(text.trim()).replace(//g, "").replace(/<\/code>/g, "") }; }); var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help"); @@ -73132,9 +75647,9 @@ selection2.call(drawIssuesList, issues); } function drawIssuesList(selection2, issues) { - var list = selection2.selectAll(".issues-list").data([0]); - list = list.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list); - var items = list.selectAll("li").data(issues, function(d2) { + var list2 = selection2.selectAll(".issues-list").data([0]); + list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2); + var items = list2.selectAll("li").data(issues, function(d2) { return d2.key; }); items.exit().remove(); @@ -73867,12 +76382,12 @@ context.layers().on("change", () => updatePhotoList(photoList.select("ul"))); } function updatePhotoList(container) { - var _a; + var _a2; function locationUnavailable(d2) { return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1])); } container.selectAll("li.placeholder").remove(); - let selection2 = container.selectAll("li").data((_a = photoLayer.getPhotos()) != null ? _a : [], (d2) => d2.id); + let selection2 = container.selectAll("li").data((_a2 = photoLayer.getPhotos()) != null ? _a2 : [], (d2) => d2.id); selection2.exit().remove(); const selectionEnter = selection2.enter().append("li"); selectionEnter.append("span").classed("filename", true); @@ -73929,8 +76444,8 @@ return layerSupported(d2) && d2.layer.enabled(); } function layerRendered(d2) { - var _a, _b, _c; - return (_c = (_b = (_a = d2.layer).rendered) == null ? void 0 : _b.call(_a, context.map().zoom())) != null ? _c : true; + var _a2, _b, _c; + return (_c = (_b = (_a2 = d2.layer).rendered) == null ? void 0 : _b.call(_a2, context.map().zoom())) != null ? _c : true; } var ul = selection2.selectAll(".layer-list-photos").data([0]); ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul); @@ -74439,9 +76954,9 @@ if (surfaceNode.focus) { surfaceNode.focus(); } - operations.forEach(function(operation) { - if (operation.point) - operation.point(anchorPoint); + operations.forEach(function(operation2) { + if (operation2.point) + operation2.point(anchorPoint); }); _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations); context.map().supersurface.call(_editMenu); @@ -74587,6 +77102,12 @@ _connection.loadEntityRelations(entityID, afterLoad(cid, callback)); } }; + context.loadNote = (entityID, callback) => { + if (_connection) { + const cid = _connection.getConnectionId(); + _connection.loadEntityNote(entityID, afterLoad(cid, callback)); + } + }; context.zoomToEntity = (entityID, zoomTo) => { context.loadEntity(entityID, (err, result) => { if (err) @@ -74984,11 +77505,11 @@ // node_modules/name-suggestion-index/lib/simplify.js var import_diacritics3 = __toESM(require_diacritics(), 1); - function simplify2(str2) { - if (typeof str2 !== "string") + function simplify2(str) { + if (typeof str !== "string") return ""; return import_diacritics3.default.remove( - str2.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase() + str.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase() ); } @@ -75746,6 +78267,17 @@ _mainFileFetcher.get("nsi_features") ]).then((vals) => { Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true); + Object.values(vals[0].presets).forEach((preset) => { + if (preset.tags["brand:wikidata"]) { + preset.removeTags = { "brand:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags }; + } + if (preset.tags["operator:wikidata"]) { + preset.removeTags = { "operator:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags }; + } + if (preset.tags["network:wikidata"]) { + preset.removeTags = { "network:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags }; + } + }); _mainPresetIndex.merge({ presets: vals[0].presets, featureCollection: vals[1] @@ -76032,8 +78564,8 @@ if (hits[0].match !== "primary" && hits[0].match !== "alternate") break; let itemID, item; - for (let j3 = 0; j3 < hits.length; j3++) { - const hit = hits[j3]; + for (let j2 = 0; j2 < hits.length; j2++) { + const hit = hits[j2]; itemID = hit.itemID; if (_nsi.dissolved[itemID]) continue; @@ -76686,7 +79218,7 @@ var _loadViewerPromise3; var _vegbilderCache; async function fetchAvailableLayers() { - var _a, _b, _c; + var _a2, _b, _c; const params = { service: "WFS", request: "GetCapabilities", @@ -76695,7 +79227,7 @@ const urlForRequest = owsEndpoint + utilQsString(params); const response = await xml_default(urlForRequest); const xPathSelector = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType/wfs:Name"; - const regexMatcher = new RegExp("^vegbilder_1_0:Vegbilder(?_360)?_(?\\d{4})$"); + const regexMatcher = /^vegbilder_1_0:Vegbilder(?_360)?_(?\d{4})$/; const NSResolver = response.createNSResolver(response); const l2 = response.evaluate( xPathSelector, @@ -76706,7 +79238,7 @@ let node; const availableLayers = []; while ((node = l2.iterateNext()) !== null) { - const match = (_a = node.textContent) == null ? void 0 : _a.match(regexMatcher); + const match = (_a2 = node.textContent) == null ? void 0 : _a2.match(regexMatcher); if (match) { availableLayers.push({ name: match[0], @@ -76767,7 +79299,7 @@ let featureCollection; try { featureCollection = await json_default(urlForRequest, options2); - } catch (e3) { + } catch { cache.loaded.set(tileid, false); return; } finally { @@ -77088,7 +79620,7 @@ // Reset is only necessary when interacting with the viewport because // this implicitly changes the currently selected bubble/sequence setStyles: function(context, hovered, reset) { - var _a, _b; + var _a2, _b; if (reset) { context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false); context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false); @@ -77096,7 +79628,7 @@ const hoveredImageKey = hovered == null ? void 0 : hovered.key; const hoveredSequence = this.getSequenceForImage(hovered); const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key; - const hoveredImageKeys = (_a = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a : []; + const hoveredImageKeys = (_a2 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a2 : []; const viewer = context.container().select(".photoviewer"); const selected = viewer.empty() ? void 0 : viewer.datum(); const selectedImageKey = selected == null ? void 0 : selected.key; @@ -77138,9 +79670,28 @@ }; // node_modules/osm-auth/src/osm-auth.mjs - var import_store = __toESM(require_store_legacy(), 1); function osmAuth(o2) { var oauth2 = {}; + var _store = null; + try { + _store = window.localStorage; + } catch (e3) { + var _mock = /* @__PURE__ */ new Map(); + _store = { + isMocked: true, + hasItem: (k2) => _mock.has(k2), + getItem: (k2) => _mock.get(k2), + setItem: (k2, v2) => _mock.set(k2, v2), + removeItem: (k2) => _mock.delete(k2), + clear: () => _mock.clear() + }; + } + function token(k2, v2) { + if (arguments.length === 1) + return _store.getItem(o2.url + k2); + else if (arguments.length === 2) + return _store.setItem(o2.url + k2, v2); + } oauth2.authenticated = function() { return !!token("oauth2_access_token"); }; @@ -77157,8 +79708,14 @@ return; } oauth2.logout(); - _generatePkceChallenge(function(pkce) { - _authenticate(pkce, callback); + _preopenPopup(function(error, popup) { + if (error) { + callback(error); + } else { + _generatePkceChallenge(function(pkce) { + _authenticate(pkce, popup, callback); + }); + } }); }; oauth2.authenticateAsync = function() { @@ -77169,15 +79726,45 @@ return new Promise((resolve, reject) => { var errback = (err, result) => { if (err) { - reject(new Error(err)); + reject(err); } else { resolve(result); } }; - _generatePkceChallenge((pkce) => _authenticate(pkce, errback)); + _preopenPopup((error, popup) => { + if (error) { + errback(error); + } else { + _generatePkceChallenge((pkce) => _authenticate(pkce, popup, errback)); + } + }); }); }; - function _authenticate(pkce, callback) { + function _preopenPopup(callback) { + if (o2.singlepage) { + callback(null, void 0); + return; + } + var w2 = 550; + var h2 = 610; + var settings = [ + ["width", w2], + ["height", h2], + ["left", window.screen.width / 2 - w2 / 2], + ["top", window.screen.height / 2 - h2 / 2] + ].map(function(x2) { + return x2.join("="); + }).join(","); + var popup = window.open("about:blank", "oauth_window", settings); + if (popup) { + callback(null, popup); + } else { + var error = new Error("Popup was blocked"); + error.status = "popup-blocked"; + callback(error); + } + } + function _authenticate(pkce, popup, callback) { var state = generateState(); var url = o2.url + "/oauth2/authorize?" + utilQsString2({ client_id: o2.client_id, @@ -77189,8 +79776,8 @@ code_challenge_method: pkce.code_challenge_method }); if (o2.singlepage) { - if (!import_store.default.enabled) { - var error = new Error("local storage unavailable, but require in singlepage mode"); + if (_store.isMocked) { + var error = new Error("localStorage unavailable, but required in singlepage mode"); error.status = "pkce-localstorage-unavailable"; callback(error); return; @@ -77204,24 +79791,8 @@ window.location = url; } } else { - var w2 = 600; - var h2 = 550; - var settings = [ - ["width", w2], - ["height", h2], - ["left", window.screen.width / 2 - w2 / 2], - ["top", window.screen.height / 2 - h2 / 2] - ].map(function(x2) { - return x2.join("="); - }).join(","); - var popup = window.open("about:blank", "oauth_window", settings); oauth2.popupWindow = popup; popup.location = url; - if (!popup) { - error = new Error("Popup was blocked"); - error.status = "popup-blocked"; - callback(error); - } } window.authComplete = function(url2) { var params2 = utilStringQs2(url2.split("?")[1]); @@ -77323,7 +79894,7 @@ } } function _doXHR() { - var url = options2.prefix !== false ? o2.url + options2.path : options2.path; + var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path; return oauth2.rawxhr( options2.method, url, @@ -77377,6 +79948,7 @@ if (!arguments.length) return o2; o2 = val; + o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org"; o2.url = o2.url || "https://www.openstreetmap.org"; o2.auto = o2.auto || false; o2.singlepage = o2.singlepage || false; @@ -77386,23 +79958,6 @@ }; return oauth2.preauth(o2); }; - var token; - if (import_store.default.enabled) { - token = function(x2, y2) { - if (arguments.length === 1) - return import_store.default.get(o2.url + x2); - else if (arguments.length === 2) - return import_store.default.set(o2.url + x2, y2); - }; - } else { - var storage = {}; - token = function(x2, y2) { - if (arguments.length === 1) - return storage[o2.url + x2]; - else if (arguments.length === 2) - return storage[o2.url + x2] = y2; - }; - } oauth2.options(o2); return oauth2; } @@ -77413,12 +79968,12 @@ return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]); }).join("&"); } - function utilStringQs2(str2) { + function utilStringQs2(str) { var i3 = 0; - while (i3 < str2.length && (str2[i3] === "?" || str2[i3] === "#")) + while (i3 < str.length && (str[i3] === "?" || str[i3] === "#")) i3++; - str2 = str2.slice(i3); - return str2.split("&").reduce(function(obj, pair3) { + str = str.slice(i3); + return str.split("&").reduce(function(obj, pair3) { var parts = pair3.split("="); if (parts.length === 2) { obj[parts[0]] = decodeURIComponent(parts[1]); @@ -77485,6 +80040,7 @@ var redirectPath = window.location.origin + window.location.pathname; var oauth = osmAuth({ url: urlroot, + apiUrl: apiUrlroot, client_id: osmApiConnections[0].client_id, client_secret: osmApiConnections[0].client_secret, scope: "read_prefs write_prefs write_api read_gpx write_notes", @@ -77600,8 +80156,8 @@ if (comment.nodeName === "comment") { var childNodes = comment.childNodes; var parsedComment = {}; - for (var j3 = 0; j3 < childNodes.length; j3++) { - var node = childNodes[j3]; + for (var j2 = 0; j2 < childNodes.length; j2++) { + var node = childNodes[j2]; var nodeName = node.nodeName; if (nodeName === "#text") continue; @@ -77801,15 +80357,19 @@ var props = {}; props.id = uid; props.loc = getLoc(attrs); - var coincident = false; - var epsilon3 = 1e-5; - do { - if (coincident) { - props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]); - } - var bbox2 = geoExtent(props.loc).bbox(); - coincident = _noteCache.rtree.search(bbox2).length; - } while (coincident); + if (!_noteCache.note[uid]) { + let coincident = false; + const epsilon3 = 1e-5; + do { + if (coincident) { + props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]); + } + const bbox2 = geoExtent(props.loc).bbox(); + coincident = _noteCache.rtree.search(bbox2).length; + } while (coincident); + } else { + props.loc = _noteCache.note[uid].loc; + } for (var i3 = 0; i3 < childNodes.length; i3++) { var node = childNodes[i3]; var nodeName = node.nodeName; @@ -77824,7 +80384,7 @@ var note = new osmNote(props); var item = encodeNoteRtree(note); _noteCache.note[note.id] = note; - _noteCache.rtree.insert(item); + updateRtree4(item, true); return note; }, user: function parseUser2(obj, uid) { @@ -77952,12 +80512,15 @@ getUrlRoot: function() { return urlroot; }, + getApiUrlRoot: function() { + return apiUrlroot; + }, changesetURL: function(changesetID) { return urlroot + "/changeset/" + changesetID; }, changesetsURL: function(center, zoom) { - var precision2 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); - return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision2) + "/" + center[0].toFixed(precision2); + var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); + return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3); }, entityURL: function(entity) { return urlroot + "/" + entity.type + "/" + entity.osmId(); @@ -78014,8 +80577,7 @@ if (this.authenticated()) { return oauth.xhr({ method: "GET", - prefix: false, - path: apiUrlroot + path + path }, done); } else { var url = apiUrlroot + path; @@ -78058,6 +80620,19 @@ options2 ); }, + // Load a single note by id , XML format + // GET /api/0.6/notes/#id + loadEntityNote: function(id2, callback) { + var options2 = { skipSeen: false }; + this.loadFromAPI( + "/api/0.6/notes/" + id2, + function(err, entities) { + if (callback) + callback(err, { data: entities }); + }, + options2 + ); + }, // Load a single entity with a specific version // GET /api/0.6/[node|way|relation]/#id/#version loadEntityVersion: function(id2, version, callback) { @@ -78126,8 +80701,7 @@ } else { var options2 = { method: "PUT", - prefix: false, - path: apiUrlroot + "/api/0.6/changeset/create", + path: "/api/0.6/changeset/create", headers: { "Content-Type": "text/xml" }, content: JXON.stringify(changeset.asJXON()) }; @@ -78145,8 +80719,7 @@ changeset = changeset.update({ id: changesetID }); var options3 = { method: "POST", - prefix: false, - path: apiUrlroot + "/api/0.6/changeset/" + changesetID + "/upload", + path: "/api/0.6/changeset/" + changesetID + "/upload", headers: { "Content-Type": "text/xml" }, content: JXON.stringify(changeset.osmChangeJXON(changes)) }; @@ -78166,8 +80739,7 @@ if (this.getConnectionId() === cid) { oauth.xhr({ method: "PUT", - prefix: false, - path: apiUrlroot + "/api/0.6/changeset/" + changeset.id + "/close", + path: "/api/0.6/changeset/" + changeset.id + "/close", headers: { "Content-Type": "text/xml" } }, function() { return true; @@ -78197,8 +80769,7 @@ utilArrayChunk(toLoad, 150).forEach((function(arr) { oauth.xhr({ method: "GET", - prefix: false, - path: apiUrlroot + "/api/0.6/users.json?users=" + arr.join() + path: "/api/0.6/users.json?users=" + arr.join() }, wrapcb(this, done, _connectionID)); }).bind(this)); function done(err, payload) { @@ -78221,8 +80792,7 @@ } oauth.xhr({ method: "GET", - prefix: false, - path: apiUrlroot + "/api/0.6/user/" + uid + ".json" + path: "/api/0.6/user/" + uid + ".json" }, wrapcb(this, done, _connectionID)); function done(err, payload) { if (err) @@ -78243,8 +80813,7 @@ } oauth.xhr({ method: "GET", - prefix: false, - path: apiUrlroot + "/api/0.6/user/details.json" + path: "/api/0.6/user/details.json" }, wrapcb(this, done, _connectionID)); function done(err, payload) { if (err) @@ -78273,8 +80842,7 @@ } oauth.xhr({ method: "GET", - prefix: false, - path: apiUrlroot + "/api/0.6/changesets?user=" + user.id + path: "/api/0.6/changesets?user=" + user.id }, wrapcb(this, done, _connectionID)); } function done(err, xml) { @@ -78315,7 +80883,7 @@ try { var regex = new RegExp(regexString); regexes.push(regex); - } catch (e3) { + } catch { } } } @@ -78476,8 +81044,7 @@ var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment }); _noteCache.inflightPost[note.id] = oauth.xhr({ method: "POST", - prefix: false, - path: urlroot + path + path }, wrapcb(this, done, _connectionID)); function done(err, xml) { delete _noteCache.inflightPost[note.id]; @@ -78522,8 +81089,7 @@ } _noteCache.inflightPost[note.id] = oauth.xhr({ method: "POST", - prefix: false, - path: urlroot + path + path }, wrapcb(this, done, _connectionID)); function done(err, xml) { delete _noteCache.inflightPost[note.id]; @@ -78556,8 +81122,14 @@ switch: function(newOptions) { urlroot = newOptions.url; apiUrlroot = newOptions.apiUrl || urlroot; - var oldOptions = utilObjectOmit(oauth.options(), "access_token"); - oauth.options(Object.assign(oldOptions, newOptions)); + if (newOptions.url && !newOptions.apiUrl) { + newOptions = { + ...newOptions, + apiUrl: newOptions.url + }; + } + const oldOptions = utilObjectOmit(oauth.options(), "access_token"); + oauth.options({ ...oldOptions, ...newOptions }); this.reset(); this.userChangesets(function() { }); @@ -78949,8 +81521,8 @@ var wikis = [rtypeWiki, tagWiki, keyWiki]; for (i3 in wikis) { var wiki = wikis[i3]; - for (var j3 in langCodes) { - var code = langCodes[j3]; + for (var j2 in langCodes) { + var code = langCodes[j2]; var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference"; var info = getWikiInfo(wiki, code, referenceId); if (info) { @@ -78986,64 +81558,11 @@ // modules/services/streetside.js var import_rbush11 = __toESM(require_rbush_min()); - - // modules/util/jsonp_request.js - var jsonpCache = {}; - window.jsonpCache = jsonpCache; - function jsonpRequest(url, callback) { - var request3 = { - abort: function() { - } - }; - if (window.JSONP_FIX) { - if (window.JSONP_DELAY === 0) { - callback(window.JSONP_FIX); - } else { - var t2 = window.setTimeout(function() { - callback(window.JSONP_FIX); - }, window.JSONP_DELAY || 0); - request3.abort = function() { - window.clearTimeout(t2); - }; - } - return request3; - } - function rand() { - var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - var c2 = ""; - var i3 = -1; - while (++i3 < 15) - c2 += chars.charAt(Math.floor(Math.random() * 52)); - return c2; - } - function create2(url2) { - var e3 = url2.match(/callback=(\w+)/); - var c2 = e3 ? e3[1] : rand(); - jsonpCache[c2] = function(data) { - if (jsonpCache[c2]) { - callback(data); - } - finalize(); - }; - function finalize() { - delete jsonpCache[c2]; - script.remove(); - } - request3.abort = finalize; - return "jsonpCache." + c2; - } - var cb = create2(url); - var script = select_default2("head").append("script").attr("type", "text/javascript").attr("src", url.replace(/(\{|%7B)callback(\}|%7D)/, cb)); - return request3; - } - - // modules/services/streetside.js - var bubbleApi = "https://dev.virtualearth.net/mapcontrol/HumanScaleServices/GetBubbles.ashx?"; - var streetsideImagesApi = "https://t.ssl.ak.tiles.virtualearth.net/tiles/"; - var bubbleAppKey = "AuftgJsO0Xs8Ts4M1xZUQJQXJNsvmh3IV8DkNieCiy3tCwCUMq76-WpkrBtNAuEm"; + var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}"; + var maxResults2 = 500; + var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0"); var pannellumViewerCSS2 = "pannellum/pannellum.css"; var pannellumViewerJS2 = "pannellum/pannellum.js"; - var maxResults2 = 2e3; var tileZoom3 = 16.5; var tiler7 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true); var dispatch11 = dispatch_default("loadedImages", "viewerChanged"); @@ -79097,37 +81616,37 @@ const id2 = tile.id + "," + String(nextPage); if (cache.loaded[id2] || cache.inflight[id2]) return; - cache.inflight[id2] = getBubbles(url, tile, (bubbles) => { + cache.inflight[id2] = getBubbles(url, tile, (response) => { cache.loaded[id2] = true; delete cache.inflight[id2]; - if (!bubbles) + if (!response) return; - bubbles.shift(); - const features = bubbles.map((bubble) => { - if (cache.points[bubble.id]) + if (response.resourceSets[0].resources.length === maxResults2) { + const split = tile.extent.split(); + loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] }); + loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] }); + loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] }); + loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] }); + } + const features = response.resourceSets[0].resources.map((bubble) => { + const bubbleId = bubble.imageUrl; + if (cache.points[bubbleId]) return null; - const loc = [bubble.lo, bubble.la]; + const loc = [bubble.lon, bubble.lat]; const d2 = { loc, - key: bubble.id, + key: bubbleId, + imageUrl: bubble.imageUrl.replace( + "{subdomain}", + bubble.imageUrlSubdomains[0] + ), ca: bubble.he, - captured_at: bubble.cd, + captured_at: bubble.vintageEnd, captured_by: "microsoft", - // nbn: bubble.nbn, - // pbn: bubble.pbn, - // ad: bubble.ad, - // rn: bubble.rn, - pr: bubble.pr, - // previous - ne: bubble.ne, - // next pano: true, sequenceKey: null }; - cache.points[bubble.id] = d2; - if (bubble.pr === void 0) { - cache.leaders.push(bubble.id); - } + cache.points[bubbleId] = d2; return { minX: loc[0], minY: loc[1], @@ -79137,67 +81656,32 @@ }; }).filter(Boolean); cache.rtree.load(features); - connectSequences(); if (which === "bubbles") { dispatch11.call("loadedImages"); } }); } - function connectSequences() { - let cache = _ssCache.bubbles; - let keepLeaders = []; - for (let i3 = 0; i3 < cache.leaders.length; i3++) { - let bubble = cache.points[cache.leaders[i3]]; - let seen = {}; - let sequence = { key: bubble.key, bubbles: [] }; - let complete = false; - do { - sequence.bubbles.push(bubble); - seen[bubble.key] = true; - if (bubble.ne === void 0) { - complete = true; - } else { - bubble = cache.points[bubble.ne]; - } - } while (bubble && !seen[bubble.key] && !complete); - if (complete) { - _ssCache.sequences[sequence.key] = sequence; - for (let j3 = 0; j3 < sequence.bubbles.length; j3++) { - sequence.bubbles[j3].sequenceKey = sequence.key; - } - sequence.geojson = { - type: "LineString", - properties: { - captured_at: sequence.bubbles[0] ? sequence.bubbles[0].captured_at : null, - captured_by: sequence.bubbles[0] ? sequence.bubbles[0].captured_by : null, - key: sequence.key - }, - coordinates: sequence.bubbles.map((d2) => d2.loc) - }; - } else { - keepLeaders.push(cache.leaders[i3]); - } - } - cache.leaders = keepLeaders; - } function getBubbles(url, tile, callback) { let rect = tile.extent.rectangle(); - let urlForRequest = url + utilQsString({ - n: rect[3], - s: rect[1], - e: rect[2], - w: rect[0], - c: maxResults2, - appkey: bubbleAppKey, - jsCallback: "{callback}" - }); - return jsonpRequest(urlForRequest, (data) => { - if (!data || data.error) { + let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2); + const controller = new AbortController(); + fetch(urlForRequest, { signal: controller.signal }).then(function(response) { + if (!response.ok) { + throw new Error(response.status + " " + response.statusText); + } + return response.json(); + }).then(function(result) { + if (!result) { callback(null); + } + return callback(result || []); + }).catch(function(err) { + if (err.name === "AbortError") { } else { - callback(data); + throw new Error(err); } }); + return controller; } function partitionViewport4(projection2) { let z2 = geoScaleToZoom(projection2.scale()); @@ -79636,7 +82120,7 @@ Object.values(_ssCache.bubbles.inflight).forEach(abortRequest6); } _ssCache = { - bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush11.default(), points: {}, leaders: [] }, + bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush11.default(), points: {} }, sequences: {} }; }, @@ -79672,7 +82156,7 @@ loadBubbles: function(projection2, margin) { if (margin === void 0) margin = 2; - loadTiles3("bubbles", bubbleApi, projection2, margin); + loadTiles3("bubbles", streetsideApi, projection2, margin); }, viewer: function() { return _pannellumViewer2; @@ -79872,13 +82356,6 @@ let line2 = attribution.append("div").attr("class", "attribution-row"); 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")); 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")); - let bubbleIdQuadKey = d2.key.toString(4); - const paddingNeeded = 16 - bubbleIdQuadKey.length; - for (let i3 = 0; i3 < paddingNeeded; i3++) { - bubbleIdQuadKey = "0" + bubbleIdQuadKey; - } - const imgUrlPrefix = streetsideImagesApi + "hs" + bubbleIdQuadKey; - const imgUrlSuffix = ".jpg?g=13515&n=z"; const faceKeys = ["01", "02", "03", "10", "11", "12"]; let quadKeys = getQuadKeys(); let faces = faceKeys.map((faceKey) => { @@ -79886,7 +82363,7 @@ const xy = qkToXY(quadKey); return { face: faceKey, - url: imgUrlPrefix + faceKey + quadKey + imgUrlSuffix, + url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey), x: xy[0], y: xy[1] }; @@ -80157,8 +82634,8 @@ if (err) { callback(err); } else { - var f3 = filterKeys(params.filter); - var result = d2.data.filter(f3).sort(sortKeys).map(valKey); + var f2 = filterKeys(params.filter); + var result = d2.data.filter(f2).sort(sortKeys).map(valKey); _taginfoCache[url] = result; callback(null, result); } @@ -80180,8 +82657,8 @@ if (err) { callback(err); } else { - var f3 = filterMultikeys(prefix); - var result = d2.data.filter(f3).map(valKey); + var f2 = filterMultikeys(prefix); + var result = d2.data.filter(f2).map(valKey); _taginfoCache[url] = result; callback(null, result); } @@ -80208,8 +82685,8 @@ callback(err); } else { var allowUpperCase = allowUpperCaseTagValues.test(params.key); - var f3 = filterValues(allowUpperCase); - var result = d2.data.filter(f3).map(valKeyDescription); + var f2 = filterValues(allowUpperCase); + var result = d2.data.filter(f2).map(valKeyDescription); _taginfoCache[url] = result; callback(null, result); } @@ -80231,8 +82708,8 @@ if (err) { callback(err); } else { - var f3 = filterRoles(geometry); - var result = d2.data.filter(f3).map(roleKey); + var f2 = filterRoles(geometry); + var result = d2.data.filter(f2).map(roleKey); _taginfoCache[url] = result; callback(null, result); } @@ -80268,7 +82745,7 @@ // modules/services/vector_tile.js var import_fast_deep_equal11 = __toESM(require_fast_deep_equal()); var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify()); - var import_polygon_clipping2 = __toESM(require_polygon_clipping_umd()); + var import_polygon_clipping = __toESM(require_polygon_clipping_umd()); var import_pbf2 = __toESM(require_pbf()); var import_vector_tile2 = __toESM(require_vector_tile()); var tiler8 = utilTiler().tileSize(512).margin(1); @@ -80315,7 +82792,7 @@ var merged = mergeCache[propertyhash]; if (merged && merged.length) { var other = merged[0]; - var coords = import_polygon_clipping2.default.union( + var coords = import_polygon_clipping.default.union( feature3.geometry.coordinates, other.geometry.coordinates ); @@ -80323,9 +82800,9 @@ continue; } merged.push(feature3); - for (var j3 = 0; j3 < merged.length; j3++) { - merged[j3].geometry.coordinates = coords; - merged[j3].__featurehash__ = featurehash; + for (var j2 = 0; j2 < merged.length; j2++) { + merged[j2].geometry.coordinates = coords; + merged[j2].__featurehash__ = featurehash; } } else { mergeCache[propertyhash] = [feature3]; @@ -80398,8 +82875,8 @@ var features = source.loaded[tiles[i3].id]; if (!features || !features.length) continue; - for (var j3 = 0; j3 < features.length; j3++) { - var feature3 = features[j3]; + for (var j2 = 0; j2 < features.length; j2++) { + var feature3 = features[j2]; var hash = feature3.__featurehash__; if (seen[hash]) continue; @@ -80720,10 +83197,10 @@ throw new Error("No Results"); } if (callback) { - var list = result.query.pages[Object.keys(result.query.pages)[0]]; + var list2 = result.query.pages[Object.keys(result.query.pages)[0]]; var translations = {}; - if (list && list.langlinks) { - list.langlinks.forEach(function(d2) { + if (list2 && list2.langlinks) { + list2.langlinks.forEach(function(d2) { translations[d2.lang] = d2["*"]; }); } @@ -81021,6 +83498,8 @@ 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"); wrap2.transition().duration(100).call(imgZoom3.transform, identity2); wrap2.selectAll("img").remove(); + wrap2.selectAll("button.back").classed("hide", !_cache4.images.forImageId.hasOwnProperty(+id2 - 1)); + wrap2.selectAll("button.forward").classed("hide", !_cache4.images.forImageId.hasOwnProperty(+id2 + 1)); getImageData(d2.id, d2.sequence_id).then(function() { if (d2.isPano) { if (!_pannellumViewer3) { @@ -81074,8 +83553,8 @@ let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null); wrapEnter.append("div").attr("class", "photo-attribution fillD"); const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio"); - controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4"); - controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA"); + controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4"); + controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA"); wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm"); wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple"); context.ui().photoviewer.on("resize.mapilio", () => { @@ -81622,19 +84101,19 @@ }) : []; } var _candidates = candidateWays(); - var operation = function() { + var operation2 = function() { var candidate = _candidates[0]; context.enter( modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true) ); }; - operation.relatedEntityIds = function() { + operation2.relatedEntityIds = function() { return _candidates.length ? [_candidates[0].id] : []; }; - operation.available = function() { + operation2.available = function() { return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph()); }; - operation.disabled = function() { + operation2.disabled = function() { if (_candidates.length === 0) { return "not_eligible"; } else if (_candidates.length > 1) { @@ -81642,18 +84121,18 @@ } return false; }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description"); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.continue.annotation.line"); }; - operation.id = "continue"; - operation.keys = [_t("operations.continue.key")]; - operation.title = _t.append("operations.continue.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "continue"; + operation2.keys = [_t("operations.continue.key")]; + operation2.title = _t.append("operations.continue.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/copy.js @@ -81664,7 +84143,7 @@ return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex"; }); } - var operation = function() { + var operation2 = function() { var graph = context.graph(); var selected = groupEntities(getFilteredIdsToCopy(), graph); var canCopy = []; @@ -81728,37 +84207,37 @@ } return descendants; } - operation.available = function() { + operation2.available = function() { return getFilteredIdsToCopy().length > 0; }; - operation.disabled = function() { + operation2.disabled = function() { var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph()); if (extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } return false; }; - operation.availableForKeypress = function() { + operation2.availableForKeypress = function() { var selection2 = window.getSelection && window.getSelection(); return !selection2 || !selection2.toString(); }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length }); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.copy.annotation", { n: selectedIDs.length }); }; var _point; - operation.point = function(val) { + operation2.point = function(val) { _point = val; - return operation; + return operation2; }; - operation.id = "copy"; - operation.keys = [uiCmd("\u2318C")]; - operation.title = _t.append("operations.copy.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "copy"; + operation2.keys = [uiCmd("\u2318C")]; + operation2.title = _t.append("operations.copy.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/disconnect.js @@ -81854,21 +84333,21 @@ } } var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph()); - var operation = function() { + var operation2 = function() { context.perform(function(graph) { return _actions.reduce(function(graph2, action) { return action(graph2); }, graph); - }, operation.annotation()); + }, operation2.annotation()); context.validator().validate(); }; - operation.relatedEntityIds = function() { + operation2.relatedEntityIds = function() { if (_vertexIDs.length) { return _disconnectingWayIds; } return _disconnectingVertexIds; }; - operation.available = function() { + operation2.available = function() { if (_actions.length === 0) return false; if (_otherIDs.length !== 0) @@ -81882,7 +84361,7 @@ return false; return true; }; - operation.disabled = function() { + operation2.disabled = function() { var reason; for (var actionIndex in _actions) { reason = _actions[actionIndex].disabled(context.graph()); @@ -81915,18 +84394,18 @@ return false; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.disconnect.annotation." + _annotationID); }; - operation.id = "disconnect"; - operation.keys = [_t("operations.disconnect.key")]; - operation.title = _t.append("operations.disconnect.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "disconnect"; + operation2.keys = [_t("operations.disconnect.key")]; + operation2.title = _t.append("operations.disconnect.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/downgrade.js @@ -81975,9 +84454,9 @@ } return null; } - var buildingKeysToKeep = ["architect", "building", "height", "layer", "source", "type", "wheelchair"]; + var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"]; var addressKeysToKeep = ["source"]; - var operation = function() { + var operation2 = function() { context.perform(function(graph) { for (var i3 in selectedIDs) { var entityID = selectedIDs[i3]; @@ -82001,14 +84480,14 @@ graph = actionChangeTags(entityID, tags)(graph); } return graph; - }, operation.annotation()); + }, operation2.annotation()); context.validator().validate(); context.enter(modeSelect(context, selectedIDs)); }; - operation.available = function() { + operation2.available = function() { return _downgradeType; }; - operation.disabled = function() { + operation2.disabled = function() { if (selectedIDs.some(hasWikidataTag)) { return "has_wikidata_tag"; } @@ -82018,11 +84497,11 @@ return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType); }; - operation.annotation = function() { + operation2.annotation = function() { var suffix; if (_downgradeType === "building_address") { suffix = "generic"; @@ -82031,11 +84510,11 @@ } return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount }); }; - operation.id = "downgrade"; - operation.keys = [uiCmd("\u232B")]; - operation.title = _t.append("operations.downgrade.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "downgrade"; + operation2.keys = [uiCmd("\u232B")]; + operation2.title = _t.append("operations.downgrade.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/extract.js @@ -82061,23 +84540,23 @@ _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph); return actionExtract(entityID, context.projection); }).filter(Boolean); - var operation = function() { + var operation2 = function() { var combinedAction = function(graph) { _actions.forEach(function(action) { graph = action(graph); }); return graph; }; - context.perform(combinedAction, operation.annotation()); + context.perform(combinedAction, operation2.annotation()); var extractedNodeIDs = _actions.map(function(action) { return action.getExtractedNodeID(); }); context.enter(modeSelect(context, extractedNodeIDs)); }; - operation.available = function() { + operation2.available = function() { return _actions.length && selectedIDs.length === _actions.length; }; - operation.disabled = function() { + operation2.disabled = function() { if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) { return "too_large"; } else if (selectedIDs.some(function(entityID) { @@ -82087,22 +84566,22 @@ } return false; }; - operation.tooltip = function() { - var disableReason = operation.disabled(); + operation2.tooltip = function() { + var disableReason = operation2.disabled(); if (disableReason) { return _t.append("operations.extract." + disableReason + "." + _amount); } else { return _t.append("operations.extract.description." + _geometryID + "." + _amount); } }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.extract.annotation", { n: selectedIDs.length }); }; - operation.id = "extract"; - operation.keys = [_t("operations.extract.key")]; - operation.title = _t.append("operations.extract.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "extract"; + operation2.keys = [_t("operations.extract.key")]; + operation2.title = _t.append("operations.extract.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/merge.js @@ -82129,10 +84608,10 @@ return mergePolygon; return mergeNodes; } - var operation = function() { - if (operation.disabled()) + var operation2 = function() { + if (operation2.disabled()) return; - context.perform(_action, operation.annotation()); + context.perform(_action, operation2.annotation()); context.validator().validate(); var resultIDs = selectedIDs.filter(context.hasEntity); if (resultIDs.length > 1) { @@ -82144,10 +84623,10 @@ } context.enter(modeSelect(context, resultIDs)); }; - operation.available = function() { + operation2.available = function() { return selectedIDs.length >= 2; }; - operation.disabled = function() { + operation2.disabled = function() { var actionDisabled = _action.disabled(context.graph()); if (actionDisabled) return actionDisabled; @@ -82157,8 +84636,8 @@ } return false; }; - operation.tooltip = function() { - var disabled = operation.disabled(); + operation2.tooltip = function() { + var disabled = operation2.disabled(); if (disabled) { if (disabled === "conflicting_relations") { return _t.append("operations.merge.conflicting_relations"); @@ -82173,20 +84652,20 @@ } return _t.append("operations.merge.description"); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.merge.annotation", { n: selectedIDs.length }); }; - operation.id = "merge"; - operation.keys = [_t("operations.merge.key")]; - operation.title = _t.append("operations.merge.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "merge"; + operation2.keys = [_t("operations.merge.key")]; + operation2.title = _t.append("operations.merge.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/paste.js function operationPaste(context) { var _pastePoint; - var operation = function() { + var operation2 = function() { if (!_pastePoint) return; var oldIDs = context.copyIDs(); @@ -82217,20 +84696,20 @@ } var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center()); var delta = geoVecSubtract(_pastePoint, copyPoint); - context.replace(actionMove(newIDs, delta, projection2), operation.annotation()); + context.replace(actionMove(newIDs, delta, projection2), operation2.annotation()); context.enter(modeSelect(context, newIDs)); }; - operation.point = function(val) { + operation2.point = function(val) { _pastePoint = val; - return operation; + return operation2; }; - operation.available = function() { + operation2.available = function() { return context.mode().id === "browse"; }; - operation.disabled = function() { + operation2.disabled = function() { return !context.copyIDs().length; }; - operation.tooltip = function() { + operation2.tooltip = function() { var oldGraph = context.copyGraph(); var ids = context.copyIDs(); if (!ids.length) { @@ -82238,25 +84717,25 @@ } return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length }); }; - operation.annotation = function() { + operation2.annotation = function() { var ids = context.copyIDs(); return _t("operations.paste.annotation", { n: ids.length }); }; - operation.id = "paste"; - operation.keys = [uiCmd("\u2318V")]; - operation.title = _t.append("operations.paste.title"); - return operation; + operation2.id = "paste"; + operation2.keys = [uiCmd("\u2318V")]; + operation2.title = _t.append("operations.paste.title"); + return operation2; } // modules/operations/reverse.js function operationReverse(context, selectedIDs) { - var operation = function() { + var operation2 = function() { context.perform(function combinedReverseAction(graph) { actions().forEach(function(action) { graph = action(graph); }); return graph; - }, operation.annotation()); + }, operation2.annotation()); context.validator().validate(); }; function actions(situation) { @@ -82289,24 +84768,24 @@ return "point"; return "feature"; } - operation.available = function(situation) { + operation2.available = function(situation) { return actions(situation).length > 0; }; - operation.disabled = function() { + operation2.disabled = function() { return false; }; - operation.tooltip = function() { + operation2.tooltip = function() { return _t.append("operations.reverse.description." + reverseTypeID()); }; - operation.annotation = function() { + operation2.annotation = function() { var acts = actions(); return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length }); }; - operation.id = "reverse"; - operation.keys = [_t("operations.reverse.key")]; - operation.title = _t.append("operations.reverse.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "reverse"; + operation2.keys = [_t("operations.reverse.key")]; + operation2.title = _t.append("operations.reverse.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/split.js @@ -82337,20 +84816,20 @@ } _waysAmount = _ways.length === 1 ? "single" : "multiple"; } - var operation = function() { - var difference = context.perform(_action, operation.annotation()); - var idsToSelect = _vertexIds.concat(difference.extantIDs().filter(function(id2) { + var operation2 = function() { + var difference2 = context.perform(_action, operation2.annotation()); + var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) { return context.entity(id2).type === "way"; })); context.enter(modeSelect(context, idsToSelect)); }; - operation.relatedEntityIds = function() { + operation2.relatedEntityIds = function() { return _selectedWayIds.length ? [] : _ways.map((way) => way.id); }; - operation.available = function() { + operation2.available = function() { return _isAvailable; }; - operation.disabled = function() { + operation2.disabled = function() { var reason = _action.disabled(context.graph()); if (reason) { return reason; @@ -82359,25 +84838,25 @@ } return false; }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node"); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.split.annotation." + _geometry, { n: _ways.length }); }; - operation.icon = function() { + operation2.icon = function() { if (_waysAmount === "multiple") { return "#iD-operation-split-multiple"; } else { return "#iD-operation-split"; } }; - operation.id = "split"; - operation.keys = [_t("operations.split.key")]; - operation.title = _t.append("operations.split.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "split"; + operation2.keys = [_t("operations.split.key")]; + operation2.title = _t.append("operations.split.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/operations/straighten.js @@ -82436,18 +84915,18 @@ } return null; } - function operation() { + function operation2() { if (!_action) return; - context.perform(_action, operation.annotation()); + context.perform(_action, operation2.annotation()); window.setTimeout(function() { context.validator().validate(); }, 300); } - operation.available = function() { + operation2.available = function() { return Boolean(_action); }; - operation.disabled = function() { + operation2.disabled = function() { var reason = _action.disabled(context.graph()); if (reason) { return reason; @@ -82477,18 +84956,18 @@ return false; } }; - operation.tooltip = function() { - var disable = operation.disabled(); + operation2.tooltip = function() { + var disable = operation2.disabled(); return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s")); }; - operation.annotation = function() { + operation2.annotation = function() { return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length }); }; - operation.id = "straighten"; - operation.keys = [_t("operations.straighten.key")]; - operation.title = _t.append("operations.straighten.title"); - operation.behavior = behaviorOperation(context).which(operation); - return operation; + operation2.id = "straighten"; + operation2.keys = [_t("operations.straighten.key")]; + operation2.title = _t.append("operations.straighten.title"); + operation2.behavior = behaviorOperation(context).which(operation2); + return operation2; } // modules/modes/select.js @@ -82620,9 +85099,9 @@ return mode; }; function loadOperations() { - _operations.forEach(function(operation) { - if (operation.behavior) { - context.uninstall(operation.behavior); + _operations.forEach(function(operation2) { + if (operation2.behavior) { + context.uninstall(operation2.behavior); } }); _operations = Object.values(operations_exports).map(function(o2) { @@ -82634,12 +85113,12 @@ operationCopy(context, selectedIDs), operationDowngrade(context, selectedIDs), operationDelete(context, selectedIDs) - ]).filter(function(operation) { - return operation.available(); + ]).filter(function(operation2) { + return operation2.available(); }); - _operations.forEach(function(operation) { - if (operation.behavior) { - context.install(operation.behavior); + _operations.forEach(function(operation2) { + if (operation2.behavior) { + context.install(operation2.behavior); } }); context.ui().closeEditMenu(); @@ -82857,13 +85336,13 @@ if (!parentId) return; var way = context.entity(parentId); - var length = way.nodes.length; + var length2 = way.nodes.length; var curr = way.nodes.indexOf(selectedIDs[0]); var index = -1; if (curr > 0) { index = curr - 1; } else if (way.isClosed()) { - index = length - 2; + index = length2 - 2; } if (index !== -1) { context.enter( @@ -82878,10 +85357,10 @@ if (!parentId) return; var way = context.entity(parentId); - var length = way.nodes.length; + var length2 = way.nodes.length; var curr = way.nodes.indexOf(selectedIDs[0]); var index = -1; - if (curr < length - 1) { + if (curr < length2 - 1) { index = curr + 1; } else if (way.isClosed()) { index = 0; @@ -82936,9 +85415,9 @@ mode.exit = function() { _newFeature = false; _focusedVertexIds = null; - _operations.forEach(function(operation) { - if (operation.behavior) { - context.uninstall(operation.behavior); + _operations.forEach(function(operation2) { + if (operation2.behavior) { + context.uninstall(operation2.behavior); } }); _operations = []; @@ -83147,7 +85626,7 @@ var map2 = context.map(); var center = map2.center(); var zoom = map2.zoom(); - var precision2 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); + var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); var oldParams = utilObjectOmit( utilStringQs(window.location.hash), ["comment", "source", "hashtags", "walkthrough"] @@ -83160,7 +85639,7 @@ if (selected.length) { newParams.id = selected.join(","); } - newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision2) + "/" + center[0].toFixed(precision2); + newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3); return Object.assign(oldParams, newParams); } function computedHash() {